|
|
@@ -10,7 +10,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref, onMounted,onUnmounted } from 'vue'
|
|
|
+import { computed, ref, onMounted,onUnmounted,nextTick} from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import Config from '@/config/index'
|
|
|
import { customApi } from '@/service/custom'
|
|
|
@@ -46,12 +46,12 @@ type SystemItem = {
|
|
|
const systemList = ref<SystemItem[]>([])
|
|
|
const currentSystemCode = ref<string | null>(null)
|
|
|
|
|
|
-const systemMenuList = computed(() =>
|
|
|
- systemList.value.map((item) => ({
|
|
|
+const systemMenuList = computed(() =>{
|
|
|
+ return systemList.value.map((item) => ({
|
|
|
...item,
|
|
|
label: getSystemDisplayName(item),
|
|
|
- })),
|
|
|
-)
|
|
|
+ }))
|
|
|
+})
|
|
|
|
|
|
const currentSystemName = computed(() => {
|
|
|
if (!currentSystemCode.value || systemList.value.length === 0) {
|
|
|
@@ -59,7 +59,7 @@ const currentSystemName = computed(() => {
|
|
|
}
|
|
|
const currentSystem = systemList.value.find((item) => item.sysCode === currentSystemCode.value)
|
|
|
if (!currentSystem) return '系统切换'
|
|
|
-
|
|
|
+
|
|
|
return getSystemDisplayName(currentSystem)
|
|
|
})
|
|
|
|
|
|
@@ -82,6 +82,7 @@ const setCache = (data: any) => {
|
|
|
}
|
|
|
|
|
|
const applySystemList = (data: any[]) => {
|
|
|
+ // console.log(data,props.eventSource)
|
|
|
systemList.value = Array.isArray(data) ? data : []
|
|
|
if (systemList.value.length > 0) {
|
|
|
const localSystem = systemList.value.find((item) => item && item.localSystem === 1)
|
|
|
@@ -93,21 +94,21 @@ const applySystemList = (data: any[]) => {
|
|
|
|
|
|
async function getSystemList(type = false) {
|
|
|
const cached = getCache()
|
|
|
- console.log('system',type,props.form)
|
|
|
+ // console.log('system',type,props.eventSource)
|
|
|
// 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) {
|
|
|
applySystemList(cached.data || [])
|
|
|
return
|
|
|
}
|
|
|
- }
|
|
|
+ // }
|
|
|
|
|
|
- // console.log('qingqiule')
|
|
|
try {
|
|
|
const res: any = await customApi.getSystemList({})
|
|
|
+ // console.log('res',res)
|
|
|
if (res && res.code === Code.StatusOK) {
|
|
|
const data = res.data || []
|
|
|
applySystemList(data)
|
|
|
@@ -146,7 +147,6 @@ async function confirmSwitchSystem(item: SystemItem) {
|
|
|
try {
|
|
|
if (props.eventSource === 'login'){
|
|
|
const baseUrl = `${item.sysUrl}/#/signin`
|
|
|
- console.log(baseUrl)
|
|
|
// #ifdef H5
|
|
|
window.location.replace(baseUrl)
|
|
|
// #endif
|
|
|
@@ -160,7 +160,6 @@ async function confirmSwitchSystem(item: SystemItem) {
|
|
|
const accessToken = res.data
|
|
|
const token = typeof accessToken === 'string' ? accessToken : String(accessToken || '')
|
|
|
const baseUrl = `${item.sysUrl}/#/signin?sysLoginToken=${btoa(token)}`
|
|
|
- console.log(baseUrl)
|
|
|
// #ifdef H5
|
|
|
window.location.replace(baseUrl)
|
|
|
// #endif
|
|
|
@@ -174,7 +173,6 @@ async function confirmSwitchSystem(item: SystemItem) {
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
|
- console.log(e)
|
|
|
uni.showToast({ title: '切换系统失败', icon: 'none' })
|
|
|
}
|
|
|
}
|
|
|
@@ -188,13 +186,13 @@ const isInit = ref(false)
|
|
|
onMounted(() => {
|
|
|
if (isInit.value) return
|
|
|
isInit.value = true
|
|
|
-
|
|
|
+
|
|
|
getSystemList()
|
|
|
|
|
|
uni.$on('updateSystemList', (source) => {
|
|
|
// console.log(source)
|
|
|
// 如果指定了事件来源,只处理来自该来源的事件
|
|
|
- if (props.eventSource && source !== props.eventSource) return
|
|
|
+ // if (props.eventSource && source !== props.eventSource) return
|
|
|
getSystemList(true)
|
|
|
})
|
|
|
})
|