新增:新增获取路由信息 API(默认前端动态路由处于关闭状态,可通过[页面配置]>[菜单来源于后台]开启)

1.在页面导航栏中通过[页面配置]>[菜单来源于后台]临时启用,刷新后配置失效
2.在前端项目 src/config/setting.json 中,可通过 menuFromServer 配置永久启用
This commit is contained in:
2023-03-09 00:06:02 +08:00
parent fb0effed9a
commit d8ceda4654
24 changed files with 260 additions and 17 deletions

View File

@@ -27,6 +27,6 @@ export function getUserInfo() {
return axios.get<UserState>(`${BASE_URL}/user/info`);
}
export function getMenuList() {
return axios.get<RouteRecordNormalized[]>('/api/user/menu');
export function listRoute() {
return axios.get<RouteRecordNormalized[]>(`${BASE_URL}/route`);
}

View File

@@ -95,7 +95,7 @@
_route.forEach((element) => {
// This is demo, modify nodes as needed
const icon = element?.meta?.icon
? () => h(compile(`<${element?.meta?.icon}/>`))
? () => h(compile(`<icon-${element?.meta?.icon}/>`))
: null;
const node =
element?.children && element?.children.length !== 0 ? (

View File

@@ -3,7 +3,7 @@ export default {
name: 'ArcoWebsite',
meta: {
locale: 'menu.arcoWebsite',
icon: 'icon-link',
icon: 'link',
requiresAuth: true,
order: 106,
},

View File

@@ -3,7 +3,7 @@ export default {
name: 'GitHub',
meta: {
locale: 'menu.github',
icon: 'icon-github',
icon: 'github',
requiresAuth: true,
order: 107,
},

View File

@@ -8,7 +8,7 @@ const EXCEPTION: AppRouteRecordRaw = {
meta: {
locale: 'menu.exception',
requiresAuth: true,
icon: 'icon-exclamation-circle',
icon: 'exclamation-circle',
order: 104,
},
children: [

View File

@@ -7,7 +7,7 @@ const FORM: AppRouteRecordRaw = {
component: DEFAULT_LAYOUT,
meta: {
locale: 'menu.form',
icon: 'icon-bookmark',
icon: 'bookmark',
requiresAuth: true,
order: 101,
},

View File

@@ -8,7 +8,7 @@ const LIST: AppRouteRecordRaw = {
meta: {
locale: 'menu.list',
requiresAuth: true,
icon: 'icon-list',
icon: 'list',
order: 100,
},
children: [

View File

@@ -8,7 +8,7 @@ const PROFILE: AppRouteRecordRaw = {
meta: {
locale: 'menu.profile',
requiresAuth: true,
icon: 'icon-file',
icon: 'file',
order: 102,
},
children: [

View File

@@ -7,7 +7,7 @@ const RESULT: AppRouteRecordRaw = {
component: DEFAULT_LAYOUT,
meta: {
locale: 'menu.result',
icon: 'icon-check-circle',
icon: 'check-circle',
requiresAuth: true,
order: 103,
},

View File

@@ -8,7 +8,7 @@ const VISUALIZATION: AppRouteRecordRaw = {
meta: {
locale: 'menu.visualization',
requiresAuth: true,
icon: 'icon-bar-chart',
icon: 'bar-chart',
order: 105,
},
children: [

View File

@@ -9,7 +9,7 @@ const DASHBOARD: AppRouteRecordRaw = {
meta: {
locale: 'menu.dashboard',
requiresAuth: true,
icon: 'icon-dashboard',
icon: 'dashboard',
order: 0,
hideChildrenInMenu: true,
},

View File

@@ -7,7 +7,7 @@ const Monitor: AppRouteRecordRaw = {
component: DEFAULT_LAYOUT,
meta: {
locale: 'menu.monitor',
icon: 'icon-computer',
icon: 'computer',
requiresAuth: true,
order: 2,
},

View File

@@ -7,7 +7,7 @@ const System: AppRouteRecordRaw = {
component: DEFAULT_LAYOUT,
meta: {
locale: 'menu.system',
icon: 'icon-settings',
icon: 'settings',
requiresAuth: true,
order: 1,
},

View File

@@ -7,7 +7,7 @@ const UserCenter: AppRouteRecordRaw = {
component: DEFAULT_LAYOUT,
meta: {
locale: 'menu.user',
icon: 'icon-user',
icon: 'user',
requiresAuth: true,
},
children: [

View File

@@ -3,7 +3,7 @@ import { Notification } from '@arco-design/web-vue';
import type { NotificationReturn } from '@arco-design/web-vue/es/notification/interface';
import type { RouteRecordNormalized } from 'vue-router';
import defaultSettings from '@/config/settings.json';
import { getMenuList } from '@/api/auth/login';
import { listRoute } from '@/api/auth/login';
import { AppState } from './types';
const useAppStore = defineStore('app', {
@@ -52,7 +52,7 @@ const useAppStore = defineStore('app', {
content: 'loading',
closable: true,
});
const { data } = await getMenuList();
const { data } = await listRoute();
this.serverMenu = data;
notifyInstance = Notification.success({
id: 'menuNotice',