修改模板

This commit is contained in:
Anyon 2021-11-26 17:20:31 +08:00
parent 68f4d6bdc8
commit 73e8ba186b
2 changed files with 18 additions and 15 deletions

View File

@ -2,18 +2,22 @@
const options = { const options = {
moduleCache: { moduleCache: {
vue: Vue, vue: Vue,
less: less less: less,
storage: {}
}, },
getFile(url) { getFile(url) {
return fetch(url).then(res => { return fetch(url).then(res => {
if (res.ok) return res.text(); if (res.ok) {
throw Object.assign(new Error(url + ' ' + res.statusText), {res}); return {getContentData: binary => binary ? res.arrayBuffer() : res.text()};
} else {
throw Object.assign(new Error(url + ' ' + res.statusText), {res});
}
}); });
}, },
addStyle(textContent) { addStyle(style) {
const style = document.head.getElementsByTagName('style')[0] || null; const before = document.head.getElementsByTagName('style')[0] || null;
const object = Object.assign(document.createElement('style'), {textContent}); const object = Object.assign(document.createElement('style'), {textContent: style});
document.head.insertBefore(object, style); document.head.insertBefore(object, before);
}, },
}; };
@ -21,7 +25,6 @@
const loadVue = (vuePath) => loadModule(vuePath, options); const loadVue = (vuePath) => loadModule(vuePath, options);
const loadVueFile = (vuePath) => () => loadVue(vuePath); const loadVueFile = (vuePath) => () => loadVue(vuePath);
const router = VueRouter.createRouter({ const router = VueRouter.createRouter({
routes: [], routes: [],
history: VueRouter.createWebHashHistory(), history: VueRouter.createWebHashHistory(),
@ -50,8 +53,8 @@
} }
}); });
window.app = Vue.createApp({ window.$think = Vue.createApp({
name: 'app', name: 'ThinkAdmin',
components: { components: {
layout: await loadVue('./static/template/layout.vue'), 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"); 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) { })().catch(function (ex) {
console.error(ex); console.error(ex);
}); });

View File

@ -15,7 +15,7 @@
<el-menu-item index="2-2">item two</el-menu-item> <el-menu-item index="2-2">item two</el-menu-item>
<el-menu-item index="2-3">item three</el-menu-item> <el-menu-item index="2-3">item three</el-menu-item>
</el-sub-menu> </el-sub-menu>
<el-menu-item index="3" disabled>Info</el-menu-item> <el-menu-item index="3">Info</el-menu-item>
<el-menu-item index="4">Orders</el-menu-item> <el-menu-item index="4">Orders</el-menu-item>
</el-menu> </el-menu>
</el-header> </el-header>
@ -23,7 +23,7 @@
<el-aside width="280px"> <el-aside width="280px">
<el-container style="height:100%"> <el-container style="height:100%">
<el-aside width="80px" style="background:rgba(54,25,88,.9);height:100%"> <el-aside width="80px" style="background:rgba(54,25,88,.9);height:100%">
</el-aside> </el-aside>
<el-container style="background:#8c939d"> <el-container style="background:#8c939d">
<el-menu default-active="1" style="width:100%"> <el-menu default-active="1" style="width:100%">