From e7877517cf76a7979b17a54b98b1efef6cb356e8 Mon Sep 17 00:00:00 2001 From: qwertyyb Date: Sat, 4 Jan 2025 19:00:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AF=8D=E5=BA=93=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复在纯五笔或纯拼音编码模式下,用户词库不生效的问题 2. 修复保存后用户词库后,设置页面的空格变为制表符的问题 close #143 --- Fire/DictManager.swift | 8 +++++--- Fire/Preferences/UserDictPane.swift | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Fire/DictManager.swift b/Fire/DictManager.swift index 7162c13..7d62f87 100644 --- a/Fire/DictManager.swift +++ b/Fire/DictManager.swift @@ -52,8 +52,8 @@ class DictManager { type, min(query) as query from wb_py_dict where query glob :queryLike \( - codeMode == .wubi ? "and type = 'wb'" - : codeMode == .pinyin ? "and type = 'py'" : "") + codeMode == .wubi ? "and type in ('wb', 'user')" + : codeMode == .pinyin ? "and type in ('py', 'user')" : "") group by text order by query, id limit :offset, \(candidateCount + 1) @@ -246,8 +246,10 @@ class DictManager { sqlite3_exec(database, "delete from wb_py_dict where type = '\(CandidateType.user.rawValue)'", nil, nil, nil) // 2. 添加用户词库 let lines = dictContent.split(whereSeparator: \.isNewline) + NSLog("[DictManager] updateUserDict: \(lines)"); let candidates = lines.map { (line) -> [Candidate] in let strs = line.split(whereSeparator: \.isWhitespace) + NSLog("[DictManager] line: \(line), strs: \(strs)") if strs.count <= 1 { return [] } @@ -302,7 +304,7 @@ class DictManager { } } let content = list.map { dictItem in - ([dictItem.code] + dictItem.texts).joined(separator: "\t") + ([dictItem.code] + dictItem.texts).joined(separator: " ") } .joined(separator: "\n") return content diff --git a/Fire/Preferences/UserDictPane.swift b/Fire/Preferences/UserDictPane.swift index 3f3ca5c..d39674f 100644 --- a/Fire/Preferences/UserDictPane.swift +++ b/Fire/Preferences/UserDictPane.swift @@ -37,17 +37,17 @@ struct UserDictPane: View { Text("用户词库") if #available(macOS 11.0, *) { TextEditor(text: $userDictTextModel.text) - .font(Font.system(size: 14)) + .font(Font.custom("Monaco", size: 14)) .frame(height: 400) .lineSpacing(6) Text("1. 编码需在行首") - .font(Font.system(size: 11)) + .font(Font.system(size: 12)) Text("2. 编码和候选项之间需用空格分隔") - .font(Font.system(size: 11)) + .font(Font.system(size: 12)) Text("3. 可以有多个候选项,每个候选项使用空格分隔") - .font(Font.system(size: 11)) + .font(Font.system(size: 12)) Text("4. 候选项可使用{yyyy}/{MM}/{dd}/{HH}/{mm}/{ss}代替当前年/月/日/时/分/秒") - .font(Font.system(size: 11)) + .font(Font.system(size: 12)) HStack { Spacer() if #available(macOS 12.0, *) {