mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-27 06:41:12 +00:00
1、系统配置修改上线 2、 pinia取代vuex
This commit is contained in:
+27
-29
@@ -6,39 +6,37 @@ import "ant-design-vue/dist/reset.css";
|
||||
import VChart from "vue-echarts";
|
||||
import "echarts";
|
||||
import './style.css'
|
||||
|
||||
import { getInitConfig } from "@/api/system/config"
|
||||
import { createPinia } from 'pinia';
|
||||
import { useConfigStore } from "@/store/index";
|
||||
|
||||
const app = createApp(App);
|
||||
const pinia = createPinia();
|
||||
|
||||
const initConfig = () => {
|
||||
return getInitConfig()
|
||||
.then((response) => {
|
||||
const { status_code, data } = response.data;
|
||||
if (status_code === 200) {
|
||||
const configData = JSON.parse(data);
|
||||
configData.forEach((item) => {
|
||||
if (item.fied_key === "login_title") {
|
||||
document.title = item.fied_value || "fastapi vue admin";
|
||||
} else if (item.fied_key === "login_logo") {
|
||||
const favicon = document.querySelector('link[rel="icon"]');
|
||||
if (favicon) {
|
||||
favicon.href = item.fied_value || "/logo.png";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
message.error("获取系统配置失败");
|
||||
console.error(error); // 打印错误信息以便调试
|
||||
});
|
||||
app.use(pinia);
|
||||
|
||||
const initConfig = async () => {
|
||||
const configStore = useConfigStore();
|
||||
await configStore.fetchConfig();
|
||||
|
||||
const loginTitle = configStore.getConfigValue("title");
|
||||
const loginLogo = configStore.getConfigValue("favicon");
|
||||
|
||||
if (loginTitle) {
|
||||
document.title = loginTitle;
|
||||
}
|
||||
|
||||
if (loginLogo) {
|
||||
const favicon = document.querySelector('link[rel="icon"]');
|
||||
if (favicon) {
|
||||
favicon.href = loginLogo;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化配置并挂载应用
|
||||
initConfig().then(() => {
|
||||
app.use(router);
|
||||
app.use(Antd);
|
||||
app.component("VChart", VChart);
|
||||
app.mount("#app");
|
||||
});
|
||||
app.use(router);
|
||||
app.use(Antd);
|
||||
app.component("VChart", VChart);
|
||||
app.mount("#app");
|
||||
});
|
||||
Reference in New Issue
Block a user