| | |
| | | RedoOutlined, |
| | | UserOutlined, |
| | | TranslationOutlined, |
| | | ApartmentOutlined, |
| | | } from "@ant-design/icons-vue"; |
| | | import { formatMessage } from '@/utils/localeUtils.js'; |
| | | |
| | |
| | | let currentCache = ref(null); |
| | | let isRouterAlive = ref(true); |
| | | const menuCache = ref([]); |
| | | const hostList = ref([]); |
| | | |
| | | const components = { |
| | | ...Icons, |
| | |
| | | } |
| | | }) |
| | | |
| | | console.log(tmpList); |
| | | |
| | | if (tmp == 0) { |
| | | router.push({ |
| | | path: '/' |
| | |
| | | } |
| | | } |
| | | |
| | | function closeAllTabs() { |
| | | routerCache.value = []; |
| | | routerCacheList.value = []; |
| | | router.push({ |
| | | path: '/' |
| | | }) |
| | | } |
| | | |
| | | function switchTabs(item) { |
| | | router.push({ |
| | | path: item.key |
| | |
| | | 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> |
| | |
| | | <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 /> |