From f8d01913a4d580c7d4cdc28d5aa1fc90625e094b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 27 Oct 2022 09:13:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:art:=20=E5=8A=A0=E5=85=A5=20Google=20Analy?= =?UTF-8?q?tics=20https://github.com/siyuan-note/siyuan/issues/6369?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/assets/template/app/index.tpl | 10 ++++++++++ app/src/assets/template/desktop/index.tpl | 10 ++++++++++ app/src/assets/template/mobile/index.tpl | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/app/src/assets/template/app/index.tpl b/app/src/assets/template/app/index.tpl index aac258cd1..dcd8a2a74 100644 --- a/app/src/assets/template/app/index.tpl +++ b/app/src/assets/template/app/index.tpl @@ -32,5 +32,15 @@ } }, 2000) + + + + diff --git a/app/src/assets/template/desktop/index.tpl b/app/src/assets/template/desktop/index.tpl index f0e940dc8..1e837293d 100644 --- a/app/src/assets/template/desktop/index.tpl +++ b/app/src/assets/template/desktop/index.tpl @@ -26,5 +26,15 @@
+ + + + diff --git a/app/src/assets/template/mobile/index.tpl b/app/src/assets/template/mobile/index.tpl index 3ebad2d7a..23f7bcbc3 100644 --- a/app/src/assets/template/mobile/index.tpl +++ b/app/src/assets/template/mobile/index.tpl @@ -72,5 +72,15 @@ + + + + From 8bc889659bdb1ba6b94346ff3af784bc69bd5350 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Thu, 27 Oct 2022 09:47:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:recycle:=20=E9=80=9A=E8=BF=87=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=20`siyuan.localhost`=20=E5=8A=A0=E8=BD=BD=20https://g?= =?UTF-8?q?ithub.com/siyuan-note/siyuan/issues/6368?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/appearance/boot/index.html | 4 +-- app/appearance/langs/en_US.json | 2 +- app/appearance/langs/es_ES.json | 2 +- app/appearance/langs/fr_FR.json | 2 +- app/appearance/langs/zh_CHT.json | 2 +- app/appearance/langs/zh_CN.json | 2 +- app/electron/main.js | 27 +++++++++++-------- .../20201004194026-s8h2cog.sy | 2 +- .../20201004184819-nj8ibyg.sy | 2 +- .../20211226122523-rl8356a.sy | 2 +- app/src/config/about.ts | 2 +- app/src/mobile/util/menu.ts | 4 +-- app/stage/auth.html | 2 +- kernel/api/export.go | 4 +-- kernel/model/export.go | 2 +- kernel/model/session.go | 2 +- kernel/util/path.go | 4 +-- kernel/util/web.go | 15 ----------- kernel/util/working.go | 3 ++- 19 files changed, 38 insertions(+), 47 deletions(-) diff --git a/app/appearance/boot/index.html b/app/appearance/boot/index.html index 75569556d..6923f5b6c 100644 --- a/app/appearance/boot/index.html +++ b/app/appearance/boot/index.html @@ -100,7 +100,7 @@ return new Promise(resolve => setTimeout(resolve, ms)) } const redirect = () => { - const uri = 'http://127.0.0.1:' + location.port + const uri = 'http://siyuan.localhost:' + location.port if (navigator.userAgent.match(/Android/i)) document.location = uri else @@ -113,7 +113,7 @@ let progressing = false while (!progressing) { try { - const progressResult = await fetch('http://127.0.0.1:' + location.port + '/api/system/bootProgress') + const progressResult = await fetch('http://siyuan.localhost:' + location.port + '/api/system/bootProgress') const progressData = await progressResult.json() document.getElementById('progress').style.width = progressData.data.progress + '%' document.getElementById('details').textContent = progressData.data.details diff --git a/app/appearance/langs/en_US.json b/app/appearance/langs/en_US.json index b568c6f11..1f119a567 100644 --- a/app/appearance/langs/en_US.json +++ b/app/appearance/langs/en_US.json @@ -689,7 +689,7 @@ "about": "About", "about1": "Copyright (c) 2020-present • Yunnan Liandi Technology Co., Ltd. • Privacy PolicyUser Agreement
The core developers of SiYuan are D and V, and the community development contributors can be seen here
", "about2": "Use on browser", - "about3": "Please use the Chrome browser and keep it in the same network as the computer, port ${port}, the IP addresses that may be connected are as follows", + "about3": "Please use the Chrome browser and keep it in the same network as the computer, port ${port}, the addresses that may be connected are as follows: ", "about4": "Open browser", "about5": "Access Authorization Code", "about6": "After configuration, it will be used as the access authentication password, leave it blank to close the authentication", diff --git a/app/appearance/langs/es_ES.json b/app/appearance/langs/es_ES.json index 275a00789..fbb9a066e 100644 --- a/app/appearance/langs/es_ES.json +++ b/app/appearance/langs/es_ES.json @@ -689,7 +689,7 @@ "about": "Acerca de", "about1": "Copyright (c) 2020-presente • Yunnan Liandi Technology Co., Ltd. • Política de privacidadAcuerdo de usuario
Los principales desarrolladores de SiYuan son D y V, y los contribuyentes al desarrollo de la comunidad pueden verse aquí
", "about2": "Uso en el navegador", - "about3": "Por favor, utilice el navegador Chrome y manténgalo en la misma red que el ordenador, puerto ${port}, las direcciones IP que pueden conectarse son las siguientes", + "about3": "Por favor, utilice el navegador Chrome y manténgalo en la misma red que el ordenador, puerto ${port}, las direcciones que se pueden conectar son las siguientes: ", "about4": "Abrir el navegador", "about5": "Código de autorización de acceso", "about6": "Después de la configuración, se utilizará como contraseña de autenticación de acceso, déjelo en blanco para cerrar la autenticación", diff --git a/app/appearance/langs/fr_FR.json b/app/appearance/langs/fr_FR.json index ce7d1b0be..015bea596 100644 --- a/app/appearance/langs/fr_FR.json +++ b/app/appearance/langs/fr_FR.json @@ -689,7 +689,7 @@ "about": "À propos de", "about1": "Copyright (c) 2020-présent • Yunnan Liandi Technology Co., Ltd. • Politique de confidentialitéAccord de l'utilisateur
Les principaux développeurs de SiYuan sont D et V, et les contributeurs au développement de la communauté peuvent être vus ici
", "about2": "Utiliser sur le navigateur", - "about3": "Veuillez utiliser le navigateur Chrome et le garder sur le même réseau que l'ordinateur, port ${port}, les adresses IP pouvant être connectées sont les suivantes", + "about3": "Veuillez utiliser le navigateur Chrome et le garder sur le même réseau que l'ordinateur, port ${port}, les adresses pouvant être connectées sont les suivantes: ", "about4": "Ouvrir le navigateur", "about5": "Accès Code d'autorisation", "about6": "Configuré comme mot de passe d'authentification d'accès, laisser vide pour désactiver l'authentification.", diff --git a/app/appearance/langs/zh_CHT.json b/app/appearance/langs/zh_CHT.json index 568a7a797..72b8f2996 100644 --- a/app/appearance/langs/zh_CHT.json +++ b/app/appearance/langs/zh_CHT.json @@ -689,7 +689,7 @@ "about": "關於", "about1": "版權所有 (c) 2020-現在 • 雲南鏈滴科技有限公司 • 隱私政策用戶協議
思源筆記的核心開發者是 DV,社區開發貢獻者可在這裡看到
", "about2": "在瀏覽器上使用", - "about3": "請使用 Chrome 瀏覽器並保持和電腦在同一個網路內,端口 ${port},可能連通的 IP 地址如下", + "about3": "請使用 Chrome 瀏覽器並保持和電腦在同一個網路內,端口 ${port},可能連通的網絡地址:", "about4": "打開瀏覽器", "about5": "存取授權碼", "about6": "配置後作為存取鑒權密碼,留空則關閉鑒權", diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json index 0c0c1ed09..81c488936 100644 --- a/app/appearance/langs/zh_CN.json +++ b/app/appearance/langs/zh_CN.json @@ -689,7 +689,7 @@ "about": "关于", "about1": "版权所有 (c) 2020-现在 • 云南链滴科技有限公司 • 隐私政策用户协议
思源笔记的核心开发者是 DV,社区开发贡献者可在这里看到
", "about2": "在浏览器上使用", - "about3": "请使用 Chrome 浏览器并保持和电脑在同一个网络内,端口 ${port},可能连通的 IP 地址:", + "about3": "请使用 Chrome 浏览器并保持和电脑在同一个网络内,端口 ${port},可能连通的网络地址:", "about4": "打开浏览器", "about5": "访问授权码", "about6": "配置后作为访问鉴权密码,留空则关闭鉴权", diff --git a/app/electron/main.js b/app/electron/main.js index 9ccf9f604..b5dcca43b 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -43,6 +43,7 @@ let siyuanOpenURL let firstOpen = false let resetWindowStateOnRestart = false let kernelPort = "6806" +const localhost = "siyuan.localhost" require('@electron/remote/main').initialize() if (!app.requestSingleInstanceLock()) { @@ -50,6 +51,10 @@ if (!app.requestSingleInstanceLock()) { return } +const getServer = () => { + return "http://" + localhost + ":" + kernelPort +} + const showErrorWindow = (title, content) => { let errorHTMLPath = path.join(appDir, 'app', 'electron', 'error.html') if (isDevEnv) { @@ -266,7 +271,7 @@ const boot = () => { }) // 加载主界面 - mainWindow.loadURL('http://127.0.0.1:' + kernelPort + '/stage/build/app/index.html?v=' + + mainWindow.loadURL(getServer() + '/stage/build/app/index.html?v=' + new Date().getTime()) // 菜单 @@ -330,7 +335,7 @@ const boot = () => { Menu.setApplicationMenu(menu) // 当前页面链接使用浏览器打开 mainWindow.webContents.on('will-navigate', (event, url) => { - if (url.startsWith('http://127.0.0.1:' + kernelPort)) { + if (url.startsWith(getServer())) { return } @@ -399,7 +404,7 @@ const boot = () => { theme: nativeTheme.shouldUseDarkColors ? 'dark' : 'light', init: true, }) - await fetch('http://127.0.0.1:' + kernelPort + '/api/system/uiproc?pid=' + process.pid, + await fetch(getServer() + '/api/system/uiproc?pid=' + process.pid, {method: 'POST'}) }) ipcMain.on('siyuan-hotkey', (event, hotkey) => { @@ -632,11 +637,11 @@ const initKernel = (initData) => { writeLog('checking kernel version') while (!gotVersion) { try { - const apiResult = await fetch('http://127.0.0.1:' + kernelPort + '/api/system/version') + const apiResult = await fetch(getServer() + '/api/system/version') apiData = await apiResult.json() gotVersion = true bootWindow.setResizable(false) - bootWindow.loadURL('http://127.0.0.1:' + kernelPort + '/appearance/boot/index.html') + bootWindow.loadURL(getServer() + '/appearance/boot/index.html') bootWindow.show() } catch (e) { writeLog('get kernel version failed: ' + e.message) @@ -656,14 +661,14 @@ const initKernel = (initData) => { if (!isDevEnv && apiData.data !== appVer) { writeLog( `kernel [${apiData.data}] is running, shutdown it now and then start kernel [${appVer}]`) - fetch('http://127.0.0.1:' + kernelPort + '/api/system/exit', {method: 'POST'}) + fetch(getServer() + '/api/system/exit', {method: 'POST'}) bootWindow.destroy() resolve(false) } else { let progressing = false while (!progressing) { try { - const progressResult = await fetch('http://127.0.0.1:' + kernelPort + '/api/system/bootProgress') + const progressResult = await fetch(getServer() + '/api/system/bootProgress') const progressData = await progressResult.json() if (progressData.data.progress >= 100) { resolve(true) @@ -673,7 +678,7 @@ const initKernel = (initData) => { } } catch (e) { writeLog('get boot progress failed: ' + e.message) - fetch('http://127.0.0.1:' + kernelPort + '/api/system/exit', {method: 'POST'}) + fetch(getServer() + '/api/system/exit', {method: 'POST'}) bootWindow.destroy() resolve(false) progressing = true @@ -804,15 +809,15 @@ const cp = require("child_process"); powerMonitor.on('suspend', () => { writeLog('system suspend') - fetch('http://127.0.0.1:' + kernelPort + '/api/sync/performSync', {method: 'POST'}) + fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) }) powerMonitor.on('resume', () => { writeLog('system resume') - fetch('http://127.0.0.1:' + kernelPort + '/api/sync/performSync', {method: 'POST'}) + fetch(getServer() + '/api/sync/performSync', {method: 'POST'}) }) powerMonitor.on('shutdown', () => { writeLog('system shutdown') - fetch('http://127.0.0.1:' + kernelPort + '/api/system/exit', {method: 'POST'}) + fetch(getServer() + '/api/system/exit', {method: 'POST'}) }) diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy index a886023d3..a65a8096a 100644 --- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy +++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20201004194026-s8h2cog.sy @@ -75,7 +75,7 @@ { "Type": "NodeTextMark", "TextMarkType": "code", - "TextMarkTextContent": "127.0.0.1" + "TextMarkTextContent": "siyuan.localhost" }, { "Type": "NodeText", diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy index ed872cd16..a2c4285c8 100644 --- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy +++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20201004184819-nj8ibyg.sy @@ -76,7 +76,7 @@ { "Type": "NodeTextMark", "TextMarkType": "code", - "TextMarkTextContent": "127.0.0.1" + "TextMarkTextContent": "siyuan.localhost" }, { "Type": "NodeText", diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy index a176270b6..ed9969632 100644 --- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy +++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20211226122523-rl8356a.sy @@ -75,7 +75,7 @@ { "Type": "NodeTextMark", "TextMarkType": "code", - "TextMarkTextContent": "127.0.0.1" + "TextMarkTextContent": "siyuan.localhost" }, { "Type": "NodeText", diff --git a/app/src/config/about.ts b/app/src/config/about.ts index 9f00c719e..13baccb1f 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -55,7 +55,7 @@ export const about = { ${window.siyuan.config.localIPs.join(" ")}
- diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts index df20a55cc..28f551a7e 100644 --- a/app/src/mobile/util/menu.ts +++ b/app/src/mobile/util/menu.ts @@ -177,7 +177,7 @@ ${accountHTML} closePanel(); if (!window.siyuan.config.localIPs || window.siyuan.config.localIPs.length === 0 || (window.siyuan.config.localIPs.length === 1 && window.siyuan.config.localIPs[0] === "")) { - window.siyuan.config.localIPs = ["127.0.0.1"]; + window.siyuan.config.localIPs = ["siyuan.localhost"]; } modelElement.style.top = "0"; modelElement.querySelector(".toolbar__icon").innerHTML = ''; @@ -193,7 +193,7 @@ ${accountHTML}
${window.siyuan.languages.about2}
- +
${window.siyuan.languages.about3.replace("${port}", location.port)}
${window.siyuan.config.localIPs.join(" ")} diff --git a/app/stage/auth.html b/app/stage/auth.html index 4d9ad1bfc..62adca09a 100644 --- a/app/stage/auth.html +++ b/app/stage/auth.html @@ -387,7 +387,7 @@