From 6e421e60c53728ef81ed8dd8fe6c6669a6b576eb Mon Sep 17 00:00:00 2001
From: GyDi <zzzgydi@gmail.com>
Date: Wed, 14 Dec 2022 16:56:33 +0800
Subject: [PATCH] fix: change default column to auto

---
 src-tauri/src/config/verge.rs               | 1 -
 src/components/proxy/use-render-list.ts     | 4 ++--
 src/components/setting/mods/misc-viewer.tsx | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src-tauri/src/config/verge.rs b/src-tauri/src/config/verge.rs
index 834fe5d..8db5cac 100644
--- a/src-tauri/src/config/verge.rs
+++ b/src-tauri/src/config/verge.rs
@@ -120,7 +120,6 @@ impl IVerge {
             proxy_guard_duration: Some(30),
             auto_close_connection: Some(true),
             enable_builtin_enhanced: Some(true),
-            proxy_layout_column: Some(1),
             ..Self::default()
         }
     }
diff --git a/src/components/proxy/use-render-list.ts b/src/components/proxy/use-render-list.ts
index 1753b01..9f8bc0a 100644
--- a/src/components/proxy/use-render-list.ts
+++ b/src/components/proxy/use-render-list.ts
@@ -31,10 +31,10 @@ export const useRenderList = (mode: string) => {
   const { verge } = useVerge();
   const { width } = useWindowWidth();
 
-  let col = verge?.proxy_layout_column || 1;
+  let col = Math.floor(verge?.proxy_layout_column || 6);
 
   // 自适应
-  if (col === 6) {
+  if (col >= 6 || col <= 0) {
     if (width > 1450) col = 5;
     else if (width > 1024) col = 4;
     else if (width > 900) col = 3;
diff --git a/src/components/setting/mods/misc-viewer.tsx b/src/components/setting/mods/misc-viewer.tsx
index d438537..a7b3dae 100644
--- a/src/components/setting/mods/misc-viewer.tsx
+++ b/src/components/setting/mods/misc-viewer.tsx
@@ -21,7 +21,7 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
   const [values, setValues] = useState({
     autoCloseConnection: false,
     enableBuiltinEnhanced: true,
-    proxyLayoutColumn: 1,
+    proxyLayoutColumn: 6,
     defaultLatencyTest: "",
   });
 
@@ -31,7 +31,7 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
       setValues({
         autoCloseConnection: verge?.auto_close_connection ?? false,
         enableBuiltinEnhanced: verge?.enable_builtin_enhanced ?? true,
-        proxyLayoutColumn: verge?.proxy_layout_column || 1,
+        proxyLayoutColumn: verge?.proxy_layout_column || 6,
         defaultLatencyTest: verge?.default_latency_test || "",
       });
     },
-- 
GitLab