mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 10:00:13 +01:00
🎨 系统公告消息提醒 Fix https://github.com/siyuan-note/siyuan/issues/5409
This commit is contained in:
parent
d1fb78ebb1
commit
f825fefa43
8 changed files with 96 additions and 22 deletions
|
|
@ -764,7 +764,7 @@
|
|||
"8": "Check update failed",
|
||||
"9": "A new version is available, please browse the release announcement %s",
|
||||
"10": "Is the latest version",
|
||||
"11": "TODO",
|
||||
"11": "\uD83D\uDCE2 系統公告:<a target='_blank' href='%s'>%s</a>",
|
||||
"12": "Query asset failed [%s]",
|
||||
"13": "Cannot create a file starting with .",
|
||||
"14": "Export failed: %s",
|
||||
|
|
@ -789,7 +789,7 @@
|
|||
"33": "Insufficient permissions to read and write files or access to the network, please check the permissions of the workspace folder and the settings of the anti-virus software/firewall. If you have run SiYuan as an administrator before, please consider switching to a new workspace directory, and do not run it as an administrator in the future (the current workspace directory may no longer be accessible by ordinary users)",
|
||||
"34": "This operation is not supported in read-only mode",
|
||||
"35": "Rebuilding index, please wait...",
|
||||
"36": "Please check the version update in the app store",
|
||||
"36": "TODO",
|
||||
"37": "Do not include spaces and special symbols in the name of the cloud sync directory",
|
||||
"38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
|
||||
"39": "TODO",
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@
|
|||
"8": "Comprobar la actualización falló",
|
||||
"9": "Una nueva versión está disponible, por favor, busque el anuncio de lanzamiento %s",
|
||||
"10": "Es la última versión",
|
||||
"11": "TODO",
|
||||
"11": "\uD83D\uDCE2 Anuncio del sistema: <a target='_blank' href='%s'>%s</a>",
|
||||
"12": "Fallo en la consulta de activos [%s]",
|
||||
"13": "No se puede crear un archivo que empiece por .",
|
||||
"14": "Exportación fallida: %s",
|
||||
|
|
@ -789,7 +789,7 @@
|
|||
"33": "Permisos insuficientes para leer y escribir archivos o acceso a la red, por favor comprueba los permisos de la carpeta del espacio de trabajo y la configuración del software antivirus/firewall. Si has ejecutado SiYuan como administrador antes, por favor considera cambiar a un nuevo directorio de espacio de trabajo, y no lo ejecutes como administrador en el futuro (el directorio de espacio de trabajo actual puede que ya no sea accesible por los usuarios ordinarios)",
|
||||
"34": "Esta operación no es compatible con el modo de sólo lectura",
|
||||
"35": "Reconstruyendo el índice, por favor espere...",
|
||||
"36": "Por favor, comprueba la actualización de la versión en la tienda de aplicaciones",
|
||||
"36": "TODO",
|
||||
"37": "No incluyas espacios ni símbolos especiales en el nombre del directorio de sincronización con la nube",
|
||||
"38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
|
||||
"39": "TODO",
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@
|
|||
"8": "La vérification de la mise à jour a échoué",
|
||||
"9": "Une nouvelle version est disponible, veuillez consulter l'annonce de la version %s",
|
||||
"10": "C'est la dernière version",
|
||||
"11": "TODO",
|
||||
"11": "\uD83D\uDCE2 Annonce système : <a target='_blank' href='%s'>%s</a>",
|
||||
"12": "Échec de la requête asset [%s]",
|
||||
"13": "Impossible de créer un fichier commençant par .",
|
||||
"14": "L'exportation a échoué : %s",
|
||||
|
|
@ -789,7 +789,7 @@
|
|||
"33": "Autorisations insuffisantes pour lire et écrire des fichiers ou accéder au réseau, veuillez vérifier les autorisations du dossier de l'espace de travail et les paramètres du logiciel anti-virus/pare-feu. Si vous avez déjà exécuté SiYuan en tant qu'administrateur, envisagez de passer à un nouveau répertoire d'espace de travail et ne l'exécutez plus en tant qu'administrateur à l'avenir (le répertoire d'espace de travail actuel peut ne plus être accessible aux utilisateurs ordinaires) ",
|
||||
"34": "Cette opération n'est pas supportée en mode lecture seule.",
|
||||
"35": "Recréation de l'index, veuillez patienter...",
|
||||
"36": "Veuillez vérifier la mise à jour de la version dans l'App Store",
|
||||
"36": "TODO",
|
||||
"37": "N'incluez pas d'espaces et de symboles spéciaux dans le nom du répertoire de synchronisation cloud",
|
||||
"38": "Le nombre de mots-clés mentionnés [%d] est trop élevé, ne prend actuellement en charge que jusqu'à [512] mots-clés",
|
||||
"39": "TODO",
|
||||
|
|
|
|||
|
|
@ -764,7 +764,7 @@
|
|||
"8": "檢查更新失敗",
|
||||
"9": "有新版本可用,請瀏覽發佈公告 %s",
|
||||
"10": "已是最新版",
|
||||
"11": "TODO",
|
||||
"11": "\uD83D\uDCE2 系統公告:<a target='_blank' href='%s'>%s</a>",
|
||||
"12": "查詢資料檔失敗 [%s]",
|
||||
"13": "無法創建 . 開頭的文件",
|
||||
"14": "匯出失敗:%s",
|
||||
|
|
@ -789,7 +789,7 @@
|
|||
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
|
||||
"34": "唯讀模式下不支援該操作",
|
||||
"35": "正在重建索引,請稍等...",
|
||||
"36": "請在應用商店中檢查版本更新",
|
||||
"36": "TODO",
|
||||
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
|
||||
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
|
||||
"39": "TODO",
|
||||
|
|
|
|||
|
|
@ -765,7 +765,7 @@
|
|||
"8": "检查更新失败",
|
||||
"9": "有新版本可用,请浏览发布公告 %s",
|
||||
"10": "已是最新版",
|
||||
"11": "TODO",
|
||||
"11": "\uD83D\uDCE2 系统公告:<a target='_blank' href='%s'>%s</a>",
|
||||
"12": "查询资源文件失败 [%s]",
|
||||
"13": "无法创建 . 开头的文件",
|
||||
"14": "导出失败:%s",
|
||||
|
|
@ -790,7 +790,7 @@
|
|||
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
|
||||
"34": "只读模式下不支持该操作",
|
||||
"35": "正在重建索引,请稍等...",
|
||||
"36": "请在应用商店中检查版本更新",
|
||||
"36": "TODO",
|
||||
"37": "云端同步目录的名称请勿包含空格和特殊符号",
|
||||
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
|
||||
"39": "TODO",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -150,6 +152,8 @@ func AutoRefreshUser() {
|
|||
if !subscriptionExpirationReminded {
|
||||
subscriptionExpirationReminded = true
|
||||
go func() {
|
||||
defer util.Recover()
|
||||
|
||||
if "ios" == util.Container {
|
||||
return
|
||||
}
|
||||
|
|
@ -170,6 +174,9 @@ func AutoRefreshUser() {
|
|||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer util.Recover()
|
||||
|
||||
if nil != Conf.User {
|
||||
time.Sleep(3 * time.Minute)
|
||||
if nil != Conf.User {
|
||||
|
|
@ -177,6 +184,55 @@ func AutoRefreshUser() {
|
|||
}
|
||||
subscriptionExpirationReminded = false
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
defer util.Recover()
|
||||
|
||||
time.Sleep(1 * time.Minute)
|
||||
announcementConf := filepath.Join(util.HomeDir, ".config", "siyuan", "announcement.json")
|
||||
var existingAnnouncements, newAnnouncements []*Announcement
|
||||
if gulu.File.IsExist(announcementConf) {
|
||||
data, err := os.ReadFile(announcementConf)
|
||||
if nil != err {
|
||||
util.LogErrorf("read announcement conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &existingAnnouncements); nil != err {
|
||||
util.LogErrorf("unmarshal announcement conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
for _, announcement := range GetAnnouncements() {
|
||||
var exist bool
|
||||
for _, existingAnnouncement := range existingAnnouncements {
|
||||
if announcement.Id == existingAnnouncement.Id {
|
||||
exist = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exist {
|
||||
existingAnnouncements = append(existingAnnouncements, announcement)
|
||||
newAnnouncements = append(newAnnouncements, announcement)
|
||||
}
|
||||
}
|
||||
|
||||
data, err := gulu.JSON.MarshalJSON(existingAnnouncements)
|
||||
if nil != err {
|
||||
util.LogErrorf("marshal announcement conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
if err = os.WriteFile(announcementConf, data, 0644); nil != err {
|
||||
util.LogErrorf("write announcement conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, newAnnouncement := range newAnnouncements {
|
||||
util.PushMsg(fmt.Sprintf(Conf.Language(11), newAnnouncement.URL, newAnnouncement.Title), 0)
|
||||
}
|
||||
}()
|
||||
|
||||
<-refreshUserTicker.C
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,34 @@ var (
|
|||
checkUpdateLock = &sync.Mutex{}
|
||||
)
|
||||
|
||||
func CheckUpdate(showMsg bool) {
|
||||
if !showMsg {
|
||||
type Announcement struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
func GetAnnouncements() (ret []*Announcement) {
|
||||
result, err := util.GetRhyResult(false)
|
||||
if nil != err {
|
||||
util.LogErrorf("get ")
|
||||
return
|
||||
}
|
||||
|
||||
if "ios" == util.Container {
|
||||
if showMsg {
|
||||
util.PushMsg(Conf.Language(36), 5000)
|
||||
announcements := result["announcement"].([]interface{})
|
||||
for _, announcement := range announcements {
|
||||
ann := announcement.(map[string]interface{})
|
||||
ret = append(ret, &Announcement{
|
||||
Id: ann["id"].(string),
|
||||
Title: ann["title"].(string),
|
||||
URL: ann["url"].(string),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func CheckUpdate(showMsg bool) {
|
||||
if !showMsg {
|
||||
return
|
||||
}
|
||||
|
||||
checkUpdateLock.Lock()
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func GetRhyResult(force bool) (map[string]interface{}, error) {
|
|||
request := httpclient.NewCloudRequest()
|
||||
_, err := request.SetResult(&cachedRhyResult).Get(AliyunServer + "/apis/siyuan/version?ver=" + Ver)
|
||||
if nil != err {
|
||||
LogErrorf("get version meta info failed: %s", err)
|
||||
LogErrorf("get version info failed: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
rhyResultCacheTime = now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue