diff --git a/base/rules.db b/base/rules.db index 10d981c8dcb96fd840ee1887ff554e8279f1d79d..4d1275e2d0045d1bbefdccfa5997d595275a7c2e 100644 Binary files a/base/rules.db and b/base/rules.db differ diff --git a/controllers/admin.py b/controllers/admin.py index 6d8e473a8d0c894c7cbf9e9533126e4a284eb709..406f944da7cd0aa999f223e46780204edb254520 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -93,6 +93,19 @@ def admin_get_ver(): online_ver,msg = getOnlineVer() return jsonify({'local_ver':getLocalVer(),'online_ver':online_ver,'msg':msg}) +@admin.route('/update_db') +def admin_update_db(): + if not verfy_token(): + # return render_template('login.html') + return R.error('请登录后再试') + cmd = 'flask db migrate && flask db upgrade' + if not os.path.exists('migrations'): + cmd = 'flask db init && '+cmd + print(f'开始执行cmd:{cmd}') + result = os.system(cmd) + print(f'cmd执行结果:{result}') + return R.success('数据库升级完毕') + @admin.route('/update_ver') def admin_update_ver(): if not verfy_token(): diff --git a/models/ruleclass.py b/models/ruleclass.py index fbe1e4ea244f3bfbe2df4173018ff72e54b287d6..f27578c9738b544321b88bd72f703b3600b90692 100644 --- a/models/ruleclass.py +++ b/models/ruleclass.py @@ -5,6 +5,7 @@ # Date : 2022/9/6 from base.database import db +from datetime import datetime class RuleClass(db.Model): __tablename__ = 'rule_class' @@ -13,6 +14,10 @@ class RuleClass(db.Model): class_name = db.Column(db.String(255)) class_url = db.Column(db.String(255)) cookie = db.Column(db.String(255)) + state = db.Column(db.Integer, default=0) + order = db.Column(db.Integer, default=0) + create_date = db.Column(db.DateTime, index=True, default=datetime.now) + write_date = db.Column(db.DateTime, index=True, default=datetime.now,onupdate=datetime.now) def __repr__(self): return "" % ( diff --git a/templates/settings.html b/templates/settings.html index 6f46de38f3bd01d04a6c32fb012dceb08ef0273e..5323e4aad6cbf0a3f78f849f22265785f49d5427 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -46,6 +46,19 @@ $(".save_conf1").click(function () { console.log(this); }); + $('#update_db').click(function (){ + $.get("/admin/update_db",function(data,status){ + console.log(data); + if(data.code === 200){ + alert(data.msg); + // location.reload(); + }else{ + alert(data.msg); + console.log('升级失败了...'); + return false + } + }); + }); });

欢迎使用DR-PY配置界面
当前版本: {{ ver }} +