Skip to content

Commit db64d72

Browse files
committed
fix: add missing constants module
1 parent c2bda7d commit db64d72

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

core/constants.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
"""
2+
JM-Cosmos II 常量定义模块
3+
4+
集中管理分类、排序、时间等常量映射。
5+
"""
6+
7+
# ==================== API 参数映射 ====================
8+
# 这些映射用于将用户输入转换为 jmcomic 库接受的 API 参数
9+
10+
# 分类映射:用户输入 -> API 参数
11+
CATEGORY_MAP = {
12+
"all": "0",
13+
"doujin": "doujin",
14+
"single": "single",
15+
"short": "short",
16+
"hanman": "hanman",
17+
"meiman": "meiman",
18+
"3d": "3D",
19+
"cosplay": "doujin_cosplay",
20+
"another": "another",
21+
}
22+
23+
# 排序映射:用户输入 -> API 参数
24+
ORDER_MAP = {
25+
"new": "mr", # 最新
26+
"hot": "mv", # 最热(观看数)
27+
"pic": "mp", # 图片多
28+
"like": "tf", # 点赞多
29+
}
30+
31+
# 时间映射:用户输入 -> API 参数
32+
TIME_MAP = {
33+
"day": "t", # 今日
34+
"week": "w", # 本周
35+
"month": "m", # 本月
36+
"all": "a", # 全部时间
37+
}
38+
39+
40+
# ==================== 显示名称映射 ====================
41+
# 这些映射用于在消息中显示友好的中文名称
42+
43+
# 分类显示名称(支持用户输入和 API 参数两种 key)
44+
CATEGORY_NAMES = {
45+
"all": "全部",
46+
"0": "全部",
47+
"doujin": "同人",
48+
"single": "单本",
49+
"short": "短篇",
50+
"hanman": "韩漫",
51+
"meiman": "美漫",
52+
"3d": "3D",
53+
"3D": "3D",
54+
"cosplay": "Cosplay",
55+
"doujin_cosplay": "Cosplay",
56+
"another": "其他",
57+
}
58+
59+
# 排序显示名称(支持用户输入和 API 参数两种 key)
60+
ORDER_NAMES = {
61+
"new": "最新",
62+
"mr": "最新",
63+
"hot": "热门",
64+
"mv": "热门",
65+
"pic": "图多",
66+
"mp": "图多",
67+
"like": "点赞",
68+
"tf": "点赞",
69+
}
70+
71+
# 时间显示名称(支持用户输入和 API 参数两种 key)
72+
TIME_NAMES = {
73+
"day": "今日",
74+
"t": "今日",
75+
"week": "本周",
76+
"w": "本周",
77+
"month": "本月",
78+
"m": "本月",
79+
"all": "全部时间",
80+
"a": "全部时间",
81+
}
82+
83+
84+
# ==================== 辅助函数 ====================
85+
86+
87+
def get_category_list() -> list[str]:
88+
"""获取所有支持的分类"""
89+
return list(CATEGORY_MAP.keys())
90+
91+
92+
def get_order_list() -> list[str]:
93+
"""获取所有支持的排序方式"""
94+
return list(ORDER_MAP.keys())
95+
96+
97+
def get_time_list() -> list[str]:
98+
"""获取所有支持的时间范围"""
99+
return list(TIME_MAP.keys())

0 commit comments

Comments
 (0)