Skip to content

Commit b5f12dc

Browse files
authored
Merge pull request #234 from suhang12332/dev
Dev
2 parents 5c8180d + 7348974 commit b5f12dc

File tree

7 files changed

+331
-6
lines changed

7 files changed

+331
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
Swift Craft Launcher is a native macOS Minecraft launcher 🍎 built with SwiftUI, offering a streamlined and efficient gaming experience. Designed for modern macOS systems, it provides comprehensive mod loader support, Microsoft account authentication, and intuitive game management.
3030

3131
<div align="center">
32-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher Screenshot" width="800">
32+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher Screenshot" width="800">
3333
</div>
3434
<div align="center">
35-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher Screenshot" width="800">
35+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher Screenshot" width="800">
3636
</div>
3737

3838
## ✨ Key Features

SwiftCraftLauncher/GameFeature/Data/ModCacheDatabase.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ class ModCacheDatabase {
230230
}
231231
}
232232

233+
/// 按 json_data 内容(如 local 标识)删除 mod 缓存数据
234+
///
235+
/// 对应需求 SQL:
236+
/// `delete from mod_cache where json_data like '%local%';`
237+
func deleteLocalModCaches() throws {
238+
try db.transaction {
239+
let sql = "DELETE FROM \(tableName) WHERE json_data like '%local%';"
240+
try db.execute(sql)
241+
}
242+
}
243+
233244
/// - Parameter hash: mod 文件的 hash 值
234245
/// - Returns: 是否存在
235246
/// - Throws: GlobalError 当操作失败时

SwiftCraftLauncher/GameFeature/Managers/ModCacheManager.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ class ModCacheManager {
131131
}
132132
}
133133

