mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-12 23:46:13 +01:00
♻️ Adjust some details (#17165)
This commit is contained in:
parent
5aa9f4b5ef
commit
3e808209e5
9 changed files with 41 additions and 19 deletions
|
|
@ -246,11 +246,11 @@ export const bazaar = {
|
|||
let themeMode = "";
|
||||
if (bazaarType === "themes") {
|
||||
const themeValue = (bazaar.element.querySelector("#bazaarSelect") as HTMLSelectElement).value;
|
||||
if ((themeValue === "0" && item.modes.includes("dark")) ||
|
||||
themeValue === "1" && item.modes.includes("light")) {
|
||||
if ((themeValue === "0" && item.modes?.includes("dark")) ||
|
||||
themeValue === "1" && item.modes?.includes("light")) {
|
||||
hide = true;
|
||||
}
|
||||
themeMode = item.modes.toString();
|
||||
themeMode = item.modes?.toString() || "";
|
||||
}
|
||||
let showSwitch = false;
|
||||
if (["icons", "themes"].includes(bazaarType)) {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ func addClassToKramdownIAL(ial [][]string, class string) [][]string {
|
|||
if len(attr) < 2 || attr[0] != "class" {
|
||||
continue
|
||||
}
|
||||
for _, item := range strings.Fields(attr[1]) {
|
||||
for item := range strings.FieldsSeq(attr[1]) {
|
||||
if item == class {
|
||||
return ial
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ type StageBazaarResult struct {
|
|||
}
|
||||
|
||||
var stageBazaarFlight singleflight.Group
|
||||
var onlineCheckFlight singleflight.Group
|
||||
var bazaarStatsFlight singleflight.Group
|
||||
|
||||
// getStageAndBazaar 获取 stage 索引和 bazaar 索引,相同 pkgType 的并发调用会合并为一次实际请求 (single-flight)
|
||||
|
|
@ -112,6 +113,25 @@ func getStageAndBazaar0(pkgType string) (result StageBazaarResult) {
|
|||
}
|
||||
}
|
||||
|
||||
func isBazaarOnline() bool {
|
||||
v, err, _ := onlineCheckFlight.Do("bazaarOnline", func() (interface{}, error) {
|
||||
return isBazaarOnline0(), nil
|
||||
})
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return v.(bool)
|
||||
}
|
||||
|
||||
func isBazaarOnline0() (ret bool) {
|
||||
// Improve marketplace loading when offline https://github.com/siyuan-note/siyuan/issues/12050
|
||||
ret = util.IsOnline(util.BazaarOSSServer+"/204", true, 3000)
|
||||
if !ret {
|
||||
util.PushErrMsg(util.Langs[util.Lang][24], 5000)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// getStageIndexFromCache 仅从缓存获取 stage 索引,过期或无缓存时返回 nil
|
||||
func getStageIndexFromCache(pkgType string) (ret *StageIndex, err error) {
|
||||
if val, found := cachedStageIndex.Get(pkgType); found {
|
||||
|
|
@ -169,15 +189,6 @@ func getStageRepoByURL(ctx context.Context, pkgType, url string) *StageRepo {
|
|||
return stageIndex.reposByURL[url]
|
||||
}
|
||||
|
||||
func isBazaarOnline() (ret bool) {
|
||||
// Improve marketplace loading when offline https://github.com/siyuan-note/siyuan/issues/12050
|
||||
ret = util.IsOnline(util.BazaarOSSServer+"/204", true, 3000)
|
||||
if !ret {
|
||||
util.PushErrMsg(util.Langs[util.Lang][24], 5000)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// bazaarStats 集市包统计信息
|
||||
type bazaarStats struct {
|
||||
Downloads int `json:"downloads"` // 下载次数
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ func HandleAssetsRemoveEvent(assetAbsPath string) {
|
|||
if gulu.File.IsDir(assetAbsPath) {
|
||||
return
|
||||
}
|
||||
// 跳过隐藏文件,如 WPS 的临时文件、Mac 的 .DS_Store
|
||||
if filelock.IsHidden(assetAbsPath) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ func watchAssets() {
|
|||
return
|
||||
}
|
||||
|
||||
//logging.LogInfof("assets changed: %s", event)
|
||||
if watcher.Write == event.Op {
|
||||
IncSync()
|
||||
}
|
||||
|
|
@ -88,6 +87,7 @@ func watchAssets() {
|
|||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if err := assetsWatcher.Start(10 * time.Second); err != nil {
|
||||
logging.LogErrorf("start assets watcher for folder [%s] failed: %s", assetsDir, err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -322,6 +322,7 @@ func GetBazaarPackageREADME(ctx context.Context, repoURL, repoHash, pkgType stri
|
|||
return
|
||||
}
|
||||
|
||||
// InstallBazaarPackage 安装集市包,themeMode 仅在 pkgType 为 "themes" 时生效
|
||||
func InstallBazaarPackage(pkgType, repoURL, repoHash, packageName string, themeMode int) error {
|
||||
installPath, jsonFileName, err := getPackageInstallPath(pkgType, packageName)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -337,10 +337,11 @@ func InitConf() {
|
|||
Conf.OpenHelp = true
|
||||
}
|
||||
} else {
|
||||
if 0 < semver.Compare("v"+util.Ver, "v"+Conf.System.KernelVersion) {
|
||||
cmp := semver.Compare("v"+util.Ver, "v"+Conf.System.KernelVersion)
|
||||
if 0 < cmp {
|
||||
logging.LogInfof("upgraded from version [%s] to [%s]", Conf.System.KernelVersion, util.Ver)
|
||||
Conf.ShowChangelog = true
|
||||
} else if 0 > semver.Compare("v"+util.Ver, "v"+Conf.System.KernelVersion) {
|
||||
} else if 0 > cmp {
|
||||
logging.LogInfof("downgraded from version [%s] to [%s]", Conf.System.KernelVersion, util.Ver)
|
||||
}
|
||||
|
||||
|
|
@ -1033,9 +1034,12 @@ const (
|
|||
MaskedAccessAuthCode = "*******"
|
||||
)
|
||||
|
||||
// GetMaskedConf 获取脱敏后的 Conf
|
||||
func GetMaskedConf() (ret *AppConf, err error) {
|
||||
// 脱敏处理
|
||||
data, err := gulu.JSON.MarshalIndentJSON(Conf, "", " ")
|
||||
// 序列化时持锁,避免与 loadThemes/LoadIcons 等写操作并发导致 slice 在编码过程中被改写而 panic https://github.com/siyuan-note/siyuan/issues/16978
|
||||
Conf.m.Lock()
|
||||
data, err := gulu.JSON.MarshalJSON(Conf)
|
||||
Conf.m.Unlock()
|
||||
if err != nil {
|
||||
logging.LogErrorf("marshal conf failed: %s", err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ func WatchEmojis() {
|
|||
}
|
||||
|
||||
func watchEmojis() {
|
||||
CloseWatchEmojis()
|
||||
emojisDir := filepath.Join(util.DataDir, "emojis")
|
||||
|
||||
CloseWatchEmojis()
|
||||
emojisWatcher = watcher.New()
|
||||
|
||||
if !gulu.File.IsDir(emojisDir) {
|
||||
|
|
@ -74,6 +74,7 @@ func watchEmojis() {
|
|||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if err := emojisWatcher.Start(10 * time.Second); err != nil {
|
||||
logging.LogErrorf("start emojis watcher for folder [%s] failed: %s", emojisDir, err)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -749,6 +749,10 @@ func checkoutRepo(id string) {
|
|||
CloseWatchEmojis()
|
||||
defer WatchEmojis()
|
||||
|
||||
// 若主题支持同步,需关闭监听器
|
||||
// CloseWatchThemes()
|
||||
// defer WatchThemes()
|
||||
|
||||
// 恢复快照时自动暂停同步,避免刚刚恢复后的数据又被同步覆盖
|
||||
syncEnabled := Conf.Sync.Enabled
|
||||
Conf.Sync.Enabled = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue