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

This commit is contained in:
Vanessa 2022-10-27 09:53:24 +08:00
commit 50835bc6ce
23 changed files with 72 additions and 47 deletions

View file

@ -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

View file

@ -689,7 +689,7 @@
"about": "About",
"about1": "Copyright (c) 2020-present • Yunnan Liandi Technology Co., Ltd. • <a target='_blank' href='https://b3log.org/siyuan/privacy.html'>Privacy Policy</a> • <a target='_blank' href='https://b3log.org/siyuan/eula.html'>User Agreement</a><div class='fn__hr'></div><div class='fn__hr'></div><div class='ft__on-surface'>The core developers of SiYuan are <a href=\"https://github.com/88250\" target=\"_blank\">D</a> and <a href=\"https://github.com/Vanessa219\" target=\"_blank\">V</a>, and the community development contributors can be seen <a href=\"https://github.com/siyuan-note/bazaar/graphs/contributors\" target=\"_blank\">here</a></div>",
"about2": "Use on browser",
"about3": "Please use the Chrome browser and keep it in the same network as the computer, port <code class='fn__code'>${port}</code>, 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 <code class='fn__code'>${port}</code>, 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",

View file

@ -689,7 +689,7 @@
"about": "Acerca de",
"about1": "Copyright (c) 2020-presente • Yunnan Liandi Technology Co., Ltd. • <a target='_blank' href='https://b3log.org/siyuan/privacy.html'>Política de privacidad</a> • <a target='_blank' href='https://b3log.org/siyuan/eula.html'>Acuerdo de usuario</a><div class='fn__hr'></div><div class='fn__hr'></div><div class='ft__on-surface'>Los principales desarrolladores de SiYuan son <a href=\"https://github.com/88250\" target=\"_blank\">D</a> y <a href=\"https://github.com/Vanessa219\" target=\"_blank\">V</a>, y los contribuyentes al desarrollo de la comunidad pueden verse <a href=\"https://github.com/siyuan-note/bazaar/graphs/contributors\" target=\"_blank\">aquí</a></div>",
"about2": "Uso en el navegador",
"about3": "Por favor, utilice el navegador Chrome y manténgalo en la misma red que el ordenador, puerto <code class='fn__code'>${port}</code>, 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 <code class='fn__code'>${port}</code>, 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",

View file

@ -689,7 +689,7 @@
"about": "À propos de",
"about1": "Copyright (c) 2020-présent • Yunnan Liandi Technology Co., Ltd. • <a target='_blank' href='https://b3log.org/siyuan/privacy.html'>Politique de confidentialité</a> • <a target='_blank' href='https://b3log.org/siyuan/eula.html'>Accord de l'utilisateur</a><div class='fn__hr'></div><div class='fn__hr'></div><div class='ft__on-surface'>Les principaux développeurs de SiYuan sont <a href=\"https://github.com/88250\" target=\"_blank\">D</a> et <a href=\"https://github.com/Vanessa219\" target=\"_blank\">V</a>, et les contributeurs au développement de la communauté peuvent être vus <a href=\"https://github.com/siyuan-note/bazaar/graphs/contributors\" target=\"_blank\">ici</a></div>",
"about2": "Utiliser sur le navigateur",
"about3": "Veuillez utiliser le navigateur Chrome et le garder sur le même réseau que l'ordinateur, port <code class='fn__code'>${port}</code>, 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 <code class='fn__code'>${port}</code>, 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.",

View file

@ -689,7 +689,7 @@
"about": "關於",
"about1": "版權所有 (c) 2020-現在 • 雲南鏈滴科技有限公司 • <a target='_blank' href='https://b3log.org/siyuan/privacy.html'>隱私政策</a> • <a target='_blank' href='https://b3log.org/siyuan/eula.html'>用戶協議</a><div class='fn__hr'></div><div class='fn__hr'></div><div class='ft__on-surface'>思源筆記的核心開發者是 <a href=\"https://github.com/88250\" target=\"_blank\">D</a> 和 <a href=\"https://github.com/Vanessa219\" target=\"_blank\">V</a>,社區開發貢獻者可在<a href=\"https://github.com/siyuan-note/bazaar/graphs/contributors\" target=\"_blank\">這裡</a>看到</div>",
"about2": "在瀏覽器上使用",
"about3": "請使用 Chrome 瀏覽器並保持和電腦在同一個網路內,端口 <code class='fn__code'>${port}</code>,可能連通的 IP 地址如下",
"about3": "請使用 Chrome 瀏覽器並保持和電腦在同一個網路內,端口 <code class='fn__code'>${port}</code>,可能連通的網絡地址:",
"about4": "打開瀏覽器",
"about5": "存取授權碼",
"about6": "配置後作為存取鑒權密碼,留空則關閉鑒權",

