This commit is contained in:
Liang Ding 2022-07-14 10:39:53 +08:00
parent d1fb78ebb1
commit f825fefa43
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
8 changed files with 96 additions and 22 deletions

View file

@ -764,7 +764,7 @@
"8": "Check update failed", "8": "Check update failed",
"9": "A new version is available, please browse the release announcement %s", "9": "A new version is available, please browse the release announcement %s",
"10": "Is the latest version", "10": "Is the latest version",
"11": "TODO", "11": "\uD83D\uDCE2 系統公告:<a target='_blank' href='%s'>%s</a>",
"12": "Query asset failed [%s]", "12": "Query asset failed [%s]",
"13": "Cannot create a file starting with .", "13": "Cannot create a file starting with .",
"14": "Export failed: %s", "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)", "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", "34": "This operation is not supported in read-only mode",
"35": "Rebuilding index, please wait...", "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", "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", "38": "The number of mentioned keywords [%d] is too many, currently only supports up to [512] keywords",
"39": "TODO", "39": "TODO",

View file

@ -764,7 +764,7 @@
"8": "Comprobar la actualización falló", "8": "Comprobar la actualización falló",
"9": "Una nueva versión está disponible, por favor, busque el anuncio de lanzamiento %s", "9": "Una nueva versión está disponible, por favor, busque el anuncio de lanzamiento %s",
"10": "Es la última versión", "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]", "12": "Fallo en la consulta de activos [%s]",
"13": "No se puede crear un archivo que empiece por .", "13": "No se puede crear un archivo que empiece por .",
"14": "Exportación fallida: %s", "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)", "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", "34": "Esta operación no es compatible con el modo de sólo lectura",
"35": "Reconstruyendo el índice, por favor espere...", "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", "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", "38": "El número de palabras clave mencionadas [%d] son demasiados, actualmente solo admite hasta [512] palabras clave",
"39": "TODO", "39": "TODO",

View file

@ -764,7 +764,7 @@
"8": "La vérification de la mise à jour a échoué", "8": "La vérification de la mise à jour a échoué",
"9": "Une nouvelle version est disponible, veuillez consulter l'annonce de la version %s", "9": "Une nouvelle version est disponible, veuillez consulter l'annonce de la version %s",
"10": "C'est la dernière version", "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]", "12": "Échec de la requête asset [%s]",
"13": "Impossible de créer un fichier commençant par .", "13": "Impossible de créer un fichier commençant par .",
"14": "L'exportation a échoué : %s", "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) ", "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.", "34": "Cette opération n'est pas supportée en mode lecture seule.",
"35": "Recréation de l'index, veuillez patienter...", "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", "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", "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", "39": "TODO",

View file

@ -764,7 +764,7 @@
"8": "檢查更新失敗", "8": "檢查更新失敗",
"9": "有新版本可用,請瀏覽發佈公告 %s", "9": "有新版本可用,請瀏覽發佈公告 %s",
"10": "已是最新版", "10": "已是最新版",
"11": "TODO", "11": "\uD83D\uDCE2 系統公告:<a target='_blank' href='%s'>%s</a>",
"12": "查詢資料檔失敗 [%s]", "12": "查詢資料檔失敗 [%s]",
"13": "無法創建 . 開頭的文件", "13": "無法創建 . 開頭的文件",
"14": "匯出失敗:%s", "14": "匯出失敗:%s",
@ -789,7 +789,7 @@
"33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)", "33": "讀寫檔或存取網路權限不足,請檢查工作空間資料夾權限和防毒軟體/防火牆的設置。如果你曾經使用管理員身份運行過思源,請考慮切換到新的工作空間目錄,後續請勿使用管理員身份運行(當前的工作空間目錄可能已經無法使用普通用戶存取)",
"34": "唯讀模式下不支援該操作", "34": "唯讀模式下不支援該操作",
"35": "正在重建索引,請稍等...", "35": "正在重建索引,請稍等...",
"36": "請在應用商店中檢查版本更新", "36": "TODO",
"37": "雲端同步目錄的名稱請勿包含空格和特殊符號", "37": "雲端同步目錄的名稱請勿包含空格和特殊符號",
"38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字", "38": "提及關鍵字數量 [%d] 過多,目前最多僅支援搜索 [512] 個關鍵字",
"39": "TODO", "39": "TODO",

