1、路由信息存储与session
2、修改与脚手架的跳转对接方式
| | |
| | | # 生产环境:只在打包时使用 |
| | | # 测试环境:只在打包时使用 |
| | | NODE_ENV=production |
| | | |
| | | VITE_DEV=false |
| | | |
| | | # 请求路径 |
| | | VITE_BASE_URL='http://localhost:48080' |
| | | VITE_BASE_URL='http://10.88.4.131' |
| | | |
| | | # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务 |
| | | VITE_UPLOAD_TYPE=server |
| | | # 上传路径 |
| | | VITE_UPLOAD_URL='http://localhost:48080/admin-api/infra/file/upload' |
| | | VITE_UPLOAD_URL='http://10.88.4.131/admin-api/infra/file/upload' |
| | | |
| | | # 接口地址 |
| | | VITE_API_URL=/admin-api |
| | |
| | | VITE_SOURCEMAP=false |
| | | |
| | | # 打包路径 |
| | | VITE_BASE_PATH=/ |
| | | VITE_BASE_PATH=/plat |
| | | |
| | | # 数据采集服务所在服务器,映射截图图片用 |
| | | VITE_VIDEO_CAMERA_DOMAIN='10.88.4.131' |
| | | |
| | | # 输出路径 |
| | | VITE_OUT_DIR=dist-prod |
| | | VITE_OUT_DIR=dist |
| | | |
| | | # 商城H5会员端域名 |
| | | VITE_MALL_H5_DOMAIN='http://' |
| | | # 公共静态文件路径 |
| | | VITE_STATIC_DIR=/plat/ |
| | | |
| | | # 验证码的开关 |
| | | VITE_APP_CAPTCHA_ENABLE=false |
| | |
| | | return request.get({ url: '/system/auth/get-permission-info' }) |
| | | } |
| | | |
| | | // 获取用应用户权限信息 |
| | | export const getUserAppInfo = (id: number) => { |
| | | return request.get({ url: '/system/auth/get-app-permission-info?id=' + id }) |
| | | } |
| | | // // 获取用应用户权限信息 |
| | | // export const getUserAppInfo = (id: number) => { |
| | | // return request.get({ url: '/system/auth/get-app-permission-info?id=' + id }) |
| | | // } |
| | | |
| | | //获取登录验证码 |
| | | export const sendSmsCode = (data: SmsCodeVO) => { |
| | |
| | | import {isRelogin} from "@/config/axios/service"; |
| | | import router from "@/router"; |
| | | import type {RouteRecordRaw} from "vue-router"; |
| | | import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; |
| | | import {CACHE_KEY, useCache, useSessionCache} from "@/hooks/web/useCache"; |
| | | import {getAccessToken} from "@/utils/auth"; |
| | | import {getInfo} from "@/api/login"; |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | |
| | | defineOptions({ name: 'Logo' }) |
| | | |
| | |
| | | |
| | | /** 刷新所有菜单权限 */ |
| | | const gotoHome = async () => { |
| | | const userStore = useUserStoreWithOut() |
| | | const permissionStore = usePermissionStoreWithOut() |
| | | isRelogin.show = true |
| | | wsCache.set(CACHE_KEY.USER, null) |
| | | await userStore.setUserInfoAction() |
| | | let userInfo = await getInfo() |
| | | wsCache.set(CACHE_KEY.USER, userInfo) |
| | | wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) |
| | | isRelogin.show = false |
| | | // 后端过滤菜单 |
| | | await permissionStore.generateRoutes() |
| | |
| | | import { cloneDeep } from 'lodash-es' |
| | | import remainingRouter from '@/router/modules/remaining' |
| | | import { flatMultiLevelRoutes, generateRoute } from '@/utils/routerHelper' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useSessionCache} from '@/hooks/web/useCache' |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | |
| | | export interface PermissionState { |
| | | routers: AppRouteRecordRaw[] |
| | |
| | | return new Promise<void>(async (resolve) => { |
| | | // 获得菜单列表,它在登录的时候,setUserInfoAction 方法中已经进行获取 |
| | | let res: AppCustomRouteRecordRaw[] = [] |
| | | if (wsCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
| | | res = wsCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] |
| | | if (wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
| | | res = wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS) as AppCustomRouteRecordRaw[] |
| | | } |
| | | const routerMap: AppRouteRecordRaw[] = generateRoute(res) |
| | | // 动态路由,404一定要放到最后面 |
| | |
| | | import { store } from '@/store' |
| | | import { defineStore } from 'pinia' |
| | | import { getAccessToken, removeToken } from '@/utils/auth' |
| | | import { CACHE_KEY, useCache, deleteUserCache } from '@/hooks/web/useCache' |
| | | import { |
| | | CACHE_KEY, |
| | | useCache, |
| | | deleteUserCache, |
| | | useSessionCache, |
| | | deleteUserSessionCache |
| | | } from '@/hooks/web/useCache' |
| | | import { getInfo, loginOut } from '@/api/login' |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | |
| | | interface UserVO { |
| | | id: number |
| | |
| | | this.roles = userInfo.roles |
| | | this.user = userInfo.user |
| | | this.isSetUser = true |
| | | console.log(userInfo.menus) |
| | | wsCache.set(CACHE_KEY.USER, userInfo) |
| | | wsCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) |
| | | if(!wsSessionCache.get(CACHE_KEY.ROLE_ROUTERS)) { |
| | | wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, userInfo.menus) |
| | | } |
| | | }, |
| | | async setUserAvatarAction(avatar: string) { |
| | | const userInfo = wsCache.get(CACHE_KEY.USER) |
| | |
| | | await loginOut() |
| | | removeToken() |
| | | deleteUserCache() // 删除用户缓存 |
| | | deleteUserSessionCache() //删除路由缓存 |
| | | this.resetState() |
| | | }, |
| | | resetState() { |
| | |
| | | |
| | | import * as AppApi from '@/api/system/app' |
| | | import {Apps} from "@/views/Home/types"; |
| | | import {CACHE_KEY, useCache} from "@/hooks/web/useCache"; |
| | | import {CACHE_KEY, useCache, useSessionCache} from "@/hooks/web/useCache"; |
| | | |
| | | |
| | | defineOptions({name: 'Home'}) |
| | | |
| | | const {wsCache} = useCache() |
| | | const {wsSessionCache} = useSessionCache() |
| | | |
| | | const loading = ref(true) |
| | | |
| | |
| | | const getAppMenuList = async (id, appCode) => { |
| | | const data = await AppApi.getAppMenuList(id) |
| | | let userInfo = wsCache.get(CACHE_KEY.USER) |
| | | userInfo.menus = data |
| | | // userInfo.menus = data |
| | | wsCache.set(CACHE_KEY.USER, userInfo) |
| | | wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
| | | wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
| | | window.location.href = '/plat/index' |
| | | } |
| | | |
| | |
| | | if (type === 0) { |
| | | await getAppMenuList(id, appCode) |
| | | } else { |
| | | const data = await AppApi.getAppMenuList(id) |
| | | let userInfo = wsCache.get(CACHE_KEY.USER) |
| | | userInfo.menus = data |
| | | wsCache.set(CACHE_KEY.USER, userInfo) |
| | | wsCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
| | | // const data = await AppApi.getAppMenuList(id) |
| | | // let userInfo = wsCache.get(CACHE_KEY.USER) |
| | | // userInfo.menus = data |
| | | // wsCache.set(CACHE_KEY.USER, userInfo) |
| | | // wsSessionCache.set(CACHE_KEY.ROLE_ROUTERS, data) |
| | | localStorage.setItem(appCode, id) |
| | | window.open(item.appDomain + '/index', '_blank') |
| | | // window.open('/plat/shasteel', '_blank') |
| | | // window.location.href = '/plat/shasteel' |
| | |
| | | <script lang="ts" setup> |
| | | import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
| | | import * as CategoryApi from '@/api/data/ind/category' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useSessionCache} from '@/hooks/web/useCache' |
| | | import { CommonStatusEnum, SystemMenuTypeEnum } from '@/utils/constants' |
| | | import { defaultProps, handleTree } from '@/utils/tree' |
| | | |
| | | defineOptions({ name: 'IndItemCategoryForm' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | } finally { |
| | | formLoading.value = false |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | } |
| | | } |
| | | |
| | |
| | | <script lang="ts" setup> |
| | | import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
| | | import * as CategoryApi from '@/api/data/plan/category' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useCache, useSessionCache} from '@/hooks/web/useCache' |
| | | import { CommonStatusEnum, SystemMenuTypeEnum } from '@/utils/constants' |
| | | import { defaultProps, handleTree } from '@/utils/tree' |
| | | |
| | | defineOptions({ name: 'PlanItemCategoryForm' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | } finally { |
| | | formLoading.value = false |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | } |
| | | } |
| | | |
| | |
| | | <script lang="ts" setup> |
| | | import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
| | | import * as MenuApi from '@/api/system/menu' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useCache, useSessionCache} from '@/hooks/web/useCache' |
| | | import { CommonStatusEnum, SystemAppMenuTypeEnum } from '@/utils/constants' |
| | | import { defaultProps, handleTree } from '@/utils/tree' |
| | | |
| | | defineOptions({ name: 'SystemAppMenuForm' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | } finally { |
| | | formLoading.value = false |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | } |
| | | } |
| | | |
| | |
| | | import { handleTree } from '@/utils/tree' |
| | | import * as MenuApi from '@/api/system/menu' |
| | | import AppMenuForm from './AppMenuForm.vue' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useCache, useSessionCache} from '@/hooks/web/useCache' |
| | | |
| | | defineOptions({ name: 'SystemAppMenu' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | await message.confirm('即将更新缓存刷新浏览器!', '刷新菜单缓存') |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.USER) |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | // wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | // 刷新浏览器 |
| | | location.reload() |
| | | } catch {} |
| | |
| | | <script lang="ts" setup> |
| | | import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
| | | import * as MenuApi from '@/api/system/menu' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useCache, useSessionCache} from '@/hooks/web/useCache' |
| | | import { CommonStatusEnum, SystemMenuTypeEnum } from '@/utils/constants' |
| | | import { defaultProps, handleTree } from '@/utils/tree' |
| | | |
| | | defineOptions({ name: 'SystemMenuForm' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | } finally { |
| | | formLoading.value = false |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | } |
| | | } |
| | | |
| | |
| | | import { handleTree } from '@/utils/tree' |
| | | import * as MenuApi from '@/api/system/menu' |
| | | import MenuForm from './MenuForm.vue' |
| | | import { CACHE_KEY, useCache } from '@/hooks/web/useCache' |
| | | import {CACHE_KEY, useCache, useSessionCache} from '@/hooks/web/useCache' |
| | | |
| | | defineOptions({ name: 'SystemMenu' }) |
| | | |
| | | const { wsCache } = useCache() |
| | | const { wsSessionCache } = useSessionCache() |
| | | const { t } = useI18n() // 国际化 |
| | | const message = useMessage() // 消息弹窗 |
| | | |
| | |
| | | await message.confirm('即将更新缓存刷新浏览器!', '刷新菜单缓存') |
| | | // 清空,从而触发刷新 |
| | | wsCache.delete(CACHE_KEY.USER) |
| | | wsCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | wsSessionCache.delete(CACHE_KEY.ROLE_ROUTERS) |
| | | // 刷新浏览器 |
| | | location.reload() |
| | | } catch {} |