Skip to content

Commit b5a3930

Browse files
committed
fix&docs: 修复配置文件加载问题,legacy分支启动
1 parent 2aa9ccb commit b5a3930

File tree

3 files changed

+59
-37
lines changed

3 files changed

+59
-37
lines changed

.idea/workspace.xml

+32-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
>
1313
> 如果您需要在某处售卖NamePicker,或者需要提供有关NamePicker的付费服务,请参照[该指南](https://www.baidu.com/s?wd=家里人全死光了怎么办)
1414
15+
> [!note]
16+
>
17+
> 该分支(即legacy分支)用于维护NamePicker v1.x.x版本
18+
>
19+
> v1.x.x版本仍然接受Bug修复,但是不会添加新功能
20+
1521
## 功能清单/大饼
1622
> 由于Tkinter过于原始,迁移至PyQt的计划将会提前
1723

main.py

+21-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,27 @@
1717
import pywinstyles
1818
import os
1919

20-
with open("config.json", "r", encoding="utf-8") as f:
21-
confc = f.read()
22-
cc = json.loads(confc)
20+
VERSION = "1.1.2dev"
21+
VER_NO = 7
22+
CODENAME = "Sonetto"
23+
24+
try:
25+
with open("config.json", "r", encoding="utf-8") as f:
26+
confc = f.read()
27+
cc = json.loads(confc)
28+
except FileNotFoundError:
29+
cfg = {"VERSION": VERSION,
30+
"VER_NO": VER_NO,
31+
"CODENAME": CODENAME,
32+
"allowRepeat": False,
33+
"alwaysOnTop": True,
34+
"SupportCW": False,
35+
"logLevel": "Info",
36+
"consoleOutput": False}
37+
conf = json.dumps(cfg)
38+
with open("config.json", "w", encoding="utf-8") as f:
39+
f.write(conf)
40+
logging.warning("没有找到config.json")
2341

2442
def returnLevel(lev):
2543
if lev == "Debug":
@@ -37,9 +55,6 @@ def returnLevel(lev):
3755
logging.basicConfig(filename='log.log', encoding="UTF-8", level=returnLevel(cc["logLevel"]), filemode='w')
3856

3957
temp_dir = tempfile.gettempdir()
40-
VERSION = "1.1.2dev"
41-
VER_NO = 7
42-
CODENAME = "Sonetto"
4358
img = Image.open("NamePicker.png")
4459
img.resize((100,100))
4560

0 commit comments

Comments
 (0)