init
This commit is contained in:
@@ -16,6 +16,21 @@ export function lastRefresh() {
|
||||
})
|
||||
}
|
||||
|
||||
export function updateSensitiveConfig(data) {
|
||||
return request({
|
||||
url: '/sensitive/word/updateSensitiveConfig',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function getSensitiveConfig() {
|
||||
return request({
|
||||
url: '/sensitive/word/getSensitiveConfig',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
// 查询敏感词详细
|
||||
export function getWord(id) {
|
||||
return request({
|
||||
|
||||
@@ -57,6 +57,15 @@
|
||||
v-hasPermi="['sensitive:word:export']"
|
||||
>导出</el-button>
|
||||
</el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
@click="handleWordConfig"
|
||||
>敏感词配置</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
@@ -76,7 +85,7 @@
|
||||
>测试文字</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-tag type="info">最新刷新词库: {{lastRefresh}}</el-tag>
|
||||
<el-tag type="info">最近刷新词库时间: {{lastRefresh}}</el-tag>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
@@ -89,7 +98,16 @@
|
||||
<cai-dict-tag :options="sensitiveTypeList" :value="scope.row.type"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="启用状态" align="center" prop="enableStatus" />
|
||||
<el-table-column label="启用状态" align="center" prop="enableStatus" >
|
||||
<template v-slot="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.enableStatus"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
@change="handleEnableStatusChange(scope.row)"
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="配置描述" align="center" prop="remark" show-overflow-tooltip/>
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
@@ -147,23 +165,26 @@
|
||||
</el-dialog>
|
||||
|
||||
<word-test-dialog v-if="wordTestVisible" ref="wordTest"/>
|
||||
<word-config-dialog v-if="wordConfigVisible" ref="wordConfig"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listWord, getWord, delWord, addWord, updateWord, refreshWord, lastRefresh } from '@/api/sensitive/word'
|
||||
import { addWord, delWord, getWord, lastRefresh, listWord, refreshWord, updateWord } from '@/api/sensitive/word'
|
||||
import { sensitiveTypeList } from '@/constant/statusMap'
|
||||
import WordTestDialog from '@/views/sensitive/word/word-test-dialog.vue'
|
||||
import WordConfigDialog from '@/views/sensitive/word/word-config-dialog.vue'
|
||||
|
||||
export default {
|
||||
name: "Word",
|
||||
components: {
|
||||
WordTestDialog
|
||||
WordTestDialog,WordConfigDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
sensitiveTypeList,
|
||||
wordTestVisible: false,
|
||||
wordConfigVisible: false,
|
||||
// 按钮loading
|
||||
buttonLoading: false,
|
||||
// 遮罩层
|
||||
@@ -276,10 +297,23 @@ export default {
|
||||
this.$refs.wordTest.init()
|
||||
})
|
||||
},
|
||||
handleWordConfig() {
|
||||
this.wordConfigVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.wordConfig.init()
|
||||
})
|
||||
},
|
||||
handleRefresh() {
|
||||
refreshWord().then(response => {
|
||||
this.$modal.msgSuccess("刷新成功");
|
||||
this.$modal.confirm('是否刷新敏感词库缓存?').then(() => {
|
||||
this.loading = true;
|
||||
return refreshWord();
|
||||
}).then(() => {
|
||||
this.loading = false;
|
||||
this.updateRefreshTime()
|
||||
this.$modal.msgSuccess("刷新成功");
|
||||
}).catch(() => {
|
||||
}).finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
handleUpdate(row) {
|
||||
@@ -318,6 +352,20 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
handleEnableStatusChange(row){
|
||||
let text = row.enableStatus === 0 ? '封禁' : '恢复'
|
||||
this.$confirm('确认要' + text + '[' + row.word + ']敏感词吗?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
return updateWord({ id: row.id, enableStatus: row.enableStatus })
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess(text + '成功')
|
||||
}).catch(function() {
|
||||
row.enableStatus = row.enableStatus === 1 ? 0 : 1
|
||||
})
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
|
||||
142
src/views/sensitive/word/word-config-dialog.vue
Normal file
142
src/views/sensitive/word/word-config-dialog.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="400px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="200px">
|
||||
<el-form-item label="是否忽略大小写" prop="ignoreCase" >
|
||||
<el-switch
|
||||
v-model="form.ignoreCase"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否忽略全角、半角" prop="ignoreWidth" >
|
||||
<el-switch
|
||||
v-model="form.ignoreWidth"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否忽略数字样式" prop="ignoreNumStyle" >
|
||||
<el-switch
|
||||
v-model="form.ignoreNumStyle"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否忽略中文样式" prop="ignoreChineseStyle" >
|
||||
<el-switch
|
||||
v-model="form.ignoreChineseStyle"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="是否忽略重复" prop="ignoreRepeat" >
|
||||
<el-switch
|
||||
v-model="form.ignoreRepeat"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用数字检测" prop="enableNumCheck" >
|
||||
<el-switch
|
||||
v-model="form.enableNumCheck"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="检测数字时的长度" prop="numCheckLen" v-if="form.enableNumCheck">
|
||||
<el-input-number v-model="form.numCheckLen" :step="1" :min="0"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用邮箱检测" prop="enableEmailCheck" >
|
||||
<el-switch
|
||||
v-model="form.enableEmailCheck"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用URL检测" prop="enableUrlCheck" >
|
||||
<el-switch
|
||||
v-model="form.enableUrlCheck"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="open = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getSensitiveConfig, updateSensitiveConfig } from '@/api/sensitive/word'
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
systemName: process.env.VUE_APP_SYSTEM_HOME,
|
||||
open: false,
|
||||
title: '',
|
||||
form: {
|
||||
ignoreCase: true,
|
||||
ignoreWidth: true,
|
||||
ignoreNumStyle: true,
|
||||
ignoreChineseStyle: true,
|
||||
ignoreEnglishStyle: true,
|
||||
ignoreRepeat: false,
|
||||
enableNumCheck: true,
|
||||
enableEmailCheck: true,
|
||||
enableUrlCheck: true,
|
||||
enableWordCheck: true,
|
||||
numCheckLen: 8,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
sourceText: [
|
||||
{ required: true, message: '数据不能为空', trigger: 'blur' }
|
||||
]
|
||||
},
|
||||
buttonLoading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.open = true
|
||||
this.title = '敏感词配置'
|
||||
this.$nextTick(() => {
|
||||
this.$refs['form'].resetFields();
|
||||
getSensitiveConfig().then(response => {
|
||||
if(response.data){
|
||||
this.form = response.data;
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
submitForm() {
|
||||
this.$refs['form'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.buttonLoading = true
|
||||
updateSensitiveConfig(this.form).then(data => {
|
||||
this.open = false
|
||||
this.buttonLoading = false
|
||||
}).finally(() => {
|
||||
this.buttonLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user