From 880d0a3ae93c27c40fd28c970b6194ff175b5bd7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=95=E9=87=91=E6=B3=BD?= <1098696801@qq.com>
Date: Tue, 28 Jun 2022 12:48:06 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E7=AE=A1=E7=90=86=20?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=93=E5=BC=80=E5=A4=96=E9=93=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../api/系统管理/菜单管理/当前用户菜单.ms | 5 ++--
.../api/系统管理/菜单管理/获取菜单tree.ms | 4 +--
db/magic-boot.sql | 1 +
magic-boot-ui/src/scripts/router.js | 5 ++--
magic-boot-ui/src/scripts/routerPermission.js | 17 +++++++++++-
magic-boot-ui/src/views/common/iframe.vue | 23 ++++++++++++++++
.../src/views/system/menu/menu-form.vue | 27 ++++++++++++++++---
.../src/views/system/menu/menu-list.vue | 2 +-
8 files changed, 71 insertions(+), 13 deletions(-)
create mode 100644 magic-boot-ui/src/views/common/iframe.vue
diff --git a/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms b/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms
index ade434b..a371f58 100644
--- a/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms
+++ b/data/magic-api/api/系统管理/菜单管理/当前用户菜单.ms
@@ -5,7 +5,7 @@
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "当前用户菜单",
"createTime" : null,
- "updateTime" : 1656340766427,
+ "updateTime" : 1656390120715,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@@ -564,7 +564,8 @@ var menus = db.select("""
sm.sort,
sm.icon,
sm.keep_alive,
- sm.component_name
+ sm.component_name,
+ sm.open_mode
from sys_menu sm where 1=1
?{userId != '1',
and sm.id in (
diff --git a/data/magic-api/api/系统管理/菜单管理/获取菜单tree.ms b/data/magic-api/api/系统管理/菜单管理/获取菜单tree.ms
index e80fc66..84a2c53 100644
--- a/data/magic-api/api/系统管理/菜单管理/获取菜单tree.ms
+++ b/data/magic-api/api/系统管理/菜单管理/获取菜单tree.ms
@@ -5,7 +5,7 @@
"groupId" : "67b2ce258e24491194b74992958c74aa",
"name" : "获取菜单tree",
"createTime" : null,
- "updateTime" : 1648014003694,
+ "updateTime" : 1656386304094,
"lock" : "0",
"createBy" : null,
"updateBy" : null,
@@ -119,7 +119,7 @@
}
================================
var toTree = (list,pid) => select t.*,toTree(list,t.id) children from list t where t.pid = pid
-var list = toTree(db.select('select id,name,pid,is_show,url,sort,permission,desc_ribe,icon,keep_alive,component_name from sys_menu where is_del = 0 order by sort'),'0')
+var list = toTree(db.select('select id,name,pid,is_show,url,sort,permission,desc_ribe,icon,keep_alive,component_name,open_mode from sys_menu where is_del = 0 order by sort'),'0')
return {
list: list,
diff --git a/db/magic-boot.sql b/db/magic-boot.sql
index 41648b2..150de92 100644
--- a/db/magic-boot.sql
+++ b/db/magic-boot.sql
@@ -198,6 +198,7 @@ CREATE TABLE `sys_menu` (
`permission` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '权限',
`sort` int(12) DEFAULT NULL COMMENT '排序',
`component_name` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '组件名称',
+ `open_mode` char(1) COLLATE utf8mb4_unicode_ci DEFAULT '0' COMMENT '打开方式,0:iframe 1:新标签页',
`is_del` int(1) DEFAULT '0' COMMENT '是否删除:0未删除,1已删除',
`create_by` varchar(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人',
`create_date` datetime DEFAULT NULL COMMENT '创建时间',
diff --git a/magic-boot-ui/src/scripts/router.js b/magic-boot-ui/src/scripts/router.js
index d6dc264..2379166 100644
--- a/magic-boot-ui/src/scripts/router.js
+++ b/magic-boot-ui/src/scripts/router.js
@@ -21,9 +21,9 @@ const routes = [
redirect: '/home',
children: [
{
- name: '首页',
path: '/home',
- component: () => import('@/views/home.vue')
+ component: () => import('@/views/home.vue'),
+ meta: { title: '首页' }
}
]
},
@@ -35,7 +35,6 @@ const routes = [
hidden: true,
children: [{
path: '/system/user/user-center',
- name: '个人中心',
component: () => import('@/views/system/user/user-center'),
meta: { title: '个人中心' }
}]
diff --git a/magic-boot-ui/src/scripts/routerPermission.js b/magic-boot-ui/src/scripts/routerPermission.js
index e7f5098..c1de86d 100644
--- a/magic-boot-ui/src/scripts/routerPermission.js
+++ b/magic-boot-ui/src/scripts/routerPermission.js
@@ -8,7 +8,22 @@ export const filterAsyncRouter = (routers, level) => {
level = level || 0
const accessedRouters = routers.filter(router => {
if (router.isShow === 1) {
- if (router.componentName) {
+ var setIframe = () => {
+ router.component = loadView(`/common/iframe`)
+ router.props = { url: router.url }
+ router.path = "/" + common.uuid()
+ }
+ if(router.url.startsWith('http')){
+ if(router.openMode == '0'){
+ setIframe()
+ }
+ } else if(router.url.startsWith('/') && router.url.indexOf('.htm') != -1) {
+ if(router.openMode == '0'){
+ setIframe()
+ }else{
+ router.path = location.href.substring(0, location.href.indexOf('/', location.href.indexOf('/', location.href.indexOf('/') + 1) + 1)) + router.path
+ }
+ } else if (router.componentName) {
router.component = loadView(`/common/show-component`)
router.props = { name: router.componentName }
} else if (router.component) {
diff --git a/magic-boot-ui/src/views/common/iframe.vue b/magic-boot-ui/src/views/common/iframe.vue
new file mode 100644
index 0000000..6ad513f
--- /dev/null
+++ b/magic-boot-ui/src/views/common/iframe.vue
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
diff --git a/magic-boot-ui/src/views/system/menu/menu-form.vue b/magic-boot-ui/src/views/system/menu/menu-form.vue
index 3a9be80..1aa5f0b 100644
--- a/magic-boot-ui/src/views/system/menu/menu-form.vue
+++ b/magic-boot-ui/src/views/system/menu/menu-form.vue
@@ -5,7 +5,7 @@
-
+
@@ -24,10 +24,22 @@
-
+
+
+
+
+
+ 菜单链接
+
-
+
+
+ iframe
+ 新标签页
+
+
+
@@ -99,6 +111,7 @@ const componentTree = ref()
const dataForm = ref()
const iconDialog = ref()
const menuType = ref('menu')
+const openModeRef = ref('0')
const getTemp = () => {
return {
id: '',
@@ -111,7 +124,8 @@ const getTemp = () => {
pid: 0,
icon: '',
keepAlive: 0,
- componentName: ''
+ componentName: '',
+ openMode: '0'
}
}
@@ -163,6 +177,10 @@ watch(menuType, (type) => {
}
})
+watch(openModeRef, (value) => {
+ temp.value.openMode = value
+})
+
function save(d) {
dataForm.value.validate((valid) => {
if (valid) {
@@ -222,6 +240,7 @@ function getInfo(row) {
for (var t in temp.value) {
temp.value[t] = row[t]
}
+ openModeRef.value = temp.value.openMode || '0'
menuType.value = temp.value.url ? 'menu' : 'button'
temp.value.name = temp.value.name.replaceAll(/(.*?)<\/font>/g,'$1')
nextTick(() => {
diff --git a/magic-boot-ui/src/views/system/menu/menu-list.vue b/magic-boot-ui/src/views/system/menu/menu-list.vue
index 808b6e7..3cd6e92 100644
--- a/magic-boot-ui/src/views/system/menu/menu-list.vue
+++ b/magic-boot-ui/src/views/system/menu/menu-list.vue
@@ -26,7 +26,7 @@
-
+