123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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) {
- return `${year}-${month}-${day}`;
- }
-
- if (type == 'year' && style == 2) {
- return `${year}-${month}`;
- }
-
- if (type == 'year' && style == 3) {
- return `${year}`;
- }
-
- if (type == 'month' && style == 1) {
- return `${month}-${day}`;
- }
-
- if (type == 'month' && style == 2) {
- return `${month}.${day}`;
- }
-
- if (type == 'day' && style == 1) {
- return `${day}`;
- }
- }
- const getTitleLength = function (title: string, length: number) {
- if (title.length >= length) {
- return title.substring(0, length) + "...";
- } else {
- return title;
- }
- }
- const getLinkPath = (item: any) => {
- if (item.is_url == 1) {
- return `${item.web_url}`;
- } else if (item.children_count == 0) {
-
- return `/${item.aLIas_pinyin}/list-1.html`;
- } else {
-
- return `/${item.aLIas_pinyin}/index.html`;
- }
- }
- const getLinkPathDetail = (item: any) => {
- if (item.islink == 1) {
- return `${item.linkurl}`;
- } else {
- return `/${item.pinyin}/${item.id}.html`;
- }
- }
- const getRoutePath = (type: Number) => {
- const route = useRoute();
-
- const fullPath = route.path;
-
- const segments = fullPath.split('/');
- const targetSegmentOne = segments[1];
- const targetSegmentTwo = segments[2];
- if (type == 1) {
- return targetSegmentOne;
- }
- if (type == 2) {
- return targetSegmentTwo;
- }
- }
- export { getTime, getTitleLength, getLinkPath, getLinkPathDetail, getRoutePath };
|