Fix frontend entrypoint for Vite build
This commit is contained in:
@@ -2,6 +2,8 @@ import json
|
||||
import os
|
||||
from app.utils.logger import logger
|
||||
|
||||
DEFAULT_SYNC_MODE = "merge_local_primary"
|
||||
|
||||
CONFIG_PATH = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), "..", "config.json")
|
||||
)
|
||||
@@ -16,6 +18,8 @@ class ServerConfig:
|
||||
self.scheme = "https"
|
||||
self.port = "32400"
|
||||
self.library_name = ""
|
||||
self.sync_mode = DEFAULT_SYNC_MODE
|
||||
self.local_path = "playlist"
|
||||
self.path_rules: list[dict[str, str]] = []
|
||||
self.load()
|
||||
|
||||
@@ -40,6 +44,8 @@ class ServerConfig:
|
||||
self.scheme = config.get("server_scheme", "https")
|
||||
self.port = config.get("server_port", "32400")
|
||||
self.library_name = config.get("library_name", "")
|
||||
self.sync_mode = config.get("sync_mode", DEFAULT_SYNC_MODE)
|
||||
self.local_path = config.get("local_path", "playlist")
|
||||
self.path_rules = config.get("path_rules", []) or []
|
||||
logger.info(f"Server config loaded: {self.__dict__}")
|
||||
|
||||
@@ -51,6 +57,8 @@ class ServerConfig:
|
||||
"server_scheme": self.scheme,
|
||||
"server_port": self.port,
|
||||
"library_name": self.library_name,
|
||||
"sync_mode": self.sync_mode,
|
||||
"local_path": self.local_path,
|
||||
"path_rules": self.path_rules,
|
||||
}
|
||||
with open(CONFIG_PATH, "w", encoding="utf-8") as f:
|
||||
@@ -72,6 +80,12 @@ class ServerConfig:
|
||||
def set_library(self, library_name: str) -> None:
|
||||
self.library_name = library_name or ""
|
||||
|
||||
def set_sync_mode(self, sync_mode: str) -> None:
|
||||
self.sync_mode = sync_mode
|
||||
|
||||
def set_local_path(self, local_path: str) -> None:
|
||||
self.local_path = local_path or "playlist"
|
||||
|
||||
def set_theme(self, theme: str) -> None:
|
||||
# check theme is valid
|
||||
if theme not in ["auto", "dark", "light"]:
|
||||
@@ -90,6 +104,8 @@ class ServerConfig:
|
||||
scheme: str = None,
|
||||
port: str = None,
|
||||
library_name: str | None = None,
|
||||
sync_mode: str | None = None,
|
||||
local_path: str | None = None,
|
||||
path_rules: list[dict[str, str]] | None = None,
|
||||
) -> None:
|
||||
if theme is not None:
|
||||
@@ -104,6 +120,10 @@ class ServerConfig:
|
||||
self.set_port(port)
|
||||
if library_name is not None:
|
||||
self.set_library(library_name)
|
||||
if sync_mode is not None:
|
||||
self.set_sync_mode(sync_mode)
|
||||
if local_path is not None:
|
||||
self.set_local_path(local_path)
|
||||
if path_rules is not None:
|
||||
self.set_path_rules(path_rules)
|
||||
self.save()
|
||||
|
||||
Reference in New Issue
Block a user