View file

@ -689,7 +689,7 @@
"about": "关于",
"about1": "版权所有 (c) 2020-现在 • 云南链滴科技有限公司 • <a target='_blank' href='https://b3log.org/siyuan/privacy.html'>隐私政策</a> • <a target='_blank' href='https://b3log.org/siyuan/eula.html'>用户协议</a><div class='fn__hr'></div><div class='fn__hr'></div><div class='ft__on-surface'>思源笔记的核心开发者是 <a href=\"https://ld246.com/member/88250\" target=\"_blank\">D</a> 和 <a href=\"https://ld246.com/member/Vanessa\" target=\"_blank\">V</a>,社区开发贡献者可在<a href=\"https://github.com/siyuan-note/bazaar/graphs/contributors\" target=\"_blank\">这里</a>看到</div>",
"about2": "在浏览器上使用",
"about3": "请使用 Chrome 浏览器并保持和电脑在同一个网络内,端口 <code class='fn__code'>${port}</code>,可能连通的 IP 地址:",
"about3": "请使用 Chrome 浏览器并保持和电脑在同一个网络内,端口 <code class='fn__code'>${port}</code>,可能连通的网络地址:",
"about4": "打开浏览器",
"about5": "访问授权码",
"about6": "配置后作为访问鉴权密码,留空则关闭鉴权",

View file

@ -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'})
})

View file

@ -75,7 +75,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "127.0.0.1"
"TextMarkTextContent": "siyuan.localhost"
},
{
"Type": "NodeText",

View file

@ -76,7 +76,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "127.0.0.1"
"TextMarkTextContent": "siyuan.localhost"
},
{
"Type": "NodeText",

View file

@ -75,7 +75,7 @@
{
"Type": "NodeTextMark",
"TextMarkType": "code",
"TextMarkTextContent": "127.0.0.1"
"TextMarkTextContent": "siyuan.localhost"
},
{
"Type": "NodeText",

View file

@ -32,5 +32,15 @@
}
}, 2000)
</script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-L7WEXVQCR9');
</script>
</body>
</html>

View file

@ -26,5 +26,15 @@
<div id="status" class="fn__flex status"></div>
<div id="commonMenu" class="b3-menu fn__none"></div>
<div id="message" class="b3-snackbars"></div>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-L7WEXVQCR9');
</script>
</body>
</html>

View file

@ -72,5 +72,15 @@
<button data-type="redo"><svg><use xlink:href="#iconRedo"></use></svg></button>
<span class="fn__flex-1"></span>
</div>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-L7WEXVQCR9');
</script>
</body>
</html>

View file

