浏览代码

fix: adjust fields order

GyDi 2 年之前
父节点
当前提交
7909cf4067
共有 3 个文件被更改,包括 13 次插入22 次删除
  1. 7 7
      src-tauri/src/enhance/field.rs
  2. 2 11
      src/components/setting/mods/clash-field-viewer.tsx
  3. 4 4
      src/utils/clash-fields.ts

+ 7 - 7
src-tauri/src/enhance/field.rs

@@ -1,34 +1,34 @@
 use serde_yaml::{Mapping, Value};
 
 pub const HANDLE_FIELDS: [&str; 9] = [
+    "mode",
     "port",
     "socks-port",
     "mixed-port",
-    "mode",
-    "ipv6",
-    "log-level",
     "allow-lan",
-    "external-controller",
+    "log-level",
+    "ipv6",
     "secret",
+    "external-controller",
 ];
 
 pub const DEFAULT_FIELDS: [&str; 5] = [
     "proxies",
     "proxy-groups",
-    "rules",
     "proxy-providers",
+    "rules",
     "rule-providers",
 ];
 
 pub const OTHERS_FIELDS: [&str; 25] = [
-    "tun",
     "dns",
+    "tun",
     "ebpf",
     "hosts",
     "script",
     "profile",
     "payload",
-    "tunnels", // clash dev
+    "tunnels",
     "auto-redir",
     "experimental",
     "interface-name",

+ 2 - 11
src/components/setting/mods/clash-field-viewer.tsx

@@ -13,17 +13,8 @@ import { BaseDialog, DialogRef } from "@/components/base";
 import { useProfiles } from "@/hooks/use-profiles";
 import { Notice } from "@/components/base";
 
-const fieldSorter = (a: string, b: string) => {
-  if (a.includes("-") === a.includes("-")) {
-    if (a.length === b.length) return a.localeCompare(b);
-    return a.length - b.length;
-  } else if (a.includes("-")) return 1;
-  else if (b.includes("-")) return -1;
-  return 0;
-};
-
-const otherFields = [...OTHERS_FIELDS].sort(fieldSorter);
-const handleFields = [...HANDLE_FIELDS, ...DEFAULT_FIELDS].sort(fieldSorter);
+const otherFields = [...OTHERS_FIELDS];
+const handleFields = [...HANDLE_FIELDS, ...DEFAULT_FIELDS];
 
 export const ClashFieldViewer = forwardRef<DialogRef>((props, ref) => {
   const { t } = useTranslation();

+ 4 - 4
src/utils/clash-fields.ts

@@ -1,9 +1,9 @@
 export const HANDLE_FIELDS = [
+  "mode",
   "port",
   "socks-port",
   "mixed-port",
   "allow-lan",
-  "mode",
   "log-level",
   "ipv6",
   "secret",
@@ -11,22 +11,22 @@ export const HANDLE_FIELDS = [
 ];
 
 export const DEFAULT_FIELDS = [
-  "rules",
   "proxies",
   "proxy-groups",
   "proxy-providers",
+  "rules",
   "rule-providers",
 ] as const;
 
 export const OTHERS_FIELDS = [
-  "tun",
   "dns",
+  "tun",
   "ebpf",
   "hosts",
   "script",
   "profile",
   "payload",
-  "tunnels", // clash dev
+  "tunnels",
   "auto-redir",
   "experimental",
   "interface-name",