Skip to content

Commit ef226b8

Browse files
committed
feat(doctor): Add DoctorCheckResult model and integrate into EntityFactory for JSON parsing
- Introduced DoctorCheckResult and DoctorCheckInfo models to handle doctor check results. - Updated EntityFactory to support parsing of DoctorCheckResult from JSON. - Removed unused translation method from EntityFactory to streamline code.
1 parent 6a2ce85 commit ef226b8

File tree

18 files changed

+240
-134
lines changed

18 files changed

+240
-134
lines changed

wox.core/plugin/doctor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type DoctorCheckResult struct {
2424
Passed bool
2525
Description string
2626
ActionName string
27-
Action func(ctx context.Context)
28-
Preview WoxPreview // Preview content for the check result
27+
Action func(ctx context.Context) `json:"-"`
28+
Preview WoxPreview // Preview content for the check result
2929
}
3030

3131
// RunDoctorChecks runs all doctor checks
@@ -101,7 +101,7 @@ func checkWoxVersion(ctx context.Context) DoctorCheckResult {
101101
Name: "i18n:plugin_doctor_version",
102102
Type: DoctorCheckUpdate,
103103
Passed: false,
104-
Description: fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "plugin_doctor_version_update_available"), updateInfo.CurrentVersion, updateInfo.LatestVersion, updateInfo.Status),
104+
Description: fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "plugin_doctor_version_update_available"), updateInfo.CurrentVersion, updateInfo.LatestVersion),
105105
ActionName: actionName,
106106
Action: func(ctx context.Context) {
107107
updateStatus := updater.GetUpdateInfo()

wox.core/plugin/icons.go

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

wox.core/resource/lang/en_US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
"plugin_url_open_in_browser": "Open in browser",
222222
"plugin_doctor_version": "Version",
223223
"plugin_doctor_version_latest": "Already using the latest version: %s",
224-
"plugin_doctor_version_update_available": "New version available, current: %s, latest: %s, status: %s",
224+
"plugin_doctor_version_update_available": "New version available, current: %s, latest: %s",
225225
"plugin_doctor_version_download": "Go to download page",
226226
"plugin_doctor_version_apply_update": "Apply update",
227227
"plugin_doctor_version_update_notes": "Update Notes",
@@ -231,6 +231,7 @@
231231
"plugin_doctor_accessibility_open_settings": "Open Accessibility Settings",
232232
"plugin_doctor_accessibility_granted": "You have granted Wox Accessibility permission",
233233
"plugin_doctor_accessibility_explanation": "# Why Wox Needs Accessibility Permission\n\nWox requires accessibility permission to perform the following functions:\n\n- **Global Hotkeys**: Allow you to activate Wox from anywhere using keyboard shortcuts\n- **Window Management**: Get information about active windows to provide context-aware results\n- **Keyboard Simulation**: Enable features like pasting results directly into applications\n\nWithout this permission, some features of Wox will be limited or unavailable.",
234+
"plugin_doctor_check": "Check",
234235
"plugin_query_history_use": "Use",
235236
"plugin_browser_open_tab": "Open",
236237
"plugin_browser_server_port": "Server Port",

wox.core/resource/lang/pt_BR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"plugin_url_open_in_browser": "Abrir no navegador",
220220
"plugin_doctor_version": "Versão",
221221
"plugin_doctor_version_latest": "Já está usando a versão mais recente: %s",
222-
"plugin_doctor_version_update_available": "Nova versão disponível, atual: %s, mais recente: %s, status: %s",
222+
"plugin_doctor_version_update_available": "Nova versão disponível, atual: %s, mais recente: %s",
223223
"plugin_doctor_version_download": "Ir para a página de download",
224224
"plugin_doctor_version_apply_update": "Aplicar atualização",
225225
"plugin_doctor_version_update_notes": "Notas da Atualização",
@@ -229,6 +229,7 @@
229229
"plugin_doctor_accessibility_open_settings": "Abrir configurações de acessibilidade",
230230
"plugin_doctor_accessibility_granted": "Você concedeu permissão de Acessibilidade ao Wox",
231231
"plugin_doctor_accessibility_explanation": "# Por que o Wox precisa de permissão de Acessibilidade\n\nO Wox requer permissão de acessibilidade para realizar as seguintes funções:\n\n- **Teclas de atalho globais**: Permite ativar o Wox de qualquer lugar usando atalhos de teclado\n- **Gerenciamento de janelas**: Obter informações sobre janelas ativas para fornecer resultados contextuais\n- **Simulação de teclado**: Habilitar recursos como colar resultados diretamente em aplicativos\n\nSem essa permissão, alguns recursos do Wox serão limitados ou indisponíveis.",
232+
"plugin_doctor_check": "Verificar",
232233
"plugin_query_history_use": "Usar",
233234
"plugin_browser_open_tab": "Abrir",
234235
"plugin_browser_server_port": "Porta do servidor",

wox.core/resource/lang/ru_RU.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"plugin_url_open_in_browser": "Открыть в браузере",
220220
"plugin_doctor_version": "Версия",
221221
"plugin_doctor_version_latest": "Уже используется последняя версия: %s",
222-
"plugin_doctor_version_update_available": "Доступна новая версия, текущая: %s, последняя: %s, статус: %s",
222+
"plugin_doctor_version_update_available": "Доступна новая версия, текущая: %s, последняя: %s",
223223
"plugin_doctor_version_download": "Перейти на страницу загрузки",
224224
"plugin_doctor_version_apply_update": "Применить обновление",
225225
"plugin_doctor_version_update_notes": "Примечания к обновлению",
@@ -229,6 +229,7 @@
229229
"plugin_doctor_accessibility_open_settings": "Открыть настройки доступности",
230230
"plugin_doctor_accessibility_granted": "Вы предоставили Wox разрешение на доступность",
231231
"plugin_doctor_accessibility_explanation": "# Почему Wox нуждается в разрешении на доступность\n\nWox требует разрешение на доступность для выполнения следующих функций:\n\n- **Глобальные горячие клавиши**: Позволяют активировать Wox из любого места с помощью сочетаний клавиш\n- **Управление окнами**: Получение информации об активных окнах для предоставления контекстно-зависимых результатов\n- **Эмуляция клавиатуры**: Включение функций, таких как вставка результатов непосредственно в приложения\n\nБез этого разрешения некоторые функции Wox будут ограничены или недоступны.",
232+
"plugin_doctor_check": "Проверить",
232233
"plugin_query_history_use": "Использовать",
233234
"plugin_browser_open_tab": "Открыть",
234235
"plugin_browser_server_port": "Порт сервера",

wox.core/resource/lang/zh_CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
"plugin_websearch_web_searches": "网页搜索",
219219
"plugin_doctor_version": "版本",
220220
"plugin_doctor_version_latest": "已经是最新版本:%s",
221-
"plugin_doctor_version_update_available": "发现新版本,当前版:%s,最新版本:%s, 更新状态:%s",
221+
"plugin_doctor_version_update_available": "发现新版本,当前版:%s,最新版本:%s",
222222
"plugin_doctor_version_download": "前往下载页面",
223223
"plugin_doctor_version_apply_update": "应用更新",
224224
"plugin_doctor_version_update_notes": "更新说明",
@@ -228,6 +228,7 @@
228228
"plugin_doctor_accessibility_open_settings": "打开辅助功能设置",
229229
"plugin_doctor_accessibility_granted": "您已授予 Wox 辅助功能权限",
230230
"plugin_doctor_accessibility_explanation": "# 为什么 Wox 需要辅助功能权限\n\nWox 需要辅助功能权限来执行以下功能:\n\n- **全局快捷键**:允许您通过键盘快捷键从任何地方激活 Wox\n- **窗口管理**:获取活动窗口的信息,以提供上下文相关的结果\n- **键盘模拟**:启用直接将结果粘贴到应用程序等功能\n\n如果没有此权限,Wox 的某些功能将受到限制或不可用。",
231+
"plugin_doctor_check": "检查",
231232
"plugin_query_history_use": "使用",
232233
"plugin_url_open": "打开",
233234
"plugin_url_remove": "从历史记录中移除",

wox.core/ui/manager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"wox/plugin"
1717
"wox/resource"
1818
"wox/setting"
19+
"wox/updater"
1920
"wox/util"
2021
"wox/util/autostart"
2122
"wox/util/hotkey"
@@ -514,6 +515,9 @@ func (m *Manager) PostSettingUpdate(ctx context.Context, key, value string) {
514515
logger.Error(ctx, fmt.Sprintf("failed to set autostart: %s", err.Error()))
515516
}
516517
}
518+
if key == "EnableAutoUpdate" {
519+
updater.CheckForUpdates(ctx)
520+
}
517521
}
518522

