From c992a5929562434a8b0482ec7389cb7f70d20bb7 Mon Sep 17 00:00:00 2001
From: Ariver <ar@MacBook-Air.local>
Date: Wed, 06 May 2026 18:49:16 +0800
Subject: [PATCH] checkpoint: v3.1.5 — 第一二行间距加大12px

---
 Apptag/TagEditorView.swift |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Apptag/TagEditorView.swift b/Apptag/TagEditorView.swift
index 96e839d..7d15f82 100644
--- a/Apptag/TagEditorView.swift
+++ b/Apptag/TagEditorView.swift
@@ -16,9 +16,11 @@
     @State private var newTagColorIndex = 0
 
     private var sortedTagNames: [String] {
-        tagColors.keys
-            .filter { !excludedTagNames.contains($0) }
-            .sorted { $0.localizedStandardCompare($1) == .orderedAscending }
+        let order = TagEditor.orderedTagNames()
+        let filtered = tagColors.keys.filter { !excludedTagNames.contains($0) }
+        let ordered = order.filter { filtered.contains($0) }
+        let remaining = filtered.filter { !ordered.contains($0) }.sorted()
+        return ordered + remaining
     }
 
     var body: some View {
@@ -48,12 +50,12 @@
                             .foregroundStyle(.secondary)
                             .padding(.vertical, 40)
                     }
-                    ForEach(sortedTagNames, id: \.self) { tagName in
-                        tagEditRow(tagName)
-                        Divider().opacity(0.15).padding(.leading, 16)
-                    }
                     if addingNewTag {
                         newTagRow()
+                        Divider().opacity(0.15).padding(.leading, 16)
+                    }
+                    ForEach(sortedTagNames, id: \.self) { tagName in
+                        tagEditRow(tagName)
                         Divider().opacity(0.15).padding(.leading, 16)
                     }
                 }
@@ -147,13 +149,12 @@
         // SIP-protected apps where xattr write silently fails.
     }
 
-    /// Add a new tag name+color to the local registry only (no xattr write until
-    /// the tag is assigned to apps via "Edit App Categories").
-    /// Does NOT call onRefresh — would overwrite tagColors with scan results.
+    /// Add a new tag name+color and persist to the database.
     private func addNewTag() {
         let name = newTagNameText.trimmingCharacters(in: .whitespaces)
         guard !name.isEmpty else { return }
         tagColors[name] = newTagColorIndex
+        TagEditor.createTag(name, color: newTagColorIndex)
         addingNewTag = false
         newTagNameText = ""
     }

--
Gitblit v1.9.3