Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
0aeec5e9
Commit
0aeec5e9
authored
Jan 15, 2021
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(mitt): logout and clear the mitt
parent
b9d53a71
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
17 deletions
+28
-17
package.json
package.json
+2
-2
useDataSource.ts
src/components/Table/src/hooks/useDataSource.ts
+8
-6
tabChange.ts
src/logics/mitt/tabChange.ts
+4
-0
permissionGuard.ts
src/router/guard/permissionGuard.ts
+0
-9
stateGuard.ts
src/router/guard/stateGuard.ts
+14
-0
No files found.
package.json
View file @
0aeec5e9
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
"devDependencies"
:
{
"devDependencies"
:
{
"
@commitlint/cli
"
:
"
^11.0.0
"
,
"
@commitlint/cli
"
:
"
^11.0.0
"
,
"
@commitlint/config-conventional
"
:
"
^11.0.0
"
,
"
@commitlint/config-conventional
"
:
"
^11.0.0
"
,
"
@iconify/json
"
:
"
^1.1.28
5
"
,
"
@iconify/json
"
:
"
^1.1.28
6
"
,
"
@ls-lint/ls-lint
"
:
"
^1.9.2
"
,
"
@ls-lint/ls-lint
"
:
"
^1.9.2
"
,
"
@purge-icons/generated
"
:
"
^0.5.1
"
,
"
@purge-icons/generated
"
:
"
^0.5.1
"
,
"
@types/echarts
"
:
"
^4.9.3
"
,
"
@types/echarts
"
:
"
^4.9.3
"
,
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
"
@types/zxcvbn
"
:
"
^4.4.0
"
,
"
@types/zxcvbn
"
:
"
^4.4.0
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.13.0
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.13.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.13.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.13.0
"
,
"
@vitejs/plugin-legacy
"
:
"
^1.2.
0
"
,
"
@vitejs/plugin-legacy
"
:
"
^1.2.
1
"
,
"
@vitejs/plugin-vue
"
:
"
^1.0.5
"
,
"
@vitejs/plugin-vue
"
:
"
^1.0.5
"
,
"
@vitejs/plugin-vue-jsx
"
:
"
^1.0.2
"
,
"
@vitejs/plugin-vue-jsx
"
:
"
^1.0.2
"
,
"
@vue/compiler-sfc
"
:
"
^3.0.5
"
,
"
@vue/compiler-sfc
"
:
"
^3.0.5
"
,
...
...
src/components/Table/src/hooks/useDataSource.ts
View file @
0aeec5e9
...
@@ -181,12 +181,14 @@ export function useDataSource(
...
@@ -181,12 +181,14 @@ export function useDataSource(
const
resultTotal
:
number
=
isArrayResult
?
0
:
get
(
res
,
totalField
);
const
resultTotal
:
number
=
isArrayResult
?
0
:
get
(
res
,
totalField
);
// 假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
// 假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
const
currentTotalPage
=
Math
.
ceil
(
resultTotal
/
pageSize
);
if
(
resultTotal
)
{
if
(
current
>
currentTotalPage
)
{
const
currentTotalPage
=
Math
.
ceil
(
resultTotal
/
pageSize
);
setPagination
({
if
(
current
>
currentTotalPage
)
{
current
:
currentTotalPage
,
setPagination
({
});
current
:
currentTotalPage
,
fetch
(
opt
);
});
fetch
(
opt
);
}
}
}
if
(
afterFetch
&&
isFunction
(
afterFetch
))
{
if
(
afterFetch
&&
isFunction
(
afterFetch
))
{
...
...
src/logics/mitt/tabChange.ts
View file @
0aeec5e9
...
@@ -25,3 +25,7 @@ export function listenerLastChangeTab(
...
@@ -25,3 +25,7 @@ export function listenerLastChangeTab(
mitt
.
on
(
key
,
callback
);
mitt
.
on
(
key
,
callback
);
immediate
&&
callback
(
lastChangeTab
);
immediate
&&
callback
(
lastChangeTab
);
}
}
export
function
removeTabChangeListener
()
{
mitt
.
clear
();
}
src/router/guard/permissionGuard.ts
View file @
0aeec5e9
import
type
{
Router
,
RouteRecordRaw
}
from
'
vue-router
'
;
import
type
{
Router
,
RouteRecordRaw
}
from
'
vue-router
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
{
permissionStore
}
from
'
/@/store/modules/permission
'
;
import
{
permissionStore
}
from
'
/@/store/modules/permission
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
getToken
}
from
'
/@/utils/auth
'
;
import
{
getToken
}
from
'
/@/utils/auth
'
;
import
{
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/constant
'
;
import
{
PAGE_NOT_FOUND_ROUTE
}
from
'
/@/router/constant
'
;
// import { RootRoute } from '../routes/index';
const
LOGIN_PATH
=
PageEnum
.
BASE_LOGIN
;
const
LOGIN_PATH
=
PageEnum
.
BASE_LOGIN
;
...
@@ -69,11 +67,4 @@ export function createPermissionGuard(router: Router) {
...
@@ -69,11 +67,4 @@ export function createPermissionGuard(router: Router) {
permissionStore
.
commitDynamicAddedRouteState
(
true
);
permissionStore
.
commitDynamicAddedRouteState
(
true
);
next
(
nextData
);
next
(
nextData
);
});
});
router
.
afterEach
((
to
)
=>
{
// Just enter the login page and clear the authentication information
if
(
to
.
path
===
LOGIN_PATH
)
{
appStore
.
resumeAllState
();
}
});
}
}
src/router/guard/stateGuard.ts
0 → 100644
View file @
0aeec5e9
import
type
{
Router
}
from
'
vue-router
'
;
import
{
appStore
}
from
'
/@/store/modules/app
'
;
import
{
PageEnum
}
from
'
/@/enums/pageEnum
'
;
import
{
removeTabChangeListener
}
from
'
/@/logics/mitt/tabChange
'
;
export
function
createHttpGuard
(
router
:
Router
)
{
router
.
afterEach
((
to
)
=>
{
// Just enter the login page and clear the authentication information
if
(
to
.
path
===
PageEnum
.
BASE_LOGIN
)
{
appStore
.
resumeAllState
();
removeTabChangeListener
();
}
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment