Skip to content

Commit 9c869de

Browse files
committed
Vue3 重构:REVIEW 敏感词
1 parent 7f8f43a commit 9c869de

File tree

7 files changed

+69
-212
lines changed

7 files changed

+69
-212
lines changed

src/api/system/sensitiveWord/index.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,13 @@ export interface SensitiveWordVO {
1010
createTime: Date
1111
}
1212

13-
export interface SensitiveWordPageReqVO extends PageParam {
14-
name?: string
15-
tag?: string
16-
status?: number
17-
createTime?: Date[]
18-
}
19-
20-
export interface SensitiveWordExportReqVO {
21-
name?: string
22-
tag?: string
23-
status?: number
24-
createTime?: Date[]
25-
}
26-
2713
export interface SensitiveWordTestReqVO {
2814
text: string
2915
tag: string[]
3016
}
3117

3218
// 查询敏感词列表
33-
export const getSensitiveWordPage = (params: SensitiveWordPageReqVO) => {
19+
export const getSensitiveWordPage = (params: PageParam) => {
3420
return request.get({ url: '/system/sensitive-word/page', params })
3521
}
3622

@@ -55,12 +41,12 @@ export const deleteSensitiveWord = (id: number) => {
5541
}
5642

5743
// 导出敏感词
58-
export const exportSensitiveWord = (params: SensitiveWordExportReqVO) => {
44+
export const exportSensitiveWord = (params) => {
5945
return request.download({ url: '/system/sensitive-word/export-excel', params })
6046
}
6147

6248
// 获取所有敏感词的标签数组
63-
export const getSensitiveWordTags = () => {
49+
export const getSensitiveWordTagList = () => {
6450
return request.get({ url: '/system/sensitive-word/get-tags' })
6551
}
6652

src/types/auto-components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ declare module '@vue/runtime-core' {
5454
ElIcon: typeof import('element-plus/es')['ElIcon']
5555
ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
5656
ElInput: typeof import('element-plus/es')['ElInput']
57+
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
5758
ElLink: typeof import('element-plus/es')['ElLink']
5859
ElOption: typeof import('element-plus/es')['ElOption']
5960
ElPagination: typeof import('element-plus/es')['ElPagination']
6061
ElPopover: typeof import('element-plus/es')['ElPopover']
6162
ElRadio: typeof import('element-plus/es')['ElRadio']
63+
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
6264
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
6365
ElRow: typeof import('element-plus/es')['ElRow']
6466
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
@@ -72,6 +74,8 @@ declare module '@vue/runtime-core' {
7274
ElTag: typeof import('element-plus/es')['ElTag']
7375
ElTooltip: typeof import('element-plus/es')['ElTooltip']
7476
ElTransfer: typeof import('element-plus/es')['ElTransfer']
77+
ElTree: typeof import('element-plus/es')['ElTree']
78+
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
7579
ElUpload: typeof import('element-plus/es')['ElUpload']
7680
Error: typeof import('./../components/Error/src/Error.vue')['default']
7781
FlowCondition: typeof import('./../components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue')['default']

src/views/system/oauth2/client/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
import type { FormExpose } from '@/components/Form'
134134
// 业务相关的 import
135135
import * as ClientApi from '@/api/system/oauth2/client'
136-
import { rules, allSchemas } from './client.data'
137136
138137
const { t } = useI18n() // 国际化
139138
const message = useMessage() // 消息弹窗

src/views/system/oauth2/token/form.vue

Lines changed: 0 additions & 131 deletions
This file was deleted.

src/views/system/sensitiveWord/form.vue renamed to src/views/system/sensitiveWord/SensitiveWordForm.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
placeholder="请选择文章标签"
3434
style="width: 380px"
3535
>
36-
<el-option v-for="tag in tags" :key="tag" :label="tag" :value="tag" />
36+
<el-option v-for="tag in tagList" :key="tag" :label="tag" :value="tag" />
3737
</el-select>
3838
</el-form-item>
3939
</el-form>
@@ -47,7 +47,6 @@
4747
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
4848
import * as SensitiveWordApi from '@/api/system/sensitiveWord'
4949
import { CommonStatusEnum } from '@/utils/constants'
50-
5150
const { t } = useI18n() // 国际化
5251
const message = useMessage() // 消息弹窗
5352
@@ -67,11 +66,10 @@ const formRules = reactive({
6766
tags: [{ required: true, message: '标签不能为空', trigger: 'blur' }]
6867
})
6968
const formRef = ref() // 表单 Ref
70-
const tags: Ref<string[]> = ref([]) // todo @blue-syd:在 openModal 里加载下
69+
const tagList = ref([]) // 标签数组
7170
7271
/** 打开弹窗 */
73-
const openModal = async (type: string, paramTags: string[], id?: number) => {
74-
tags.value = paramTags
72+
const open = async (type: string, id?: number) => {
7573
modelVisible.value = true
7674
modelTitle.value = t('action.' + type)
7775
formType.value = type
@@ -81,13 +79,14 @@ const openModal = async (type: string, paramTags: string[], id?: number) => {
8179
formLoading.value = true
8280
try {
8381
formData.value = await SensitiveWordApi.getSensitiveWord(id)
84-
console.log(formData.value)
8582
} finally {
8683
formLoading.value = false
8784
}
8885
}
86+
// 获得 Tag 标签列表
87+
tagList.value = await SensitiveWordApi.getSensitiveWordTagList()
8988
}
90-
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
89+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
9190
9291
/** 提交表单 */
9392
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
@@ -101,10 +100,10 @@ const submitForm = async () => {
101100
try {
102101
const data = formData.value as unknown as SensitiveWordApi.SensitiveWordVO
103102
if (formType.value === 'create') {
104-
await SensitiveWordApi.createSensitiveWord(data) // TODO @blue-syd:去掉 API 后缀
103+
await SensitiveWordApi.createSensitiveWord(data)
105104
message.success(t('common.createSuccess'))
106105
} else {
107-
await SensitiveWordApi.updateSensitiveWord(data) // TODO @blue-syd:去掉 API 后缀
106+
await SensitiveWordApi.updateSensitiveWord(data)
108107
message.success(t('common.updateSuccess'))
109108
}
110109
modelVisible.value = false

src/views/system/sensitiveWord/testForm.vue renamed to src/views/system/sensitiveWord/SensitiveWordTestForm.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<template>
2-
<!-- 对话框(测试敏感词) -->
3-
<Dialog :title="modelTitle" v-model="modelVisible">
2+
<Dialog title="检测敏感词" v-model="modelVisible">
43
<el-form
54
ref="formRef"
65
:model="formData"
@@ -17,10 +16,10 @@
1716
multiple
1817
filterable
1918
allow-create
20-
placeholder="请选择文章标签"
19+
placeholder="请选择标签"
2120
style="width: 380px"
2221
>
23-
<el-option v-for="tag in tags" :key="tag" :label="tag" :value="tag" />
22+
<el-option v-for="tag in tagList" :key="tag" :label="tag" :value="tag" />
2423
</el-select>
2524
</el-form-item>
2625
</el-form>
@@ -34,13 +33,10 @@
3433
</template>
3534
<script setup lang="ts">
3635
import * as SensitiveWordApi from '@/api/system/sensitiveWord'
37-
3836
const message = useMessage() // 消息弹窗
3937
4038
const modelVisible = ref(false) // 弹窗的是否展示
41-
const modelTitle = ref('检测敏感词') // 弹窗的标题
4239
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
43-
const tags: Ref<string[]> = ref([])
4440
const formData = ref({
4541
text: '',
4642
tags: []
@@ -50,14 +46,16 @@ const formRules = reactive({
5046
tags: [{ required: true, message: '标签不能为空', trigger: 'blur' }]
5147
})
5248
const formRef = ref() // 表单 Ref
49+
const tagList = ref([]) // 标签数组
5350
5451
/** 打开弹窗 */
55-
const openModal = async (paramTags: string[]) => {
56-
tags.value = paramTags
52+
const open = async () => {
5753
modelVisible.value = true
5854
resetForm()
55+
// 获得 Tag 标签列表
56+
tagList.value = await SensitiveWordApi.getSensitiveWordTagList()
5957
}
60-
defineExpose({ openModal }) // 提供 openModal 方法,用于打开弹窗
58+
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
6159
6260
/** 提交表单 */
6361
const submitForm = async () => {

0 commit comments

Comments
 (0)