mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 01:29:26 +08:00
update
This commit is contained in:
@@ -76,7 +76,9 @@ with app.app_context():
|
||||
|
||||
# 初始化用户信息
|
||||
with app.app_context():
|
||||
setup.init_admin_user()
|
||||
if setup_db_required:
|
||||
setup.init_admin_user()
|
||||
setup.init_option()
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +91,8 @@ for module in get_submodules():
|
||||
|
||||
@app.before_request
|
||||
def requestCheck():
|
||||
print("hh")
|
||||
# print("hh")
|
||||
pass
|
||||
|
||||
@app.after_request
|
||||
def requestAfter(response):
|
||||
@@ -107,7 +110,9 @@ def page_unauthorized(error):
|
||||
@app.context_processor
|
||||
def inject_global_variables():
|
||||
config = {
|
||||
'version': setting.APP_VERSION
|
||||
'version': setting.APP_VERSION,
|
||||
'title' : '面板',
|
||||
'ip' : '127.0.0.1'
|
||||
}
|
||||
return dict(config=config)
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ class Tasks(db.Model):
|
||||
id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID")
|
||||
name = db.Column(db.TEXT, unique=False, nullable=False, comment="任务名称")
|
||||
type = db.Column(db.TEXT, unique=False, nullable=False, comment="域名")
|
||||
execstr = db.Column(db.TEXT, unique=False, nullable=False, comment="返回内容")
|
||||
execstr = db.Column(db.TEXT, unique=False, nullable=False, comment="执行命令")
|
||||
start = db.Column(db.Integer(), unique=False, nullable=True, comment="开始执行时间")
|
||||
end = db.Column(db.Integer(), unique=False, nullable=True, comment="结束执行时间")
|
||||
status = db.Column(db.Integer(), unique=False, nullable=True, default=1, comment="状态")
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
import json
|
||||
|
||||
from admin.model import db, Option
|
||||
import core.mw as mw
|
||||
|
||||
def getOption(name, type='common') -> str:
|
||||
data = Option.query.filter_by(name=name, type=type).first()
|
||||
if data is not None:
|
||||
return data.value
|
||||
return ''
|
||||
|
||||
def getOptionByJson(name, type='common') -> object:
|
||||
data = Option.query.filter_by(name=name, type=type).first()
|
||||
if data is not None:
|
||||
return json.loads(data.value)
|
||||
return []
|
||||
|
||||
def setOption(name, value, type='common') -> bool:
|
||||
data = Option.query.filter_by(name=name, type=type).first()
|
||||
if data is None:
|
||||
add_option = Option(
|
||||
name=name,
|
||||
type=type,
|
||||
value=value)
|
||||
db.session.add(add_option)
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
return True
|
||||
|
||||
db.session.query(Option).filter_by(name=name, type=type).update({"value":value})
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
return True
|
||||
@@ -9,6 +9,7 @@
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
from flask import request
|
||||
@@ -18,7 +19,7 @@ from admin.user_login_check import panel_login_required
|
||||
|
||||
import core.mw as mw
|
||||
|
||||
pg = MwPlugin.instance()
|
||||
|
||||
|
||||
blueprint = Blueprint('plugins', __name__, url_prefix='/plugins', template_folder='../../templates/default')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
@@ -37,7 +38,28 @@ def init():
|
||||
'mysql': '5.7',
|
||||
'phpmyadmin': '4.4.15',
|
||||
}
|
||||
return []
|
||||
|
||||
pn_dir = mw.getPluginDir()
|
||||
pn_server_dir = mw.getServerDir()
|
||||
pn_list = []
|
||||
for pn in plugin_names:
|
||||
info = {}
|
||||
pn_json = pn_dir + '/' + pn + '/info.json'
|
||||
pn_server = pn_server_dir + '/' + pn
|
||||
if not os.path.exists(pn_server):
|
||||
|
||||
tmp = mw.readFile(pn_json)
|
||||
tmp = json.loads(tmp)
|
||||
|
||||
info['title'] = tmp['title']
|
||||
info['name'] = tmp['name']
|
||||
info['versions'] = tmp['versions']
|
||||
info['default_ver'] = plugin_names[pn]
|
||||
pn_list.append(info)
|
||||
else:
|
||||
return mw.returnData(False, 'ok')
|
||||
|
||||
return mw.returnData(True, 'ok', pn_list)
|
||||
|
||||
# 首页软件展示
|
||||
@blueprint.route('/index_list', endpoint='index_list', methods=['GET','POST'])
|
||||
@@ -60,9 +82,41 @@ def list():
|
||||
if not mw.isNumber(page):
|
||||
page = 0
|
||||
|
||||
# pg.getList(plugins_type, search, int(page))
|
||||
pg = MwPlugin.instance()
|
||||
return pg.getList(plugins_type, search, int(page))
|
||||
|
||||
# 插件设置是否在首页展示
|
||||
@blueprint.route('/set_index', endpoint='set_index', methods=['POST'])
|
||||
@panel_login_required
|
||||
def set_index():
|
||||
name = request.form.get('name', '')
|
||||
status = request.form.get('status', '0')
|
||||
version = request.form.get('version', '')
|
||||
|
||||
pg = MwPlugin.instance()
|
||||
if status == '1':
|
||||
return pg.addIndex(name, version)
|
||||
return pg.removeIndex(name, version)
|
||||
|
||||
# 插件卸载
|
||||
@blueprint.route('/uninstall', endpoint='uninstall', methods=['POST'])
|
||||
@panel_login_required
|
||||
def uninstall():
|
||||
rundir = mw.getRunDir()
|
||||
name = request.form.get('name', '')
|
||||
version = request.form.get('version', '')
|
||||
|
||||
if name.strip() == '':
|
||||
return mw.returnData(False, '缺少插件名称!', ())
|
||||
|
||||
if version.strip() == '':
|
||||
return mw.returnData(False, '缺少版本信息!', ())
|
||||
|
||||
pg = MwPlugin.instance()
|
||||
|
||||
# pg.getList(plugins_type, search, int(page))
|
||||
return []
|
||||
|
||||
# 文件读取
|
||||
@blueprint.route('/file', endpoint='file', methods=['GET'])
|
||||
@panel_login_required
|
||||
|
||||
+10
-1
@@ -11,7 +11,7 @@
|
||||
from flask import request
|
||||
|
||||
from admin.model import db, Users
|
||||
|
||||
import admin.model.option as option
|
||||
import core.mw as mw
|
||||
|
||||
# 初始化用户信息
|
||||
@@ -36,4 +36,13 @@ def init_admin_user():
|
||||
db.session.add(add_user)
|
||||
db.session.commit()
|
||||
db.session.close()
|
||||
return True
|
||||
|
||||
def init_option():
|
||||
option.setOption('title', '后羿面板')
|
||||
option.setOption('recycle_bin', 'open')
|
||||
option.setOption('template', 'default')
|
||||
|
||||
# 首页展示初始化
|
||||
option.setOption('display_index', '[]')
|
||||
return True
|
||||
Reference in New Issue
Block a user