|
@@ -14,6 +14,7 @@ import { computed, ref, onMounted,onUnmounted } from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import Config from '@/config/index'
|
|
import Config from '@/config/index'
|
|
|
import { customApi } from '@/service/custom'
|
|
import { customApi } from '@/service/custom'
|
|
|
|
|
+import { userToken } from "@/composables/config";
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
iconColor: {
|
|
iconColor: {
|
|
@@ -23,6 +24,11 @@ const props = defineProps({
|
|
|
textColor: {
|
|
textColor: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: '#141d22'
|
|
default: '#141d22'
|
|
|
|
|
+ },
|
|
|
|
|
+ // 事件来源标识,用于区分不同组件的事件监听
|
|
|
|
|
+ eventSource: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: ''
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -87,7 +93,11 @@ const applySystemList = (data: any[]) => {
|
|
|
|
|
|
|
|
async function getSystemList(type = false) {
|
|
async function getSystemList(type = false) {
|
|
|
const cached = getCache()
|
|
const cached = getCache()
|
|
|
- console.log(1,type)
|
|
|
|
|
|
|
+ console.log('system',type,props.form)
|
|
|
|
|
+ // top-window组件中,没有token不去请求接口
|
|
|
|
|
+ if (props.eventSource === 'top') {
|
|
|
|
|
+ if (!userToken.value) return
|
|
|
|
|
+ }
|
|
|
if (!type){
|
|
if (!type){
|
|
|
if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
|
|
if (cached && cached.timestamp && Date.now() - cached.timestamp < CACHE_DURATION) {
|
|
|
applySystemList(cached.data || [])
|
|
applySystemList(cached.data || [])
|
|
@@ -165,10 +175,13 @@ const isInit = ref(false)
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
if (isInit.value) return
|
|
if (isInit.value) return
|
|
|
isInit.value = true
|
|
isInit.value = true
|
|
|
- console.log('注册')
|
|
|
|
|
- // getSystemList()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ getSystemList()
|
|
|
|
|
|
|
|
- uni.$on('updateSystemList', () => {
|
|
|
|
|
|
|
+ uni.$on('updateSystemList', (source) => {
|
|
|
|
|
+ console.log(source)
|
|
|
|
|
+ // 如果指定了事件来源,只处理来自该来源的事件
|
|
|
|
|
+ if (props.eventSource && source !== props.eventSource) return
|
|
|
getSystemList(true)
|
|
getSystemList(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|