Ver Fonte

✨ feat(文本覆盖规则): 扩大兼容性

dodo hold há 10 meses atrás
pai
commit
50daec43a8
2 ficheiros alterados com 97 adições e 21 exclusões
  1. 7 0
      src/api/overrideRules.ts
  2. 90 21
      src/views/settings/overrideRules.vue

+ 7 - 0
src/api/overrideRules.ts

@@ -10,6 +10,13 @@ export interface OverrideRuleRecord {
     output_type: string;
     status: boolean;
     sort: number;
+    description: string;
+    daily_calls_limit: number;
+    hourly_calls_limit: number;
+    use_special_text: number;
+    use_risk_control: number;
+    current_daily_calls?: number;
+    current_hourly_calls?: number;
     create_time: Date;
     last_time: Date;
 }

+ 90 - 21
src/views/settings/overrideRules.vue

@@ -110,8 +110,9 @@
                     </a-typography-paragraph>
                 </template>
                 <template #rule="{ record }">
-                    <a-tag v-if="record.rule === 'text'" color="green">文本匹配</a-tag>
-                    <a-tag v-else-if="record.rule === 'regex'" color="orange">正则表达式</a-tag>
+                    <a-tag v-if="record.rule === 'keyword'" color="blue">关键词</a-tag>
+                    <a-tag v-else-if="record.rule === 'regex'" color="orange">正则</a-tag>
+                    <a-tag v-else-if="record.rule === 'text'" color="green">全文匹配</a-tag>
                     <a-tag v-else>{{ record.rule }}</a-tag>
                 </template>
                 <template #output="{ record }">
@@ -141,8 +142,29 @@
                         禁用
                     </a-tag>
                 </template>
-                <template #sort="{ record }">
-                    <a-badge :count="record.sort" />
+                <template #limits="{ record }">
+                    <div style="font-size: 12px;">
+                        <div v-if="record.daily_calls_limit > 0">
+                            <a-tag color="blue" size="small">日限: {{ record.current_daily_calls || 0 }}/{{ record.daily_calls_limit }}</a-tag>
+                        </div>
+                        <div v-if="record.hourly_calls_limit > 0">
+                            <a-tag color="cyan" size="small">时限: {{ record.current_hourly_calls || 0 }}/{{ record.hourly_calls_limit }}</a-tag>
+                        </div>
+                        <div v-if="record.use_special_text === 1">
+                            <a-tag color="orange" size="small">验证入参 special_text</a-tag>
+                        </div>
+                        <div v-if="record.use_risk_control === 1">
+                            <a-tag color="red" size="small">启用风控</a-tag>
+                        </div>
+                    </div>
+                </template>
+                <template #description="{ record }">
+                    <a-typography-paragraph v-if="record.description" :ellipsis="{ rows: 2 }">
+                        <a-typography-text type="secondary">
+                            {{ record.description }}
+                        </a-typography-text>
+                    </a-typography-paragraph>
+                    <span v-else style="color: #ccc;">-</span>
                 </template>
                 <template #time="{ record }">
                     <div style="color:gray;">
@@ -169,7 +191,7 @@
                 <a-row :gutter="24">
                     <a-col :span="12">
                         <a-form-item label="平台" required>
-                            <a-select v-model="editForm.platform" :options="platformOptions" placeholder="请选择平台" />
+                            <a-input v-model="editForm.platform" placeholder="请输入平台标识,如:tk、jd、pdd" />
                         </a-form-item>
                     </a-col>
                     <a-col :span="12">
@@ -188,8 +210,8 @@
                         </a-form-item>
                     </a-col>
                     <a-col :span="12">
-                        <a-form-item label="权重">
-                            <a-input-number v-model="editForm.sort" placeholder="数值越大越优先" :min="0" />
+                        <a-form-item label="权重(优先级)">
+                            <a-input-number v-model="editForm.sort" placeholder="数值越大越优先" :min="0" style="width: 100%;" />
                         </a-form-item>
                     </a-col>
                     <a-col :span="24">
@@ -197,6 +219,39 @@
                             <a-textarea v-model="editForm.output_text" placeholder="请输入替换后的文本" :auto-size="{ minRows: 2, maxRows: 4 }" />
                         </a-form-item>
                     </a-col>
