Skip to content

Commit 90855b1

Browse files
committed
chore:调整项目结构
1 parent e7aa6a3 commit 90855b1

9 files changed

Lines changed: 80 additions & 71 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<p align="center">
1313
<a href="http://flask.pocoo.org/docs/1.0/" rel="nofollow">
1414
<img src="https://img.shields.io/badge/flask-1.1.2-green.svg" alt="flask version" data-canonical-src="https://img.shields.io/badge/flask-1.1.2-green.svg" style="max-width:100%;"></a>
15-
<a href="https://pypi.org/project/Lin-CMS/" rel="nofollow"><img src="https://img.shields.io/badge/lin--cms-0.3.0a8-orange.svg" alt="lin--cms version" data-canonical-src="https://img.shields.io/badge/lin--cms-0.3.0a8-orange.svge" style="max-width:100%;"></a>
15+
<a href="https://pypi.org/project/Lin-CMS/" rel="nofollow"><img src="https://img.shields.io/badge/lin--cms-0.3.0a9-orange.svg" alt="lin--cms version" data-canonical-src="https://img.shields.io/badge/lin--cms-0.3.0a9-orange.svge" style="max-width:100%;"></a>
1616
<a href="https://doc.cms.talelin.com/" rel="nofollow"><img src="https://img.shields.io/badge/license-MIT-lightgrey.svg" alt="LISENCE" data-canonical-src="https://img.shields.io/badge/license-MIT-lightgrey.svg" style="max-width:100%;"></a>
1717
</p>
1818

@@ -35,9 +35,9 @@ Lin-CMS 是林间有风团队经过大量项目实践所提炼出的一套**内
3535

3636
### 当前最新版本
3737

38-
lin-cms-flask(当前示例工程):0.3.0a8
38+
lin-cms-flask(当前示例工程):0.3.0a9
3939

40-
lin-cms(核心库) :0.3.0a8
40+
lin-cms(核心库) :0.3.0a9
4141

4242
### 文档地址
4343

@@ -117,10 +117,10 @@ Lin 的服务端框架是基于 Python Flask 的,所以如果您比较熟悉 F
117117
打开您的命令行工具(terminal),在其中键入:
118118

119119
```bash
120-
git clone https://github.com/TaleLin/lin-cms-flask.git -b 0.3.x starter
120+
git clone https://github.com/TaleLin/lin-cms-flask.git starter
121121
```
122122

123-
> **Tips:** 当前分支不是默认分支,所以需要分支切换到`0.3.x`
123+
> **Tips:**
124124
>
125125
> 我们以 `starter` 作为工程名,当然您也可以以任意您喜爱的名字作为工程名。
126126
>

app/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ def register_blueprints(app):
1515
app.register_blueprint(create_cms(), url_prefix="/cms")
1616

1717

18+
def register_cli(app):
19+
from app.cli import db_cli, plugin_cli
20+
21+
app.cli.add_command(db_cli)
22+
app.cli.add_command(plugin_cli)
23+
24+
1825
def register_api(app):
1926
from lin.apidoc import api
2027

@@ -63,4 +70,5 @@ def create_app(register_all=True, **kwargs):
6370
register_api(app)
6471
apply_cors(app)
6572
Lin(app, **kwargs)
73+
register_cli(app)
6674
return app

app/config/__init__.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +0,0 @@
1-
"""
2-
:copyright: © 2020 by the Lin team.
3-
:license: MIT, see LICENSE for more details.
4-
"""
5-
6-
import os
7-
from datetime import timedelta
8-
9-
10-
class BaseConfig(object):
11-
"""
12-
基础配置
13-
"""
14-
15-
# 先读 env 环境变量中的配置
16-
17-
# 指定加密KEY
18-
SECRET_KEY = os.getenv("SECRET_KEY", "https://github.com/TaleLin/lin-cms-flask")
19-
20-
# 指定访问api服务的url, 用于文件上传
21-
# SITE_DOMAIN="https://lincms.example.com"
22-
23-
# 指定数据库
24-
SQLALCHEMY_DATABASE_URI = os.getenv(
25-
"SQLALCHEMY_DATABASE_URI",
26-
"sqlite:////" + os.getcwd() + os.path.sep + "lincms.db",
27-
)
28-
29-
# 屏蔽 sql alchemy 的 FSADeprecationWarning
30-
SQLALCHEMY_TRACK_MODIFICATIONS = False
31-
32-
# 令牌配置
33-
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
34-
35-
# 默认文件上传配置
36-
FILE = {
37-
"STORE_DIR": "assets",
38-
"SINGLE_LIMIT": 1024 * 1024 * 2,
39-
"TOTAL_LIMIT": 1024 * 1024 * 20,
40-
"NUMS": 10,
41-
"INCLUDE": set(["jpg", "png", "jpeg"]),
42-
"EXCLUDE": set([]),
43-
}
44-
45-
# 运行日志
46-
LOG = {
47-
"LEVEL": "DEBUG",
48-
"DIR": "logs",
49-
"SIZE_LIMIT": 1024 * 1024 * 5,
50-
"REQUEST_LOG": True,
51-
"FILE": True,
52-
}
53-
54-
# 分页配置
55-
COUNT_DEFAULT = 10
56-
PAGE_DEFAULT = 0
57-
58-
# 兼容中文
59-
JSON_AS_ASCII = False

