From ccd7b3c5b24fa115a732ea915e2e586de717ea1c Mon Sep 17 00:00:00 2001 From: “dzb” <2632970487@qq.com> Date: 星期一, 26 九月 2022 21:39:43 +0800 Subject: [PATCH] 完成logo管理 --- src/App.vue | 72 +++++++++++++++++++++++------------ 1 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/App.vue b/src/App.vue index 240acf4..0c85672 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,32 +1,54 @@ <template> <div id="app"> - <nav> - <router-link to="/">Home</router-link> | - <router-link to="/about">About</router-link> - </nav> - <router-view/> + <router-view /> </div> </template> +<script> +export default { + data() { + return { + mytitle: '', + } + }, + async created() { + const imgObj = await this.getIcon(); + this.changIcon(imgObj); + }, + methods: { + changIcon(obj) { + var link = document.querySelector("link [rel*='icon']") || document.createElement("link"); + var title = document.querySelector("title") || document.createElement("title"); + link.type = "image/x-icon"; + link.rel = "shortcut icon"; + link.href = obj.chromeLinkUrl; //icon鍥炬爣 + title.innerHTML = obj.title; + document.getElementsByTagName("head")[0].appendChild(link); + document.getElementsByTagName("head")[0].appendChild(title); + }, + // 鑾峰彇icon + async getIcon() { + let result; + const pic = JSON.parse(localStorage.getItem('pic')); + if (pic) { + result = pic; + console.log('缂撳瓨') + } else { + console.log('璇锋眰'); + await this.$axios({ + method: 'get', + url: 'sccg/system/portal/logo/search', + }).then(res => { + console.log(res); + result = res.data; + localStorage.setItem('pic',JSON.stringify(result)); + }) + } + return result; + }, + } +}; +</script> <style> -#app { - font-family: Avenir, Helvetica, Arial, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - text-align: center; - color: #2c3e50; -} -nav { - padding: 30px; -} - -nav a { - font-weight: bold; - color: #2c3e50; -} - -nav a.router-link-exact-active { - color: #42b983; -} -</style> +</style> \ No newline at end of file -- Gitblit v1.8.0