+                    <a-col :span="24">
+                        <a-form-item label="备注">
+                            <a-textarea v-model="editForm.description" placeholder="请输入备注说明" :auto-size="{ minRows: 2, maxRows: 3 }" />
+                        </a-form-item>
+                    </a-col>
+                    <a-col :span="12">
+                        <a-form-item label="每日调用限制">
+                            <a-input-number v-model="editForm.daily_calls_limit" placeholder="0表示不限制" :min="0" style="width: 100%;" />
+                        </a-form-item>
+                    </a-col>
+                    <a-col :span="12">
+                        <a-form-item label="每小时调用限制">
+                            <a-input-number v-model="editForm.hourly_calls_limit" placeholder="0表示不限制" :min="0" style="width: 100%;" />
+                        </a-form-item>
+                    </a-col>
+                    <a-col :span="12">
+                        <a-form-item label="验证入参 special_text">
+                            <a-switch v-model="editForm.use_special_text" :checked-value="1" :unchecked-value="0"
+                                checked-text="是" unchecked-text="否" />
+                            <div style="font-size: 12px; color: #999; margin-top: 4px;">
+                                是否仅在入参 special_text=1 时匹配
+                            </div>
+                        </a-form-item>
+                    </a-col>
+                    <a-col :span="12">
+                        <a-form-item label="启用风控">
+                            <a-switch v-model="editForm.use_risk_control" :checked-value="1" :unchecked-value="0"
+                                checked-text="是" unchecked-text="否" />
+                            <div style="font-size: 12px; color: #999; margin-top: 4px;">
+                                OAID/地区/IP控制
+                            </div>
+                        </a-form-item>
+                    </a-col>
                     <a-col :span="12">
                         <a-form-item label="状态">
                             <a-switch v-model="editForm.status" :checked-value="true" :unchecked-value="false"
@@ -291,7 +346,7 @@ const columns = computed<TableColumnData[]>(() => [
     {
         title: '原始文本',
         slotName: 'original_text',
-        width: 200,
+        width: 180,
     },
     {
         title: '规则类型',
@@ -301,7 +356,17 @@ const columns = computed<TableColumnData[]>(() => [
     {
         title: '输出',
         slotName: 'output',
-        width: 200,
+        width: 180,
+    },
+    {
+        title: '限制条件',
+        slotName: 'limits',
+        width: 150,
+    },
+    {
+        title: '备注',
+        slotName: 'description',
+        width: 150,
     },
     {
         title: '状态',
@@ -310,7 +375,7 @@ const columns = computed<TableColumnData[]>(() => [
     },
     {
         title: '权重',
-        slotName: 'sort',
+        dataIndex: 'sort',
         width: 80,
     },
     {
@@ -325,16 +390,10 @@ const columns = computed<TableColumnData[]>(() => [
     },
 ]);
 
-const platformOptions = computed<SelectOptionData[]>(() => [
-    { label: '淘宝客', value: 'tk' },
-    { label: '京东', value: 'jd' },
-    { label: '拼多多', value: 'pdd' },
-    { label: '抖音', value: 'dy' },
-]);
-
 const ruleOptions = computed<SelectOptionData[]>(() => [
-    { label: '文本匹配', value: 'text' },
-    { label: '正则表达式', value: 'regex' },
+    { label: '关键词', value: 'keyword' },
+    { label: '正则', value: 'regex' },
+    { label: '全文匹配', value: 'text' },
 ]);
 
 const outputTypeOptions = computed<SelectOptionData[]>(() => [
@@ -396,11 +455,16 @@ const isEdit = ref(false);
 const editForm = ref<Partial<OverrideRuleRecord>>({
     platform: '',
     original_text: '',
-    rule: 'text',
+    rule: 'keyword',
     output_text: '',
     output_type: 'content',
     status: true,
     sort: 0,
+    description: '',
+    daily_calls_limit: 0,
+    hourly_calls_limit: 0,
+    use_special_text: 0,
+    use_risk_control: 0,
 });
 
 const onEdit = (current: OverrideRuleRecord) => {
@@ -417,11 +481,16 @@ const onAdd = () => {
     editForm.value = {
         platform: '',
         original_text: '',
-        rule: 'text',
+        rule: 'keyword',
         output_text: '',
         output_type: 'content',
         status: true,
         sort: 0,
+        description: '',
+        daily_calls_limit: 0,
+        hourly_calls_limit: 0,
+        use_special_text: 0,
+        use_risk_control: 0,
     };
     visible.value = true;
 };