mirror of https://github.com/1Panel-dev/1Panel
zhengkunwang
8 months ago
committed by
GitHub
16 changed files with 59 additions and 1400 deletions
@ -1,129 +0,0 @@
|
||||
<template> |
||||
<el-row :gutter="20" v-loading="loading"> |
||||
<el-col :xs="24" :sm="18" :md="10" :lg="10" :xl="10"> |
||||
<el-form ref="wafForm" label-position="left" label-width="auto" :model="form" :rules="rules"> |
||||
<el-form-item prop="enable" :label="$t('website.enable')"> |
||||
<el-switch v-model="form.enable" @change="updateEnable"></el-switch> |
||||
</el-form-item> |
||||
<el-form-item prop="cycle" :label="$t('website.cycle')"> |
||||
<el-input v-model.number="form.cycle" maxlength="15"> |
||||
<template #append>{{ $t('commons.units.second') }}</template> |
||||
</el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="frequency" :label="$t('website.frequency')"> |
||||
<el-input v-model.number="form.frequency" maxlength="15"> |
||||
<template #append>{{ $t('commons.units.time') }}</template> |
||||
</el-input> |
||||
</el-form-item> |
||||
<el-alert |
||||
:title="$t('website.ccHelper', [form.cycle, form.frequency])" |
||||
type="info" |
||||
:closable="false" |
||||
></el-alert> |
||||
<el-form-item></el-form-item> |
||||
<el-form-item> |
||||
<el-button type="primary" @click="submit(wafForm)"> |
||||
{{ $t('commons.button.save') }} |
||||
</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
|
||||
<script lang="ts" setup> |
||||
import { Website } from '@/api/interface/website'; |
||||
import { GetWafConfig, UpdateWafEnable, UpdateWafFile } from '@/api/modules/website'; |
||||
import { checkNumberRange, Rules } from '@/global/form-rules'; |
||||
import i18n from '@/lang'; |
||||
import { MsgSuccess } from '@/utils/message'; |
||||
import { FormInstance } from 'element-plus'; |
||||
import { computed, onMounted, reactive, ref } from 'vue'; |
||||
|
||||
const props = defineProps({ |
||||
id: { |
||||
type: Number, |
||||
default: 0, |
||||
}, |
||||
}); |
||||
const id = computed(() => { |
||||
return props.id; |
||||
}); |
||||
|
||||
const data = ref<Website.WafRes>(); |
||||
const loading = ref(false); |
||||
const form = reactive({ |
||||
enable: false, |
||||
cycle: 60, |
||||
frequency: 120, |
||||
}); |
||||
const req = ref<Website.WafReq>({ |
||||
websiteId: 0, |
||||
key: '$CCDeny', |
||||
rule: 'cc', |
||||
}); |
||||
const enableUpdate = ref<Website.WafUpdate>({ |
||||
websiteId: 0, |
||||
key: '$CCDeny', |
||||
enable: false, |
||||
}); |
||||
const fileUpdate = reactive({ |
||||
content: '', |
||||
websiteId: 0, |
||||
type: 'cc', |
||||
}); |
||||
const rules = ref({ |
||||
cycle: [Rules.requiredInput, checkNumberRange(1, 9999999)], |
||||
frequency: [Rules.requiredInput, checkNumberRange(1, 9999999)], |
||||
}); |
||||
const wafForm = ref<FormInstance>(); |
||||
|
||||
const get = async () => { |
||||
loading.value = true; |
||||
const res = await GetWafConfig(req.value); |
||||
loading.value = false; |
||||
data.value = res.data; |
||||
form.enable = data.value.enable; |
||||
if (data.value.content != '') { |
||||
const params = data.value.content.split('/'); |
||||
form.frequency = Number(params[0]); |
||||
form.cycle = Number(params[1]); |
||||
} |
||||
}; |
||||
|
||||
const updateEnable = async (enable: boolean) => { |
||||
enableUpdate.value.enable = enable; |
||||
loading.value = true; |
||||
try { |
||||
await UpdateWafEnable(enableUpdate.value); |
||||
} catch (error) { |
||||
form.enable = !enable; |
||||
} |
||||
loading.value = false; |
||||
}; |
||||
|
||||
const submit = async (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return; |
||||
await formEl.validate((valid) => { |
||||
if (!valid) { |
||||
return; |
||||
} |
||||
fileUpdate.content = String(form.frequency) + '/' + String(form.cycle); |
||||
loading.value = true; |
||||
UpdateWafFile(fileUpdate) |
||||
.then(() => { |
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); |
||||
}) |
||||
.finally(() => { |
||||
loading.value = false; |
||||
}); |
||||
}); |
||||
}; |
||||
|
||||
onMounted(() => { |
||||
req.value.websiteId = id.value; |
||||
enableUpdate.value.websiteId = id.value; |
||||
fileUpdate.websiteId = id.value; |
||||
get(); |
||||
}); |
||||
</script> |
@ -1,134 +0,0 @@
|
||||
<template> |
||||
<el-row> |
||||
<el-col :xs="24" :sm="18" :md="10" :lg="10" :xl="10"> |
||||
<el-form-item prop="enable" :label="$t('website.enable')"> |
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('website.ext')"> |
||||
<el-input type="textarea" :rows="3" v-model="exts" :placeholder="$t('website.wafInputHelper')" /> |
||||
</el-form-item> |
||||
<ComplexTable :data="data" v-loading="loading"> |
||||
<template #toolbar> |
||||
<el-button type="primary" icon="Plus" @click="openCreate"> |
||||
{{ $t('commons.button.add') }} |
||||
</el-button> |
||||
</template> |
||||
<el-table-column :label="$t('website.fileExt')" prop="file"></el-table-column> |
||||
<el-table-column :label="$t('commons.table.operate')"> |
||||
<template #default="{ $index }"> |
||||
<el-button link type="primary" @click="remove($index)"> |
||||
{{ $t('commons.button.delete') }} |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</ComplexTable> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { Website } from '@/api/interface/website'; |
||||
import { GetWafConfig, UpdateWafEnable, UpdateWafFile } from '@/api/modules/website'; |
||||
import { computed, onMounted, reactive, ref } from 'vue'; |
||||
import i18n from '@/lang'; |
||||
import { MsgSuccess } from '@/utils/message'; |
||||
|
||||
const props = defineProps({ |
||||
id: { |
||||
type: Number, |
||||
default: 0, |
||||
}, |
||||
}); |
||||
const id = computed(() => { |
||||
return props.id; |
||||
}); |
||||
|
||||
const loading = ref(false); |
||||
const data = ref([]); |
||||
const req = ref<Website.WafReq>({ |
||||
websiteId: 0, |
||||
key: '$fileExtDeny', |
||||
rule: 'file_ext_block', |
||||
}); |
||||
const fileUpdate = reactive({ |
||||
content: '', |
||||
websiteId: 0, |
||||
type: 'file_ext_block', |
||||
}); |
||||
const enableUpdate = ref<Website.WafUpdate>({ |
||||
websiteId: 0, |
||||
key: '$fileExtDeny', |
||||
enable: false, |
||||
}); |
||||
const exts = ref(); |
||||
|
||||
const get = async () => { |
||||
data.value = []; |
||||
loading.value = true; |
||||
const res = await GetWafConfig(req.value); |
||||
loading.value = false; |
||||
|
||||
if (res.data.content != '') { |
||||
const ipList = JSON.parse(res.data.content); |
||||
ipList.forEach((value: string) => { |
||||
data.value.push({ |
||||
file: value, |
||||
}); |
||||
}); |
||||
} |
||||
|
||||
enableUpdate.value.enable = res.data.enable; |
||||
}; |
||||
|
||||
const remove = (index: number) => { |
||||
const copyList = data.value.concat(); |
||||
copyList.splice(index, 1); |
||||
const extArray = []; |
||||
copyList.forEach((d) => { |
||||
extArray.push(d.file); |
||||
}); |
||||
submit(extArray); |
||||
}; |
||||
|
||||
const openCreate = () => { |
||||
const extArray = exts.value.split('\n'); |
||||
if (extArray.length === 0) { |
||||
return; |
||||
} |
||||
data.value.forEach((d) => { |
||||
extArray.push(d.file); |
||||
}); |
||||
submit(extArray); |
||||
}; |
||||
|
||||
const submit = async (extArray: string[]) => { |
||||
fileUpdate.content = JSON.stringify(extArray); |
||||
loading.value = true; |
||||
UpdateWafFile(fileUpdate) |
||||
.then(() => { |
||||
exts.value = ''; |
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); |
||||
get(); |
||||
}) |
||||
.finally(() => { |
||||
loading.value = false; |
||||
}); |
||||
}; |
||||
|
||||
const updateEnable = async (enable: boolean) => { |
||||
enableUpdate.value.enable = enable; |
||||
loading.value = true; |
||||
try { |
||||
await UpdateWafEnable(enableUpdate.value); |
||||
} catch (error) { |
||||
enableUpdate.value.enable = !enable; |
||||
} |
||||
loading.value = false; |
||||
}; |
||||
|
||||
onMounted(() => { |
||||
req.value.websiteId = id.value; |
||||
enableUpdate.value.websiteId = id.value; |
||||
fileUpdate.websiteId = id.value; |
||||
get(); |
||||
}); |
||||
</script> |
@ -1,74 +0,0 @@
|
||||
<template> |
||||
<el-tabs tab-position="left" v-model="index"> |
||||
<el-tab-pane :label="$t('firewall.ccDeny')" name="cc"> |
||||
<CCDeny :id="id" v-if="index == 'cc'"></CCDeny> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.ipWhiteList')" name="ipWhiteList"> |
||||
<SimpleList |
||||
:id="id" |
||||
:rule="'ip_white'" |
||||
:param-key="'$ipWhiteAllow'" |
||||
v-if="index == 'ipWhiteList'" |
||||
></SimpleList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.ipBlockList')" name="ipBlockList"> |
||||
<SimpleList |
||||
:id="id" |
||||
:rule="'ip_block'" |
||||
:param-key="'$ipBlockDeny'" |
||||
v-if="index == 'ipBlockList'" |
||||
></SimpleList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.urlWhiteList')" name="urlWhiteList"> |
||||
<SimpleList |
||||
:id="id" |
||||
:rule="'url_white'" |
||||
:param-key="'$urlWhiteAllow'" |
||||
v-if="index == 'urlWhiteList'" |
||||
></SimpleList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.urlBlockList')" name="urlBlockList"> |
||||
<SimpleList |
||||
:id="id" |
||||
:rule="'url_block'" |
||||
:param-key="'$urlBlockDeny'" |
||||
v-if="index == 'urlBlockList'" |
||||
></SimpleList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.cookieBlockList')" name="cookie"> |
||||
<ValueList :id="id" :rule="'cookie_block'" :param-key="'$cookieDeny'" v-if="index == 'cookie'"></ValueList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.argsCheck')" name="args"> |
||||
<ValueList :id="id" :rule="'args_check'" :param-key="'$argsDeny'" v-if="index == 'args'"></ValueList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.postCheck')" name="post"> |
||||
<ValueList :id="id" :rule="'post_check'" :param-key="'$postDeny'" v-if="index == 'post'"></ValueList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.userAgent')" name="ua"> |
||||
<ValueList :id="id" :rule="'user_agent'" :param-key="'$userAgent'" v-if="index == 'ua'"></ValueList> |
||||
</el-tab-pane> |
||||
<el-tab-pane :label="$t('firewall.fileExtBlockList')" name="fileExtBlockList"> |
||||
<FileBlockList :id="id" v-if="index == 'fileExtBlockList'"></FileBlockList> |
||||
</el-tab-pane> |
||||
</el-tabs> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { computed, ref } from 'vue'; |
||||
import CCDeny from './ccdeny/index.vue'; |
||||
import SimpleList from './simple-list/index.vue'; |
||||
import FileBlockList from './file-block-list/index.vue'; |
||||
import ValueList from './value-list/index.vue'; |
||||
|
||||
const props = defineProps({ |
||||
id: { |
||||
type: Number, |
||||
default: 0, |
||||
}, |
||||
}); |
||||
|
||||
const id = computed(() => { |
||||
return props.id; |
||||
}); |
||||
|
||||
let index = ref('cc'); |
||||
</script> |
@ -1,181 +0,0 @@
|
||||
<template> |
||||
<el-row> |
||||
<el-col :xs="24" :sm="18" :md="10" :lg="10" :xl="10"> |
||||
<el-form-item prop="enable" :label="$t('website.enable')"> |
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch> |
||||
</el-form-item> |
||||
<el-form-item> |
||||
<el-alert |
||||
type="info" |
||||
v-if="rule === 'ip_white'" |
||||
:title="$t('website.ipWhiteListHelper')" |
||||
:closable="false" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('website.ipValue')"> |
||||
<el-input type="textarea" :rows="3" v-model="ips" :placeholder="$t('website.wafInputHelper')" /> |
||||
</el-form-item> |
||||
<ComplexTable :data="data" v-loading="loading"> |
||||
<template #toolbar> |
||||
<el-button type="primary" icon="Plus" @click="openCreate"> |
||||
{{ $t('commons.button.add') }} |
||||
</el-button> |
||||
</template> |
||||
<el-table-column :label="$t('website.ipValue')" prop="ip"></el-table-column> |
||||
<el-table-column :label="$t('commons.table.operate')"> |
||||
<template #default="{ $index }"> |
||||
<el-button link type="primary" @click="removeIp($index)"> |
||||
{{ $t('commons.button.delete') }} |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</ComplexTable> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { Website } from '@/api/interface/website'; |
||||
import { GetWafConfig, UpdateWafEnable, UpdateWafFile } from '@/api/modules/website'; |
||||
import { computed, onMounted, reactive, ref } from 'vue'; |
||||
import i18n from '@/lang'; |
||||
import { checkIpV4V6 } from '@/utils/util'; |
||||
import { MsgSuccess } from '@/utils/message'; |
||||
import { MsgError } from '@/utils/message'; |
||||
|
||||
const props = defineProps({ |
||||
id: { |
||||
type: Number, |
||||
default: 0, |
||||
}, |
||||
rule: { |
||||
type: String, |
||||
default: 'ip_white', |
||||
}, |
||||
paramKey: { |
||||
type: String, |
||||
default: '$ipWhiteAllow', |
||||
}, |
||||
}); |
||||
const id = computed(() => { |
||||
return props.id; |
||||
}); |
||||
const rule = computed(() => { |
||||
return props.rule; |
||||
}); |
||||
const key = computed(() => { |
||||
return props.paramKey; |
||||
}); |
||||
|
||||
const loading = ref(false); |
||||
const data = ref([]); |
||||
const req = ref<Website.WafReq>({ |
||||
websiteId: 0, |
||||
key: '$ipWhiteAllow', |
||||
rule: 'ip_white', |
||||
}); |
||||
const fileUpdate = reactive({ |
||||
content: '', |
||||
websiteId: 0, |
||||
type: 'ip_white', |
||||
}); |
||||
const enableUpdate = ref<Website.WafUpdate>({ |
||||
websiteId: 0, |
||||
key: '$ipWhiteAllow', |
||||
enable: false, |
||||
}); |
||||
const ips = ref(); |
||||
|
||||
const get = async () => { |
||||
data.value = []; |
||||
loading.value = true; |
||||
const res = await GetWafConfig(req.value); |
||||
loading.value = false; |
||||
|
||||
if (res.data.content != '') { |
||||
const ipList = JSON.parse(res.data.content); |
||||
ipList.forEach((ip: string) => { |
||||
data.value.push({ |
||||
ip: ip, |
||||
}); |
||||
}); |
||||
} |
||||
enableUpdate.value.enable = res.data.enable; |
||||
}; |
||||
|
||||
const removeIp = (index: number) => { |
||||
const copyList = data.value.concat(); |
||||
copyList.splice(index, 1); |
||||
let ipArray = []; |
||||
copyList.forEach((d) => { |
||||
ipArray.push(d.ip); |
||||
}); |
||||
submit(ipArray); |
||||
}; |
||||
|
||||
const openCreate = () => { |
||||
const ipArray = ips.value.split('\n'); |
||||
if (ipArray.length == 0) { |
||||
return; |
||||
} |
||||
let newIpArray = []; |
||||
ipArray.forEach((ip: string) => { |
||||
const newIp = ip.replace(/(^\s*)|(\s*$)/g, ''); |
||||
if (newIp != '') { |
||||
newIpArray.push(newIp); |
||||
} |
||||
}); |
||||
if (newIpArray.length == 0) { |
||||
return; |
||||
} |
||||
if (req.value.rule.indexOf('ip') > -1) { |
||||
for (const id in newIpArray) { |
||||
if (checkIpV4V6(newIpArray[id])) { |
||||
MsgError(i18n.global.t('commons.rule.ipErr', [ipArray[id]])); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
data.value.forEach((d) => { |
||||
newIpArray.push(d.ip); |
||||
}); |
||||
if (newIpArray.length > 0) { |
||||
submit(newIpArray); |
||||
} |
||||
}; |
||||
|
||||
const submit = async (ipList: string[]) => { |
||||
fileUpdate.content = JSON.stringify(ipList); |
||||
loading.value = true; |
||||
UpdateWafFile(fileUpdate) |
||||
.then(() => { |
||||
ips.value = ''; |
||||
get(); |
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); |
||||
}) |
||||
.finally(() => { |
||||
loading.value = false; |
||||
}); |
||||
}; |
||||
|
||||
const updateEnable = async (enable: boolean) => { |
||||
enableUpdate.value.enable = enable; |
||||
loading.value = true; |
||||
try { |
||||
await UpdateWafEnable(enableUpdate.value); |
||||
} catch (error) { |
||||
enableUpdate.value.enable = !enable; |
||||
} |
||||
loading.value = false; |
||||
}; |
||||
|
||||
onMounted(() => { |
||||
req.value.websiteId = id.value; |
||||
req.value.rule = rule.value; |
||||
req.value.key = key.value; |
||||
enableUpdate.value.websiteId = id.value; |
||||
enableUpdate.value.key = key.value; |
||||
fileUpdate.type = rule.value; |
||||
fileUpdate.websiteId = id.value; |
||||
get(); |
||||
}); |
||||
</script> |
@ -1,184 +0,0 @@
|
||||
<template> |
||||
<el-row> |
||||
<el-col :xs="24" :sm="18" :md="14" :lg="14" :xl="14"> |
||||
<el-form> |
||||
<el-form-item prop="enable" :label="$t('website.enable')" v-if="rule != 'user_agent'"> |
||||
<el-switch v-model="enableUpdate.enable" @change="updateEnable"></el-switch> |
||||
</el-form-item> |
||||
<el-form-item :label="$t('website.data')"> |
||||
<el-row :gutter="10" style="width: 100%"> |
||||
<el-col :span="12"> |
||||
<el-input |
||||
type="text" |
||||
v-model="add.value" |
||||
label="value" |
||||
:placeholder="$t('website.wafValueHelper')" |
||||
/> |
||||
</el-col> |
||||
<el-col :span="12"> |
||||
<el-input |
||||
type="text" |
||||
v-model="add.remark" |
||||
label="remark" |
||||
:placeholder="$t('website.wafRemarkHelper')" |
||||
/> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
</el-form> |
||||
<ComplexTable :data="data" v-loading="loading"> |
||||
<template #toolbar> |
||||
<el-button type="primary" icon="Plus" @click="openCreate"> |
||||
{{ $t('commons.button.add') }} |
||||
</el-button> |
||||
</template> |
||||
<el-table-column :label="$t('website.value')" prop="value"></el-table-column> |
||||
<el-table-column :label="$t('website.remark')" prop="remark"></el-table-column> |
||||
<el-table-column :label="$t('commons.table.operate')" width="100px"> |
||||
<template #default="{ $index }"> |
||||
<el-button link type="primary" @click="remove($index)"> |
||||
{{ $t('commons.button.delete') }} |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</ComplexTable> |
||||
</el-col> |
||||
</el-row> |
||||
</template> |
||||
<script lang="ts" setup> |
||||
import { Website } from '@/api/interface/website'; |
||||
import { GetWafConfig, UpdateWafEnable, UpdateWafFile } from '@/api/modules/website'; |
||||
import { computed, onMounted, reactive, ref } from 'vue'; |
||||
import i18n from '@/lang'; |
||||
import { MsgSuccess } from '@/utils/message'; |
||||
|
||||
const props = defineProps({ |
||||
id: { |
||||
type: Number, |
||||
default: 0, |
||||
}, |
||||
rule: { |
||||
type: String, |
||||
default: 'url', |
||||
}, |
||||
paramKey: { |
||||
type: String, |
||||
default: 'url', |
||||
}, |
||||
}); |
||||
const id = computed(() => { |
||||
return props.id; |
||||
}); |
||||
const rule = computed(() => { |
||||
return props.rule; |
||||
}); |
||||
const key = computed(() => { |
||||
return props.paramKey; |
||||
}); |
||||
|
||||
const loading = ref(false); |
||||
const data = ref([]); |
||||
const req = ref<Website.WafReq>({ |
||||
websiteId: 0, |
||||
key: '', |
||||
rule: 'url', |
||||
}); |
||||
const fileUpdate = reactive({ |
||||
content: '', |
||||
websiteId: 0, |
||||
type: 'url', |
||||
}); |
||||
const enableUpdate = ref<Website.WafUpdate>({ |
||||
websiteId: 0, |
||||
key: '$UrlDeny', |
||||
enable: false, |
||||
}); |
||||
let add = ref({ |
||||
value: '', |
||||
remark: '', |
||||
enable: 1, |
||||
}); |
||||
let contentArray = ref([]); |
||||
|
||||
const get = async () => { |
||||
data.value = []; |
||||
loading.value = true; |
||||
const res = await GetWafConfig(req.value); |
||||
loading.value = false; |
||||
enableUpdate.value.enable = res.data.enable; |
||||
if (res.data.content != '') { |
||||
contentArray.value = JSON.parse(res.data.content); |
||||
contentArray.value.forEach((value) => { |
||||
if (value != '') { |
||||
data.value.push({ |
||||
value: value[0], |
||||
remark: value[1], |
||||
enable: value[2], |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
}; |
||||
|
||||
const remove = (index: number) => { |
||||
contentArray.value.splice(index, 1); |
||||
submit([]); |
||||
}; |
||||
|
||||
const openCreate = () => { |
||||
if (add.value.value == '') { |
||||
return; |
||||
} |
||||
let newArray = []; |
||||
newArray[0] = add.value.value; |
||||
newArray[1] = add.value.remark; |
||||
newArray[2] = add.value.enable; |
||||
|
||||
data.value.push(newArray); |
||||
submit(newArray); |
||||
}; |
||||
|
||||
const updateEnable = async (enable: boolean) => { |
||||
enableUpdate.value.enable = enable; |
||||
loading.value = true; |
||||
try { |
||||
await UpdateWafEnable(enableUpdate.value); |
||||
} catch (error) { |
||||
enableUpdate.value.enable = !enable; |
||||
} |
||||
loading.value = false; |
||||
}; |
||||
|
||||
const submit = async (addArray: string[]) => { |
||||
if (addArray.length > 0) { |
||||
contentArray.value.push(addArray); |
||||
} |
||||
|
||||
fileUpdate.content = JSON.stringify(contentArray.value); |
||||
loading.value = true; |
||||
UpdateWafFile(fileUpdate) |
||||
.then(() => { |
||||
add.value = { |
||||
value: '', |
||||
remark: '', |
||||
enable: 1, |
||||
}; |
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess')); |
||||
get(); |
||||
}) |
||||
.finally(() => { |
||||
loading.value = false; |
||||
}); |
||||
}; |
||||
|
||||
onMounted(() => { |
||||
req.value.websiteId = id.value; |
||||
req.value.rule = rule.value; |
||||
req.value.key = key.value; |
||||
enableUpdate.value.key = key.value; |
||||
enableUpdate.value.websiteId = id.value; |
||||
fileUpdate.websiteId = id.value; |
||||
fileUpdate.type = rule.value; |
||||
get(); |
||||
}); |
||||
</script> |
Loading…
Reference in new issue