新增功能:添加zhaozuohong.vip镜像选项
This commit is contained in:
parent
501259b420
commit
de2c2af2bd
9 changed files with 123 additions and 14 deletions
|
@ -1,4 +1,4 @@
|
|||
from typing import List
|
||||
from typing import List, Literal, get_args, get_origin
|
||||
|
||||
from pydantic import BaseModel, model_validator
|
||||
from pydantic_core import PydanticUndefined
|
||||
|
@ -15,6 +15,18 @@ class ConfModel(BaseModel):
|
|||
data[name] = expected_type
|
||||
else:
|
||||
data[name] = field.default
|
||||
value = data[name]
|
||||
|
||||
# 检查 Literal 类型并修正
|
||||
if get_origin(expected_type) is Literal:
|
||||
valid_literals = get_args(expected_type)
|
||||
if value not in valid_literals:
|
||||
# 修正为默认值
|
||||
data[name] = (
|
||||
field.default
|
||||
if field.default is not PydanticUndefined
|
||||
else None
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
|
@ -55,9 +67,17 @@ class LaunchPart(ConfModel):
|
|||
is_show_log: bool = False
|
||||
|
||||
|
||||
class OtherPart(ConfModel):
|
||||
"""其他配置"""
|
||||
|
||||
# xx.zhaozuohong.vip镜像 (访问xx.zhaozuohong.vip url时,0=原路径 1=在.zhaozuohong.vip前添加-cf前缀)
|
||||
base_mirror: Literal["0", "1"] = "0"
|
||||
|
||||
|
||||
class Conf(
|
||||
Total,
|
||||
UpdatePart,
|
||||
LaunchPart,
|
||||
OtherPart,
|
||||
):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue