Adds a minimal endpoint for activating a theme by name and mode without
requiring the caller to fetch and re-POST the entire appearance config blob.
Request body:
{ "theme": "<theme-dir-name>", "mode": 0|1 }
Behaviour:
- Sets both ThemeLight and ThemeDark to the supplied theme name
- Sets Mode (0 = light, 1 = dark)
- Calls InitAppearance() to validate the theme exists and reads its
version from theme.json for cache-busting
- Saves conf.json
- Broadcasts the "setAppearance" WebSocket event so all open windows
call loadAssets() and reload the theme CSS with the new ?v= parameter
Returns the full Appearance config (same shape as setAppearance).
Motivation: external tools (e.g. OS-level theme switchers) previously
had to GET /api/system/getConf, patch the appearance object, and POST
the entire blob to /api/setting/setAppearance. /api/setting/setTheme
reduces that to a single, self-contained call with no dependencies.
Co-authored-by: You name <konty@github.com>
下面这段代码
dir, err := os.Open(dirname)
if err != nil {
return err
}
defer dir.Close()
dirs, err := dir.Readdir(-1)
可以简化成 `os.ReadDir(dirname)`.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>