2021-05-13 10:56:04 +08:00
|
|
|
<template>
|
|
|
|
<div id="app">
|
2022-05-20 16:40:09 +08:00
|
|
|
<router-view />
|
2021-05-13 10:56:04 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-20 16:40:09 +08:00
|
|
|
import storage from "@/plugins/storage";
|
|
|
|
import { getBaseSite } from "@/api/common.js";
|
2021-05-13 10:56:04 +08:00
|
|
|
export default {
|
2022-05-20 16:40:09 +08:00
|
|
|
name: "App",
|
|
|
|
mounted() {
|
2022-05-31 09:51:43 +08:00
|
|
|
this.init();
|
2022-05-20 16:40:09 +08:00
|
|
|
},
|
2022-05-31 09:51:43 +08:00
|
|
|
methods:{
|
|
|
|
init(){
|
2022-06-01 10:13:53 +08:00
|
|
|
if(!storage.getItem("siteName")||!storage.getItem("logoImg")||!storage.getItem("sitelogo_expiration_time")) {
|
2022-05-31 09:51:43 +08:00
|
|
|
this.getSite();
|
|
|
|
}else{
|
|
|
|
// 如果缓存过期,则获取最新的信息
|
2022-06-01 10:13:53 +08:00
|
|
|
if (new Date() > storage.getItem("sitelogo_expiration_time")) {
|
2022-05-31 09:51:43 +08:00
|
|
|
this.getSite();
|
|
|
|
return;
|
|
|
|
}else{
|
2022-06-01 10:13:53 +08:00
|
|
|
window.document.title = storage.getItem("siteName");
|
2022-05-31 09:51:43 +08:00
|
|
|
//动态获取icon
|
|
|
|
let link =document.querySelector("link[rel*='icon']") ||document.createElement("link");
|
|
|
|
link.type = "image/x-icon";
|
2022-06-01 10:13:53 +08:00
|
|
|
link.href = storage.getItem("logoImg");
|
2022-05-31 09:51:43 +08:00
|
|
|
link.rel = "shortcut icon";
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
getSite(){
|
|
|
|
//获取基本站点信息
|
|
|
|
getBaseSite().then((res) => {
|
|
|
|
if (res.success && res.result.settingValue) {
|
|
|
|
let data = JSON.parse(res.result.settingValue);
|
|
|
|
// 过期时间
|
|
|
|
var expirationTime = new Date().setHours(new Date().getHours() + 1);
|
|
|
|
// 存放过期时间
|
2022-06-01 10:13:53 +08:00
|
|
|
storage.setItem("sitelogo_expiration_time", expirationTime);
|
2022-05-31 09:51:43 +08:00
|
|
|
// 存放信息
|
2022-06-01 10:13:53 +08:00
|
|
|
storage.setItem('siteName', data.siteName);
|
|
|
|
storage.setItem('logoImg', data.buyerSideLogo);
|
2022-05-31 09:51:43 +08:00
|
|
|
|
|
|
|
window.document.title = data.siteName;
|
|
|
|
//动态获取icon
|
|
|
|
let link =document.querySelector("link[rel*='icon']") ||document.createElement("link");
|
|
|
|
link.type = "image/x-icon";
|
|
|
|
link.href = data.buyerSideLogo;
|
|
|
|
link.rel = "shortcut icon";
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-05-13 10:56:04 +08:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style lang="scss">
|
2022-05-20 16:40:09 +08:00
|
|
|
#app {
|
2021-05-13 10:56:04 +08:00
|
|
|
@include background_color($light_background_color);
|
|
|
|
}
|
|
|
|
</style>
|