|
@@ -1,34 +1,34 @@
|
|
|
//1.格式化日期 start ---------------------------------------->
|
|
|
//time 日期字符串 type 从什么时候开始返回 year = 返回年月日 month = 返回月日..
|
|
|
//style 样式,比如 年-月-日 年.月.日
|
|
|
-const getTime = function(time:string,type:string,style:Number){
|
|
|
+const getTime = function (time: string, type: string, style: Number) {
|
|
|
const date = new Date(time);
|
|
|
const year = date.getFullYear();
|
|
|
const month = date.getMonth() + 1;
|
|
|
const day = date.getDate();
|
|
|
|
|
|
//返回 年-月-日
|
|
|
- if(type == 'year'&& style == 1){
|
|
|
+ if (type == 'year' && style == 1) {
|
|
|
return `${year}-${month}-${day}`;
|
|
|
}
|
|
|
//返回 年-月
|
|
|
- if(type == 'year'&& style == 2){
|
|
|
+ if (type == 'year' && style == 2) {
|
|
|
return `${year}-${month}`;
|
|
|
}
|
|
|
//返回 年
|
|
|
- if(type == 'year'&& style == 3){
|
|
|
+ if (type == 'year' && style == 3) {
|
|
|
return `${year}`;
|
|
|
}
|
|
|
//返回 月-日
|
|
|
- if(type == 'month'&& style == 1){
|
|
|
+ if (type == 'month' && style == 1) {
|
|
|
return `${month}-${day}`;
|
|
|
}
|
|
|
//返回 月.日
|
|
|
- if(type == 'month'&& style == 2){
|
|
|
+ if (type == 'month' && style == 2) {
|
|
|
return `${month}.${day}`;
|
|
|
}
|
|
|
//返回 日
|
|
|
- if(type == 'day'&& style == 1){
|
|
|
+ if (type == 'day' && style == 1) {
|
|
|
return `${day}`;
|
|
|
}
|
|
|
}
|
|
@@ -36,10 +36,10 @@ const getTime = function(time:string,type:string,style:Number){
|
|
|
|
|
|
//2.格式化标题长度 start ---------------------------------------->
|
|
|
//title 标题 length 长度
|
|
|
-const getTitleLength = function(title:string,length:number){
|
|
|
- if(title.length >= length){
|
|
|
+const getTitleLength = function (title: string, length: number) {
|
|
|
+ if (title.length >= length) {
|
|
|
return title.substring(0, length) + "...";
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return title;
|
|
|
}
|
|
|
}
|
|
@@ -47,26 +47,30 @@ const getTitleLength = function(title:string,length:number){
|
|
|
|
|
|
//3.格式化跳转路径 start ---------------------------------------->
|
|
|
//3.1跳转到频道页面或者一级列表页
|
|
|
-const getLinkPath = (item:any) => {
|
|
|
- if (item.children_count == 0) {
|
|
|
- return `/${item.aLIas_pinyin}/list-1.html`;
|
|
|
- } else {
|
|
|
- return `/${item.aLIas_pinyin}/index.html`;
|
|
|
- }
|
|
|
+const getLinkPath = (item: any) => {
|
|
|
+ if(item.is_url==1){
|
|
|
+ return `${item.web_url}`;
|
|
|
+ }else if(item.children_count == 0){
|
|
|
+ //return `/newsList/${item.category_id}?page=1`;
|
|
|
+ return `/${item.aLIas_pinyin}/list-1.html`;
|
|
|
+ }else{
|
|
|
+ //return `/primaryNavigation/${item.aLIas_pinyin}/`;
|
|
|
+ return `/${item.aLIas_pinyin}/index.html`;
|
|
|
+ }
|
|
|
}
|
|
|
//3.2跳转到详情页
|
|
|
-const getLinkPathDetail = (item:any) => {
|
|
|
+const getLinkPathDetail = (item: any) => {
|
|
|
if (item.islink == 1) {
|
|
|
- return `${item.linkurl}`;
|
|
|
+ return `${item.linkurl}`;
|
|
|
} else {
|
|
|
- return `/${item.pinyin}/${item.id}.html`;
|
|
|
+ return `/${item.pinyin}/${item.id}.html`;
|
|
|
}
|
|
|
}
|
|
|
//3.格式化跳转路径 end ---------------------------------------->
|
|
|
|
|
|
|
|
|
//4.获得路由路径 start ---------------------------------------->
|
|
|
-const getRoutePath = (type:Number) => {
|
|
|
+const getRoutePath = (type: Number) => {
|
|
|
const route = useRoute();
|
|
|
//获得当前的完整路径
|
|
|
const fullPath = route.path;
|
|
@@ -75,10 +79,10 @@ const getRoutePath = (type:Number) => {
|
|
|
const targetSegmentOne = segments[1];
|
|
|
const targetSegmentTwo = segments[2];
|
|
|
|
|
|
- if(type == 1){
|
|
|
+ if (type == 1) {
|
|
|
return targetSegmentOne;
|
|
|
}
|
|
|
- if(type == 2){
|
|
|
+ if (type == 2) {
|
|
|
return targetSegmentTwo;
|
|
|
}
|
|
|
}
|
|
@@ -86,4 +90,4 @@ const getRoutePath = (type:Number) => {
|
|
|
|
|
|
|
|
|
//4.获得路由路径 end ---------------------------------------->
|
|
|
-export { getTime,getTitleLength,getLinkPath,getLinkPathDetail,getRoutePath};
|
|
|
+export { getTime, getTitleLength, getLinkPath, getLinkPathDetail, getRoutePath };
|