Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
8b5513f8
提交
8b5513f8
authored
5月 25, 2022
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 添加路由参数配置,支持自动隐藏 Layout、自动全屏功能并添加示例页
上级
45b337d6
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
79 行增加
和
15 行删除
+79
-15
.env.development
.env.development
+4
-4
index.vue
src/layouts/default/index.vue
+9
-4
demo.ts
src/locales/lang/zh-CN/routes/demo.ts
+7
-1
index.ts
src/router/guard/index.ts
+22
-0
example.ts
src/router/routes/modules/demo/example.ts
+23
-4
index.vue
src/views/demo/example/index.vue
+8
-0
tsconfig.json
tsconfig.json
+2
-2
vue-router.d.ts
types/vue-router.d.ts
+4
-0
没有找到文件。
.env.development
浏览文件 @
8b5513f8
...
@@ -13,12 +13,12 @@ VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhos
...
@@ -13,12 +13,12 @@ VITE_PROXY = [["/basic-api","http://localhost:3000"],["/upload","http://localhos
VITE_DROP_CONSOLE = false
VITE_DROP_CONSOLE = false
# Basic interface address SPA
# Basic interface address SPA
VITE_GLOB_API_URL=/basic-api
#
VITE_GLOB_API_URL=/basic-api
# VITE_GLOB_API_URL=http://localhost:81
81
VITE_GLOB_API_URL=http://192.168.0.156:80
81
# Interface prefix
# Interface prefix
VITE_GLOB_API_URL_PREFIX=
#
VITE_GLOB_API_URL_PREFIX=
#
VITE_GLOB_API_URL_PREFIX=/api
VITE_GLOB_API_URL_PREFIX=/api
# File upload address, optional
# File upload address, optional
VITE_GLOB_UPLOAD_URL=/upload
VITE_GLOB_UPLOAD_URL=/upload
src/layouts/default/index.vue
浏览文件 @
8b5513f8
<
template
>
<
template
>
<Layout
:class=
"prefixCls"
v-bind=
"lockEvents"
>
<Layout
:class=
"prefixCls"
v-bind=
"lockEvents"
>
<LayoutFeatures
/>
<LayoutFeatures
/>
<LayoutHeader
fixed
v-if=
"getShowFullHeaderRef"
/>
<LayoutHeader
fixed
v-if=
"getShowFullHeaderRef
&& !hideLayout
"
/>
<Layout
:class=
"[layoutClass]"
>
<Layout
:class=
"[layoutClass]"
>
<LayoutSideBar
v-if=
"
getShowSidebar || getIsMobile
"
/>
<LayoutSideBar
v-if=
"
(getShowSidebar || getIsMobile) && !hideLayout
"
/>
<Layout
:class=
"`$
{prefixCls}-main`">
<Layout
:class=
"`$
{prefixCls}-main`">
<LayoutMultipleHeader
/>
<LayoutMultipleHeader
v-if=
"!hideLayout"
/>
<LayoutContent
/>
<LayoutContent
/>
<LayoutFooter
/>
<LayoutFooter
v-if=
"!hideLayout"
/>
</Layout>
</Layout>
</Layout>
</Layout>
</Layout>
</Layout>
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
import
{
useMenuSetting
}
from
'/@/hooks/setting/useMenuSetting'
import
{
useMenuSetting
}
from
'/@/hooks/setting/useMenuSetting'
import
{
useDesign
}
from
'/@/hooks/web/useDesign'
import
{
useDesign
}
from
'/@/hooks/web/useDesign'
import
{
useLockPage
}
from
'/@/hooks/web/useLockPage'
import
{
useLockPage
}
from
'/@/hooks/web/useLockPage'
import
{
router
}
from
'/@/router'
import
{
useAppInject
}
from
'/@/hooks/web/useAppInject'
import
{
useAppInject
}
from
'/@/hooks/web/useAppInject'
...
@@ -58,6 +59,9 @@
...
@@ -58,6 +59,9 @@
return
cls
return
cls
})
})
// 判断是否需要隐藏布局
const
hideLayout
=
computed
(()
=>
!!
router
.
currentRoute
.
value
.
meta
?.
hideLayout
)
return
{
return
{
getShowFullHeaderRef
,
getShowFullHeaderRef
,
getShowSidebar
,
getShowSidebar
,
...
@@ -66,6 +70,7 @@
...
@@ -66,6 +70,7 @@
getIsMixSidebar
,
getIsMixSidebar
,
layoutClass
,
layoutClass
,
lockEvents
,
lockEvents
,
hideLayout
,
}
}
},
},
})
})
...
...
src/locales/lang/zh-CN/routes/demo.ts
浏览文件 @
8b5513f8
...
@@ -161,7 +161,13 @@ export default {
...
@@ -161,7 +161,13 @@ export default {
page
:
'引导页'
,
page
:
'引导页'
,
},
},
example
:
{
example
:
{
page
:
'示例页'
,
example
:
'示例页'
,
api
:
'API 示例'
,
hideLayout
:
'测试 - 隐藏布局'
,
fullScreen
:
'测试 - 自动全屏'
,
},
},
system
:
{
system
:
{
moduleName
:
'系统管理'
,
moduleName
:
'系统管理'
,
...
...
src/router/guard/index.ts
浏览文件 @
8b5513f8
...
@@ -12,6 +12,7 @@ import { createStateGuard } from './stateGuard'
...
@@ -12,6 +12,7 @@ import { createStateGuard } from './stateGuard'
import
nProgress
from
'nprogress'
import
nProgress
from
'nprogress'
import
projectSetting
from
'/@/settings/projectSetting'
import
projectSetting
from
'/@/settings/projectSetting'
import
{
createParamMenuGuard
}
from
'./paramMenuGuard'
import
{
createParamMenuGuard
}
from
'./paramMenuGuard'
import
{
useFullscreen
}
from
'@vueuse/core'
// Don't change the order of creation
// Don't change the order of creation
export
function
setupRouterGuard
(
router
:
Router
)
{
export
function
setupRouterGuard
(
router
:
Router
)
{
...
@@ -24,6 +25,7 @@ export function setupRouterGuard(router: Router) {
...
@@ -24,6 +25,7 @@ export function setupRouterGuard(router: Router) {
createPermissionGuard
(
router
)
createPermissionGuard
(
router
)
createParamMenuGuard
(
router
)
// must after createPermissionGuard (menu has been built.)
createParamMenuGuard
(
router
)
// must after createPermissionGuard (menu has been built.)
createStateGuard
(
router
)
createStateGuard
(
router
)
createAutoFullScreenGuard
(
router
)
}
}
/**
/**
...
@@ -145,3 +147,23 @@ export function createProgressGuard(router: Router) {
...
@@ -145,3 +147,23 @@ export function createProgressGuard(router: Router) {
return
true
return
true
})
})
}
}
export
function
createAutoFullScreenGuard
(
router
:
Router
)
{
const
{
enter
,
exit
,
isFullscreen
}
=
useFullscreen
()
router
.
beforeEach
(
async
(
to
)
=>
{
if
(
to
.
meta
.
autoFullScreen
)
{
!
isFullscreen
.
value
&&
enter
()
}
return
true
})
router
.
afterEach
(
async
(
to
)
=>
{
if
(
!
to
.
meta
.
autoFullScreen
)
{
isFullscreen
.
value
&&
exit
()
}
return
true
})
}
src/router/routes/modules/demo/example.ts
浏览文件 @
8b5513f8
...
@@ -10,9 +10,8 @@ const setup: AppRouteModule = {
...
@@ -10,9 +10,8 @@ const setup: AppRouteModule = {
redirect
:
'/example/index'
,
redirect
:
'/example/index'
,
meta
:
{
meta
:
{
orderNo
:
90001
,
orderNo
:
90001
,
hideChildrenInMenu
:
true
,
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
title
:
t
(
'routes.demo.example.
pag
e'
),
title
:
t
(
'routes.demo.example.
exampl
e'
),
},
},
children
:
[
children
:
[
{
{
...
@@ -20,9 +19,29 @@ const setup: AppRouteModule = {
...
@@ -20,9 +19,29 @@ const setup: AppRouteModule = {
name
:
'ExamplePage'
,
name
:
'ExamplePage'
,
component
:
()
=>
import
(
'/@/views/demo/example/index.vue'
),
component
:
()
=>
import
(
'/@/views/demo/example/index.vue'
),
meta
:
{
meta
:
{
title
:
t
(
'routes.demo.example.
page
'
),
title
:
t
(
'routes.demo.example.
api
'
),
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
hideMenu
:
true
,
},
},
{
path
:
'hide-layout'
,
name
:
'HideLayoutPage'
,
component
:
()
=>
import
(
'/@/views/demo/example/index.vue'
),
meta
:
{
title
:
t
(
'routes.demo.example.hideLayout'
),
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
hideLayout
:
true
,
},
},
{
path
:
'auto-full-screen'
,
name
:
'AutoFullScreenPage'
,
component
:
()
=>
import
(
'/@/views/demo/example/index.vue'
),
meta
:
{
title
:
t
(
'routes.demo.example.fullScreen'
),
icon
:
'healthicons:virus-lab-research-test-tube-outline'
,
hideLayout
:
true
,
autoFullScreen
:
true
,
},
},
},
},
],
],
...
...
src/views/demo/example/index.vue
浏览文件 @
8b5513f8
...
@@ -12,6 +12,14 @@
...
@@ -12,6 +12,14 @@
text
.
value
=
body
text
.
value
=
body
},
1500
)
},
1500
)
})
})
API
.
permission
.
tree
.
request
({
pid
:
'0'
,
})
.
then
((
body
)
=>
{
console
.
log
(
body
)
})
})
})
</
script
>
</
script
>
...
...
tsconfig.json
浏览文件 @
8b5513f8
...
@@ -41,6 +41,6 @@
...
@@ -41,6 +41,6 @@
"build/**/*.d.ts"
,
"build/**/*.d.ts"
,
"mock/**/*.ts"
,
"mock/**/*.ts"
,
"vite.config.ts"
"vite.config.ts"
]
,
]
"exclude"
:
[
"node_modules"
,
"tests/server/**/*.ts"
,
"dist"
,
"**/*.js"
]
//
"exclude"
:
[
"node_modules"
,
"tests/server/**/*.ts"
,
"dist"
,
"**/*.js"
]
}
}
types/vue-router.d.ts
浏览文件 @
8b5513f8
...
@@ -41,5 +41,9 @@ declare module 'vue-router' {
...
@@ -41,5 +41,9 @@ declare module 'vue-router' {
ignoreRoute
?:
boolean
ignoreRoute
?:
boolean
// Hide path for children
// Hide path for children
hidePathForChildren
?:
boolean
hidePathForChildren
?:
boolean
// 隐藏布局
hideLayout
?:
boolean
// 自动全屏
autoFullScreen
?:
boolean
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论