mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-03 14:11:47 +01:00
♻️ 通过域名 siyuan.localhost 加载 https://github.com/siyuan-note/siyuan/issues/6368
This commit is contained in:
parent
f8d01913a4
commit
8bc889659b
19 changed files with 38 additions and 47 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,8 @@ const (
|
|||
ContainerAndroid = "android" // Android 端
|
||||
ContainerIOS = "ios" // iOS 端
|
||||
|
||||
FixedPort = "6806" // 固定端口
|
||||
LocalHost = "siyuan.localhost" // 本地域名,由操作系统自动解析到 127.0.0.1
|
||||
FixedPort = "6806" // 固定端口
|
||||
)
|
||||
|
||||
func initPathDir() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue