Bladeren bron

fix:修复一些警告

Jerry Liang 6 maanden geleden
bovenliggende
commit
301a596917

+ 8 - 17
src/router/guard.ts

@@ -15,7 +15,7 @@ const { loadingBar } = useDiscreteApi()
 const configureStore = useConfigureStore(createPinia())
 
 export function setupRouterGuard(router: Router) {
-  router.beforeEach(async (to, from, next) => {
+  router.beforeEach(async (to, from) => {
     console.log({ to, from })
     console.log(to.name)
     console.log(to.path)
@@ -43,21 +43,19 @@ export function setupRouterGuard(router: Router) {
           name: payload?.name ?? '',
         })
 
-        next(from.fullPath)
+        return from.fullPath
       } else {
         // 🚨 登录参数错误时跳转到 errorPage
-        next({ name: 'errorPage' })
+        return { name: 'errorPage' }
       }
-      return
     }
 
     if (to.name === 'signin') {
       if (!userStore.token) {
-        next()
+        return
       } else {
-        next(from.fullPath)
+        return from.fullPath
       }
-      return
     }
 
     if (!userStore.token) {
@@ -66,7 +64,6 @@ export function setupRouterGuard(router: Router) {
       } else {
         userStore.cleanup(to.fullPath)
       }
-      next()
       return
     }
 
@@ -82,22 +79,16 @@ export function setupRouterGuard(router: Router) {
           children: userStore.routeList,
         })
 
-        next(to.fullPath)
+        return to.fullPath
       } catch (error) {
         console.error('Error resolving user menu or adding route:', error)
         userStore.cleanup()
-        next()
       }
-
-      return
     }
-
-    next()
   })
 
