Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 year ago
parent
commit
727d8509bb

+ 1 - 1
app/appearance/langs/en_US.json

@@ -1172,7 +1172,7 @@
     "55": "Indexed references of [%d] documents",
     "56": "Reindexing, please wait until rebuilding is complete before trying to open",
     "57": "Failed to create temp key",
-    "58": "Verifying index...",
+    "58": "[%d/%d] Verifying index...",
     "59": "Failed to set sync ignore list",
     "60": "Failed to get the update package: %s",
     "61": "⬆️ The new version installation package is ready, do you want to install the new version now?",

+ 1 - 1
app/appearance/langs/es_ES.json

@@ -1172,7 +1172,7 @@
     "55": "Referencias indexadas de [%d] documentos",
     "56": "Reindexando, espere hasta que se complete la reconstrucción antes de intentar abrir",
     "57": "Fallo en la creación de la clave temporal",
-    "58": "Verificando índice...",
+    "58": "[%d/%d] Verificando índice...",
     "59": " Falló la configuración de sincronización de la lista de ignorados",
     "60": "Fallo al obtener el paquete de actualización: %s",
     "61": "⬆️ El paquete de instalación de la nueva versión está listo, ¿quieres instalar la nueva versión ahora?",

+ 1 - 1
app/appearance/langs/fr_FR.json

@@ -1172,7 +1172,7 @@
     "55": "Références indexées de [%d] documents",
     "56": "Réindexation, veuillez attendre que la reconstruction soit terminée avant d'essayer d'ouvrir",
     "57": "Échec de la création d'une clé temporaire",
-    "58": "Vérification de l'index...",
+    "58": "[%d/%d] Vérification de l'index...",
     "59": "Échec de la définition de la liste des ignores de synchronisation",
     "60": "Échec de la récupération du paquet de mise à jour : %s",
     "61": "⬆️ Le package d'installation de la nouvelle version est prêt, voulez-vous installer la nouvelle version maintenant ?",

+ 1 - 1
app/appearance/langs/zh_CHT.json

@@ -1172,7 +1172,7 @@
     "55": "已完成索引 [%d] 篇文檔的引用關係",
     "56": "正在重建索引,請等重建索引完畢後再嘗試打開",
     "57": "建立臨時密鑰失敗",
-    "58": "正在校驗索引...",
+    "58": "[%d/%d] 正在校驗索引...",
     "59": "設置同步忽略列表失敗",
     "60": "獲取更新檔失敗:%s",
     "61": "⬆️ 新版本安裝檔已經準備就緒,是否現在安裝新版本?",

+ 1 - 1
app/appearance/langs/zh_CN.json

@@ -1172,7 +1172,7 @@
     "55": "已完成索引 [%d] 篇文档的引用关系",
     "56": "正在重建索引,请等重建索引完毕后再尝试打开",
     "57": "创建临时密钥失败",
-    "58": "正在校验索引...",
+    "58": "[%d/%d] 正在校验索引...",
     "59": "设置同步忽略列表失败",
     "60": "获取更新包失败:%s",
     "61": "⬆️ 新版本安装包已经准备就绪,是否现在安装新版本?",

+ 2 - 2
app/electron/main.js

