From d004b601f28213b706f007970c9664c0d005eb18 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 23 Apr 2024 13:17:30 +0800 Subject: [PATCH] :art: Prompt when there is no normal exit https://github.com/siyuan-note/siyuan/issues/11054 --- app/appearance/langs/en_US.json | 4 +++- app/appearance/langs/es_ES.json | 4 +++- app/appearance/langs/fr_FR.json | 4 +++- app/appearance/langs/zh_CHT.json | 4 +++- app/appearance/langs/zh_CN.json | 4 +++- kernel/model/conf.go | 17 +++++++++++++++++ 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index 796fdca04..d144a7fc9 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -1475,6 +1475,8 @@ "240": "Drag heading under container blocks in the doc is not supported", "241": "Drag to its subheading is not supported", "242": "The binding block already exists in the current database", - "243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]" + "243": "Only list the first [%d] tags (including subtags), if you need to adjust, please modify [Settings - Doc Tree - Maximum number to list]", + "244": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]", + "245": "It did not exit normally after the last use. It is recommended to execute [Doc Tree - Rebuild Index]. To exit normally, you need to use [Exit Application] in the right panel" } } diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index a73cc39c8..2b96a12d1 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -1475,6 +1475,8 @@ "240": "No se admite arrastrar encabezado debajo de los bloques contenedores en el documento", "241": "No se admite arrastrar a su subtítulo", "242": "El bloque de enlace ya existe en la base de datos actual", - "243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]" + "243": "Enumere solo las primeras [%d] etiquetas (incluidas las subetiquetas), modifique [Configuración - Árbol de documentos - Número máximo a listar]", + "244": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]", + "245": "No salió normalmente después del último uso. Se recomienda ejecutar [Árbol de documentos - Reconstruir índice]. Para salir normalmente, necesita usar [Salir de la aplicación] en el panel derecho" } } diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index aba4aaa3c..ea9d663f8 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -1475,6 +1475,8 @@ "240": "Le déplacement du titre sous les blocs conteneurs dans la doc n'est pas pris en charge", "241": "Le glisser vers son sous-titre n'est pas pris en charge", "242": "Le bloc de liaison existe déjà dans la base de données actuelle", - "243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister]." + "243": "Répertorier uniquement les [%d] premières balises (y compris les sous-balises). veuillez modifier [Paramètres - Arbre des documents - Nombre maximum de documents à lister].", + "244": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]", + "245": "Il ne s'est pas terminé normalement après la dernière utilisation. Il est recommandé d'exécuter [Doc Tree - Rebuild Index]. Pour quitter normalement, vous devez utiliser [Quitter l'application] dans le panneau de droite" } } diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index b8a74786c..d1e2e16cc 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -1475,6 +1475,8 @@ "240": "不支援拖曳文件中容器區塊下的標題", "241": "不支持拖曳為自己的子標題", "242": "目前資料庫中已經存在該綁定區塊", - "243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]" + "243": "僅列出前 [%d] 個標籤(含子標籤),如需調整請修改 [設置 - 文檔樹 - 最大列出數量]", + "244": "上次使用後未正常退出,建議執行一次 [文檔樹 - 重建索引]", + "245": "上次使用後未正常退出,建議執行一次 [文件樹 - 重建索引],正常退出需使用右側欄面板中的 [退出應用]" } } diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 4fdc85428..2734c553b 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -1475,6 +1475,8 @@ "240": "不支持拖拽文档中容器块下的标题", "241": "不支持拖拽为自己的子标题", "242": "当前数据库中已经存在该绑定块", - "243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]" + "243": "仅列出前 [%d] 个标签(含子标签),如需调整请修改 [设置 - 文档树 - 最大列出数量]", + "244": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引]", + "245": "上次使用后未正常退出,建议执行一次 [文档树 - 重建索引],正常退出需使用右侧栏面板中的 [退出应用]" } } diff --git a/kernel/model/conf.go b/kernel/model/conf.go index eac91b466..fe67b6b4e 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -80,6 +80,7 @@ type AppConf struct { ShowChangelog bool `json:"showChangelog"` // 是否显示版本更新日志 CloudRegion int `json:"cloudRegion"` // 云端区域,0:中国大陆,1:北美 Snippet *conf.Snpt `json:"snippet"` // 代码片段 + State int `json:"state"` // 运行状态,0:已经正常退出,1:运行中 m *sync.Mutex } @@ -464,6 +465,21 @@ func InitConf() { Conf.LocalIPs = util.GetLocalIPs() + if 1 == Conf.State { + // 上次未正常退出 + go func() { + util.WaitForUILoaded() + time.Sleep(2 * time.Second) + if util.ContainerIOS == util.Container || util.ContainerAndroid == util.Container { + util.PushMsg(Conf.language(245), 15000) + } else { + util.PushMsg(Conf.language(244), 15000) + } + }() + } + + Conf.State = 1 // 运行中 + Conf.Save() logging.SetLogLevel(Conf.LogLevel) @@ -702,6 +718,7 @@ func (conf *AppConf) save0(data []byte) { } func (conf *AppConf) Close() { + conf.State = 0 // 已经正常退出 conf.Save() }