refactor: 重构项目结构
- 优化 `车站-设备-告警` 轮询机制 - 改进设备卡片的布局 - 支持修改设备 - 告警轮询中获取完整告警数据 - 车站告警详情支持导出完整的 `今日告警列表` - 支持将状态持久化到 `IndexedDB` - 新增轮询控制 (调试模式) - 新增离线开发模式 (调试模式) - 新增 `IndexedDB` 数据控制 (调试模式)
This commit is contained in:
81
src/stores/setting.ts
Normal file
81
src/stores/setting.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { NDM_SETTING_STORE_ID } from '@/constants';
|
||||
import { darkTheme, lightTheme } from 'naive-ui';
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useUserStore } from './user';
|
||||
import router from '@/router';
|
||||
|
||||
export const useSettingStore = defineStore(
|
||||
NDM_SETTING_STORE_ID,
|
||||
() => {
|
||||
const darkThemeEnabled = ref(true);
|
||||
const themeMode = computed(() => {
|
||||
return darkThemeEnabled.value ? darkTheme : lightTheme;
|
||||
});
|
||||
|
||||
const menuCollpased = ref(false);
|
||||
|
||||
const stationGridCols = ref(6);
|
||||
|
||||
const debugModeEnabled = ref(false);
|
||||
const enableDebugMode = () => {
|
||||
debugModeEnabled.value = true;
|
||||
};
|
||||
const disableDebugMode = () => {
|
||||
debugModeEnabled.value = false;
|
||||
};
|
||||
|
||||
// 离线开发模式
|
||||
// 控制 版本轮询 stomp连接 app-layout中的自动getUserInfo
|
||||
const offlineDev = ref(false);
|
||||
watch(offlineDev, (newValue, oldValue) => {
|
||||
// 如果启用离线开发模式且当前未登录 自动填写token以绕过路由守卫并跳过登录页
|
||||
if (!oldValue && newValue) {
|
||||
const userStore = useUserStore();
|
||||
if (!userStore.userLoginResult) {
|
||||
userStore.userLoginResult = {
|
||||
tenantId: '',
|
||||
uuid: '',
|
||||
token: 'test',
|
||||
refreshToken: '',
|
||||
expire: '',
|
||||
expiration: '',
|
||||
};
|
||||
}
|
||||
if (!userStore.userLoginResult.token) {
|
||||
userStore.userLoginResult.token = 'test';
|
||||
}
|
||||
if (router.currentRoute.value.path === '/login') {
|
||||
router.push({ path: '/' });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
darkThemeEnabled,
|
||||
themeMode,
|
||||
|
||||
menuCollpased,
|
||||
|
||||
stationGridCols,
|
||||
|
||||
debugModeEnabled,
|
||||
enableDebugMode,
|
||||
disableDebugMode,
|
||||
|
||||
offlineDev,
|
||||
};
|
||||
},
|
||||
{
|
||||
persist: [
|
||||
{
|
||||
omit: ['debugModeEnabled'],
|
||||
storage: window.localStorage,
|
||||
},
|
||||
{
|
||||
pick: ['debugModeEnabled'],
|
||||
storage: window.sessionStorage,
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user