Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 102249e0
authored
Jul 11, 2024
by
likui628
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'main' into small-change
2 parents
2c79ac1e
c4c8103a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
29 deletions
apps/web-antd/src/apis/modules/mock.ts
apps/web-antd/src/layouts/basic.vue
apps/web-antd/src/store/modules/access.ts
apps/web-antd/src/store/modules/app.ts
apps/web-antd/src/views/_essential/authentication/login.vue
apps/web-antd/src/apis/modules/mock.ts
View file @
102249e
import
{
requestClient
}
from
'#/forward'
;
import
{
requestClient
}
from
'#/forward'
;
/**
/**
* 模拟
人
意状态码
* 模拟
任
意状态码
*/
*/
async
function
getMockStatus
(
status
:
string
)
{
async
function
getMockStatus
(
status
:
string
)
{
return
requestClient
.
get
(
'/mock/status'
,
{
params
:
{
status
}
});
return
requestClient
.
get
(
'/mock/status'
,
{
params
:
{
status
}
});
...
...
apps/web-antd/src/layouts/basic.vue
View file @
102249e
...
@@ -85,7 +85,11 @@ const menus = computed(() => [
...
@@ -85,7 +85,11 @@ const menus = computed(() => [
const
appStore
=
useAppStore
();
const
appStore
=
useAppStore
();
const
accessStore
=
useAccessStore
();
const
accessStore
=
useAccessStore
();
const
{
openLoginExpiredModal
,
userInfo
}
=
toRefs
(
accessStore
);
const
{
loading
:
loginLoading
,
openLoginExpiredModal
,
userInfo
,
}
=
toRefs
(
accessStore
);
const
router
=
useRouter
();
const
router
=
useRouter
();
async
function
handleLogout
()
{
async
function
handleLogout
()
{
...
@@ -126,6 +130,7 @@ function handleMakeAll() {
...
@@ -126,6 +130,7 @@ function handleMakeAll() {
<
template
#
dialog
>
<
template
#
dialog
>
<AuthenticationLoginExpiredModal
<AuthenticationLoginExpiredModal
v-model:open=
"openLoginExpiredModal"
v-model:open=
"openLoginExpiredModal"
:loading=
"loginLoading"
password-placeholder=
"123456"
password-placeholder=
"123456"
username-placeholder=
"vben"
username-placeholder=
"vben"
@
submit=
"accessStore.authLogin"
@
submit=
"accessStore.authLogin"
...
...
apps/web-antd/src/store/modules/access.ts
View file @
102249e
...
@@ -8,13 +8,16 @@ import { useRouter } from 'vue-router';
...
@@ -8,13 +8,16 @@ import { useRouter } from 'vue-router';
import
{
DEFAULT_HOME_PATH
,
LOGIN_PATH
}
from
'@vben/constants'
;
import
{
DEFAULT_HOME_PATH
,
LOGIN_PATH
}
from
'@vben/constants'
;
import
{
useCoreAccessStore
}
from
'@vben-core/stores'
;
import
{
useCoreAccessStore
}
from
'@vben-core/stores'
;
import
{
notification
}
from
'ant-design-vue'
;
import
{
defineStore
}
from
'pinia'
;
import
{
defineStore
}
from
'pinia'
;
import
{
getAccessCodes
,
getUserInfo
,
userLogin
}
from
'#/apis'
;
import
{
getAccessCodes
,
getUserInfo
,
userLogin
}
from
'#/apis'
;
import
{
$t
}
from
'#/locales'
;
export
const
useAccessStore
=
defineStore
(
'access'
,
()
=>
{
export
const
useAccessStore
=
defineStore
(
'access'
,
()
=>
{
const
coreStoreAccess
=
useCoreAccessStore
();
const
coreStoreAccess
=
useCoreAccessStore
();
const
router
=
useRouter
();
const
router
=
useRouter
();
const
loading
=
ref
(
false
);
const
loading
=
ref
(
false
);
const
openLoginExpiredModal
=
ref
(
false
);
const
openLoginExpiredModal
=
ref
(
false
);
...
@@ -44,7 +47,7 @@ export const useAccessStore = defineStore('access', () => {
...
@@ -44,7 +47,7 @@ export const useAccessStore = defineStore('access', () => {
*/
*/
async
function
authLogin
(
async
function
authLogin
(
params
:
LoginAndRegisterParams
,
params
:
LoginAndRegisterParams
,
onSuccess
?:
()
=>
Promise
<
void
>
,
onSuccess
?:
()
=>
Promise
<
void
>
|
void
,
)
{
)
{
// 异步处理用户登录操作并获取 accessToken
// 异步处理用户登录操作并获取 accessToken
let
userInfo
:
UserInfo
|
null
=
null
;
let
userInfo
:
UserInfo
|
null
=
null
;
...
@@ -72,10 +75,21 @@ export const useAccessStore = defineStore('access', () => {
...
@@ -72,10 +75,21 @@ export const useAccessStore = defineStore('access', () => {
coreStoreAccess
.
setUserInfo
(
userInfo
);
coreStoreAccess
.
setUserInfo
(
userInfo
);
coreStoreAccess
.
setAccessCodes
(
accessCodes
);
coreStoreAccess
.
setAccessCodes
(
accessCodes
);
openLoginExpiredModal
.
value
=
false
;
if
(
openLoginExpiredModal
.
value
)
{
onSuccess
openLoginExpiredModal
.
value
=
false
;
?
await
onSuccess
?.()
}
else
{
:
await
router
.
push
(
userInfo
.
homePath
||
DEFAULT_HOME_PATH
);
onSuccess
?
await
onSuccess
?.()
:
await
router
.
push
(
userInfo
.
homePath
||
DEFAULT_HOME_PATH
);
}
if
(
userInfo
?.
realName
)
{
notification
.
success
({
description
:
`
${
$t
(
'authentication.loginSuccessDesc'
)}
:
${
userInfo
?.
realName
}
`,
duration: 3,
message: $t('authentication.loginSuccess'),
});
}
}
}
} finally {
} finally {
loading.value = false;
loading.value = false;
...
...
apps/web-antd/src/store/modules/app.ts
View file @
102249e
...
@@ -12,7 +12,7 @@ export const useAppStore = defineStore('app', () => {
...
@@ -12,7 +12,7 @@ export const useAppStore = defineStore('app', () => {
* 重置所有状态
* 重置所有状态
*/
*/
async
function
resetAppState
()
{
async
function
resetAppState
()
{
accessStore
.
$
reset
();
accessStore
.
reset
();
coreTabbarStore
.
$reset
();
coreTabbarStore
.
$reset
();
}
}
...
...
apps/web-antd/src/views/_essential/authentication/login.vue
View file @
102249e
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
type
{
LoginAndRegisterParams
}
from
'@vben/universal-ui'
;
import
{
AuthenticationLogin
}
from
'@vben/universal-ui'
;
import
{
AuthenticationLogin
}
from
'@vben/universal-ui'
;
import
{
App
}
from
'ant-design-vue'
;
import
{
$t
}
from
'#/locales'
;
import
{
useAccessStore
}
from
'#/store'
;
import
{
useAccessStore
}
from
'#/store'
;
defineOptions
({
name
:
'Login'
});
defineOptions
({
name
:
'Login'
});
const
accessStore
=
useAccessStore
();
const
accessStore
=
useAccessStore
();
const
{
notification
}
=
App
.
useApp
();
/**
* @param params 登录表单数据
*/
async
function
handleLogin
(
params
:
LoginAndRegisterParams
)
{
const
{
userInfo
}
=
await
accessStore
.
authLogin
(
params
);
if
(
userInfo
?.
realName
)
{
notification
.
success
({
description
:
`
${
$t
(
'authentication.loginSuccessDesc'
)}
:
${
userInfo
?.
realName
}
`,
duration: 3,
message: $t('authentication.loginSuccess'),
});
}
}
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -33,6 +13,6 @@ async function handleLogin(params: LoginAndRegisterParams) {
...
@@ -33,6 +13,6 @@ async function handleLogin(params: LoginAndRegisterParams) {
:loading=
"accessStore.loading"
:loading=
"accessStore.loading"
password-placeholder=
"123456"
password-placeholder=
"123456"
username-placeholder=
"vben"
username-placeholder=
"vben"
@
submit=
"
handle
Login"
@
submit=
"
accessStore.auth
Login"
/>
/>
</
template
>
</
template
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment