UPDATE WEB UI

This commit is contained in:
HibiKier
2023-04-02 22:57:36 +08:00
parent 3cc834d424
commit 62e29f389b
13 changed files with 583 additions and 493 deletions
+10 -4
View File
@@ -67,18 +67,24 @@ class StaticData(Generic[T]):
temp[k] = copy.deepcopy(v)
return temp
def save(self, path: Union[str, Path] = None) -> NoReturn:
def save(self, path: Optional[Union[str, Path]] = None):
path = path or self.file
if isinstance(path, str):
path = Path(path)
if path:
with open(path, "w", encoding="utf8") as f:
if path.name.endswith("yaml"):
yaml.dump(self._data, f, indent=2, Dumper=yaml.RoundTripDumper, allow_unicode=True)
yaml.dump(
self._data,
f,
indent=2,
Dumper=yaml.RoundTripDumper,
allow_unicode=True,
)
else:
json.dump(self.dict(), f, ensure_ascii=False, indent=4)
def reload(self) -> NoReturn:
def reload(self):
if self.file.exists():
if self.file.name.endswith("json"):
self._data: dict = json.load(open(self.file, "r", encoding="utf8"))
@@ -94,7 +100,7 @@ class StaticData(Generic[T]):
def __str__(self) -> str:
return str(self._data)
def __setitem__(self, key, value) -> NoReturn:
def __setitem__(self, key, value):
self._data[key] = value
def __getitem__(self, key) -> T:
+1 -1
View File
@@ -140,4 +140,4 @@ class PluginData(BaseModel):
)
def __hash__(self):
return hash(self.name + self.menu_type[0])
return hash(self.name + str(self.menu_type[0]))
+1 -1
View File
@@ -24,7 +24,7 @@ class PluginDataManager(StaticData[PluginData]):
raise ValueError(f"PluginInfoManager {info.model}:{info.name} 插件名称及类型已存在")
self._data[info.model] = info
def get(self, item: str, default: Any = None) -> PluginData:
def get(self, item: str, default: Any = None) -> Optional[PluginData]:
return self._data.get(item, default)
def __getitem__(self, item) -> Optional[PluginData]: