|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <view class="cwg-system">
|
|
|
+ <view class="cwg-system" v-if="systemMenuList.length">
|
|
|
<cwg-dropdown :menu-list="systemMenuList" @menuClick="handleMenuClick">
|
|
|
<view class="pc-header-btn">
|
|
|
<text class="current-system-name">{{ currentSystemName }}</text>
|
|
|
@@ -10,7 +10,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref, onMounted } from 'vue'
|
|
|
+import { computed, ref, onMounted,onUnmounted } from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import Config from '@/config/index'
|
|
|
import { customApi } from '@/service/custom'
|
|
|
@@ -85,13 +85,17 @@ const applySystemList = (data: any[]) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function getSystemList() {
|
|
|
+async function getSystemList(type = false) {
|
|
|
const cached = getCache()
|
|
|
- if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
|
|
|
- applySystemList(cached.data || [])
|
|
|
- return
|
|
|
+ console.log(1)
|
|
|
+ if (!type){
|
|
|
+ if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
|
|
|
+ applySystemList(cached.data || [])
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ console.log('qingqiule')
|
|
|
try {
|
|
|
const res: any = await customApi.getSystemList({})
|
|
|
if (res && res.code === Code.StatusOK) {
|
|
|
@@ -155,8 +159,20 @@ function handleMenuClick({ value }: { value: any }) {
|
|
|
switchSystem(value)
|
|
|
}
|
|
|
|
|
|
+const isInit = ref(false)
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
+ if (isInit.value) return
|
|
|
+ isInit.value = true
|
|
|
+
|
|
|
getSystemList()
|
|
|
+
|
|
|
+ uni.$on('updateSystemList', () => {
|
|
|
+ getSystemList(true)
|
|
|
+ })
|
|
|
+})
|
|
|
+onUnmounted(() => {
|
|
|
+ uni.$off('updateSystemList')
|
|
|
})
|
|
|
</script>
|
|
|
|