app/config/base.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
:copyright: © 2020 by the Lin team.
3+
:license: MIT, see LICENSE for more details.
4+
"""
5+
6+
import os
7+
from datetime import timedelta
8+
9+
10+
class BaseConfig(object):
11+
"""
12+
基础配置
13+
"""
14+
15+
# 先读 env 环境变量中的配置
16+
17+
# 指定加密KEY
18+
SECRET_KEY = os.getenv("SECRET_KEY", "https://github.com/TaleLin/lin-cms-flask")
19+
20+
# 指定访问api服务的url, 用于文件上传
21+
# SITE_DOMAIN="https://lincms.example.com"
22+
23+
# 指定数据库
24+
SQLALCHEMY_DATABASE_URI = os.getenv(
25+
"SQLALCHEMY_DATABASE_URI",
26+
"sqlite:////" + os.getcwd() + os.path.sep + "lincms.db",
27+
)
28+
29+
# 屏蔽 sql alchemy 的 FSADeprecationWarning
30+
SQLALCHEMY_TRACK_MODIFICATIONS = False
31+
32+
# 令牌配置
33+
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
34+
35+
# 默认文件上传配置
36+
FILE = {
37+
"STORE_DIR": "assets",
38+
"SINGLE_LIMIT": 1024 * 1024 * 2,
39+
"TOTAL_LIMIT": 1024 * 1024 * 20,
40+
"NUMS": 10,
41+
"INCLUDE": set(["jpg", "png", "jpeg"]),
42+
"EXCLUDE": set([]),
43+
}
44+
45+
# 运行日志
46+
LOG = {
47+
"LEVEL": "DEBUG",
48+
"DIR": "logs",
49+
"SIZE_LIMIT": 1024 * 1024 * 5,
50+
"REQUEST_LOG": True,
51+
"FILE": True,
52+
}
53+
54+
# 分页配置
55+
COUNT_DEFAULT = 10
56+
PAGE_DEFAULT = 0
57+
58+
# 兼容中文
59+
JSON_AS_ASCII = False

app/config/development.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from . import BaseConfig
1+
from .base import BaseConfig
22

33

44
class DevelopmentConfig(BaseConfig):
55
"""
66
开发环境配置
77
"""
8+
9+
pass

app/config/production.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
from . import BaseConfig
1+
from .base import BaseConfig
22

33

44
class ProductionConfig(BaseConfig):
55
"""
66
生产环境配置
77
"""
8+
9+
pass

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Lin-CMS==0.3.0a8
1+
Lin-CMS==0.3.0a9
22
Flask-Cors==3.0.9
33
python-dotenv==0.15.0
44
pytest-ordering==0.6

requirements-prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Lin-CMS==0.3.0a8
1+
Lin-CMS==0.3.0a9
22
Flask-Cors==3.0.9
33
python-dotenv==0.15.0
44
gevent==20.9.0

starter.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55

66
from app import create_app
7-
from app.cli import db_cli, plugin_cli
87
from app.config.code_message import MESSAGE
98
from app.config.http_status_desc import DESC
109
from app.model.lin import (
@@ -27,8 +26,6 @@
2726
config_DESC=DESC,
2827
)
2928

30-
app.cli.add_command(db_cli)
31-
app.cli.add_command(plugin_cli)
3229

3330
if app.config.get("ENV") != "production":
3431

0 commit comments

Comments
 (0)