Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a56a2f60
authored
Apr 02, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REVIEW OAuth2 客户端
parent
d50bbf01
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
44 deletions
+46
-44
src/api/system/oauth2/client.ts
+9
-13
src/views/system/oauth2/client/ClientForm.vue
+17
-17
src/views/system/oauth2/client/index.vue
+20
-14
No files found.
src/api/system/oauth2/client.ts
View file @
a56a2f60
...
@@ -21,31 +21,27 @@ export interface OAuth2ClientVO {
...
@@ -21,31 +21,27 @@ export interface OAuth2ClientVO {
createTime
:
Date
createTime
:
Date
}
}
export
interface
OAuth2ClientPageReqVO
extends
PageParam
{
// 查询 OAuth2 客户端的列表
name
?:
string
export
const
getOAuth2ClientPage
=
(
params
:
PageParam
)
=>
{
status
?:
number
}
// 查询 OAuth2列表
export
const
getOAuth2ClientPageApi
=
(
params
:
OAuth2ClientPageReqVO
)
=>
{
return
request
.
get
({
url
:
'/system/oauth2-client/page'
,
params
})
return
request
.
get
({
url
:
'/system/oauth2-client/page'
,
params
})
}
}
// 查询 OAuth2详情
// 查询 OAuth2
客户端的
详情
export
const
getOAuth2Client
Api
=
(
id
:
number
)
=>
{
export
const
getOAuth2Client
=
(
id
:
number
)
=>
{
return
request
.
get
({
url
:
'/system/oauth2-client/get?id='
+
id
})
return
request
.
get
({
url
:
'/system/oauth2-client/get?id='
+
id
})
}
}
// 新增 OAuth2
// 新增 OAuth2
客户端
export
const
createOAuth2Client
Api
=
(
data
:
OAuth2ClientVO
)
=>
{
export
const
createOAuth2Client
=
(
data
:
OAuth2ClientVO
)
=>
{
return
request
.
post
({
url
:
'/system/oauth2-client/create'
,
data
})
return
request
.
post
({
url
:
'/system/oauth2-client/create'
,
data
})
}
}
// 修改 OAuth2
// 修改 OAuth2
客户端
export
const
updateOAuth2Client
Api
=
(
data
:
OAuth2ClientVO
)
=>
{
export
const
updateOAuth2Client
=
(
data
:
OAuth2ClientVO
)
=>
{
return
request
.
put
({
url
:
'/system/oauth2-client/update'
,
data
})
return
request
.
put
({
url
:
'/system/oauth2-client/update'
,
data
})
}
}
// 删除 OAuth2
// 删除 OAuth2
export
const
deleteOAuth2Client
Api
=
(
id
:
number
)
=>
{
export
const
deleteOAuth2Client
=
(
id
:
number
)
=>
{
return
request
.
delete
({
url
:
'/system/oauth2-client/delete?id='
+
id
})
return
request
.
delete
({
url
:
'/system/oauth2-client/delete?id='
+
id
})
}
}
src/views/system/oauth2/client/
f
orm.vue
→
src/views/system/oauth2/client/
ClientF
orm.vue
View file @
a56a2f60
<
template
>
<
template
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
width=
"800
"
>
<Dialog
:title=
"modelTitle"
v-model=
"modelVisible"
scroll
max-height=
"500px
"
>
<el-form
<el-form
ref=
"formRef"
ref=
"formRef"
:model=
"formData"
:model=
"formData"
:rules=
"formRules"
:rules=
"formRules"
label-width=
"1
2
0px"
label-width=
"1
6
0px"
v-loading=
"formLoading"
v-loading=
"formLoading"
>
>
<el-form-item
label=
"客户端编号"
prop=
"secret"
>
<el-form-item
label=
"客户端编号"
prop=
"secret"
>
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<el-input
v-model=
"formData.name"
placeholder=
"请输入应用名"
/>
<el-input
v-model=
"formData.name"
placeholder=
"请输入应用名"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"应用图标"
>
<el-form-item
label=
"应用图标"
>
<
imageUpload
v-model=
"formData.logo"
:limit=
"1"
/>
<
UploadImg
v-model=
"formData.logo"
:limit=
"1"
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"应用描述"
>
<el-form-item
label=
"应用描述"
>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入应用名"
/>
<el-input
type=
"textarea"
v-model=
"formData.description"
placeholder=
"请输入应用名"
/>
...
@@ -25,11 +25,12 @@
...
@@ -25,11 +25,12 @@
<el-form-item
label=
"状态"
prop=
"status"
>
<el-form-item
label=
"状态"
prop=
"status"
>
<el-radio-group
v-model=
"formData.status"
>
<el-radio-group
v-model=
"formData.status"
>
<el-radio
<el-radio
v-for=
"dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"dict.value"
:key=
"dict.value"
:label=
"parseInt(dict.value)"
:label=
"dict.value"
>
{{
dict
.
label
}}
</el-radio
>
>
{{
dict
.
label
}}
</el-radio>
</el-radio-group>
</el-radio-group>
</el-form-item>
</el-form-item>
<el-form-item
label=
"访问令牌的有效期"
prop=
"accessTokenValiditySeconds"
>
<el-form-item
label=
"访问令牌的有效期"
prop=
"accessTokenValiditySeconds"
>
...
@@ -47,7 +48,7 @@
...
@@ -47,7 +48,7 @@
style=
"width: 500px"
style=
"width: 500px"
>
>
<el-option
<el-option
v-for=
"dict in getDictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE)"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE)"
:key=
"dict.value"
:key=
"dict.value"
:label=
"dict.label"
:label=
"dict.label"
:value=
"dict.value"
:value=
"dict.value"
...
@@ -137,15 +138,14 @@
...
@@ -137,15 +138,14 @@
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<template
#
footer
>
<template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"submitForm"
type=
"primary"
:disabled=
"formLoading"
>
确 定
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
<el-button
@
click=
"modelVisible = false"
>
取 消
</el-button>
</div>
</
template
>
</
template
>
</Dialog>
</Dialog>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
CommonStatusEnum
}
from
'@/utils/constants'
import
*
as
ClientApi
from
'@/api/system/oauth2/client'
import
*
as
ClientApi
from
'@/api/system/oauth2/client'
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
...
@@ -161,7 +161,7 @@ const formData = ref({
...
@@ -161,7 +161,7 @@ const formData = ref({
name
:
undefined
,
name
:
undefined
,
logo
:
undefined
,
logo
:
undefined
,
description
:
undefined
,
description
:
undefined
,
status
:
DICT_TYPE
.
COMMON_STATUS
,
status
:
CommonStatusEnum
.
ENABLE
,
accessTokenValiditySeconds
:
30
*
60
,
accessTokenValiditySeconds
:
30
*
60
,
refreshTokenValiditySeconds
:
30
*
24
*
60
,
refreshTokenValiditySeconds
:
30
*
24
*
60
,
redirectUris
:
[],
redirectUris
:
[],
...
@@ -190,7 +190,7 @@ const formRules = reactive({
...
@@ -190,7 +190,7 @@ const formRules = reactive({
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
/** 打开弹窗 */
/** 打开弹窗 */
const
open
Modal
=
async
(
type
:
string
,
id
?:
number
)
=>
{
const
open
=
async
(
type
:
string
,
id
?:
number
)
=>
{
modelVisible
.
value
=
true
modelVisible
.
value
=
true
modelTitle
.
value
=
t
(
'action.'
+
type
)
modelTitle
.
value
=
t
(
'action.'
+
type
)
formType
.
value
=
type
formType
.
value
=
type
...
@@ -199,13 +199,13 @@ const openModal = async (type: string, id?: number) => {
...
@@ -199,13 +199,13 @@ const openModal = async (type: string, id?: number) => {
if
(
id
)
{
if
(
id
)
{
formLoading
.
value
=
true
formLoading
.
value
=
true
try
{
try
{
formData
.
value
=
await
ClientApi
.
getOAuth2Client
Api
(
id
)
formData
.
value
=
await
ClientApi
.
getOAuth2Client
(
id
)
}
finally
{
}
finally
{
formLoading
.
value
=
false
formLoading
.
value
=
false
}
}
}
}
}
}
defineExpose
({
open
Modal
})
// 提供 openModal
方法,用于打开弹窗
defineExpose
({
open
})
// 提供 open
方法,用于打开弹窗
/** 提交表单 */
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
...
@@ -219,10 +219,10 @@ const submitForm = async () => {
...
@@ -219,10 +219,10 @@ const submitForm = async () => {
try
{
try
{
const
data
=
formData
.
value
as
unknown
as
ClientApi
.
OAuth2ClientVO
const
data
=
formData
.
value
as
unknown
as
ClientApi
.
OAuth2ClientVO
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
await
ClientApi
.
createOAuth2Client
Api
(
data
)
await
ClientApi
.
createOAuth2Client
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
message
.
success
(
t
(
'common.createSuccess'
))
}
else
{
}
else
{
await
ClientApi
.
updateOAuth2Client
Api
(
data
)
await
ClientApi
.
updateOAuth2Client
(
data
)
message
.
success
(
t
(
'common.updateSuccess'
))
message
.
success
(
t
(
'common.updateSuccess'
))
}
}
modelVisible
.
value
=
false
modelVisible
.
value
=
false
...
@@ -242,7 +242,7 @@ const resetForm = () => {
...
@@ -242,7 +242,7 @@ const resetForm = () => {
name
:
undefined
,
name
:
undefined
,
logo
:
undefined
,
logo
:
undefined
,
description
:
undefined
,
description
:
undefined
,
status
:
DICT_TYPE
.
COMMON_STATUS
,
status
:
CommonStatusEnum
.
ENABLE
,
accessTokenValiditySeconds
:
30
*
60
,
accessTokenValiditySeconds
:
30
*
60
,
refreshTokenValiditySeconds
:
30
*
24
*
60
,
refreshTokenValiditySeconds
:
30
*
24
*
60
,
redirectUris
:
[],
redirectUris
:
[],
...
...
src/views/system/oauth2/client/index.vue
View file @
a56a2f60
...
@@ -14,12 +14,13 @@
...
@@ -14,12 +14,13 @@
placeholder=
"请输入应用名"
placeholder=
"请输入应用名"
clearable
clearable
@
keyup
.
enter=
"handleQuery"
@
keyup
.
enter=
"handleQuery"
class=
"!w-240px"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item
label=
"状态"
prop=
"status"
>
<el-form-item
label=
"状态"
prop=
"status"
>
<el-select
v-model=
"queryParams.status"
placeholder=
"请选择状态"
clearable
size=
"small
"
>
<el-select
v-model=
"queryParams.status"
placeholder=
"请选择状态"
clearable
class=
"!w-240px
"
>
<el-option
<el-option
v-for=
"dict in getDictOptions(DICT_TYPE.COMMON_STATUS)"
v-for=
"dict in get
Int
DictOptions(DICT_TYPE.COMMON_STATUS)"
:key=
"dict.value"
:key=
"dict.value"
:label=
"dict.label"
:label=
"dict.label"
:value=
"dict.value"
:value=
"dict.value"
...
@@ -29,7 +30,12 @@
...
@@ -29,7 +30,12 @@
<el-form-item>
<el-form-item>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"handleQuery"
><Icon
icon=
"ep:search"
class=
"mr-5px"
/>
搜索
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
@
click=
"resetQuery"
><Icon
icon=
"ep:refresh"
class=
"mr-5px"
/>
重置
</el-button>
<el-button
type=
"primary"
@
click=
"openModal('create')"
v-hasPermi=
"['infra:config:create']"
>
<el-button
plain
type=
"primary"
@
click=
"openForm('create')"
v-hasPermi=
"['system:oauth2-client:create']"
>
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
<Icon
icon=
"ep:plus"
class=
"mr-5px"
/>
新增
</el-button>
</el-button>
</el-form-item>
</el-form-item>
...
@@ -82,8 +88,8 @@
...
@@ -82,8 +88,8 @@
<el-button
<el-button
link
link
type=
"primary"
type=
"primary"
@
click=
"open
Modal
('update', scope.row.id)"
@
click=
"open
Form
('update', scope.row.id)"
v-hasPermi=
"['
infra:config
:update']"
v-hasPermi=
"['
system:oauth2-client
:update']"
>
>
编辑
编辑
</el-button>
</el-button>
...
@@ -91,7 +97,7 @@
...
@@ -91,7 +97,7 @@
link
link
type=
"danger"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
@
click=
"handleDelete(scope.row.id)"
v-hasPermi=
"['
infra:config
:delete']"
v-hasPermi=
"['
system:oauth2-client
:delete']"
>
>
删除
删除
</el-button>
</el-button>
...
@@ -108,13 +114,13 @@
...
@@ -108,13 +114,13 @@
</content-wrap>
</content-wrap>
<!-- 表单弹窗:添加/修改 -->
<!-- 表单弹窗:添加/修改 -->
<ClientForm
ref=
"
modal
Ref"
@
success=
"getList"
/>
<ClientForm
ref=
"
form
Ref"
@
success=
"getList"
/>
</template>
</template>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
DICT_TYPE
,
getDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
get
Int
DictOptions
}
from
'@/utils/dict'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
{
dateFormatter
}
from
'@/utils/formatTime'
import
*
as
ClientApi
from
'@/api/system/oauth2/client'
import
*
as
ClientApi
from
'@/api/system/oauth2/client'
import
ClientForm
from
'./
f
orm.vue'
import
ClientForm
from
'./
ClientF
orm.vue'
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
t
}
=
useI18n
()
// 国际化
const
{
t
}
=
useI18n
()
// 国际化
...
@@ -133,7 +139,7 @@ const queryFormRef = ref() // 搜索的表单
...
@@ -133,7 +139,7 @@ const queryFormRef = ref() // 搜索的表单
const
getList
=
async
()
=>
{
const
getList
=
async
()
=>
{
loading
.
value
=
true
loading
.
value
=
true
try
{
try
{
const
data
=
await
ClientApi
.
getOAuth2ClientPage
Api
(
queryParams
)
const
data
=
await
ClientApi
.
getOAuth2ClientPage
(
queryParams
)
list
.
value
=
data
.
list
list
.
value
=
data
.
list
total
.
value
=
data
.
total
total
.
value
=
data
.
total
}
finally
{
}
finally
{
...
@@ -154,9 +160,9 @@ const resetQuery = () => {
...
@@ -154,9 +160,9 @@ const resetQuery = () => {
}
}
/** 添加/修改操作 */
/** 添加/修改操作 */
const
modal
Ref
=
ref
()
const
form
Ref
=
ref
()
const
open
Modal
=
(
type
:
string
,
id
?:
number
)
=>
{
const
open
Form
=
(
type
:
string
,
id
?:
number
)
=>
{
modalRef
.
value
.
openModal
(
type
,
id
)
formRef
.
value
.
open
(
type
,
id
)
}
}
/** 删除按钮操作 */
/** 删除按钮操作 */
...
@@ -165,7 +171,7 @@ const handleDelete = async (id: number) => {
...
@@ -165,7 +171,7 @@ const handleDelete = async (id: number) => {
// 删除的二次确认
// 删除的二次确认
await
message
.
delConfirm
()
await
message
.
delConfirm
()
// 发起删除
// 发起删除
await
ClientApi
.
deleteOAuth2Client
Api
(
id
)
await
ClientApi
.
deleteOAuth2Client
(
id
)
message
.
success
(
t
(
'common.delSuccess'
))
message
.
success
(
t
(
'common.delSuccess'
))
// 刷新列表
// 刷新列表
await
getList
()
await
getList
()
...
...
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