mirror of
https://github.com/coaidev/coai.git
synced 2025-05-28 17:30:15 +09:00
fix config loader
This commit is contained in:
parent
11a4f3dd2f
commit
6dae6c448e
@ -232,3 +232,14 @@ export function updateFavicon(url: string) {
|
||||
const link = document.querySelector("link[rel*='icon']");
|
||||
return link && link.setAttribute("href", url);
|
||||
}
|
||||
|
||||
export function updateDocumentTitle(title: string) {
|
||||
/**
|
||||
* Update document title
|
||||
* @param title Document title
|
||||
* @example
|
||||
* updateDocumentTitle("Hello world!");
|
||||
*/
|
||||
|
||||
document.title = title;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { updateFavicon } from "@/utils/dom.ts";
|
||||
import { updateDocumentTitle, updateFavicon } from "@/utils/dom.ts";
|
||||
|
||||
export let appName =
|
||||
localStorage.getItem("app_name") ||
|
||||
@ -20,7 +20,7 @@ export const deeptrainAppName = import.meta.env.VITE_DEEPTRAIN_APP || "chatnio";
|
||||
export const deeptrainApiEndpoint =
|
||||
import.meta.env.VITE_DEEPTRAIN_API_ENDPOINT || "https://api.deeptrain.net";
|
||||
|
||||
document.title = appName;
|
||||
updateDocumentTitle(appName);
|
||||
updateFavicon(appLogo);
|
||||
|
||||
export function getDev(): boolean {
|
||||
@ -65,22 +65,18 @@ export function setAppName(name: string): void {
|
||||
/**
|
||||
* set the app name in localStorage
|
||||
*/
|
||||
name = name.trim();
|
||||
if (name.length === 0) return;
|
||||
|
||||
name = name.trim() || "Chat Nio";
|
||||
localStorage.setItem("app_name", name);
|
||||
appName = name;
|
||||
|
||||
document.title = name;
|
||||
updateDocumentTitle(name);
|
||||
}
|
||||
|
||||
export function setAppLogo(logo: string): void {
|
||||
/**
|
||||
* set the app logo in localStorage
|
||||
*/
|
||||
logo = logo.trim();
|
||||
if (logo.length === 0) return;
|
||||
|
||||
logo = logo.trim() || "/favicon.ico";
|
||||
localStorage.setItem("app_logo", logo);
|
||||
appLogo = logo;
|
||||
|
||||
|
@ -13,8 +13,8 @@ type ApiInfo struct {
|
||||
}
|
||||
|
||||
type generalState struct {
|
||||
Title string `json:"title" mapstructure:"title"`
|
||||
Logo string `json:"logo" mapstructure:"logo"`
|
||||
Title string `json:"title" mapstructure:"title,omitempty"`
|
||||
Logo string `json:"logo" mapstructure:"logo,omitempty"`
|
||||
Backend string `json:"backend" mapstructure:"backend"`
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ func (c *SystemConfig) SaveConfig() error {
|
||||
// fix: import cycle not allowed
|
||||
{
|
||||
viper.Set("system.general.backend", c.GetBackend())
|
||||
viper.Set("system.general.title", c.General.Title)
|
||||
viper.Set("system.general.logo", c.General.Logo)
|
||||
}
|
||||
return viper.WriteConfig()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user