mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 09:30:48 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
f5e0da0ac1
@ -230,6 +230,11 @@ func exportConf(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if nil != clonedConf.Appearance {
|
||||||
|
clonedConf.Appearance.DarkThemes = nil
|
||||||
|
clonedConf.Appearance.LightThemes = nil
|
||||||
|
clonedConf.Appearance.Icons = nil
|
||||||
|
}
|
||||||
if nil != clonedConf.Editor {
|
if nil != clonedConf.Editor {
|
||||||
clonedConf.Editor.Emoji = []string{}
|
clonedConf.Editor.Emoji = []string{}
|
||||||
}
|
}
|
||||||
|
@ -17,22 +17,22 @@
|
|||||||
package conf
|
package conf
|
||||||
|
|
||||||
type Appearance struct {
|
type Appearance struct {
|
||||||
Mode int `json:"mode"` // 模式:0:明亮,1:暗黑
|
Mode int `json:"mode"` // 模式:0:明亮,1:暗黑
|
||||||
ModeOS bool `json:"modeOS"` // 模式是否跟随系统
|
ModeOS bool `json:"modeOS"` // 模式是否跟随系统
|
||||||
DarkThemes []string `json:"darkThemes"` // 暗黑模式外观主题列表
|
DarkThemes []*AppearanceTheme `json:"darkThemes"` // 暗黑模式外观主题列表
|
||||||
LightThemes []string `json:"lightThemes"` // 明亮模式外观主题列表
|
LightThemes []*AppearanceTheme `json:"lightThemes"` // 明亮模式外观主题列表
|
||||||
ThemeDark string `json:"themeDark"` // 选择的暗黑模式外观主题
|
ThemeDark string `json:"themeDark"` // 选择的暗黑模式外观主题
|
||||||
ThemeLight string `json:"themeLight"` // 选择的明亮模式外观主题
|
ThemeLight string `json:"themeLight"` // 选择的明亮模式外观主题
|
||||||
ThemeVer string `json:"themeVer"` // 选择的主题版本
|
ThemeVer string `json:"themeVer"` // 选择的主题版本
|
||||||
Icons []string `json:"icons"` // 图标列表
|
Icons []string `json:"icons"` // 图标列表
|
||||||
Icon string `json:"icon"` // 选择的图标
|
Icon string `json:"icon"` // 选择的图标
|
||||||
IconVer string `json:"iconVer"` // 选择的图标版本
|
IconVer string `json:"iconVer"` // 选择的图标版本
|
||||||
CodeBlockThemeLight string `json:"codeBlockThemeLight"` // 明亮模式下代码块主题
|
CodeBlockThemeLight string `json:"codeBlockThemeLight"` // 明亮模式下代码块主题
|
||||||
CodeBlockThemeDark string `json:"codeBlockThemeDark"` // 暗黑模式下代码块主题
|
CodeBlockThemeDark string `json:"codeBlockThemeDark"` // 暗黑模式下代码块主题
|
||||||
Lang string `json:"lang"` // 选择的界面语言,同 AppConf.Lang
|
Lang string `json:"lang"` // 选择的界面语言,同 AppConf.Lang
|
||||||
ThemeJS bool `json:"themeJS"` // 是否启用了主题 JavaScript
|
ThemeJS bool `json:"themeJS"` // 是否启用了主题 JavaScript
|
||||||
CloseButtonBehavior int `json:"closeButtonBehavior"` // 关闭按钮行为,0:退出,1:最小化到托盘
|
CloseButtonBehavior int `json:"closeButtonBehavior"` // 关闭按钮行为,0:退出,1:最小化到托盘
|
||||||
HideStatusBar bool `json:"hideStatusBar"` // 是否隐藏底部状态栏
|
HideStatusBar bool `json:"hideStatusBar"` // 是否隐藏底部状态栏
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAppearance() *Appearance {
|
func NewAppearance() *Appearance {
|
||||||
@ -49,3 +49,8 @@ func NewAppearance() *Appearance {
|
|||||||
HideStatusBar: false,
|
HideStatusBar: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AppearanceTheme struct {
|
||||||
|
Name string `json:"name"` // daylight
|
||||||
|
Label string `json:"label"` // i18n display name
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/siyuan-note/filelock"
|
"github.com/siyuan-note/filelock"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/bazaar"
|
"github.com/siyuan-note/siyuan/kernel/bazaar"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,11 +50,11 @@ func InitAppearance() {
|
|||||||
}
|
}
|
||||||
loadThemes()
|
loadThemes()
|
||||||
|
|
||||||
if !gulu.Str.Contains(Conf.Appearance.ThemeDark, Conf.Appearance.DarkThemes) {
|
if !containTheme(Conf.Appearance.ThemeDark, Conf.Appearance.DarkThemes) {
|
||||||
Conf.Appearance.ThemeDark = "midnight"
|
Conf.Appearance.ThemeDark = "midnight"
|
||||||
Conf.Appearance.ThemeJS = false
|
Conf.Appearance.ThemeJS = false
|
||||||
}
|
}
|
||||||
if !gulu.Str.Contains(Conf.Appearance.ThemeLight, Conf.Appearance.LightThemes) {
|
if !containTheme(Conf.Appearance.ThemeLight, Conf.Appearance.LightThemes) {
|
||||||
Conf.Appearance.ThemeLight = "daylight"
|
Conf.Appearance.ThemeLight = "daylight"
|
||||||
Conf.Appearance.ThemeJS = false
|
Conf.Appearance.ThemeJS = false
|
||||||
}
|
}
|
||||||
@ -66,6 +67,15 @@ func InitAppearance() {
|
|||||||
Conf.Save()
|
Conf.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containTheme(name string, themes []*conf.AppearanceTheme) bool {
|
||||||
|
for _, t := range themes {
|
||||||
|
if t.Name == name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var themeWatchers = sync.Map{} // [string]*fsnotify.Watcher{}
|
var themeWatchers = sync.Map{} // [string]*fsnotify.Watcher{}
|
||||||
|
|
||||||
func closeThemeWatchers() {
|
func closeThemeWatchers() {
|
||||||
@ -118,10 +128,33 @@ func loadThemes() {
|
|||||||
|
|
||||||
modes := themeConf.Modes
|
modes := themeConf.Modes
|
||||||
for _, mode := range modes {
|
for _, mode := range modes {
|
||||||
|
t := &conf.AppearanceTheme{Name: name}
|
||||||
|
if "zh_CN" == util.Lang {
|
||||||
|
if "midnight" == name {
|
||||||
|
t.Label = name + "(默认主题)"
|
||||||
|
} else if "daylight" == name {
|
||||||
|
t.Label = name + "(默认主题)"
|
||||||
|
} else {
|
||||||
|
if nil != themeConf.DisplayName && "" != themeConf.DisplayName.ZhCN && name != themeConf.DisplayName.ZhCN {
|
||||||
|
t.Label = themeConf.DisplayName.ZhCN + "(" + name + ")"
|
||||||
|
} else {
|
||||||
|
t.Label = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if "midnight" == name {
|
||||||
|
t.Label = name + " (Default)"
|
||||||
|
} else if "daylight" == name {
|
||||||
|
t.Label = name + " (Default)"
|
||||||
|
} else {
|
||||||
|
t.Label = name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if "dark" == mode {
|
if "dark" == mode {
|
||||||
Conf.Appearance.DarkThemes = append(Conf.Appearance.DarkThemes, name)
|
Conf.Appearance.DarkThemes = append(Conf.Appearance.DarkThemes, t)
|
||||||
} else if "light" == mode {
|
} else if "light" == mode {
|
||||||
Conf.Appearance.LightThemes = append(Conf.Appearance.LightThemes, name)
|
Conf.Appearance.LightThemes = append(Conf.Appearance.LightThemes, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ func BazaarThemes(keyword string) (ret []*bazaar.Theme) {
|
|||||||
installs = append(installs, Conf.Appearance.LightThemes...)
|
installs = append(installs, Conf.Appearance.LightThemes...)
|
||||||
for _, installed := range installs {
|
for _, installed := range installs {
|
||||||
for _, theme := range ret {
|
for _, theme := range ret {
|
||||||
if installed == theme.Name {
|
if installed.Name == theme.Name {
|
||||||
theme.Installed = true
|
theme.Installed = true
|
||||||
if themeConf, err := bazaar.ThemeJSON(theme.Name); err == nil {
|
if themeConf, err := bazaar.ThemeJSON(theme.Name); err == nil {
|
||||||
theme.Outdated = 0 > semver.Compare("v"+themeConf.Version, "v"+theme.Version)
|
theme.Outdated = 0 > semver.Compare("v"+themeConf.Version, "v"+theme.Version)
|
||||||
|
@ -184,7 +184,7 @@ func SearchDocsByKeyword(keyword string, flashcard bool) (ret []map[string]strin
|
|||||||
var rootBlocks []*sql.Block
|
var rootBlocks []*sql.Block
|
||||||
if 0 < len(keywords) {
|
if 0 < len(keywords) {
|
||||||
for _, box := range boxes {
|
for _, box := range boxes {
|
||||||
if util.ContainsSubStr(box.Name, keywords) {
|
if gulu.Str.Contains(box.Name, keywords) {
|
||||||
if flashcard {
|
if flashcard {
|
||||||
newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)
|
newFlashcardCount, dueFlashcardCount, flashcardCount := countBoxFlashcard(box.ID, deck, deckBlockIDs)
|
||||||
if 0 < flashcardCount {
|
if 0 < flashcardCount {
|
||||||
|
Loading…
Reference in New Issue
Block a user