mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2026-01-20 16:53:37 +08:00
feat: add horizontal nav (#45)
* feat: add horizontal nav * workflow: update linter.yml * fix: update * fix: update * fix: update * Rename Link.vue to link.vue * Rename SidebarItem.vue to sidebarItem.vue * Rename Logo.vue to logo.vue * Rename AppMain.vue to appMain.vue * Rename Navbar.vue to navbar.vue * fix: update * fix: update * fix: update * workflow: update linter.yml * fix: update * chore: update * workflow: update * fix: update * fix: update * fix: update * perf: 外链功能实现方式改变 * style: update nav style * perf: 优化国际化 * fix: update * fix: update
This commit is contained in:
43
src/main.ts
43
src/main.ts
@@ -1,6 +1,7 @@
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import { setupStore } from "/@/store";
|
||||
import { getServerConfig } from "./config";
|
||||
import { createApp, Directive } from "vue";
|
||||
import { usI18n } from "../src/plugins/i18n";
|
||||
import { useTable } from "../src/plugins/vxe-table";
|
||||
@@ -14,13 +15,8 @@ import "./assets/iconfont/iconfont.js";
|
||||
import "./assets/iconfont/iconfont.css";
|
||||
import "v-contextmenu/dist/themes/default.css";
|
||||
|
||||
import { setConfig, getConfig } from "./config";
|
||||
import axios from "axios";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.config.globalProperties.$config = getConfig();
|
||||
|
||||
// 响应式storage
|
||||
import Storage from "responsive-storage";
|
||||
// @ts-ignore
|
||||
@@ -47,6 +43,13 @@ app.use(Storage, {
|
||||
default: Storage.getData(undefined, "locale") ?? {
|
||||
locale: "zh"
|
||||
}
|
||||
},
|
||||
// layout模式以及主题
|
||||
layout: {
|
||||
type: Object,
|
||||
default: Storage.getData(undefined, "layout") ?? {
|
||||
layout: "vertical-dark"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -56,35 +59,7 @@ Object.keys(directives).forEach(key => {
|
||||
app.directive(key, (directives as { [key: string]: Directive })[key]);
|
||||
});
|
||||
|
||||
// 获取项目动态全局配置
|
||||
export const getServerConfig = async (): Promise<undefined> => {
|
||||
return axios({
|
||||
baseURL: "",
|
||||
method: "get",
|
||||
url:
|
||||
process.env.NODE_ENV === "production"
|
||||
? "/manages/serverConfig.json"
|
||||
: "/serverConfig.json"
|
||||
})
|
||||
.then(({ data: config }) => {
|
||||
let $config = app.config.globalProperties.$config;
|
||||
// 自动注入项目配置
|
||||
if (app && $config && typeof config === "object") {
|
||||
$config = Object.assign($config, config);
|
||||
app.config.globalProperties.$config = $config;
|
||||
// 设置全局配置
|
||||
setConfig($config);
|
||||
}
|
||||
// 设置全局baseURL
|
||||
app.config.globalProperties.$baseUrl = $config.baseURL;
|
||||
return $config;
|
||||
})
|
||||
.catch(() => {
|
||||
throw "请在public文件夹下添加serverConfig.json配置文件";
|
||||
});
|
||||
};
|
||||
|
||||
getServerConfig().then(async () => {
|
||||
getServerConfig(app).then(async () => {
|
||||
setupStore(app);
|
||||
app.use(router).use(useElementPlus).use(useTable).use(usI18n);
|
||||
await router.isReady();
|
||||
|
||||
Reference in New Issue
Block a user