feat: 添加版本信息缓存机制
This commit is contained in:
@@ -135,19 +135,22 @@ class GlobalConfig(ConfigBase):
|
|||||||
Data_StageTimeStamp = ConfigItem(
|
Data_StageTimeStamp = ConfigItem(
|
||||||
"Data", "StageTimeStamp", "2000-01-01 00:00:00", DateTimeValidator()
|
"Data", "StageTimeStamp", "2000-01-01 00:00:00", DateTimeValidator()
|
||||||
)
|
)
|
||||||
Data_Stage = ConfigItem("Data", "Stage", "{ }")
|
Data_Stage = ConfigItem("Data", "Stage", "{ }", JSONValidator())
|
||||||
Data_LastNoticeUpdated = ConfigItem(
|
Data_LastNoticeUpdated = ConfigItem(
|
||||||
"Data", "LastNoticeUpdated", "2000-01-01 00:00:00", DateTimeValidator()
|
"Data", "LastNoticeUpdated", "2000-01-01 00:00:00", DateTimeValidator()
|
||||||
)
|
)
|
||||||
Data_IfShowNotice = ConfigItem("Data", "IfShowNotice", True, BoolValidator())
|
Data_IfShowNotice = ConfigItem("Data", "IfShowNotice", True, BoolValidator())
|
||||||
Data_Notice = ConfigItem("Data", "Notice", "{ }")
|
Data_Notice = ConfigItem("Data", "Notice", "{ }", JSONValidator())
|
||||||
Data_LastWebConfigUpdated = ConfigItem(
|
Data_LastWebConfigUpdated = ConfigItem(
|
||||||
"Data", "LastWebConfigUpdated", "2000-01-01 00:00:00", DateTimeValidator()
|
"Data", "LastWebConfigUpdated", "2000-01-01 00:00:00", DateTimeValidator()
|
||||||
)
|
)
|
||||||
Data_LastCheckVersion = ConfigItem(
|
Data_LastCheckVersion = ConfigItem(
|
||||||
"Data", "LastCheckVersion", "2000-01-01 00:00:00", DateTimeValidator()
|
"Data", "LastCheckVersion", "2000-01-01 00:00:00", DateTimeValidator()
|
||||||
)
|
)
|
||||||
Data_WebConfig = ConfigItem("Data", "WebConfig", "{ }")
|
Data_UpdateVersionInfo = ConfigItem(
|
||||||
|
"Data", "UpdateVersionInfo", "{ }", JSONValidator()
|
||||||
|
)
|
||||||
|
Data_WebConfig = ConfigItem("Data", "WebConfig", "{ }", JSONValidator())
|
||||||
|
|
||||||
|
|
||||||
class QueueItem(ConfigBase):
|
class QueueItem(ConfigBase):
|
||||||
|
|||||||
@@ -134,6 +134,21 @@ class DateTimeValidator(ConfigValidator):
|
|||||||
return "2000-01-01 00:00:00"
|
return "2000-01-01 00:00:00"
|
||||||
|
|
||||||
|
|
||||||
|
class JSONValidator(ConfigValidator):
|
||||||
|
|
||||||
|
def validate(self, value: Any) -> bool:
|
||||||
|
if not isinstance(value, str):
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
json.loads(value)
|
||||||
|
return True
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def correct(self, value: Any) -> str:
|
||||||
|
return value if self.validate(value) else "{ }"
|
||||||
|
|
||||||
|
|
||||||
class EncryptValidator(ConfigValidator):
|
class EncryptValidator(ConfigValidator):
|
||||||
"""加密数据验证器"""
|
"""加密数据验证器"""
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class _UpdateHandler:
|
|||||||
)
|
)
|
||||||
),
|
),
|
||||||
current_version if self.remote_version is None else self.remote_version,
|
current_version if self.remote_version is None else self.remote_version,
|
||||||
{},
|
json.loads(Config.get("Data", "UpdateVersionInfo")),
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("开始检查更新")
|
logger.info("开始检查更新")
|
||||||
@@ -122,6 +122,9 @@ class _UpdateHandler:
|
|||||||
update_version_info[key] = []
|
update_version_info[key] = []
|
||||||
update_version_info[key] += value
|
update_version_info[key] += value
|
||||||
|
|
||||||
|
await Config.set(
|
||||||
|
"Data", "UpdateVersionInfo", json.dumps(update_version_info)
|
||||||
|
)
|
||||||
return True, remote_version, update_version_info
|
return True, remote_version, update_version_info
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user