@@ -297,10 +297,10 @@ const boot = () => {
     currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
 
     // set proxy
-    net.fetch(getServer() + "/api/system/getConf", {method: "POST"}).then((response) => {
+    net.fetch(getServer() + "/api/system/getNetwork", {method: "POST"}).then((response) => {
         return response.json();
     }).then((response) => {
-        setProxy(`${response.data.conf.system.networkProxy.scheme}://${response.data.conf.system.networkProxy.host}:${response.data.conf.system.networkProxy.port}`, currentWindow.webContents).then(() => {
+        setProxy(`${response.data.proxy.scheme}://${response.data.proxy.host}:${response.data.proxy.port}`, currentWindow.webContents).then(() => {
             // 加载主界面
             currentWindow.loadURL(getServer() + "/stage/build/app/index.html?v=" + new Date().getTime());
         });

+ 1 - 1
kernel/api/router.go

@@ -34,7 +34,6 @@ func ServeAPI(ginServer *gin.Engine) {
 	ginServer.Handle("POST", "/api/system/logoutAuth", model.LogoutAuth)
 	ginServer.Handle("GET", "/api/system/getCaptcha", model.GetCaptcha)
 	ginServer.Handle("POST", "/api/system/setUILayout", setUILayout) // 这里不加鉴权 After modifying the access authentication code on the browser side, the other side does not refresh https://github.com/siyuan-note/siyuan/issues/8028
-
 	ginServer.Handle("GET", "/snippets/*filepath", serveSnippets)
 
 	// 需要鉴权
@@ -63,6 +62,7 @@ func ServeAPI(ginServer *gin.Engine) {
 	ginServer.Handle("POST", "/api/system/checkUpdate", model.CheckAuth, checkUpdate)
 	ginServer.Handle("POST", "/api/system/exportLog", model.CheckAuth, exportLog)
 	ginServer.Handle("POST", "/api/system/getChangelog", model.CheckAuth, getChangelog)
+	ginServer.Handle("POST", "/api/system/getNetwork", model.CheckAuth, getNetwork)
 
 	ginServer.Handle("POST", "/api/storage/setLocalStorage", model.CheckAuth, model.CheckReadonly, setLocalStorage)
 	ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)

+ 16 - 0
kernel/api/system.go

@@ -33,6 +33,22 @@ import (
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
+func getNetwork(c *gin.Context) {
+	ret := gulu.Ret.NewResult()
+	defer c.JSON(http.StatusOK, ret)
+
+	maskedConf, err := model.GetMaskedConf()
+	if nil != err {
+		ret.Code = -1
+		ret.Msg = "get conf failed: " + err.Error()
+		return
+	}
+
+	ret.Data = map[string]interface{}{
+		"proxy": maskedConf.System.NetworkProxy,
+	}
+}
+
 func getChangelog(c *gin.Context) {
 	ret := gulu.Ret.NewResult()
 	defer c.JSON(http.StatusOK, ret)

+ 10 - 7
kernel/model/index_fix.go

@@ -54,7 +54,11 @@ func FixIndexJob() {
 
 	task.AppendTask(task.DatabaseIndexFix, removeDuplicateDatabaseRefs)
 
-	util.PushStatusBar(Conf.Language(185))
+	// 后面要加任务的话记得修改推送任务栏的进度 util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 1, 5))
+
+	task.AppendTask(task.DatabaseIndexFix, func() {
+		util.PushStatusBar(Conf.Language(185))
+	})
 	debug.FreeOSMemory()
 }
 
@@ -67,7 +71,7 @@ func removeDuplicateDatabaseRefs() {
 	autoFixLock.Lock()
 	defer autoFixLock.Unlock()
 
-	util.PushStatusBar(Conf.Language(58))
+	util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 5, 5))
 	duplicatedRootIDs := sql.GetRefDuplicatedDefRootIDs()
 	for _, rootID := range duplicatedRootIDs {
 		refreshRefsByDefID(rootID)
@@ -85,7 +89,7 @@ func removeDuplicateDatabaseIndex() {
 	autoFixLock.Lock()
 	defer autoFixLock.Unlock()
 
-	util.PushStatusBar(Conf.Language(58))
+	util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 1, 5))
 	duplicatedRootIDs := sql.GetDuplicatedRootIDs("blocks")
 	if 1 > len(duplicatedRootIDs) {
 		duplicatedRootIDs = sql.GetDuplicatedRootIDs("blocks_fts")
@@ -94,7 +98,6 @@ func removeDuplicateDatabaseIndex() {
 		}
 	}
 
-	util.PushStatusBar(Conf.Language(58))
 	roots := sql.GetBlocks(duplicatedRootIDs)
 	rootMap := map[string]*sql.Block{}
 	for _, root := range roots {
@@ -132,7 +135,7 @@ func resetDuplicateBlocksOnFileSys() {
 	autoFixLock.Lock()
 	defer autoFixLock.Unlock()
 
-	util.PushStatusBar(Conf.Language(58))
+	util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 2, 5))
 	boxes := Conf.GetBoxes()
 	luteEngine := lute.New()
 	blockIDs := map[string]bool{}
@@ -288,7 +291,7 @@ func fixBlockTreeByFileSys() {
 	autoFixLock.Lock()
 	defer autoFixLock.Unlock()
 
-	util.PushStatusBar(Conf.Language(58))
+	util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 3, 5))
 	boxes := Conf.GetOpenedBoxes()
 	luteEngine := lute.New()
 	for _, box := range boxes {
@@ -353,7 +356,7 @@ func fixBlockTreeByFileSys() {
 func fixDatabaseIndexByBlockTree() {
 	defer logging.Recover()
 
-	util.PushStatusBar(Conf.Language(58))
+	util.PushStatusBar(fmt.Sprintf(Conf.Language(58), 4, 5))
 	rootUpdatedMap := treenode.GetRootUpdated()
 	dbRootUpdatedMap, err := sql.GetRootUpdated()
 	if nil == err {

+ 4 - 0
kernel/model/session.go

@@ -206,6 +206,10 @@ func CheckAuth(c *gin.Context) {
 			c.Next()
 			return
 		}
+		if strings.HasPrefix(c.Request.RequestURI, "/api/system/getNetwork") {
+			c.Next()
+			return
+		}
 	}
 
 	// 通过 Cookie