This commit is contained in:
仲么了
2024-01-05 15:14:35 +08:00
parent 379732c7d5
commit ae1ae5b2a7
7 changed files with 263 additions and 268 deletions

View File

@@ -58,226 +58,226 @@ const init = async () => {
* 后台初始化请求,获取站点配置,动态路由等信息 * 后台初始化请求,获取站点配置,动态路由等信息
*/ */
getRouteMenu().then((res: any) => { getRouteMenu().then((res: any) => {
const arr = [ // const arr = [
{ // {
id: 1, // id: 1,
pid: 0, // pid: 0,
type: 'menu', // type: 'menu',
title: '控制台', // title: '控制台',
name: 'dashboard', // name: 'dashboard',
path: 'dashboard', // path: 'dashboard',
icon: 'fa fa-dashboard', // icon: 'fa fa-dashboard',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/dashboard/index.vue', // component: '/src/views/dashboard/index.vue',
keepalive: 'dashboard', // keepalive: 'dashboard',
extend: 'none', // extend: 'none',
children: [] // children: []
}, // },
{ // {
id: 3, // id: 3,
pid: 0, // pid: 0,
type: 'menu', // type: 'menu',
title: '审计管理', // title: '审计管理',
name: 'test', // name: 'test',
path: 'test', // path: 'test',
icon: 'el-icon-List', // icon: 'el-icon-List',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/dashboard/test.vue', // component: '/src/views/dashboard/test.vue',
keepalive: 'test', // keepalive: 'test',
extend: 'none', // extend: 'none',
children: [ // children: [
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '审计列表', // title: '审计列表',
name: 'comptroller/list', // name: 'comptroller/list',
path: 'comptroller/list', // path: 'comptroller/list',
icon: 'el-icon-List', // icon: 'el-icon-List',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/comptroller/list.vue', // component: '/src/views/comptroller/list.vue',
keepalive: 'auth/role', // keepalive: 'auth/role',
extend: 'none', // extend: 'none',
children: [] // children: []
} // }
] // ]
}, // },
{ // {
id: 3, // id: 3,
pid: 0, // pid: 0,
type: 'menu_dir', // type: 'menu_dir',
title: '电压暂降', // title: '电压暂降',
name: 'voltage/sags', // name: 'voltage/sags',
path: 'voltage/sags', // path: 'voltage/sags',
icon: 'el-icon-BellFilled', // icon: 'el-icon-BellFilled',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
extend: 'none', // extend: 'none',
children: [ // children: [
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu_dir', // type: 'menu_dir',
title: '运行管理', // title: '运行管理',
name: 'voltage/sags/operationsManagement', // name: 'voltage/sags/operationsManagement',
path: 'voltage/sags/operationsManagement', // path: 'voltage/sags/operationsManagement',
icon: 'fa-solid fa-bars-progress', // icon: 'fa-solid fa-bars-progress',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
extend: 'none', // extend: 'none',
children: [ // children: [
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '终端运行管理', // title: '终端运行管理',
name: 'voltage/sags/operationsManagement/index', // name: 'voltage/sags/operationsManagement/index',
path: 'voltage/sags/operationsManagement/index', // path: 'voltage/sags/operationsManagement/index',
icon: 'fa-solid fa-recycle', // icon: 'fa-solid fa-recycle',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/voltage/sags/operationsManagement/index.vue', // component: '/src/views/voltage/sags/operationsManagement/index.vue',
keepalive: 'voltage/sags/operationsManagement/index', // keepalive: 'voltage/sags/operationsManagement/index',
extend: 'none', // extend: 'none',
children: [] // children: []
}, // },
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '终端运行统计', // title: '终端运行统计',
name: 'voltage/sags/operationsManagement/statistics', // name: 'voltage/sags/operationsManagement/statistics',
path: 'voltage/sags/operationsManagement/statistics', // path: 'voltage/sags/operationsManagement/statistics',
icon: 'fa-solid fa-chart-column', // icon: 'fa-solid fa-chart-column',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/voltage/sags/operationsManagement/statistics.vue', // component: '/src/views/voltage/sags/operationsManagement/statistics.vue',
keepalive: 'voltage/sags/operationsManagement/statistics', // keepalive: 'voltage/sags/operationsManagement/statistics',
extend: 'none', // extend: 'none',
children: [] // children: []
}, // },
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '监测点台账信息', // title: '监测点台账信息',
name: 'voltage/sags/operationsManagement/point', // name: 'voltage/sags/operationsManagement/point',
path: 'voltage/sags/operationsManagement/point', // path: 'voltage/sags/operationsManagement/point',
icon: 'fa-brands fa-square-pinterest', // icon: 'fa-brands fa-square-pinterest',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/voltage/sags/operationsManagement/point.vue', // component: '/src/views/voltage/sags/operationsManagement/point.vue',
keepalive: 'voltage/sags/operationsManagement/point', // keepalive: 'voltage/sags/operationsManagement/point',
extend: 'none', // extend: 'none',
children: [] // children: []
} // }
] // ]
}, // },
{ // {
id: 2, // id: 2,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '区域', // title: '区域',
name: 'Event-boot/Region/distribution', // name: 'Event-boot/Region/distribution',
path: 'Event-boot/Region/distribution', // path: 'Event-boot/Region/distribution',
icon: 'el-icon-Management', // icon: 'el-icon-Management',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/Event-boot/Region/distribution.vue', // component: '/src/views/Event-boot/Region/distribution.vue',
keepalive: 'Event-boot/Region/distribution', // keepalive: 'Event-boot/Region/distribution',
extend: 'none', // extend: 'none',
children: [ // children: [
{ // {
id: 2, // id: 2,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '区域概览', // title: '区域概览',
name: 'Region/overview', // name: 'Region/overview',
path: 'Region/overview', // path: 'Region/overview',
icon: 'el-icon-Promotion', // icon: 'el-icon-Promotion',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/dashboard/index.vue', // component: '/src/views/dashboard/index.vue',
keepalive: 'Region/overview', // keepalive: 'Region/overview',
extend: 'none', // extend: 'none',
children: [] // children: []
}, // },
{ // {
id: 1, // id: 1,
pid: 3, // pid: 3,
type: 'menu', // type: 'menu',
title: '监测网分布', // title: '监测网分布',
name: 'Region/distribution', // name: 'Region/distribution',
path: 'Region/distribution', // path: 'Region/distribution',
icon: 'el-icon-Share', // icon: 'el-icon-Share',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/Event-boot/Region/distribution.vue', // component: '/src/views/Event-boot/Region/distribution.vue',
keepalive: 'Region/distribution', // keepalive: 'Region/distribution',
extend: 'none', // extend: 'none',
children: [] // children: []
} // }
] // ]
} // }
] // ]
}, // },
{ // {
id: 2, // id: 2,
pid: 0, // pid: 0,
type: 'menu_dir', // type: 'menu_dir',
title: '权限管理', // title: '权限管理',
name: 'auth', // name: 'auth',
path: 'auth', // path: 'auth',
icon: 'fa-solid fa-layer-group', // icon: 'fa-solid fa-layer-group',
menu_type: null, // menu_type: null,
url: '', // url: '',
component: '', // component: '',
keepalive: 0, // keepalive: 0,
extend: 'none', // extend: 'none',
children: [ // children: [
{ // {
id: 3, // id: 3,
pid: 2, // pid: 2,
type: 'menu', // type: 'menu',
title: '角色管理', // title: '角色管理',
name: 'auth/role', // name: 'auth/role',
path: 'auth/role', // path: 'auth/role',
icon: 'el-icon-Avatar', // icon: 'el-icon-Avatar',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/auth/role/index.vue', // component: '/src/views/auth/role/index.vue',
keepalive: 'auth/role', // keepalive: 'auth/role',
extend: 'none', // extend: 'none',
children: [] // children: []
}, // },
{ // {
id: 13, // id: 13,
pid: 2, // pid: 2,
type: 'menu', // type: 'menu',
title: '菜单规则管理', // title: '菜单规则管理',
name: 'auth/menu', // name: 'auth/menu',
path: 'auth/menu', // path: 'auth/menu',
icon: 'el-icon-Menu', // icon: 'el-icon-Menu',
menu_type: 'tab', // menu_type: 'tab',
url: '', // url: '',
component: '/src/views/auth/menu/index.vue', // component: '/src/views/auth/menu/index.vue',
keepalive: 'auth/menu', // keepalive: 'auth/menu',
extend: 'none', // extend: 'none',
children: [] // children: []
} // }
] // ]
} // }
] // ]
const handlerMenu = (data: any) => { const handlerMenu = (data: any) => {
data.forEach((item: any) => { data.forEach((item: any) => {
item.path = item.routeName || item.title item.path = item.routePath
item.name = item.title item.name = item.title
item.component = '/src/views/dashboard/index.vue' item.component = item.routeName || '/src/views/dashboard/index.vue'
item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu' item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu'
item.menu_type = item.children && item.children.length > 0 ? null : 'tab' item.menu_type = item.children && item.children.length > 0 ? null : 'tab'
if (item.children) { if (item.children) {
@@ -287,8 +287,8 @@ const init = async () => {
} }
handlerMenu(res.data) handlerMenu(res.data)
// handleAdminRoute(arr) // handleAdminRoute(arr)
// handleAdminRoute(res.data) handleAdminRoute(res.data)
handleAdminRoute([...arr, ...res.data]) // handleAdminRoute([...arr, ...res.data])
// 预跳转到上次路径 // 预跳转到上次路径
if (route.params.to) { if (route.params.to) {

View File

@@ -1,6 +1,6 @@
import { createRouter, createWebHashHistory } from 'vue-router' import { createRouter, createWebHashHistory } from 'vue-router'
import staticRoutes from '@/router/static' import staticRoutes from '@/router/static'
import { useConfig } from '@/stores/config' import { useAdminInfo } from '@/stores/adminInfo'
import NProgress from 'nprogress' import NProgress from 'nprogress'
import { loading } from '@/utils/loading' import { loading } from '@/utils/loading'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@@ -23,7 +23,8 @@ router.beforeEach((to, from, next) => {
next() next()
} else { } else {
// 获取 token // 获取 token
const token = localStorage.getItem('token') const adminInfo = useAdminInfo()
const token = adminInfo.getToken()
// token 不存在 // token 不存在
if (token === null || token === '') { if (token === null || token === '') {
ElMessage.error('您还没有登录,请先登录') ElMessage.error('您还没有登录,请先登录')

View File

@@ -153,7 +153,6 @@ const handleMenuRule = (routes: any, pathPrefix = '/', type = ['menu', 'menu_dir
name: routes[key].name, name: routes[key].name,
component: routes[key].component, component: routes[key].component,
meta: { meta: {
...routes[key],
id: routes[key].id, id: routes[key].id,
title: routes[key].title, title: routes[key].title,
icon: routes[key].icon, icon: routes[key].icon,

View File

@@ -1,15 +1,15 @@
<template> <template>
<div class='default-main'> <div class="default-main">
<TableHeader> <TableHeader>
<template v-slot:operation> <template v-slot:operation>
<el-button :icon='Plus' type='primary' @click='addMenu'>添加</el-button> <el-button :icon="Plus" type="primary" @click="addMenu">添加</el-button>
</template> </template>
</TableHeader> </TableHeader>
<Table ref='tableRef' :pagination='false' /> <Table ref="tableRef" :pagination="false" />
<popupForm ref='popupRef'></popupForm> <popupForm ref="popupRef"></popupForm>
</div> </div>
</template> </template>
<script setup lang='ts'> <script setup lang="ts">
import { Plus } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue' import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
@@ -25,7 +25,7 @@ const tableRef = ref()
const popupRef = ref() const popupRef = ref()
const navTabs = useNavTabs() const navTabs = useNavTabs()
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/user-boot/function/getRouteMenu', url: '/user-boot/function/functionTree',
column: [ column: [
{ title: '菜单名称', field: 'title', align: 'left', treeNode: true }, { title: '菜单名称', field: 'title', align: 'left', treeNode: true },
{ {
@@ -47,7 +47,7 @@ const tableStore = new TableStore({
type: 'primary', type: 'primary',
icon: 'el-icon-EditPen', icon: 'el-icon-EditPen',
render: 'tipButton', render: 'tipButton',
click: (row) => { click: row => {
popupRef.value.open('编辑菜单', row) popupRef.value.open('编辑菜单', row)
} }
}, },
@@ -63,8 +63,7 @@ const tableStore = new TableStore({
confirmButtonType: 'danger', confirmButtonType: 'danger',
title: '确定删除该菜单吗?' title: '确定删除该菜单吗?'
}, },
click: (row) => { click: row => {}
}
} }
] ]
} }
@@ -74,19 +73,7 @@ provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
tableStore.table.ref = tableRef.value tableStore.table.ref = tableRef.value
// tableStore.index() tableStore.index()
const handlerRouter = (arr: any[]) => {
return arr.map((item: any, index: number) => {
if (item.children && item.children.length > 0) {
item.children = handlerRouter(item.children)
}
return {
...item.meta,
...item
}
})
}
tableStore.table.data = handlerRouter(navTabs.state.tabsViewRoutes)
tableStore.table.loading = false tableStore.table.loading = false
}) })
const addMenu = () => { const addMenu = () => {

View File

@@ -1,45 +1,45 @@
<template> <template>
<el-dialog class='ba-operate-dialog' v-model='dialogVisible' :title='title'> <el-dialog class="ba-operate-dialog" v-model="dialogVisible" :title="title">
<el-scrollbar> <el-scrollbar>
<el-form :inline='false' :model='form' label-width='120px'> <el-form :inline="false" :model="form" label-width="120px">
<el-form-item label='上级菜单'> <el-form-item label="上级菜单">
<el-cascader <el-cascader
v-model='form.pid' v-model="form.pid"
:options='tableStore.table.data' :options="tableStore.table.data"
:props='cascaderProps' :props="cascaderProps"
style='width: 100%' style="width: 100%"
/> />
</el-form-item> </el-form-item>
<el-form-item label='菜单名称'> <el-form-item label="菜单名称">
<el-input v-model='form.name' placeholder='请输入菜单名称' /> <el-input v-model="form.name" placeholder="请输入菜单名称" />
</el-form-item> </el-form-item>
<el-form-item label='图标'> <el-form-item label="图标">
<IconSelector v-model='form.icon' placeholder='请选择图标' /> <IconSelector v-model="form.icon" placeholder="请选择图标" />
</el-form-item> </el-form-item>
<el-form-item label='菜单路由'> <el-form-item label="菜单路由">
<el-input v-model='form.path' placeholder='请输入菜单名称' /> <el-input v-model="form.path" placeholder="请输入菜单名称" />
</el-form-item> </el-form-item>
<el-form-item label='组件路径'> <el-form-item label="组件路径">
<el-input v-model='form.routeName' placeholder='请输入组件路径,如/src/views/dashboard/index.vue' /> <el-input v-model="form.routeName" placeholder="请输入组件路径,如/src/views/dashboard/index.vue" />
</el-form-item> </el-form-item>
<el-form-item label='排序'> <el-form-item label="排序">
<el-input-number v-model='form.sort' :min='0' /> <el-input-number v-model="form.sort" :min="0" />
</el-form-item> </el-form-item>
<el-form-item label='菜单描述'> <el-form-item label="菜单描述">
<el-input v-model='form.remark' :rows='2' type='textarea' placeholder='请输入描述' /> <el-input v-model="form.remark" :rows="2" type="textarea" placeholder="请输入描述" />
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-scrollbar> </el-scrollbar>
<template #footer> <template #footer>
<span class='dialog-footer'> <span class="dialog-footer">
<el-button @click='dialogVisible = false'>取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
<el-button type='primary' @click='submit'>确认</el-button> <el-button type="primary" @click="submit">确认</el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script lang='ts' setup> <script lang="ts" setup>
import { ref, inject } from 'vue' import { ref, inject } from 'vue'
import { reactive } from 'vue' import { reactive } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
@@ -51,7 +51,6 @@ const cascaderProps = {
label: 'title', label: 'title',
value: 'id' value: 'id'
} }
// do not use same name with ref
const form = reactive({ const form = reactive({
code: '', code: '',
icon: '', icon: '',
@@ -68,8 +67,15 @@ const form = reactive({
const dialogVisible = ref(false) const dialogVisible = ref(false)
const title = ref('新增菜单') const title = ref('新增菜单')
const open = (text: string, data?: anyObj) => { const open = (text: string, data?: anyObj) => {
console.log(data)
title.value = text title.value = text
Object.assign(form, data) if (data) {
for (let key in form) {
form[key] = data[key]
}
form.path = data.routePath
form.name = data.title
}
dialogVisible.value = true dialogVisible.value = true
} }
const submit = () => { const submit = () => {

View File

@@ -0,0 +1 @@
<template>推送日志</template>

View File

@@ -2,6 +2,7 @@ import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx' import vueJsx from '@vitejs/plugin-vue-jsx'
import path from 'path' import path from 'path'
const nodeResolve = (dir: string) => path.resolve(__dirname, '.', dir) const nodeResolve = (dir: string) => path.resolve(__dirname, '.', dir)
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
@@ -10,7 +11,7 @@ export default defineConfig({
proxy: { proxy: {
'/api': { '/api': {
// target: 'http://192.168.1.81:10215', //数据中心 // target: 'http://192.168.1.81:10215', //数据中心
target: 'https://pqmcn.com:8092/api', //数据中心 target: 'http://192.168.1.22:10215', //治理
changeOrigin: true, changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '') //路径重写,把'/api'替换为'' rewrite: path => path.replace(/^\/api/, '') //路径重写,把'/api'替换为''
} }