mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +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:
@@ -1,3 +1,5 @@
|
||||
import { App } from "vue";
|
||||
import axios from "axios";
|
||||
let config: object = {};
|
||||
|
||||
const setConfig = (cfg?: unknown) => {
|
||||
@@ -22,4 +24,33 @@ const getConfig = (key?: string) => {
|
||||
return config;
|
||||
};
|
||||
|
||||
// 获取项目动态全局配置
|
||||
export const getServerConfig = async (app: App): Promise<undefined> => {
|
||||
app.config.globalProperties.$config = getConfig();
|
||||
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配置文件";
|
||||
});
|
||||
};
|
||||
|
||||
export { getConfig, setConfig };
|
||||
|
||||
Reference in New Issue
Block a user