134+
/// 清理 json_data 中包含 local 标记的 mod 缓存
135+
/// - Throws: GlobalError 当操作失败时
136+
func clearLocalModCaches() throws {
137+
try queue.sync {
138+
try ensureInitialized()
139+
try modCacheDB.deleteLocalModCaches()
140+
}
141+
}
142+
134143
/// 清空所有 mod 缓存(静默版本)
135144
func clearSilently() {
136145
do {
@@ -140,6 +149,15 @@ class ModCacheManager {
140149
}
141150
}
142151

152+
/// 清理 json_data 中包含 local 标记的 mod 缓存(静默版本)
153+
func clearLocalModCachesSilently() {
154+
do {
155+
try clearLocalModCaches()
156+
} catch {
157+
GlobalErrorHandler.shared.handle(error)
158+
}
159+
}
160+
143161
/// - Parameter hash: mod 文件的 hash 值
144162
/// - Returns: 是否存在
145163
func has(hash: String) -> Bool {

SwiftCraftLauncher/GameFeature/Views/Settings/GameSettingsView.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ public struct GameSettingsView: View {
100100
).font(.callout)
101101
}.foregroundStyle(.primary)
102102
}.labeledContentStyle(.custom)
103+
104+
HStack {
105+
Spacer()
106+
Button {
107+
Task {
108+
await Task.detached(priority: .utility) {
109+
do {
110+
try ModCacheManager.shared.clearLocalModCaches()
111+
} catch {
112+
GlobalErrorHandler.shared.handle(error)
113+
}
114+
}.value
115+
116+
calculateCacheInfoSafely()
117+
}
118+
} label: {
119+
Text(
120+
"settings.game.clear_cache.label".localized()
121+
)
122+
}
123+
InfoIconWithPopover(text: "settings.game.clear_cache.help".localized())
124+
}
103125
}
104126
.onAppear {
105127
calculateCacheInfoSafely()

SwiftCraftLauncher/Resources/Localizable.xcstrings

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79652,6 +79652,280 @@
7965279652
}
7965379653
}
7965479654
},
79655+
"settings.game.clear_cache.label" : {
79656+
"extractionState" : "manual",
79657+
"localizations" : {
79658+
"ar" : {
79659+
"stringUnit" : {
79660+
"state" : "translated",
79661+
"value" : "مسح ذاكرة التخزين المؤقت"
79662+
}
79663+
},
79664+
"da" : {
79665+
"stringUnit" : {
79666+
"state" : "translated",
79667+
"value" : "Ryd cache"
79668+
}
79669+
},
79670+
"de" : {
79671+
"stringUnit" : {
79672+
"state" : "translated",
79673+
"value" : "Cache löschen"
79674+
}
79675+
},
79676+
"en" : {
79677+
"stringUnit" : {
79678+
"state" : "translated",
79679+
"value" : "Clear Cache"
79680+
}
79681+
},
79682+
"es" : {
79683+
"stringUnit" : {
79684+
"state" : "translated",
79685+
"value" : "Borrar caché"
79686+
}
79687+
},
79688+
"fi" : {
79689+
"stringUnit" : {
79690+
"state" : "translated",
79691+
"value" : "Tyhjennä välimuisti"
79692+
}
79693+
},
79694+
"fr" : {
79695+
"stringUnit" : {
79696+
"state" : "translated",
79697+
"value" : "Effacer le cache"
79698+
}
79699+
},
79700+
"hi" : {
79701+
"stringUnit" : {
79702+
"state" : "translated",
79703+
"value" : "कैश साफ़ करें"
79704+
}
79705+
},
79706+
"it" : {
79707+
"stringUnit" : {
79708+
"state" : "translated",
79709+
"value" : "Svuota la cache"
79710+
}
79711+
},
79712+
"ja" : {
79713+
"stringUnit" : {
79714+
"state" : "translated",
79715+
"value" : "キャッシュを消去"
79716+
}
79717+
},
79718+
"ko" : {
79719+
"stringUnit" : {
79720+
"state" : "translated",
79721+
"value" : "캐시 지우기"
79722+
}
79723+
},
79724+
"nb" : {
79725+
"stringUnit" : {
79726+
"state" : "translated",
79727+
"value" : "Tøm hurtigbuffer"
79728+
}
79729+
},
79730+
"nl" : {
79731+
"stringUnit" : {
79732+
"state" : "translated",
79733+
"value" : "Cache wissen"
79734+
}
79735+
},
79736+
"pl" : {
79737+
"stringUnit" : {
79738+
"state" : "translated",
79739+
"value" : "Wyczyść pamięć podręczną"
79740+
}
79741+
},
79742+
"pt" : {
79743+
"stringUnit" : {
79744+
"state" : "translated",
79745+
"value" : "Limpar cache"
79746+
}
79747+
},
79748+
"ru" : {
79749+
"stringUnit" : {
79750+
"state" : "translated",
79751+
"value" : "Очистить кэш"
79752+
}
79753+
},
79754+
"sv" : {
79755+
"stringUnit" : {
79756+
"state" : "translated",
79757+
"value" : "Rensa cache"
79758+
}
79759+
},
79760+
"th" : {
79761+
"stringUnit" : {
79762+
"state" : "translated",
79763+
"value" : "ล้างแคช"
79764+
}
79765+
},
79766+
"tr" : {
79767+
"stringUnit" : {
79768+
"state" : "translated",
79769+
"value" : "Önbelleği temizle"
79770+
}
79771+
},
79772+
"vi" : {
79773+
"stringUnit" : {
79774+
"state" : "translated",
79775+
"value" : "Xóa bộ nhớ đệm"
79776+
}
79777+
},
79778+
"zh-Hans" : {
79779+
"stringUnit" : {
79780+
"state" : "translated",
79781+
"value" : "清除缓存"
79782+
}
79783+
},
79784+
"zh-Hant" : {
79785+
"stringUnit" : {
79786+
"state" : "translated",
79787+
"value" : "清除快取"
79788+
}
79789+
}
79790+
}
79791+
},
79792+
"settings.game.clear_cache.help" : {
79793+
"extractionState" : "manual",
79794+
"localizations" : {
79795+
"ar" : {
79796+
"stringUnit" : {
79797+
"state" : "translated",
79798+
"value" : "يمسح ذاكرة التخزين المؤقت المحلية للملفات الإضافية (mod) التي فشلت في الفحص، حتى يمكن تشغيل الفحص مرة أخرى لجلب التفاصيل قدر الإمكان."
79799+
}
79800+
},
79801+
"da" : {
79802+
"stringUnit" : {
79803+
"state" : "translated",
79804+
"value" : "Rydder den lokale mod-cache, der mislykkedes med scanning, så scanning kan udløses igen for at hente detaljer så meget som muligt."
79805+
}
79806+
},
79807+
"de" : {
79808+
"stringUnit" : {
79809+
"state" : "translated",
79810+
"value" : "Löscht den lokalen Mod-Cache, der beim Scannen fehlgeschlagen ist, damit das Scannen erneut ausgelöst werden kann, um Details so weit wie möglich abzurufen."
79811+
}
79812+
},
79813+
"en" : {
79814+
"stringUnit" : {
79815+
"state" : "translated",
79816+
"value" : "Clears the local mod cache that failed to scan, so scanning can be triggered again to fetch details as much as possible."
79817+
}
79818+
},
79819+
"es" : {
79820+
"stringUnit" : {
79821+
"state" : "translated",
79822+
"value" : "Borra la caché local de mods que falló al escanear, para que se pueda volver a ejecutar el escaneo y obtener los detalles en la medida de lo posible."
79823+
}
79824+
},
79825+
"fi" : {
79826+
"stringUnit" : {
79827+
"state" : "translated",
79828+
"value" : "Tyhjentää paikallisen modivälimuistin, joka epäonnistui skannauksessa, jotta skannaus voidaan käynnistää uudelleen ja hakemaan tiedot mahdollisimman paljon."
79829+
}
79830+
},
79831+
"fr" : {
79832+
"stringUnit" : {
79833+
"state" : "translated",
79834+
"value" : "Efface le cache local des mods dont le scan a échoué, afin que le scan puisse être relancé pour récupérer les détails autant que possible."
79835+
}
79836+
},
79837+
"hi" : {
79838+
"stringUnit" : {
79839+
"state" : "translated",
79840+
"value" : "यह उन स्थानीय mod कैश को साफ़ करता है जिसका स्कैन करने में विफल रहा, ताकि स्कैन फिर से ट्रिगर हो सके और यथासंभव विवरण मिल सकें।"
79841+
}
79842+
},
79843+
"it" : {
79844+
"stringUnit" : {
79845+
"state" : "translated",
79846+
"value" : "Svuota la cache locale dei mod che non è riuscita a essere scansionata, così la scansione può essere riavviata per ottenere i dettagli il più possibile."
79847+
}
79848+
},
79849+
"ja" : {
79850+
"stringUnit" : {
79851+
"state" : "translated",
79852+
"value" : "スキャンに失敗したローカルのmodキャッシュを消去します。スキャンを再実行して、可能な限り詳細を取得します。"
79853+
}
79854+
},
79855+
"ko" : {
79856+
"stringUnit" : {
79857+
"state" : "translated",
79858+
"value" : "스캔에 실패한 로컬 모드 캐시를 지웁니다. 스캔을 다시 실행해 가능한 한 상세 정보를 가져옵니다."
79859+
}
79860+
},
79861+
"nb" : {
79862+
"stringUnit" : {
79863+
"state" : "translated",
79864+
"value" : "Tømmer lokal mod-buffer som feilet å skanne, slik at skanning kan trigges på nytt for å hente detaljer så langt som mulig."
79865+
}
79866+
},
79867+
"nl" : {
79868+
"stringUnit" : {
79869+
"state" : "translated",
79870+
"value" : "Wist de lokale mod-cache waarvan het scannen is mislukt, zodat het scannen opnieuw kan worden geactiveerd om details zo veel mogelijk op te halen."
79871+
}
79872+
},
79873+
"pl" : {
79874+
"stringUnit" : {
79875+
"state" : "translated",
79876+
"value" : "Wyczyści lokalny cache modów, których skanowanie nie powiodło się, aby można było ponownie uruchomić skanowanie i uzyskać szczegóły w możliwie największym stopniu."
79877+
}
79878+
},
79879+
"pt" : {
79880+
"stringUnit" : {
79881+
"state" : "translated",
79882+
"value" : "Limpa a cache local dos mods que falharam na verificação, para que a verificação possa ser acionada novamente e buscar os detalhes o máximo possível."
79883+
}
79884+
},
79885+
"ru" : {
79886+
"stringUnit" : {
79887+
"state" : "translated",
79888+
"value" : "Очищает локальный кэш mod’ов, сканирование которых не удалось, чтобы можно было повторно запустить сканирование и получить детали в максимально возможной степени."
79889+
}
79890+
},
79891+
"sv" : {
79892+
"stringUnit" : {
79893+
"state" : "translated",
79894+
"value" : "Rensar lokal modcache som misslyckades med skanning, så att skanning kan utlösas igen för att hämta detaljer så mycket som möjligt."
79895+
}
79896+
},
79897+
"th" : {
79898+
"stringUnit" : {
79899+
"state" : "translated",
79900+
"value" : "ล้างแคชม็อดในเครื่องที่สแกนไม่สำเร็จ เพื่อให้สามารถสแกนซ้ำอีกครั้งและดึงรายละเอียดได้มากที่สุดเท่าที่จะทำได้"
79901+
}
79902+
},
79903+
"tr" : {
79904+
"stringUnit" : {
79905+
"state" : "translated",
79906+
"value" : "Tarama sırasında başarısız olan yerel mod önbelleğini temizler; böylece tarama yeniden tetiklenip ayrıntılar mümkün olduğunca alınabilir."
79907+
}
79908+
},
79909+
"vi" : {
79910+
"stringUnit" : {
79911+
"state" : "translated",
79912+
"value" : "Xóa bộ nhớ đệm mod cục bộ bị lỗi khi quét, để có thể kích hoạt lại việc quét nhằm lấy thông tin chi tiết nhiều nhất có thể."
79913+
}
79914+
},
79915+
"zh-Hans" : {
79916+
"stringUnit" : {
79917+
"state" : "translated",
79918+
"value" : "清理扫描失败的本地 mod 缓存,用于重新触发扫描,以尽可能获取详情"
79919+
}
79920+
},
79921+
"zh-Hant" : {
79922+
"stringUnit" : {
79923+
"state" : "translated",
79924+
"value" : "清理掃描失敗的本地 mod 快取,用於重新觸發掃描,以盡可能取得詳情"
79925+
}
79926+
}
79927+
}
79928+
},
7965579929
"settings.general.tab" : {
7965679930
"extractionState" : "manual",
7965779931
"localizations" : {

doc/README_zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
Swift Craft Launcher 是一款采用 SwiftUI 构建的原生 macOS Minecraft 启动器 🍎,提供流畅高效的游戏体验。专为现代 macOS 系统设计,集成全面的模组加载器支持、Microsoft 账户认证和直观的游戏管理功能。
3030

3131
<div align="center">
32-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher 截图" width="800">
32+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher 截图" width="800">
3333
</div>
3434
<div align="center">
35-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher 截图" width="800">
35+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher 截图" width="800">
3636
</div>
3737

3838
## ✨ 核心特性

doc/README_zh-TW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
Swift Craft Launcher 是一款採用 SwiftUI 構建的原生 macOS Minecraft 啟動器 🍎,提供流暢高效的遊戲體驗。專為現代 macOS 系統設計,整合全面的模組載入器支援、Microsoft 帳戶認證和直觀的遊戲管理功能。
3030

3131
<div align="center">
32-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher 截图" width="800">
32+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.17.31.gif" alt="SwiftCraftLauncher 截图" width="800">
3333
</div>
3434
<div align="center">
35-
<img src="https://suhang12332.github.io/Swift-Craft-Launcher-Assets/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher 截图" width="800">
35+
<img src="https://raw.githubusercontent.com/suhang12332/Swift-Craft-Launcher-Assets/refs/heads/main/imagebed/readme/screenshot2026-01-29-01.14.06.gif" alt="SwiftCraftLauncher 截图" width="800">
3636
</div>
3737

3838
## ✨ 核心特色

0 commit comments

Comments
 (0)