mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-07 17:38:55 +08:00
- 新增 eslint.config.js(flat config, vue3-essential),移除废弃的 .eslintrc.js/.eslintignore(引用已废弃的 babel-eslint),package.json 增加 lint/lint:fix 脚本 - 清理 17 处调试 console.log;修复 24 处空 catch(15 处补 console.warn 业务提示,9 处加注释说明可安全忽略) - 修复存量 lint error:9 处 prop 默认值改为函数形式、3 处未使用组件、1 处 v-if/v-for 同级、1 处空 else - vue.config.js 生产环境 terser 开启 drop_console 兜底
78 lines
2.2 KiB
Vue
78 lines
2.2 KiB
Vue
<template>
|
|
<div id="app">
|
|
<router-view />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import storage from "@/plugins/storage";
|
|
import { getBaseSite, getThemeSetting } from "@/api/common.js";
|
|
import { fetchAndApplyTheme } from "@/utils/theme";
|
|
|
|
export default {
|
|
name: "App",
|
|
mounted() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
applySiteInfo(data) {
|
|
const expirationTime = new Date().setHours(new Date().getHours() + 1);
|
|
storage.setItem("sitelogo_expiration_time", expirationTime);
|
|
storage.setItem("siteName", data.siteName);
|
|
storage.setItem("logoImg", data.buyerSideLogo);
|
|
storage.setItem("siteIcon", data.buyerSideIcon);
|
|
this.$store.commit("SET_SITENAME", data.siteName);
|
|
this.$store.commit("SET_LOGOIMG", data.buyerSideLogo);
|
|
if (this.$route.meta.title === undefined) {
|
|
window.document.title = data.siteName;
|
|
}
|
|
let link =
|
|
document.querySelector("link[rel*='icon']") ||
|
|
document.createElement("link");
|
|
link.type = "image/x-icon";
|
|
link.href = data.buyerSideIcon;
|
|
link.rel = "shortcut icon";
|
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
},
|
|
init() {
|
|
const expirationTime = storage.getItem("sitelogo_expiration_time");
|
|
const cacheValid =
|
|
expirationTime && new Date() <= new Date(Number(expirationTime));
|
|
if (cacheValid) {
|
|
this.applySiteInfo({
|
|
siteName: storage.getItem("siteName"),
|
|
buyerSideLogo: storage.getItem("logoImg"),
|
|
buyerSideIcon: storage.getItem("siteIcon"),
|
|
});
|
|
}
|
|
this.getSite();
|
|
this.getTheme();
|
|
},
|
|
getSite() {
|
|
getBaseSite().then((res) => {
|
|
if (res.success && res.result.settingValue) {
|
|
try {
|
|
const data = JSON.parse(res.result.settingValue);
|
|
this.applySiteInfo(data);
|
|
} catch {
|
|
// 站点配置解析失败时使用缓存
|
|
}
|
|
}
|
|
}).catch((err) => {
|
|
console.warn('获取站点配置失败', err);
|
|
});
|
|
},
|
|
getTheme() {
|
|
fetchAndApplyTheme(getThemeSetting).catch((err) => {
|
|
console.warn('获取主题配置失败', err);
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="scss">
|
|
#app {
|
|
@include background_color($light_background_color);
|
|
}
|
|
</style>
|