From acebf48e2e139f6f298cfbba829cc3c29db3c891 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 03 七月 2024 10:20:23 +0800
Subject: [PATCH] #
---
zy-asrs-admin/src/views/IndexView.vue | 61 +++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/zy-asrs-admin/src/views/IndexView.vue b/zy-asrs-admin/src/views/IndexView.vue
index e5aa0ae..13eb79d 100644
--- a/zy-asrs-admin/src/views/IndexView.vue
+++ b/zy-asrs-admin/src/views/IndexView.vue
@@ -13,6 +13,7 @@
RedoOutlined,
UserOutlined,
TranslationOutlined,
+ ApartmentOutlined,
} from "@ant-design/icons-vue";
import { formatMessage } from '@/utils/localeUtils.js';
@@ -25,6 +26,7 @@
let currentCache = ref(null);
let isRouterAlive = ref(true);
const menuCache = ref([]);
+const hostList = ref([]);
const components = {
...Icons,
@@ -71,8 +73,6 @@
}
})
- console.log(tmpList);
-
if (tmp == 0) {
router.push({
path: '/'
@@ -106,6 +106,14 @@
}
}
+function closeAllTabs() {
+ routerCache.value = [];
+ routerCacheList.value = [];
+ router.push({
+ path: '/'
+ })
+}
+
function switchTabs(item) {
router.push({
path: item.key
@@ -119,6 +127,41 @@
globalState.locale = locale;
localStorage.setItem('locale', locale)
reloadTabs()
+}
+
+getHostList()
+function getHostList() {
+ post('/api/show/host.action', {}).then((resp) => {
+ let result = resp.data;
+ let data = result.data;
+ let hostId = data.hostId;
+ if (data.root) {
+ post('/api/host/list', {}).then((resp) => {
+ let result = resp.data;
+ let data = result.data;
+ hostList.value = data;
+ data.forEach((item) => {
+ if (item.id == hostId) {
+ globalState.currentHost = item;
+ }
+ })
+ })
+ }
+ })
+}
+
+const switchHost = (item) => {
+ globalState.currentHost = item;
+ postForm('/api/root/change/host/auth', {
+ hostId: item.id
+ }).then((resp) => {
+ let result = resp.data;
+ if (result.code == 200) {
+ window.location.reload();
+ } else {
+ message.error(formatMessage('common.fail', '鍔犺浇澶辫触'));
+ }
+ })
}
</script>
@@ -159,6 +202,20 @@
<MenuFoldOutlined v-else class="trigger" @click="() => (collapsed = !collapsed)" />
</div>
<div class="header-top-right">
+ <div class="trigger" v-if="globalState.currentHost">
+ <a-dropdown>
+ <div>
+ <ApartmentOutlined />
+ {{ globalState.currentHost?.name }}
+ </div>
+ <template #overlay>
+ <a-menu>
+ <a-menu-item v-for="(item, index) in hostList" :key="index" @click="switchHost(item)"
+ :class="globalState.currentHost?.id == item.id ? 'active' : ''">{{ item.name }}</a-menu-item>
+ </a-menu>
+ </template>
+ </a-dropdown>
+ </div>
<div class="trigger">
<a-dropdown>
<TranslationOutlined />
--
Gitblit v1.9.1