Skip to content

Commit 65184b3

Browse files
committed
chore: wip
1 parent faa5180 commit 65184b3

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ app = Quark()
2222
# 配置数据库
2323
app.config["DB_URL"] = "sqlite://data.db"
2424

25+
# 配置应用密钥
26+
app.config["APP_SECRET_KEY"] = "abcdefghijklmnopqrstuvwxyz"
2527

2628
# 创建路由
2729
@app.get("/")
@@ -50,7 +52,7 @@ python main.py
5052
密码:```123456```
5153

5254
## 特别注意
53-
1. **后台用户认证使用了AppKey作为JWT的加密密串,生产环境请务必更改**
55+
1. **后台用户认证使用了APP_SECRET_KEY作为JWT的加密密串,生产环境请务必更改**
5456

5557
## 技术支持
5658
为了避免打扰作者日常工作,你可以在Github上提交 [Issues](https://github.com/quarkcloudio/quark-py/issues)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "quark-py"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "FastAPI + Ant Design Pro front-end and back-end separated admin dashboard, Build Anything With Quark"
55
readme = "README.md"
66
requires-python = ">=3.10,<3.13"

src/quark/loader.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ def load_class(file_path, class_name):
1313
if not os.path.exists(abs_file_path):
1414
return None
1515
spec = importlib.util.spec_from_file_location("dynamic_module", file_path)
16+
if spec is None:
17+
return None
1618
module = importlib.util.module_from_spec(spec)
19+
if module is None:
20+
return None
21+
if spec.loader is None:
22+
return None
1723
spec.loader.exec_module(module)
1824
return getattr(module, class_name)
1925

2026

2127
def load_object(file_path, class_name):
2228
"""从文件加载类对象"""
2329
cls = load_class(file_path, class_name)
30+
if cls is None:
31+
return None
32+
2433
obj = cls()
2534
return obj
2635

@@ -58,6 +67,10 @@ def get_classes_in_package(package_path):
5867
if spec is None:
5968
continue
6069
module = importlib.util.module_from_spec(spec)
70+
if module is None:
71+
continue
72+
if spec.loader is None:
73+
continue
6174
spec.loader.exec_module(module)
6275

6376
# 遍历模块中的所有成员,检查是否为类

src/quark/quark.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ class Quark(FastAPI):
2323
# 配置
2424
config: dict[str, Any] = {
2525
"APP_NAME": "Quark",
26-
"APP_VERSION": "0.1.0",
26+
"APP_VERSION": "0.1.3",
2727
"APP_SECRET_KEY": "your-secret-key",
2828
"CACHE_PREFIX": "quark-cache",
29-
"MODULE_PATH": "app/",
29+
"MODULE_PATH": ".app",
3030
"LOCALE": "zh-hans",
3131
"DB_CONFIG": None,
3232
"DB_URL": None,
3333
"DB_MODULES": {
34-
"models": ["quark.models"],
34+
"models": ["quark.models", ".app.models"],
3535
},
3636
}
3737

@@ -42,6 +42,7 @@ def __init__(self, *args, **kwargs):
4242
# 注册中间件
4343
self.register_middleware()
4444

45+
# 日志
4546
self.logger = logging.getLogger(__name__)
4647

4748
# 获取当前文件的绝对路径

0 commit comments

Comments
 (0)