| | |
| | | <script setup> |
| | | import { nextTick, ref, inject, computed } from 'vue'; |
| | | import { nextTick, ref, inject } from 'vue'; |
| | | import { useRouter } from "vue-router"; |
| | | import { get, post } from '@/utils/request.js' |
| | | import { get, post, postForm } from '@/utils/request.js' |
| | | import { logout } from '@/config.js'; |
| | | import * as Icons from "@ant-design/icons-vue"; |
| | | import { message } from 'ant-design-vue'; |
| | | import { |
| | | MenuUnfoldOutlined, |
| | | MenuFoldOutlined, |
| | |
| | | }; |
| | | |
| | | getMenu() |
| | | |
| | | function getMenu() { |
| | | post('/api/menu/tree', {}).then((result) => { |
| | | console.log(result.data.data); |
| | | get('/api/auth/menu', {}).then((result) => { |
| | | menuCache.value = result.data.data; |
| | | }) |
| | | } |
| | | |
| | | function menuSelect(item) { |
| | | console.log(item.key); |
| | | router.push({ |
| | | path: item.key |
| | | }) |
| | | |
| | | let name = item.item.name; |
| | | currentCache.value = name; |
| | | console.log(routerCache.value); |
| | | // console.log(routerCache.value); |
| | | |
| | | if (name != undefined && routerCache.value.indexOf(name) == -1) { |
| | | routerCache.value.push(item.item.name) |
| | |
| | | } |
| | | |
| | | function reloadTabs() { |
| | | const hide = message.loading(formatMessage('common.loading', '加载中')); |
| | | try { |
| | | isRouterAlive.value = false; |
| | | nextTick(() => { |
| | | isRouterAlive.value = true; |
| | | message.success(formatMessage('common.success', '加载成功')); |
| | | }) |
| | | } catch (error) { |
| | | message.error(formatMessage('common.fail', '加载失败')); |
| | | } finally { |
| | | hide(); |
| | | } |
| | | } |
| | | |
| | | function switchTabs(name) { |
| | |
| | | currentCache.value = name; |
| | | selectedKeys.value = [routerCacheMap.value.get(name)] |
| | | |
| | | console.log(routerCacheMap, name, routerCacheMap.value.get(name)); |
| | | // console.log(routerCacheMap, name, routerCacheMap.value.get(name)); |
| | | |
| | | } |
| | | |
| | | const switchLocale = (locale) => { |
| | | globalState.locale = locale; |
| | | localStorage.setItem('locale', locale) |
| | | reloadTabs() |
| | | console.log(locale); |
| | | } |
| | | |
| | | </script> |