Skip to content

Commit d20272f

Browse files
authored
fix: 修复mindoc部署在安卓termux上的时区问题 (#1029)
* 在函数开头添加输入元素检测,当焦点在输入框、textarea、select 或可编辑元素中时,直接返回不执行快捷键操作 * feat: 支持 Cherry Markdown 阅读页目录滚动功能 - 为 Cherry 编辑器阅读模式的目录添加最大高度限制 - 当目录过长时支持垂直滚动查看后续条目 - 使用 calc(100vh - 180px) 动态计算合适的滚动容器高度 - 启用 webkit 平滑滚动以改善移动端体验 * fix: 修复mindoc部署在安卓termux上的时区问题
1 parent 1a153cf commit d20272f

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/mindoc-org/mindoc/commands"
1818
"github.com/mindoc-org/mindoc/commands/daemon"
1919
_ "github.com/mindoc-org/mindoc/routers"
20+
"github.com/mindoc-org/mindoc/utils"
2021
)
2122

2223
func isViaDaemonUnix() bool {
@@ -49,6 +50,11 @@ func main() {
4950

5051
d := daemon.NewDaemon()
5152

53+
// 安卓 go/src/time/zoneinfo_android.go 固定localLoc 为 UTC
54+
if runtime.GOOS == "android" {
55+
utils.FixTimezone()
56+
}
57+
5258
if runtime.GOOS != "windows" && !isViaDaemonUnix() {
5359
s, err := service.New(d, d.Config())
5460

utils/android_time.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package utils
2+
3+
import (
4+
"os/exec"
5+
"strings"
6+
"time"
7+
)
8+
9+
func FixTimezone() {
10+
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
11+
if err != nil {
12+
return
13+
}
14+
timeZone, err := time.LoadLocation(strings.TrimSpace(string(out)))
15+
if err != nil {
16+
return
17+
}
18+
time.Local = timeZone
19+
}

0 commit comments

Comments
 (0)