From 25ce022aef4f23ec54b55a70cdd1062415734e2f Mon Sep 17 00:00:00 2001 From: clay <20932067@zju.edu.cn> Date: Mon, 21 Nov 2022 23:41:28 +0800 Subject: [PATCH] =?UTF-8?q?clay=20commit=20:=20=E5=B0=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/utils/sist.js | 46 ++++++++++++------- src/views/content/components/dire_data.vue | 2 +- .../content/components/dire_data_tow.vue | 2 +- src/views/content/components/file_list.vue | 3 ++ src/views/content/components/simple_list.vue | 3 ++ src/views/header/index.vue | 4 +- .../index/components/academy_and_sciences.vue | 12 +++-- src/views/index/components/announcements.vue | 6 +++ src/views/index/components/news_center.vue | 3 ++ src/views/index/components/slideshow_card.vue | 7 ++- .../components/undergraduate_and_graduate.vue | 3 ++ vue.config.js | 30 ++++++------ 13 files changed, 82 insertions(+), 41 deletions(-) diff --git a/.env.development b/.env.development index 5882923..ef756bc 100644 --- a/.env.development +++ b/.env.development @@ -4,7 +4,7 @@ ENV = 'development' # EBTS/开发环境 #VUE_APP_BASE_API = '/dev-api' #VUE_APP_BASE_API = 'http://localhost:8085/dev-api' -VUE_APP_BASE_API = 'http://sist.swjtu.edu.cn/dev-api' +VUE_APP_BASE_API = '/dev-api' SITE_TYPE = 'NEd5n92EMIpyyBslaNqsRgE' #VUE_APP_BASE_API = 'http://sistapi.hchyun.cn/dev-api' diff --git a/src/utils/sist.js b/src/utils/sist.js index 902a56b..e82436c 100644 --- a/src/utils/sist.js +++ b/src/utils/sist.js @@ -101,22 +101,32 @@ export function toArticle(news, width) { let routeData = null; if (info.three == null) { if (width) { - routeData = vm.$router.resolve("/pc/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); + routeData = "/pc/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); } else { - routeData = vm.$router.resolve("/mobile/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); + routeData = "/mobile/" + info.second.encodeId + "?id=" + news.id + "&type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); } } else { console.log(info.three, "toArticle,info.three") if (width) { - routeData = vm.$router.resolve("/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang")); + routeData = "/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang"); } else { - routeData = vm.$router.resolve("/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang")); + routeData = "/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?id=" + news.id + "&lang=" + sessionStorage.getItem("lang"); } } - window.open(routeData.href,"_blank") + linkTo(routeData) }) } +function linkTo(routeData) { + let userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 + if (userAgent.indexOf("Safari") > -1) { + window.location.href = window.location.origin + routeData + } else { + window.open(routeData.href, "_blank") + } +} + + export function lookMoreComment(item, width) { info(item.id).then(res => { let info = null @@ -153,19 +163,23 @@ export function lookMoreFixedComment(id, width) { } if (info == null) { return - } - if (info.three == null) { - if (width) { - vm.$router.push("/pc/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); + let routeData = null; + if (info.three == null) { + if (width) { + routeData = "/pc/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); + } else { + routeData = "/mobile/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); + } } else { - vm.$router.push("/mobile/" + info.second.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); - } - } else { - if (width) { - vm.$router.push("/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); - } else { - vm.$router.push("/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang")); + if (width) { + routeData = "/pc/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); + } else { + routeData = "/mobile/" + info.second.encodeId + "/" + info.three.encodeId + "?type=" + info.second.type + "&lang=" + sessionStorage.getItem("lang"); + } } + linkTo(routeData) + // window.location.href = window.location.origin + routeData.href + // window.open(window.location.origin + routeData.href, "_blank") } } diff --git a/src/views/content/components/dire_data.vue b/src/views/content/components/dire_data.vue index 5a4da96..87fbe72 100644 --- a/src/views/content/components/dire_data.vue +++ b/src/views/content/components/dire_data.vue @@ -64,7 +64,7 @@ export default { }, methods: { linkClick(chile) { - if (chile.link != null && chile.link != "") { + if (chile.link!=null && chile.link != "" && chile.link != '""'){ window.open(chile.link); } } diff --git a/src/views/content/components/dire_data_tow.vue b/src/views/content/components/dire_data_tow.vue index 6d93d73..adc467b 100644 --- a/src/views/content/components/dire_data_tow.vue +++ b/src/views/content/components/dire_data_tow.vue @@ -56,7 +56,7 @@ export default { }, methods:{ linkClick(chile){ - if (chile.link!=null && chile.link != ""){ + if (chile.link!=null && chile.link != "" && chile.link != '""'){ window.open(chile.link) } } diff --git a/src/views/content/components/file_list.vue b/src/views/content/components/file_list.vue index a9639b8..a94f980 100644 --- a/src/views/content/components/file_list.vue +++ b/src/views/content/components/file_list.vue @@ -95,6 +95,9 @@ export default { }, methods: { getDateTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let year = time.getFullYear(); let month = time.getMonth() + 1 diff --git a/src/views/content/components/simple_list.vue b/src/views/content/components/simple_list.vue index ee325b4..9e7a318 100644 --- a/src/views/content/components/simple_list.vue +++ b/src/views/content/components/simple_list.vue @@ -99,6 +99,9 @@ export default { }, methods: { getDateTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let year = time.getFullYear(); let month = time.getMonth() + 1 diff --git a/src/views/header/index.vue b/src/views/header/index.vue index 67ee9ec..d2583b6 100644 --- a/src/views/header/index.vue +++ b/src/views/header/index.vue @@ -142,9 +142,7 @@ export default { window.open(routeData.href, "_blank") }, menuCut(menu) { - console.log(menu) - // this.ch_logo_blue=false - this.$router.push("/pc/" + menu.encodeId + "?type=" + menu.type + "&lang=" + sessionStorage.getItem("lang")); + window.open("/pc/" + menu.encodeId + "?type=" + menu.type + "&lang=" + sessionStorage.getItem("lang")) }, switchLang() { let lang = '' diff --git a/src/views/index/components/academy_and_sciences.vue b/src/views/index/components/academy_and_sciences.vue index 551cbe3..db11c14 100644 --- a/src/views/index/components/academy_and_sciences.vue +++ b/src/views/index/components/academy_and_sciences.vue @@ -57,7 +57,7 @@ -
+
{{getDateTime(sciencesData[2].publishTime)}} @@ -74,7 +74,7 @@ -
+
@@ -121,7 +121,7 @@ export default { methods: { clickTo(link) { //console.log(link) - window.location.href = link;//当前标签页 + window.location.href = window.location.origin + link; //当前标签页 }, getArticle(news) { toArticle(news, this.width); @@ -150,6 +150,9 @@ export default { }, getDateTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let year = time.getFullYear(); let month = time.getMonth() + 1 @@ -164,6 +167,9 @@ export default { }, getMonthTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let month = time.getMonth() + 1 if (month < 10){ diff --git a/src/views/index/components/announcements.vue b/src/views/index/components/announcements.vue index 11b9d21..cffd8d5 100644 --- a/src/views/index/components/announcements.vue +++ b/src/views/index/components/announcements.vue @@ -75,12 +75,18 @@ export default { }); }, getDateTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let year = time.getFullYear(); let month = time.getMonth() + 1 return year + "-" + month; }, getDayTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let day = time.getDate(); return day; diff --git a/src/views/index/components/news_center.vue b/src/views/index/components/news_center.vue index 967e11a..142674f 100644 --- a/src/views/index/components/news_center.vue +++ b/src/views/index/components/news_center.vue @@ -78,6 +78,9 @@ export default { }); }, getDateTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let year = time.getFullYear(); let month = time.getMonth() + 1 diff --git a/src/views/index/components/slideshow_card.vue b/src/views/index/components/slideshow_card.vue index c47cd4b..cea8325 100644 --- a/src/views/index/components/slideshow_card.vue +++ b/src/views/index/components/slideshow_card.vue @@ -67,7 +67,12 @@ export default { methods: { clickTo(link) { //console.log(link) - window.location.href = link;//当前标签页 + if (/android/i.test(navigator.userAgent)) { + window.open(link, "_blank") + } + if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { + window.location.href = window.location.origin + link;//当前标签页 + } }, constructor() { this.bannerWrap = document.getElementsByClassName("banner-card")[0]; diff --git a/src/views/index/components/undergraduate_and_graduate.vue b/src/views/index/components/undergraduate_and_graduate.vue index 054460c..9555196 100644 --- a/src/views/index/components/undergraduate_and_graduate.vue +++ b/src/views/index/components/undergraduate_and_graduate.vue @@ -101,6 +101,9 @@ export default { }, getMonthTime(date) { + if(typeof(date) == "string" && date.indexOf('-') != -1){ + date = date.replace(/-/g,'/'); + } let time = new Date(date); let month = time.getMonth() + 1 if (month < 10) { diff --git a/vue.config.js b/vue.config.js index eea3725..530f68a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -29,21 +29,21 @@ module.exports = { productionSourceMap: true, // webpack-dev-server 相关配置 devServer: { - // host: '0.0.0.0', - // // port: port, - // port: 8080, - // open: true, - // proxy: { - // // detail: https://cli.vuejs.org/config/#devserver-proxy - // [process.env.VUE_APP_BASE_API]: { - // target: `http://localhost:8085`, - // // target: `http://hchyunapi.tomey.live`, - // changeOrigin: true, - // pathRewrite: { - // ['^' + process.env.VUE_APP_BASE_API]: '' - // } - // } - // }, + host: '0.0.0.0', + // port: port, + port: 8080, + open: true, + proxy: { + // detail: https://cli.vuejs.org/config/#devserver-proxy + [process.env.VUE_APP_BASE_API]: { + target: `https://sist.swjtu.edu.cn/`, + // target: `http://hchyunapi.tomey.live`, + changeOrigin: true, + pathRewrite: { + ['^' + process.env.VUE_APP_BASE_API]: '/dev-api' + } + } + }, disableHostCheck: true }, // 强制内联CSS