View file

@ -765,7 +765,7 @@
"8": "检查更新失败", "8": "检查更新失败",
"9": "有新版本可用,请浏览发布公告 %s", "9": "有新版本可用,请浏览发布公告 %s",
"10": "已是最新版", "10": "已是最新版",
"11": "TODO", "11": "\uD83D\uDCE2 系统公告:<a target='_blank' href='%s'>%s</a>",
"12": "查询资源文件失败 [%s]", "12": "查询资源文件失败 [%s]",
"13": "无法创建 . 开头的文件", "13": "无法创建 . 开头的文件",
"14": "导出失败:%s", "14": "导出失败:%s",
@ -790,7 +790,7 @@
"33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)", "33": "读写文件或访问网络权限不足,请检查工作空间文件夹权限和杀毒软件/防火墙的设置。如果你曾经使用管理员身份运行过思源,请考虑切换到新的工作空间目录,后续请勿使用管理员身份运行(当前的工作空间目录可能已经无法使用普通用户访问)",
"34": "只读模式下不支持该操作", "34": "只读模式下不支持该操作",
"35": "正在重建索引,请稍等...", "35": "正在重建索引,请稍等...",
"36": "请在应用商店中检查版本更新", "36": "TODO",
"37": "云端同步目录的名称请勿包含空格和特殊符号", "37": "云端同步目录的名称请勿包含空格和特殊符号",
"38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字", "38": "提及关键字数量 [%d] 过多,目前最多仅支持搜索 [512] 个关键字",
"39": "TODO", "39": "TODO",

View file

@ -21,6 +21,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
"os"
"path/filepath"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -150,6 +152,8 @@ func AutoRefreshUser() {
if !subscriptionExpirationReminded { if !subscriptionExpirationReminded {
subscriptionExpirationReminded = true subscriptionExpirationReminded = true
go func() { go func() {
defer util.Recover()
if "ios" == util.Container { if "ios" == util.Container {
return return
} }
@ -170,13 +174,65 @@ func AutoRefreshUser() {
}() }()
} }
if nil != Conf.User { go func() {
time.Sleep(3 * time.Minute) defer util.Recover()
if nil != Conf.User { if nil != Conf.User {
RefreshUser(Conf.User.UserToken) time.Sleep(3 * time.Minute)
if nil != Conf.User {
RefreshUser(Conf.User.UserToken)
}
subscriptionExpirationReminded = false
} }
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 <-refreshUserTicker.C
} }
} }

View file

@ -27,15 +27,33 @@ var (
checkUpdateLock = &sync.Mutex{} checkUpdateLock = &sync.Mutex{}
) )
func CheckUpdate(showMsg bool) { type Announcement struct {
if !showMsg { 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 return
} }
if "ios" == util.Container { announcements := result["announcement"].([]interface{})
if showMsg { for _, announcement := range announcements {
util.PushMsg(Conf.Language(36), 5000) 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 return
} }

View file

@ -39,7 +39,7 @@ func GetRhyResult(force bool) (map[string]interface{}, error) {
request := httpclient.NewCloudRequest() request := httpclient.NewCloudRequest()
_, err := request.SetResult(&cachedRhyResult).Get(AliyunServer + "/apis/siyuan/version?ver=" + Ver) _, err := request.SetResult(&cachedRhyResult).Get(AliyunServer + "/apis/siyuan/version?ver=" + Ver)
if nil != err { if nil != err {
LogErrorf("get version meta info failed: %s", err) LogErrorf("get version info failed: %s", err)
return nil, err return nil, err
} }
rhyResultCacheTime = now rhyResultCacheTime = now