Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 过滤方法规则 #363

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions src/services/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,39 +234,10 @@ export default () =>
return request.post('/engine/hook/rule_type/add', params)
}

ruleAdd(params: {
rule_type_id: string
rule_value: string
rule_source: string
rule_target: string
inherit: string
track: string
language_id: number,
ignore_blacklist?: boolean,
ignore_internal?: boolean,
tags?: any,
untags?: any,
command?: any,
stack_blacklist?: any
}): Promise<iResponse> {
ruleAdd(params: any): Promise<iResponse> {
return request.post('/engine/hook/rule/add', params)
}
modifyAdd(params: {
rule_id: number
rule_type_id: string
rule_value: string
rule_source: string
rule_target: string
inherit: string
track: string
language_id: number,
ignore_blacklist?: boolean,
ignore_internal?: boolean,
tags?: any,
untags?: any,
command?: any,
stack_blacklist?: any
}): Promise<iResponse> {
modifyAdd(params: any): Promise<iResponse> {
return request.post('/engine/hook/rule/modify', params)
}

Expand Down
52 changes: 29 additions & 23 deletions src/views/setting/components/hookTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
class="resetAllBtn"
@click="hookTypeDialog = true"
><i class="el-icon-plus"></i>
{{ $t('views.hookPage.addHookType') }}</el-button
添加规则类型</el-button
>
<el-button size="small" class="resetAllBtn" @click="hookDialog = true"
><i class="el-icon-plus"></i>
{{ $t('views.hookPage.addHook') }}</el-button
添加规则</el-button
>
</div>
</div>
Expand Down Expand Up @@ -212,17 +212,17 @@
</el-table-column>
</el-table>

<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 30, 50]"
:page-size="pageSize"
background
layout=" prev, pager, next, jumper,total, sizes"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
</el-pagination>
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 30, 50]"
:page-size="pageSize"
background
layout=" prev, pager, next, jumper,total, sizes"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
</el-pagination>

<el-dialog :visible.sync="hookTypeDialog">
<el-form
Expand Down Expand Up @@ -275,7 +275,7 @@
size="small"
:label-width="$i18n.locale === 'en' ? '160px' : '100px'"
>
<el-form-item :label="$t('views.hookPage.hookType')">
<el-form-item label="规则集">
<span>{{ fmtType(hook.type) }}</span>
</el-form-item>
<el-form-item :label="$t('views.hookPage.hooksType')">
Expand Down Expand Up @@ -356,6 +356,7 @@
</div>
</el-form-item>
</template>
<template v-if="ruleType !== '3'">
<template v-for="(item, key) in hook.target">
<el-form-item
:key="'target' + key"
Expand Down Expand Up @@ -413,6 +414,7 @@
</div>
</el-form-item>
</template>
</template>
<el-form-item :label="$t('views.hookPage.hookTrack')">
<el-radio v-model="hook.inherit" selected label="false">{{
$t('views.hookPage.onlyNow')
Expand All @@ -424,7 +426,7 @@
$t('views.hookPage.nowChildren')
}}</el-radio>
</el-form-item>
<el-form-item :label="$t('views.hookPage.ignoreInternal')">
<el-form-item v-if="ruleType !== '3'" :label="$t('views.hookPage.ignoreInternal')">
<el-checkbox v-model="hook.ignore_internal"></el-checkbox>
</el-form-item>
<el-form-item :label="$t('views.hookPage.ignoreBlacklist')">
Expand Down Expand Up @@ -528,7 +530,7 @@ export default class HookTable extends VueBase {
ignore_blacklist: false,
tags: [],
untags: [],
command: ''
command: '',
}
relations = [
{ label: this.$t('views.hookPage.or'), value: '|' },
Expand Down Expand Up @@ -630,7 +632,7 @@ export default class HookTable extends VueBase {
this.hookDialog = true
this.hook.ignore_internal = row.ignore_internal
this.hook.ignore_blacklist = row.ignore_blacklist
this.hook.tags = row.tags
this.hook.tags = row.tags
this.hook.untags = row.untags
this.hook.command = row.command
}
Expand Down Expand Up @@ -862,21 +864,22 @@ export default class HookTable extends VueBase {
if (this.hook.id) {
this.loadingStart()
const rule_source = this.fmtParams(this.hook.source)
const rule_target = this.fmtParams(this.hook.target)
const rule_target: any = this.fmtParams(this.hook.target)
const { status, msg } = await this.services.setting.modifyAdd({
rule_id: this.hook.id,
rule_type_id: this.hook.rule_type_id,
rule_value: this.hook.rule_value,
rule_target: rule_target,
rule_target: rule_target || undefined,
rule_source: rule_source,
inherit: this.hook.inherit,
track: 'false',
language_id: this.activeLanguage,
ignore_internal: this.hook.ignore_internal,
ignore_internal: this.hook.ignore_internal || undefined,
ignore_blacklist: this.hook.ignore_blacklist,
tags: this.hook.tags,
untags: this.hook.untags,
command: this.hook.command,
type: Number(this.ruleType)
})

this.loadingDone()
Expand All @@ -888,26 +891,27 @@ export default class HookTable extends VueBase {
})
return
}
this.$message.success('操作成功')
await this.getTable()
this.clearHook()
} else {
this.loadingStart()
const rule_source = this.fmtParams(this.hook.source)
const rule_target = this.fmtParams(this.hook.target)

const { status, msg } = await this.services.setting.ruleAdd({
rule_type_id: this.hook.rule_type_id,
rule_value: this.hook.rule_value,
rule_target: rule_target,
rule_target: rule_target || undefined,
rule_source: rule_source,
inherit: this.hook.inherit,
track: 'false',
language_id: this.activeLanguage,
ignore_internal: this.hook.ignore_internal,
ignore_internal: this.hook.ignore_internal || undefined,
ignore_blacklist: this.hook.ignore_blacklist,
tags: this.hook.tags,
untags: this.hook.untags,
command: this.hook.command,
type: Number(this.ruleType)
})

this.loadingDone()
Expand All @@ -919,6 +923,8 @@ export default class HookTable extends VueBase {
})
return
}
console.log('操作成功')
this.$message.success('操作成功')
await this.getBase()
await this.getTable()
this.clearHook()
Expand Down
Loading