-  router.beforeResolve((_, __, next) => {
-    next()
-  })
+  // next已弃用
+  router.beforeResolve((_, __) => {})
 
   router.afterEach(() => {
     configureStore.setNavigating(false)

+ 8 - 1
src/stores/modules/data/siteAlarmList.ts

@@ -17,7 +17,13 @@ export interface SiteAlarmListDataSet {
 
 export const useSiteAlarmListDataStore = defineSetupStore(STORES_KEY, CURRENT_VERSION, () => {
   // 站点告警数据
-  let siteAlarmListDate: SiteAlarmListDataSet = {}
+  const siteAlarmListDate: SiteAlarmListDataSet = {}
+
+  function $reset() {
+    for (const key in siteAlarmListDate) {
+      delete siteAlarmListDate[key]
+    }
+  }
 
   // 获取某个站点的告警列表
   function siteAlarmListGet(sn: string): SiteAlarmList[] | undefined {
@@ -76,5 +82,6 @@ export const useSiteAlarmListDataStore = defineSetupStore(STORES_KEY, CURRENT_VE
     // actions - function()
     querySiteAlarmList,
     clearSitesData,
+    $reset,
   }
 })

+ 8 - 1
src/stores/modules/data/siteInfoData.ts

@@ -17,7 +17,13 @@ export interface SiteInfoDataSet {
 
 export const useSiteInfoDataStore = defineSetupStore(STORES_KEY, CURRENT_VERSION, () => {
   // 站点信息数据
-  let siteInfoDate: SiteInfoDataSet = {}
+  const siteInfoDate: SiteInfoDataSet = {}
+
+  function $reset() {
+    for (const key in siteInfoDate) {
+      delete siteInfoDate[key]
+    }
+  }
 
   // 获取某个站点的基本信息
   function siteInfoGet(sn: string): SiteInfo | undefined {
@@ -80,5 +86,6 @@ export const useSiteInfoDataStore = defineSetupStore(STORES_KEY, CURRENT_VERSION
     // actions - function()
     querySiteInfo,
     clearSitesData,
+    $reset,
   }
 })

+ 7 - 0
src/stores/modules/data/siteModeData.ts

@@ -19,6 +19,12 @@ export const useSiteModeDataStore = defineSetupStore(STORES_KEY, CURRENT_VERSION
   // 站点模式数据
   const siteModeData: SiteModeDataSet = {}
 
+  function $reset() {
+    for (const key in siteModeData) {
+      delete siteModeData[key]
+    }
+  }
+
   // 获取某个站点的工作模式信息
   function siteModeInfoGet(sn: string): SiteModeInfo | undefined {
     if (sn in siteModeData) {
@@ -76,5 +82,6 @@ export const useSiteModeDataStore = defineSetupStore(STORES_KEY, CURRENT_VERSION
     // actions - function()
     querySiteModeInfo,
     clearSitesData,
+    $reset,
   }
 })

+ 12 - 2
src/stores/modules/data/sitePowerFlowData.ts

@@ -83,8 +83,17 @@ export const useSitePowerFlowDataStore = defineSetupStore(
   CURRENT_VERSION,
   () => {
     // 站点功率流数据
-    let sitePowerFlowDate: SitePowerFlowDataSet = {}
-    let sitePowerFlowChartData: SitePowerChartDataSet = {}
+    const sitePowerFlowDate: SitePowerFlowDataSet = {}
+    const sitePowerFlowChartData: SitePowerChartDataSet = {}
+
+    function $reset() {
+      for (const key in sitePowerFlowDate) {
+        delete sitePowerFlowDate[key]
+      }
+      for (const key in sitePowerFlowChartData) {
+        delete sitePowerFlowChartData[key]
+      }
+    }
 
     // 获取某个站点的功率数据
     function powerFlowGet(sn: string, date: string): SitePowerFlow | undefined {
@@ -201,6 +210,7 @@ export const useSitePowerFlowDataStore = defineSetupStore(
 
       // actions - function()
       queryPowerFlow,
+      $reset,
     }
   },
   {

+ 10 - 0
src/stores/modules/views/siteInfoManageState.ts

@@ -45,6 +45,15 @@ export const useSiteInfoManageStateStore = defineSetupStore(STORES_KEY, CURRENT_
     customQueryFilter: ref<CustomSiteInfoFilter[]>([]),
   }
 
+  function $reset() {
+    siteInfoState.titleFilter = ref<string[]>(defaultTitleSelectOption)
+    siteInfoState.queryFilter = ref<SiteInfoFilter>({
+      logic: 'or',
+      subFilter: [],
+    })
+    siteInfoState.customQueryFilter = ref<CustomSiteInfoFilter[]>([])
+  }
+
   const getTitleFilterRef = () => {
     return siteInfoState.titleFilter
   }
@@ -116,5 +125,6 @@ export const useSiteInfoManageStateStore = defineSetupStore(STORES_KEY, CURRENT_
     setCustomQueryFilter,
 
     queryConfig, // 查询用户配置
+    $reset,
   }
 })

+ 6 - 2
src/stores/modules/views/siteRuntimeChartConfig.ts

@@ -8,7 +8,7 @@ export const useSiteRuntimeChartConfigStore = defineSetupStore(
   CURRENT_VERSION,
   () => {
     // 默认值
-    let siteRuntimeChartConfig: string[] = [
+    const siteRuntimeChartConfig: string[] = [
       'mode', // 工作模式(mode)
       'run_status', // 运行状态(run_status)
       'elecnet_state', // 市电状态(elecnet_state)
@@ -23,12 +23,15 @@ export const useSiteRuntimeChartConfigStore = defineSetupStore(
       'p_load', // 家庭负载功率(p_load)
     ]
 
+    function $reset() {}
+
     const getConfig = (): string[] => {
       return siteRuntimeChartConfig
     }
 
     const updateConfig = (config: string[]) => {
-      siteRuntimeChartConfig = config
+      siteRuntimeChartConfig.length = 0
+      siteRuntimeChartConfig.push(...config)
     }
 
     return {
@@ -44,6 +47,7 @@ export const useSiteRuntimeChartConfigStore = defineSetupStore(
 
       // actions - function()
       updateConfig, // 更新配置
+      $reset,
     }
   },
   {

+ 8 - 1
src/stores/modules/views/sitesMonitorConfig.ts

@@ -32,7 +32,13 @@ export interface MonitorConfigSet {
 }
 
 export const useSitesMonitorConfigStore = defineSetupStore(STORES_KEY, CURRENT_VERSION, () => {
-  let siteMonitorConfig: MonitorConfigSet = {}
+  const siteMonitorConfig: MonitorConfigSet = {}
+
+  function $reset() {
+    for (const key in siteMonitorConfig) {
+      delete siteMonitorConfig[key]
+    }
+  }
 
   // 监听每一个配置
 
@@ -392,5 +398,6 @@ export const useSitesMonitorConfigStore = defineSetupStore(STORES_KEY, CURRENT_V
     // actions - function()
     setConfig,
     updateConfig, // 自动更新,不对外开放
+    $reset,
   }
 })

+ 8 - 1
src/stores/modules/views/sitesMonitorState.ts

@@ -13,7 +13,13 @@ export interface MonitorStateSet {
 }
 
 export const useSitesMonitorStateStore = defineSetupStore(STORES_KEY, CURRENT_VERSION, () => {
-  let siteMonitorState: MonitorStateSet = {}
+  const siteMonitorState: MonitorStateSet = {}
+
+  function $reset() {
+    for (const key in siteMonitorState) {
+      delete siteMonitorState[key]
+    }
+  }
 
   // 设置某个监控页面显示的日期
   function setMonitorStateDate(pageName: string, date: number) {
@@ -70,5 +76,6 @@ export const useSitesMonitorStateStore = defineSetupStore(STORES_KEY, CURRENT_VE
     // actions - function()
     setMonitorStateDate,
     setMonitorStateLegend,
+    $reset,
   }
 })

+ 7 - 0
src/stores/modules/views/xlogViewsState.ts

@@ -20,6 +20,12 @@ export interface XlogViewsStateSet {
 export const useXlogViewsStateStore = defineSetupStore(STORES_KEY, CURRENT_VERSION, () => {
   const xlogViewsState: XlogViewsStateSet = {}
 
+  function $reset() {
+    for (const key in xlogViewsState) {
+      delete xlogViewsState[key]
+    }
+  }
+
   // 初始化(懒创建)
   function ensure(uuid: string): Required<XlogViewsStateData> {
     xlogViewsState[uuid] ??= {}
@@ -63,5 +69,6 @@ export const useXlogViewsStateStore = defineSetupStore(STORES_KEY, CURRENT_VERSI
 
     // actions - function()
     setCmdListDate,
+    $reset,
   }
 })