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

This commit is contained in:
Vanessa 2023-11-24 21:58:36 +08:00
commit 727d8509bb
10 changed files with 38 additions and 15 deletions

View File

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

View File

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

View File

@ -1172,7 +1172,7 @@
"55": "Références indexées de [%d] documents", "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", "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", "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", "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", "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 ?", "61": "⬆️ Le package d'installation de la nouvelle version est prêt, voulez-vous installer la nouvelle version maintenant ?",

View File

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

View File

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

View File

@ -297,10 +297,10 @@ const boot = () => {
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent; currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
// set proxy // 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(); return response.json();
}).then((response) => { }).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()); currentWindow.loadURL(getServer() + "/stage/build/app/index.html?v=" + new Date().getTime());
}); });

View File

@ -34,7 +34,6 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/system/logoutAuth", model.LogoutAuth) ginServer.Handle("POST", "/api/system/logoutAuth", model.LogoutAuth)
ginServer.Handle("GET", "/api/system/getCaptcha", model.GetCaptcha) 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("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) 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/checkUpdate", model.CheckAuth, checkUpdate)
ginServer.Handle("POST", "/api/system/exportLog", model.CheckAuth, exportLog) ginServer.Handle("POST", "/api/system/exportLog", model.CheckAuth, exportLog)
ginServer.Handle("POST", "/api/system/getChangelog", model.CheckAuth, getChangelog) 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/setLocalStorage", model.CheckAuth, model.CheckReadonly, setLocalStorage)
ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage) ginServer.Handle("POST", "/api/storage/getLocalStorage", model.CheckAuth, getLocalStorage)

View File

@ -33,6 +33,22 @@ import (
"github.com/siyuan-note/siyuan/kernel/util" "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) { func getChangelog(c *gin.Context) {
ret := gulu.Ret.NewResult() ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret) defer c.JSON(http.StatusOK, ret)

View File

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

View File

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