Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
啊嘞嘞EC
vue-vben-admin
提交
0a3683a1
V
vue-vben-admin
项目概览
啊嘞嘞EC
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0a3683a1
编写于
7月 13, 2021
作者:
无
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: customized user home page
新增自定义的用户首页(可以每个用户都不相同)
上级
f5e31feb
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
62 addition
and
6 deletion
+62
-6
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+3
-0
mock/sys/user.ts
mock/sys/user.ts
+2
-0
src/components/Application/src/AppLogo.vue
src/components/Application/src/AppLogo.vue
+3
-1
src/router/guard/permissionGuard.ts
src/router/guard/permissionGuard.ts
+15
-1
src/router/routes/modules/dashboard.ts
src/router/routes/modules/dashboard.ts
+1
-1
src/store/modules/multipleTab.ts
src/store/modules/multipleTab.ts
+3
-1
src/store/modules/permission.ts
src/store/modules/permission.ts
+28
-0
src/store/modules/user.ts
src/store/modules/user.ts
+4
-2
types/store.d.ts
types/store.d.ts
+3
-0
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
0a3683a1
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
-
**NoticeList**
添加分页、超长自动省略、标题点击事件、标题删除线等功能
-
**NoticeList**
添加分页、超长自动省略、标题点击事件、标题删除线等功能
-
**MixSider**
优化 Mix 菜单布局时 底部折叠按钮 的样式,与其它菜单布局时的风格保持一致
-
**MixSider**
优化 Mix 菜单布局时 底部折叠按钮 的样式,与其它菜单布局时的风格保持一致
-
可以为不同的用户指定不同的后台首页:
-
在
`getUserInfo`
接口返回的用户信息中增加
`homePath`
字段(可选)即可为当前用户定制首页路径
### 🐛 Bug Fixes
### 🐛 Bug Fixes
...
@@ -18,6 +20,7 @@
...
@@ -18,6 +20,7 @@
-
修复左侧混合菜单的悬停触发逻辑
-
修复左侧混合菜单的悬停触发逻辑
-
修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题
-
修复顶栏菜单在显示包含需要隐藏的菜单项目时出错的问题
-
修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由
-
修复悬停触发模式下左侧混合菜单会在没有子菜单且被激活时直接跳转路由
-
**Breadcrumb**
修复带有重定向的菜单点击无法跳转的问题
-
**其它**
-
**其它**
-
修复菜单默认折叠的配置不起作用的问题
-
修复菜单默认折叠的配置不起作用的问题
-
修复
`safari`
浏览器报错导致网站打不开
-
修复
`safari`
浏览器报错导致网站打不开
...
...
mock/sys/user.ts
浏览文件 @
0a3683a1
...
@@ -11,6 +11,7 @@ export function createFakeUserList() {
...
@@ -11,6 +11,7 @@ export function createFakeUserList() {
desc
:
'
manager
'
,
desc
:
'
manager
'
,
password
:
'
123456
'
,
password
:
'
123456
'
,
token
:
'
fakeToken1
'
,
token
:
'
fakeToken1
'
,
homePath
:
'
/dashboard/analysis
'
,
roles
:
[
roles
:
[
{
{
roleName
:
'
Super Admin
'
,
roleName
:
'
Super Admin
'
,
...
@@ -26,6 +27,7 @@ export function createFakeUserList() {
...
@@ -26,6 +27,7 @@ export function createFakeUserList() {
avatar
:
'
https://q1.qlogo.cn/g?b=qq&nk=339449197&s=640
'
,
avatar
:
'
https://q1.qlogo.cn/g?b=qq&nk=339449197&s=640
'
,
desc
:
'
tester
'
,
desc
:
'
tester
'
,
token
:
'
fakeToken2
'
,
token
:
'
fakeToken2
'
,
homePath
:
'
/dashboard/workbench
'
,
roles
:
[
roles
:
[
{
{
roleName
:
'
Tester
'
,
roleName
:
'
Tester
'
,
...
...
src/components/Application/src/AppLogo.vue
浏览文件 @
0a3683a1
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,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
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
useUserStore
}
from
'
/@/store/modules/user
'
;
const
props
=
{
const
props
=
{
/**
/**
...
@@ -39,6 +40,7 @@
...
@@ -39,6 +40,7 @@
setup
(
props
)
{
setup
(
props
)
{
const
{
prefixCls
}
=
useDesign
(
'
app-logo
'
);
const
{
prefixCls
}
=
useDesign
(
'
app-logo
'
);
const
{
getCollapsedShowTitle
}
=
useMenuSetting
();
const
{
getCollapsedShowTitle
}
=
useMenuSetting
();
const
userStore
=
useUserStore
();
const
{
title
}
=
useGlobSetting
();
const
{
title
}
=
useGlobSetting
();
const
go
=
useGo
();
const
go
=
useGo
();
...
@@ -56,7 +58,7 @@
...
@@ -56,7 +58,7 @@
]);
]);
function
goHome
()
{
function
goHome
()
{
go
(
PageEnum
.
BASE_HOME
);
go
(
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
);
}
}
return
{
return
{
...
...
src/router/guard/permissionGuard.ts
浏览文件 @
0a3683a1
...
@@ -7,8 +7,12 @@ import { useUserStoreWithOut } from '/@/store/modules/user';
...
@@ -7,8 +7,12 @@ import { useUserStoreWithOut } from '/@/store/modules/user';
import
{
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/routes/basic
'
;
import
{
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/routes/basic
'
;
import
{
RootRoute
}
from
'
/@/router/routes
'
;
const
LOGIN_PATH
=
PageEnum
.
BASE_LOGIN
;
const
LOGIN_PATH
=
PageEnum
.
BASE_LOGIN
;
const
ROOT_PATH
=
RootRoute
.
path
;
const
whitePathList
:
PageEnum
[]
=
[
LOGIN_PATH
];
const
whitePathList
:
PageEnum
[]
=
[
LOGIN_PATH
];
export
function
createPermissionGuard
(
router
:
Router
)
{
export
function
createPermissionGuard
(
router
:
Router
)
{
...
@@ -17,7 +21,17 @@ export function createPermissionGuard(router: Router) {
...
@@ -17,7 +21,17 @@ export function createPermissionGuard(router: Router) {
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
// Jump to the 404 page after processing the login
// Jump to the 404 page after processing the login
if
(
from
.
path
===
LOGIN_PATH
&&
to
.
name
===
PAGE_NOT_FOUND_ROUTE
.
name
)
{
if
(
from
.
path
===
LOGIN_PATH
&&
to
.
name
===
PAGE_NOT_FOUND_ROUTE
.
name
)
{
next
(
PageEnum
.
BASE_HOME
);
next
(
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
);
return
;
}
if
(
from
.
path
===
ROOT_PATH
&&
to
.
path
===
PageEnum
.
BASE_HOME
&&
userStore
.
getUserInfo
.
homePath
&&
userStore
.
getUserInfo
.
homePath
!==
PageEnum
.
BASE_HOME
)
{
next
(
userStore
.
getUserInfo
.
homePath
);
return
;
return
;
}
}
...
...
src/router/routes/modules/dashboard.ts
浏览文件 @
0a3683a1
...
@@ -19,7 +19,7 @@ const dashboard: AppRouteModule = {
...
@@ -19,7 +19,7 @@ const dashboard: AppRouteModule = {
name
:
'
Analysis
'
,
name
:
'
Analysis
'
,
component
:
()
=>
import
(
'
/@/views/dashboard/analysis/index.vue
'
),
component
:
()
=>
import
(
'
/@/views/dashboard/analysis/index.vue
'
),
meta
:
{
meta
:
{
affix
:
true
,
//
affix: true,
title
:
t
(
'
routes.dashboard.analysis
'
),
title
:
t
(
'
routes.dashboard.analysis
'
),
},
},
},
},
...
...
src/store/modules/multipleTab.ts
浏览文件 @
0a3683a1
...
@@ -13,6 +13,7 @@ import { getRawRoute } from '/@/utils';
...
@@ -13,6 +13,7 @@ import { getRawRoute } from '/@/utils';
import
{
MULTIPLE_TABS_KEY
}
from
'
/@/enums/cacheEnum
'
;
import
{
MULTIPLE_TABS_KEY
}
from
'
/@/enums/cacheEnum
'
;
import
projectSetting
from
'
/@/settings/projectSetting
'
;
import
projectSetting
from
'
/@/settings/projectSetting
'
;
import
{
useUserStore
}
from
'
/@/store/modules/user
'
;
export
interface
MultipleTabState
{
export
interface
MultipleTabState
{
cacheTabList
:
Set
<
string
>
;
cacheTabList
:
Set
<
string
>
;
...
@@ -181,7 +182,8 @@ export const useMultipleTabStore = defineStore({
...
@@ -181,7 +182,8 @@ export const useMultipleTabStore = defineStore({
if
(
index
===
0
)
{
if
(
index
===
0
)
{
// There is only one tab, then jump to the homepage, otherwise jump to the right tab
// There is only one tab, then jump to the homepage, otherwise jump to the right tab
if
(
this
.
tabList
.
length
===
1
)
{
if
(
this
.
tabList
.
length
===
1
)
{
toTarget
=
PageEnum
.
BASE_HOME
;
const
userStore
=
useUserStore
();
toTarget
=
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
;
}
else
{
}
else
{
// Jump to the right tab
// Jump to the right tab
const
page
=
this
.
tabList
[
index
+
1
];
const
page
=
this
.
tabList
[
index
+
1
];
...
...
src/store/modules/permission.ts
浏览文件 @
0a3683a1
...
@@ -22,6 +22,7 @@ import { getMenuList } from '/@/api/sys/menu';
...
@@ -22,6 +22,7 @@ import { getMenuList } from '/@/api/sys/menu';
import
{
getPermCode
}
from
'
/@/api/sys/user
'
;
import
{
getPermCode
}
from
'
/@/api/sys/user
'
;
import
{
useMessage
}
from
'
/@/hooks/web/useMessage
'
;
import
{
useMessage
}
from
'
/@/hooks/web/useMessage
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
interface
PermissionState
{
interface
PermissionState
{
// Permission code list
// Permission code list
...
@@ -117,6 +118,32 @@ export const usePermissionStore = defineStore({
...
@@ -117,6 +118,32 @@ export const usePermissionStore = defineStore({
return
!
ignoreRoute
;
return
!
ignoreRoute
;
};
};
/**
* @description 根据设置的首页path,修正routes中的affix标记(固定首页)
* */
const
patchHomeAffix
=
(
routes
:
AppRouteRecordRaw
[])
=>
{
if
(
!
routes
||
routes
.
length
===
0
)
return
;
const
homePath
=
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
;
function
patcher
(
routes
:
AppRouteRecordRaw
[],
parentPath
=
''
)
{
if
(
parentPath
)
parentPath
=
parentPath
+
'
/
'
;
routes
.
forEach
((
route
:
AppRouteRecordRaw
)
=>
{
const
{
path
,
children
}
=
route
;
const
currentPath
=
path
.
startsWith
(
'
/
'
)
?
path
:
parentPath
+
path
;
if
(
currentPath
===
homePath
)
{
route
.
meta
=
Object
.
assign
({},
route
.
meta
,
{
affix
:
true
});
throw
new
Error
(
'
end
'
);
}
children
&&
children
.
length
>
0
&&
patcher
(
children
,
currentPath
);
});
}
try
{
patcher
(
routes
);
}
catch
(
e
)
{
// 已处理完毕跳出循环
}
return
;
};
switch
(
permissionMode
)
{
switch
(
permissionMode
)
{
case
PermissionModeEnum
.
ROLE
:
case
PermissionModeEnum
.
ROLE
:
routes
=
filter
(
asyncRoutes
,
routeFilter
);
routes
=
filter
(
asyncRoutes
,
routeFilter
);
...
@@ -176,6 +203,7 @@ export const usePermissionStore = defineStore({
...
@@ -176,6 +203,7 @@ export const usePermissionStore = defineStore({
}
}
routes
.
push
(
ERROR_LOG_ROUTE
);
routes
.
push
(
ERROR_LOG_ROUTE
);
patchHomeAffix
(
routes
);
return
routes
;
return
routes
;
},
},
},
},
...
...
src/store/modules/user.ts
浏览文件 @
0a3683a1
...
@@ -88,13 +88,15 @@ export const useUserStore = defineStore({
...
@@ -88,13 +88,15 @@ export const useUserStore = defineStore({
const
sessionTimeout
=
this
.
sessionTimeout
;
const
sessionTimeout
=
this
.
sessionTimeout
;
sessionTimeout
&&
this
.
setSessionTimeout
(
false
);
sessionTimeout
&&
this
.
setSessionTimeout
(
false
);
!
sessionTimeout
&&
goHome
&&
(
await
router
.
replace
(
PageEnum
.
BASE_HOME
));
!
sessionTimeout
&&
goHome
&&
(
await
router
.
replace
(
userInfo
.
homePath
||
PageEnum
.
BASE_HOME
));
return
userInfo
;
return
userInfo
;
}
catch
(
error
)
{
}
catch
(
error
)
{
return
Promise
.
reject
(
error
);
return
Promise
.
reject
(
error
);
}
}
},
},
async
getUserInfoAction
()
{
async
getUserInfoAction
()
:
Promise
<
UserInfo
>
{
const
userInfo
=
await
getUserInfo
();
const
userInfo
=
await
getUserInfo
();
const
{
roles
}
=
userInfo
;
const
{
roles
}
=
userInfo
;
const
roleList
=
roles
.
map
((
item
)
=>
item
.
value
)
as
RoleEnum
[];
const
roleList
=
roles
.
map
((
item
)
=>
item
.
value
)
as
RoleEnum
[];
...
...
types/store.d.ts
浏览文件 @
0a3683a1
import
{
ErrorTypeEnum
}
from
'
/@/enums/exceptionEnum
'
;
import
{
ErrorTypeEnum
}
from
'
/@/enums/exceptionEnum
'
;
import
{
MenuModeEnum
,
MenuTypeEnum
}
from
'
/@/enums/menuEnum
'
;
import
{
MenuModeEnum
,
MenuTypeEnum
}
from
'
/@/enums/menuEnum
'
;
import
{
RoleInfo
}
from
'
/@/api/sys/model/userModel
'
;
// Lock screen information
// Lock screen information
export
interface
LockInfo
{
export
interface
LockInfo
{
...
@@ -35,6 +36,8 @@ export interface UserInfo {
...
@@ -35,6 +36,8 @@ export interface UserInfo {
realName
:
string
;
realName
:
string
;
avatar
:
string
;
avatar
:
string
;
desc
?:
string
;
desc
?:
string
;
homePath
?:
string
;
roles
:
RoleInfo
[];
}
}
export
interface
BeforeMiniState
{
export
interface
BeforeMiniState
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录