519523
func (m *Manager) ExitApp(ctx context.Context) {

wox.core/ui/router.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,14 +1008,7 @@ func handleAIMCPServerTools(w http.ResponseWriter, r *http.Request) {
10081008
func handleDoctorCheck(w http.ResponseWriter, r *http.Request) {
10091009
ctx := util.NewTraceContext()
10101010
results := plugin.RunDoctorChecks(ctx)
1011-
allPassed := true
1012-
for _, result := range results {
1013-
if !result.Passed {
1014-
allPassed = false
1015-
break
1016-
}
1017-
}
1018-
writeSuccessResponse(w, allPassed)
1011+
writeSuccessResponse(w, results)
10191012
}
10201013

10211014
func handleUserDataLocation(w http.ResponseWriter, r *http.Request) {

wox.core/updater/updater.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,23 @@ type UpdateInfo struct {
6666
func StartAutoUpdateChecker(ctx context.Context) {
6767
util.Go(ctx, "auto-update-checker", func() {
6868
newCtx := util.NewTraceContext()
69-
checkForUpdates(newCtx)
69+
CheckForUpdates(newCtx)
7070
for range time.NewTicker(time.Hour * 6).C {
71-
checkForUpdates(newCtx)
71+
CheckForUpdates(newCtx)
7272
}
7373
})
7474
}
7575

76-
func checkForUpdates(ctx context.Context) {
76+
func CheckForUpdates(ctx context.Context) {
7777
util.GetLogger().Info(ctx, "start checking for updates")
7878

7979
setting := setting.GetSettingManager().GetWoxSetting(ctx)
8080
if setting != nil && !setting.EnableAutoUpdate {
8181
util.GetLogger().Info(ctx, "auto update is disabled, skipping")
82+
currentUpdateInfo.Status = UpdateStatusNone
83+
currentUpdateInfo.HasUpdate = false
84+
currentUpdateInfo.DownloadedPath = ""
85+
currentUpdateInfo.UpdateError = nil
8286
return
8387
}
8488

wox.ui.flutter/wox/lib/api/wox_api.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:wox/entity/wox_plugin.dart';
99
import 'package:wox/entity/wox_query.dart';
1010
import 'package:wox/entity/wox_setting.dart';
1111
import 'package:wox/entity/wox_theme.dart';
12+
import 'package:wox/models/doctor_check_result.dart';
1213
import 'package:wox/utils/wox_http_util.dart';
1314

1415
class WoxApi {
@@ -174,8 +175,8 @@ class WoxApi {
174175
});
175176
}
176177

177-
Future<bool> doctorCheck() async {
178-
return await WoxHttpUtil.instance.postData("/doctor/check", null);
178+
Future<List<DoctorCheckResult>> doctorCheck() async {
179+
return await WoxHttpUtil.instance.postData<List<DoctorCheckResult>>("/doctor/check", null);
179180
}
180181

181182
Future<String> getUserDataLocation() async {

0 commit comments

Comments
 (0)