mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -76,7 +76,9 @@ with app.app_context():
|
|||||||
|
|
||||||
# 初始化用户信息
|
# 初始化用户信息
|
||||||
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
|
@app.before_request
|
||||||
def requestCheck():
|
def requestCheck():
|
||||||
print("hh")
|
# print("hh")
|
||||||
|
pass
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def requestAfter(response):
|
def requestAfter(response):
|
||||||
@@ -107,7 +110,9 @@ def page_unauthorized(error):
|
|||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_global_variables():
|
def inject_global_variables():
|
||||||
config = {
|
config = {
|
||||||
'version': setting.APP_VERSION
|
'version': setting.APP_VERSION,
|
||||||
|
'title' : '面板',
|
||||||
|
'ip' : '127.0.0.1'
|
||||||
}
|
}
|
||||||
return dict(config=config)
|
return dict(config=config)
|
||||||
|
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class Tasks(db.Model):
|
|||||||
id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID")
|
id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID")
|
||||||
name = db.Column(db.TEXT, unique=False, nullable=False, comment="任务名称")
|
name = db.Column(db.TEXT, unique=False, nullable=False, comment="任务名称")
|
||||||
type = 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="开始执行时间")
|
start = db.Column(db.Integer(), unique=False, nullable=True, comment="开始执行时间")
|
||||||
end = 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="状态")
|
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 os
|
||||||
|
import json
|
||||||
|
|
||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
from flask import request
|
from flask import request
|
||||||
@@ -18,7 +19,7 @@ from admin.user_login_check import panel_login_required
|
|||||||
|
|
||||||
import core.mw as mw
|
import core.mw as mw
|
||||||
|
|
||||||
pg = MwPlugin.instance()
|
|
||||||
|
|
||||||
blueprint = Blueprint('plugins', __name__, url_prefix='/plugins', template_folder='../../templates/default')
|
blueprint = Blueprint('plugins', __name__, url_prefix='/plugins', template_folder='../../templates/default')
|
||||||
@blueprint.route('/index', endpoint='index')
|
@blueprint.route('/index', endpoint='index')
|
||||||
@@ -37,7 +38,28 @@ def init():
|
|||||||
'mysql': '5.7',
|
'mysql': '5.7',
|
||||||
'phpmyadmin': '4.4.15',
|
'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'])
|
@blueprint.route('/index_list', endpoint='index_list', methods=['GET','POST'])
|
||||||
@@ -60,9 +82,41 @@ def list():
|
|||||||
if not mw.isNumber(page):
|
if not mw.isNumber(page):
|
||||||
page = 0
|
page = 0
|
||||||
|
|
||||||
# pg.getList(plugins_type, search, int(page))
|
pg = MwPlugin.instance()
|
||||||
return pg.getList(plugins_type, search, int(page))
|
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'])
|
@blueprint.route('/file', endpoint='file', methods=['GET'])
|
||||||
@panel_login_required
|
@panel_login_required
|
||||||
|
|||||||
+10
-1
@@ -11,7 +11,7 @@
|
|||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
from admin.model import db, Users
|
from admin.model import db, Users
|
||||||
|
import admin.model.option as option
|
||||||
import core.mw as mw
|
import core.mw as mw
|
||||||
|
|
||||||
# 初始化用户信息
|
# 初始化用户信息
|
||||||
@@ -36,4 +36,13 @@ def init_admin_user():
|
|||||||
db.session.add(add_user)
|
db.session.add(add_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
db.session.close()
|
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
|
return True
|
||||||
+1
-1
@@ -89,7 +89,7 @@ def getPanelTmp():
|
|||||||
|
|
||||||
|
|
||||||
def getServerDir():
|
def getServerDir():
|
||||||
return getRunDir() + '/server'
|
return getFatherDir() + '/server'
|
||||||
|
|
||||||
def getLogsDir():
|
def getLogsDir():
|
||||||
return getRunDir() + '/wwwlogs'
|
return getRunDir() + '/wwwlogs'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="renderer" content="webkit">
|
<meta name="renderer" content="webkit">
|
||||||
<title>{{data['title']}}</title>
|
<title>{{config['title']}}</title>
|
||||||
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
|
<link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
|
||||||
<link href="/static/bootstrap-3.3.5/css/bootstrap.min.css?v={{config.version}}" rel="stylesheet">
|
<link href="/static/bootstrap-3.3.5/css/bootstrap.min.css?v={{config.version}}" rel="stylesheet">
|
||||||
<link href="/static/css/site.css?v={{config.version}}" rel="stylesheet">
|
<link href="/static/css/site.css?v={{config.version}}" rel="stylesheet">
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="sidebar-scroll">
|
<div class="sidebar-scroll">
|
||||||
<div class="sidebar-auto">
|
<div class="sidebar-auto">
|
||||||
<div id="task" class="task cw" onclick="messageBox();"></div>
|
<div id="task" class="task cw" onclick="messageBox();"></div>
|
||||||
<h3 class="mypcip"><span class="f14 cw">{{data['ip']}}</span></h3>
|
<h3 class="mypcip"><span class="f14 cw">{{config['ip']}}</span></h3>
|
||||||
<ul class="menu">
|
<ul class="menu">
|
||||||
<li id="memuA"><a class="menu_home" href="/">首页</a></li>
|
<li id="memuA"><a class="menu_home" href="/">首页</a></li>
|
||||||
<li id="memuAsite"><a class="menu_web" href="/site/index">网站</a></li>
|
<li id="memuAsite"><a class="menu_web" href="/site/index">网站</a></li>
|
||||||
|
|||||||
+35
-8
@@ -11,12 +11,12 @@
|
|||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import json
|
import json
|
||||||
import core.mw as mw
|
|
||||||
|
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
import core.mw as mw
|
||||||
|
import admin.model.option as option
|
||||||
|
|
||||||
class pa_thread(threading.Thread):
|
class pa_thread(threading.Thread):
|
||||||
|
|
||||||
def __init__(self, func, args, name=''):
|
def __init__(self, func, args, name=''):
|
||||||
@@ -105,10 +105,7 @@ class MwPlugin(object):
|
|||||||
self.__index_data = json.loads(mw.readFile(self.__index))
|
self.__index_data = json.loads(mw.readFile(self.__index))
|
||||||
|
|
||||||
def getIndexList(self):
|
def getIndexList(self):
|
||||||
if not os.path.exists(self.__index):
|
indexList = option.getOptionByJson('display_index')
|
||||||
mw.writeFile(self.__index, '[]')
|
|
||||||
|
|
||||||
indexList = json.loads(mw.readFile(self.__index))
|
|
||||||
plist = []
|
plist = []
|
||||||
for i in indexList:
|
for i in indexList:
|
||||||
tmp = i.split('-')
|
tmp = i.split('-')
|
||||||
@@ -144,6 +141,36 @@ class MwPlugin(object):
|
|||||||
plist = self.checkStatusMThreads(plist)
|
plist = self.checkStatusMThreads(plist)
|
||||||
return plist
|
return plist
|
||||||
|
|
||||||
|
def addIndex(self, name, version):
|
||||||
|
vname = name + '-' + version
|
||||||
|
indexList = option.getOptionByJson('display_index')
|
||||||
|
if vname in indexList:
|
||||||
|
return mw.returnData(False, '请不要重复添加!')
|
||||||
|
if len(indexList) > 12:
|
||||||
|
return mw.returnData(False, '首页最多只能显示12个软件!')
|
||||||
|
|
||||||
|
indexList.append(vname)
|
||||||
|
option.setOption('display_index', json.dumps(indexList))
|
||||||
|
return mw.returnData(True, '添加成功!')
|
||||||
|
|
||||||
|
def removeIndex(self, name, version):
|
||||||
|
vname = name + '-' + version
|
||||||
|
indexList = option.getOptionByJson('display_index')
|
||||||
|
if not vname in indexList:
|
||||||
|
return mw.returnData(True, '删除成功!!')
|
||||||
|
indexList.remove(vname)
|
||||||
|
|
||||||
|
print(indexList)
|
||||||
|
option.setOption('display_index', json.dumps(indexList))
|
||||||
|
return mw.returnData(True, '删除成功!')
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 卸载插件
|
||||||
|
def uninstall(self):
|
||||||
|
pass
|
||||||
|
|
||||||
# 插件搜索匹配
|
# 插件搜索匹配
|
||||||
def searchKey(self, info,
|
def searchKey(self, info,
|
||||||
keyword: str | None = None,
|
keyword: str | None = None,
|
||||||
@@ -167,7 +194,7 @@ class MwPlugin(object):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
def checkIndexList(self, name, version):
|
def checkIndexList(self, name, version):
|
||||||
indexList = self.__index_data
|
indexList = option.getOptionByJson('display_index')
|
||||||
for i in indexList:
|
for i in indexList:
|
||||||
t = i.split('-')
|
t = i.split('-')
|
||||||
if t[0] == name:
|
if t[0] == name:
|
||||||
|
|||||||
Reference in New Issue
Block a user