mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 00:32:06 +08:00
UPDATE WEB UI
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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]))
|
||||
|
||||
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user