🐛 fix(rules): Change rule type from 'auto' to 'default' and update

This commit is contained in:
web 2025-07-17 03:30:12 -07:00
parent 3304a55fd4
commit 3e290d7cb5
11 changed files with 48 additions and 41 deletions

View File

@ -159,7 +159,7 @@ export default function ImportYamlRules({ onImportSuccess }: ImportYamlRulesProp
enable: false, enable: false,
tags: [], tags: [],
icon: '', icon: '',
type: 'auto', type: 'default',
default: isDefault, default: isDefault,
}); });
setImportProgress(i + 1); setImportProgress(i + 1);

View File

@ -50,7 +50,7 @@ export default function Page() {
enable: false, enable: false,
tags: values.tags || [], tags: values.tags || [],
icon: values.icon || '', icon: values.icon || '',
type: values.type || 'auto', type: values.type || 'default',
default: false, default: false,
}); });
toast.success(t('createSuccess')); toast.success(t('createSuccess'));
@ -117,39 +117,41 @@ export default function Page() {
/> />
), ),
}, },
{
accessorKey: 'icon',
header: t('appIcon'),
cell: ({ row }) =>
row.getValue('icon') ? (
<Image
src={row.getValue('icon')}
alt={row.getValue('name')}
className='h-8 w-8 rounded-md'
width={32}
height={32}
/>
) : (
<div className='bg-muted flex h-8 w-8 items-center justify-center rounded-md'>
{row.original.name?.slice(0, 2)}
</div>
),
},
{
accessorKey: 'name',
header: t('name'),
},
{ {
accessorKey: 'type', accessorKey: 'type',
header: t('type'), header: t('type'),
cell: ({ row }) => { cell: ({ row }) => {
const type = row.original.type; const type = row.original.type || 'default';
if (type === 'auto') return t('auto'); if (type === 'default') {
if (type === 'ban') return t('ban'); return <Badge variant='default'>{t('default')}</Badge>;
return type || '--'; }
if (type === 'reject') {
return <Badge variant='destructive'>{t('reject')}</Badge>;
}
if (type === 'direct') {
return <Badge variant='secondary'>{t('direct')}</Badge>;
}
return <Badge variant='default'>{t('default')}</Badge>;
}, },
}, },
{
accessorKey: 'name',
header: t('name'),
cell: ({ row }) => (
<div className='flex items-center gap-2'>
{row.original.icon && (
<Image
src={row.original.icon}
alt={row.original.name}
className='h-6 w-6 rounded-md'
width={24}
height={24}
/>
)}
<span>{row.original.name}</span>
</div>
),
},
{ {
accessorKey: 'tags', accessorKey: 'tags',
header: t('tags'), header: t('tags'),

View File

@ -43,7 +43,7 @@ const formSchema = z.object({
tags: z.array(z.string()).default([]), tags: z.array(z.string()).default([]),
rules: z.string().default(''), rules: z.string().default(''),
icon: z.string().default(''), icon: z.string().default(''),
type: z.string().default('auto'), type: z.string().default('default'),
}); });
interface RuleFormProps<T> { interface RuleFormProps<T> {
@ -172,8 +172,9 @@ export default function RuleForm<T extends Record<string, any>>({
<SelectValue placeholder={t('selectType')} /> <SelectValue placeholder={t('selectType')} />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value='auto'>{t('auto')}</SelectItem> <SelectItem value='default'>{t('default')}</SelectItem>
<SelectItem value='ban'>{t('ban')}</SelectItem> <SelectItem value='reject'>{t('reject')}</SelectItem>
<SelectItem value='direct'>{t('direct')}</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</FormControl> </FormControl>

View File

@ -1,8 +1,6 @@
{ {
"analyzing": "Analyzing...", "analyzing": "Analyzing...",
"appIcon": "Rule Icon", "appIcon": "Rule Icon",
"auto": "Auto",
"ban": "Ban",
"cancel": "Cancel", "cancel": "Cancel",
"confirm": "Confirm", "confirm": "Confirm",
"confirmDelete": "Confirm Deletion", "confirmDelete": "Confirm Deletion",
@ -10,10 +8,12 @@
"createRule": "Add Rule", "createRule": "Add Rule",
"createSuccess": "Rule created successfully", "createSuccess": "Rule created successfully",
"createdAt": "Created At", "createdAt": "Created At",
"default": "Default",
"defaultRule": "Default Rule", "defaultRule": "Default Rule",
"delete": "Delete", "delete": "Delete",
"deleteSuccess": "Rule deleted successfully", "deleteSuccess": "Rule deleted successfully",
"deleteWarning": "Are you sure you want to delete this rule? This action cannot be undone.", "deleteWarning": "Are you sure you want to delete this rule? This action cannot be undone.",
"direct": "Direct",
"downloadTemplate": "Download Template", "downloadTemplate": "Download Template",
"edit": "Edit", "edit": "Edit",
"editRule": "Edit Rule", "editRule": "Edit Rule",
@ -32,6 +32,7 @@
"noValidRules": "No valid rules found", "noValidRules": "No valid rules found",
"pleaseUploadFile": "Please upload a YAML file", "pleaseUploadFile": "Please upload a YAML file",
"preview": "Preview", "preview": "Preview",
"reject": "Reject",
"rulesFormat": "Rule format: rule type,match content,[policy], where policy is optional.\nIf policy is not specified, the current rule group name will be used automatically. Examples:", "rulesFormat": "Rule format: rule type,match content,[policy], where policy is optional.\nIf policy is not specified, the current rule group name will be used automatically. Examples:",
"rulesLabel": "Rule Content", "rulesLabel": "Rule Content",
"searchRule": "Search rule name", "searchRule": "Search rule name",

View File

@ -1,8 +1,6 @@
{ {
"analyzing": "分析中...", "analyzing": "分析中...",
"appIcon": "ルールアイコン", "appIcon": "ルールアイコン",
"auto": "自動",
"ban": "ブロック",
"cancel": "キャンセル", "cancel": "キャンセル",
"confirm": "確認", "confirm": "確認",
"confirmDelete": "削除の確認", "confirmDelete": "削除の確認",

View File

@ -1,8 +1,6 @@
{ {
"analyzing": "分析中...", "analyzing": "分析中...",
"appIcon": "规则图标", "appIcon": "规则图标",
"auto": "自动",
"ban": "封禁",
"cancel": "取消", "cancel": "取消",
"confirm": "确认", "confirm": "确认",
"confirmDelete": "确认删除", "confirmDelete": "确认删除",
@ -10,10 +8,12 @@
"createRule": "添加规则", "createRule": "添加规则",
"createSuccess": "创建规则成功", "createSuccess": "创建规则成功",
"createdAt": "创建时间", "createdAt": "创建时间",
"default": "默认",
"defaultRule": "默认规则", "defaultRule": "默认规则",
"delete": "删除", "delete": "删除",
"deleteSuccess": "删除规则成功", "deleteSuccess": "删除规则成功",
"deleteWarning": "确定要删除所选规则吗?此操作不可恢复。", "deleteWarning": "确定要删除所选规则吗?此操作不可恢复。",
"direct": "直连",
"downloadTemplate": "下载模板", "downloadTemplate": "下载模板",
"edit": "编辑", "edit": "编辑",
"editRule": "编辑规则", "editRule": "编辑规则",
@ -32,6 +32,7 @@
"noValidRules": "没有找到有效的规则", "noValidRules": "没有找到有效的规则",
"pleaseUploadFile": "请上传YAML文件", "pleaseUploadFile": "请上传YAML文件",
"preview": "预览", "preview": "预览",
"reject": "拒绝",
"rulesFormat": "规则格式说明:规则类型,匹配内容,[策略], 其中策略为可选项。\n不指定策略时将自动使用当前规则组名称, 示例:", "rulesFormat": "规则格式说明:规则类型,匹配内容,[策略], 其中策略为可选项。\n不指定策略时将自动使用当前规则组名称, 示例:",
"rulesLabel": "规则内容", "rulesLabel": "规则内容",
"searchRule": "搜索规则名称", "searchRule": "搜索规则名称",

View File

@ -1,8 +1,6 @@
{ {
"analyzing": "分析中...", "analyzing": "分析中...",
"appIcon": "規則圖標", "appIcon": "規則圖標",
"auto": "自動",
"ban": "封禁",
"cancel": "取消", "cancel": "取消",
"confirm": "確認", "confirm": "確認",
"confirmDelete": "確認刪除", "confirmDelete": "確認刪除",

View File

@ -1288,8 +1288,8 @@ declare namespace API {
type: string; type: string;
tags: string[]; tags: string[];
rules: string; rules: string;
default: boolean;
enable: boolean; enable: boolean;
default: boolean;
created_at: number; created_at: number;
updated_at: number; updated_at: number;
}; };

View File

@ -696,9 +696,11 @@ declare namespace API {
id: number; id: number;
icon: string; icon: string;
name: string; name: string;
type: string;
tags: string[]; tags: string[];
rules: string; rules: string;
enable: boolean; enable: boolean;
default: boolean;
created_at: number; created_at: number;
updated_at: number; updated_at: number;
}; };

View File

@ -696,9 +696,11 @@ declare namespace API {
id: number; id: number;
icon: string; icon: string;
name: string; name: string;
type: string;
tags: string[]; tags: string[];
rules: string; rules: string;
enable: boolean; enable: boolean;
default: boolean;
created_at: number; created_at: number;
updated_at: number; updated_at: number;
}; };

View File

@ -794,9 +794,11 @@ declare namespace API {
id: number; id: number;
icon: string; icon: string;
name: string; name: string;
type: string;
tags: string[]; tags: string[];
rules: string; rules: string;
enable: boolean; enable: boolean;
default: boolean;
created_at: number; created_at: number;
updated_at: number; updated_at: number;
}; };