getgridea / gridea

✍️ A static blog writing client (一个静态博客写作客户端)
https://open.gridea.dev
MIT License
9.94k stars 794 forks source link

json 中的 switch 保存后没有正确显示状态 #493

Closed chiperman closed 4 years ago

chiperman commented 4 years ago

我的环境

名称
操作系统 Windows10
软件版本 0.9.2
主题名称 Pan

期望行为

自定义了json文件后,不管怎么选,下次打开还是默认值

当前行为

设置一个 "type": "switch" 以后,如果默认 "value": true, ,那么进去以后选项按钮是打开的 image 可是,假设我关闭这个按钮以后并保存,然后重新打开 Gridea,进入这个自定义配置里面,这个选项还是表现为开启状态,实际上是已经关掉了,我认为是保存以后,没有自动修改 json 文件里面的 value 值。

EryouHao commented 4 years ago

有复现的主题链接发一下吗?理论上应该没问题的, 默认主题也有 switch 选项,可以对比着看一下,配置之后理论上会在 博客源原文件夹(默认是 Documents/Gridea)/config/theme.json 里面有相关的实际配置值 https://github.com/getgridea/gridea-theme-notes/blob/master/config.json

chiperman commented 4 years ago

主题地址 Pan 里面的自定义配置-开启建站时间switch控件,实际上我试了一下是否开启 Valine 评论按钮也遇到这个问题。 预览后,可以在底部看见 「我」已经运行xxx天 这个footer 信息 image 然后去自定义配置中关闭按钮,保存并且重新打开,会发现按钮重新显示开启,但实际上,这个时候预览会发现「我」已经运行xxx天 这个footer 信息已经不在了,但是自定义配置中显示有问题

chiperman commented 4 years ago

补充信息:在style-override.js中 进行了显示判断

 if (typeof params.buildTimeLaunch !== 'undefined' && !params.buildTimeLaunch) {

    result += `
    .runtime {
        display: none;
      }
    `
  }
chiperman commented 4 years ago

已经解决,json 中不要写 "value": true 这个默认值,否则每次打开都会显示为开启状态

    {
      "name": "buildTimeLaunch",
      "label": "是否需要开启博客建站时间",
      "group": "建站时间",
      "value": true,
      "type": "switch",
      "note": "开启则在 footer.js 中运行博客建立时间插件"
    },