diff --git a/app.py b/app.py index af7e9be3839b95cf0489815b960396dc0c44cc88..b83792ebcde32c69bd3b959f753473c7cd459a61 100644 --- a/app.py +++ b/app.py @@ -31,12 +31,12 @@ def create_flask_app(): wlan_info,_ = get_wlan_info() logger.info(rule_list) logger.info(f'局域网: {getHost(1, app.config.get("HTTP_PORT"))}/index\n本地: {getHost(0, app.config.get("HTTP_PORT"))}/index\nwlan_info:{wlan_info}') + db.init_app(app) + db.app = app + db.create_all(app=app) return app app = create_flask_app() -db.init_app(app) -db.app = app -db.create_all(app=app) migrate = Migrate(app, db) now_python_ver = ".".join([str(i) for i in sys.version_info[:3]]) diff --git a/base/rules.db b/base/rules.db index 3031ee08ba95c02107da8b1929187dc640cee660..5a84f58d1d455e133f6bbac702382b7fcd9799b7 100644 Binary files a/base/rules.db and b/base/rules.db differ diff --git a/controllers/admin.py b/controllers/admin.py index be374ab50696808313328e176ffdf8165f86e477..5713b66d445e5ecddafbf492f5bc2c6bd710ca94 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -8,6 +8,9 @@ import os from flask import Blueprint,request,render_template,jsonify,make_response from controllers.service import storage_service,rules_service from base.R import R +from base.database import db +from utils.log import logger +import shutil from utils.update import getLocalVer,getOnlineVer,download_new_version,download_lives,copy_to_update from utils import parser from utils.web import getParmas,verfy_token @@ -97,12 +100,17 @@ def admin_update_db(): if not verfy_token(): # return render_template('login.html') return R.error('请登录后再试') + old_dbfile = 'migrations' + if os.path.exists(old_dbfile): + logger.info(f'开始删除历史数据库迁移文件:{old_dbfile}') + shutil.rmtree(old_dbfile) + db.session.execute('drop table if exists alembic_version') cmd = 'flask db migrate && flask db upgrade' if not os.path.exists('migrations'): cmd = 'flask db init && '+cmd - print(f'开始执行cmd:{cmd}') + logger.info(f'开始执行cmd:{cmd}') result = os.system(cmd) - print(f'cmd执行结果:{result}') + logger.info(f'cmd执行结果:{result}') return R.success('数据库升级完毕') @admin.route('/update_ver') diff --git a/controllers/home.py b/controllers/home.py index 099c24a413dd6b557e3cbc4d884f963d1743e875..68d6c791ad84e44486e260e2f36bdc9bdac82df9 100644 --- a/controllers/home.py +++ b/controllers/home.py @@ -254,21 +254,22 @@ def config_gen(): # print(set_local) set_area = render_template('config.txt',pys=pys,rules=rules,alists=alists,alists_str=alists_str,live_url=get_live_url(new_conf,1),mode=1,host=getHost(1),jxs=jxs) set_online = render_template('config.txt',pys=pys,rules=rules,alists=alists,alists_str=alists_str,live_url=get_live_url(new_conf,2),mode=1,host=getHost(2),jxs=jxs) + ali_token = new_conf.ALI_TOKEN with open('txt/pycms0.json','w+',encoding='utf-8') as f: - customConfig = getCustonDict(getHost(0)) + customConfig = getCustonDict(getHost(0),ali_token) set_dict = custom_merge(parseText(set_local), customConfig) merged_hide(set_dict) # set_dict = json.loads(set_local) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) with open('txt/pycms1.json','w+',encoding='utf-8') as f: - customConfig = getCustonDict(getHost(1)) + customConfig = getCustonDict(getHost(1),ali_token) set_dict = custom_merge(parseText(set_area), customConfig) merged_hide(set_dict) # set_dict = json.loads(set_area) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) with open('txt/pycms2.json','w+',encoding='utf-8') as f: - customConfig = getCustonDict(getHost(2)) + customConfig = getCustonDict(getHost(2),ali_token) set_dict = custom_merge(parseText(set_online), customConfig) merged_hide(set_dict) # set_dict = json.loads(set_online) diff --git a/js/version.txt b/js/version.txt index 47b6be3fafeca7189c78e02514ed4decdd310d16..50d98542ab72e62d6d7be6638f75a22ff99837f1 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.7.2 \ No newline at end of file +3.7.3 \ No newline at end of file diff --git a/readme.md b/readme.md index 0e0b2b025210f3e943574957b2907391bee99bea..32552978c902cc0f234c0f817d696a3630c90811 100644 --- a/readme.md +++ b/readme.md @@ -46,6 +46,8 @@ [dockerfile教程](https://blog.csdn.net/qq_46158060/article/details/125718218) [获取本地设备信息](https://blog.csdn.net/cui_yonghua/article/details/125508991) [获取本地设备信息](https://m.jb51.net/article/140716.htm) +###### 2022/09/22 +- [X] 1.v3.7.3修复静态文件阿里token没渲染的bug,修复数据库升级bug,优化app.py ###### 2022/09/21 - [X] 1.未来功能增加显示和隐藏多选规则的实际逻辑,增加顺序字段等待有缘人 - [X] 2.版本升级至3.7.0 diff --git a/templates/settings.html b/templates/settings.html index 414595cfc5f86798ba814b5f2f601f07f61f768c..a58e58822a57597ad1636725a92732d76cde4afc 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -47,7 +47,7 @@ console.log(this); }); $('#update_db').click(function (){ - if(confirm('确定要升级数据库?判断标准为是否正常打开缓存文件列表-查看界面,如果正常就不需要进行此操作。升级数据库后将正常使用未来功能多选操作,可对规则进行多选显示或者隐藏')){ + if(confirm('确定要升级数据库?升级过程可能较长,需要耐心等待提示完成。判断标准为是否正常打开缓存文件列表-查看界面,如果正常就不需要进行此操作。升级数据库后将正常使用未来功能多选操作,可对规则进行多选显示或者隐藏')){ $.get("/admin/update_db",function(data,status){ console.log(data); if(data.code === 200){