From 73e8ba186bcb824a63bac37ea722b9c59e082ea0 Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 26 Nov 2021 17:20:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/app.js | 29 ++++++++++++++++------------- static/template/layout.vue | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/static/app.js b/static/app.js index fab3d55fe..36ee5b2f7 100644 --- a/static/app.js +++ b/static/app.js @@ -2,18 +2,22 @@ const options = { moduleCache: { vue: Vue, - less: less + less: less, + storage: {} }, getFile(url) { return fetch(url).then(res => { - if (res.ok) return res.text(); - throw Object.assign(new Error(url + ' ' + res.statusText), {res}); + if (res.ok) { + return {getContentData: binary => binary ? res.arrayBuffer() : res.text()}; + } else { + throw Object.assign(new Error(url + ' ' + res.statusText), {res}); + } }); }, - addStyle(textContent) { - const style = document.head.getElementsByTagName('style')[0] || null; - const object = Object.assign(document.createElement('style'), {textContent}); - document.head.insertBefore(object, style); + addStyle(style) { + const before = document.head.getElementsByTagName('style')[0] || null; + const object = Object.assign(document.createElement('style'), {textContent: style}); + document.head.insertBefore(object, before); }, }; @@ -21,7 +25,6 @@ const loadVue = (vuePath) => loadModule(vuePath, options); const loadVueFile = (vuePath) => () => loadVue(vuePath); - const router = VueRouter.createRouter({ routes: [], history: VueRouter.createWebHashHistory(), @@ -50,8 +53,8 @@ } }); - window.app = Vue.createApp({ - name: 'app', + window.$think = Vue.createApp({ + name: 'ThinkAdmin', components: { layout: await loadVue('./static/template/layout.vue'), } @@ -59,10 +62,10 @@ // 全局字体文件 const icons = await loadVue("https://unpkg.com/@element-plus/icons@0.0.11/lib/index.js"); - for (let i in icons) app.component(i, icons[i]); + for (let i in icons) window.$think.component(i, icons[i]); + + window.$think.use(router).use(ElementPlus).mount(document.body); - app.use(router).use(ElementPlus).mount(document.body); - })().catch(function (ex) { console.error(ex); }); \ No newline at end of file diff --git a/static/template/layout.vue b/static/template/layout.vue index 9f694facd..c00d7f571 100644 --- a/static/template/layout.vue +++ b/static/template/layout.vue @@ -15,7 +15,7 @@ item two item three - Info + Info Orders @@ -23,7 +23,7 @@ - +