@ -55,7 +55,7 @@ export const about = {
<span class="b3-label__text"><code class="fn__code">${window.siyuan.config.localIPs.join("</code> <code class='fn__code'>")}</code></span>
</div>
<div class="fn__space"></div>
<button data-type="open" data-url="http://${window.siyuan.config.system.networkServe ? window.siyuan.config.localIPs[0] : "127.0.0.1"}:${location.port}" class="b3-button b3-button--outline fn__size200 fn__flex-center">
<button data-type="open" data-url="http://${window.siyuan.config.system.networkServe ? window.siyuan.config.localIPs[0] : "siyuan.localhost"}:${location.port}" class="b3-button b3-button--outline fn__size200 fn__flex-center">
<svg><use xlink:href="#iconLink"></use></svg>${window.siyuan.languages.about4}
</button>
</label>

View file

@ -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 = '<use xlink:href="#iconInfo"></use>';
@ -193,7 +193,7 @@ ${accountHTML}
<div class="b3-label">
${window.siyuan.languages.about2}
<div class="fn__hr"></div>
<input class="b3-text-field fn__block" readonly value="http://${window.siyuan.config.system.networkServe ? window.siyuan.config.localIPs[0] : "127.0.0.1"}:${location.port}">
<input class="b3-text-field fn__block" readonly value="http://${window.siyuan.config.system.networkServe ? window.siyuan.config.localIPs[0] : "siyuan.localhost"}:${location.port}">
<div class="b3-label__text">${window.siyuan.languages.about3.replace("${port}", location.port)}</div>
<div class="fn__hr"></div>
<span class="b3-label__text"><code class="fn__code">${window.siyuan.config.localIPs.join("</code> <code class='fn__code'>")}</code></span>

View file

@ -159,6 +159,10 @@ export const onGetConfig = (isStart: boolean) => {
if (window.siyuan.config.newbie) {
mountHelp();
}
gtag("event", "config", {
});
};
const initBar = () => {

View file

@ -387,7 +387,7 @@
<div class="b3-snackbar__content"></div>
</div>
<script>
if (location.hostname !== '127.0.0.1') {
if (location.hostname !== 'siyuan.localhost' && location.hostname !== '127.0.0.1') {
document.querySelector('.b3-button--white').remove()
}

View file

@ -209,7 +209,7 @@ func exportTempContent(c *gin.Context) {
}
url := path.Join("/export/temp/", filepath.Base(p))
ret.Data = map[string]interface{}{
"url": "http://127.0.0.1:" + util.ServerPort + url,
"url": "http://" + util.LocalHost + ":" + util.ServerPort + url,
}
}
@ -229,7 +229,7 @@ func exportPreviewHTML(c *gin.Context) {
}
name, content := model.ExportHTML(id, "", true, keepFold)
// 导出 PDF 预览时点击块引转换后的脚注跳转不正确 https://github.com/siyuan-note/siyuan/issues/5894
content = strings.ReplaceAll(content, "http://127.0.0.1:"+util.ServerPort+"/#", "#")
content = strings.ReplaceAll(content, "http://"+util.LocalHost+":"+util.ServerPort+"/#", "#")
ret.Data = map[string]interface{}{
"id": id,

View file

@ -438,7 +438,7 @@ func ExportHTML(id, savePath string, pdf, keepFold bool) (name, dom string) {
}
}
} else { // 导出 PDF 需要将资源文件路径改为 HTTP 伺服
luteEngine.RenderOptions.LinkBase = "http://127.0.0.1:" + util.ServerPort + "/"
luteEngine.RenderOptions.LinkBase = "http://" + util.LocalHost + ":" + util.ServerPort + "/"
}
if pdf {

View file

@ -171,7 +171,7 @@ func CheckAuth(c *gin.Context) {
}
// 放过来自本机的某些请求
if strings.HasPrefix(c.Request.RemoteAddr, "127.0.0.1") {
if strings.HasPrefix(c.Request.RemoteAddr, util.LocalHost) || strings.HasPrefix(c.Request.RemoteAddr, "127.0.0.1") {
if strings.HasPrefix(c.Request.RequestURI, "/assets/") || strings.HasPrefix(c.Request.RequestURI, "/history/assets/") {
c.Next()
return

View file

@ -87,7 +87,7 @@ var LocalIPs []string
func GetLocalIPs() (ret []string) {
if ContainerAndroid == Container {
// Android 上用不了 net.InterfaceAddrs() https://github.com/golang/go/issues/40569所以前面使用启动内核传入的参数 localIPs
LocalIPs = append(LocalIPs, "127.0.0.1")
LocalIPs = append(LocalIPs, LocalHost)
LocalIPs = gulu.Str.RemoveDuplicatedElem(LocalIPs)
return LocalIPs
}
@ -104,7 +104,7 @@ func GetLocalIPs() (ret []string) {
ret = append(ret, networkIp.IP.String())
}
}
ret = append(ret, "127.0.0.1")
ret = append(ret, LocalHost)
ret = gulu.Str.RemoveDuplicatedElem(ret)
return
}

View file

@ -17,9 +17,7 @@
package util
import (
"net"
"strings"
"time"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
@ -50,16 +48,3 @@ func JsonArg(c *gin.Context, result *gulu.Result) (arg map[string]interface{}, o
ok = true
return
}
func isPortOpen(port string) bool {
timeout := time.Second
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", port), timeout)
if nil != err {
return false
}
if nil != conn {
conn.Close()
return true
}
return false
}

View file

@ -293,7 +293,8 @@ const (
ContainerAndroid = "android" // Android 端
ContainerIOS = "ios" // iOS 端
FixedPort = "6806" // 固定端口
LocalHost = "siyuan.localhost" // 本地域名,由操作系统自动解析到 127.0.0.1
FixedPort = "6806" // 固定端口
)
func initPathDir() {