mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -28,7 +28,7 @@ from admin.model import db as sys_db
|
||||
from admin import setup
|
||||
|
||||
import core.mw as mw
|
||||
import setting
|
||||
import config
|
||||
import utils.config as utils_config
|
||||
|
||||
root_dir = mw.getRunDir()
|
||||
@@ -56,7 +56,7 @@ app.config['SESSION_COOKIE_NAME'] = "MW_VER_1"
|
||||
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=31)
|
||||
|
||||
# db的配置
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+setting.SQLITE_PATH # 使用 SQLite 数据库
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = mw.getSqitePrefix()+config.SQLITE_PATH # 使用 SQLite 数据库
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ Migrate(app, sys_db)
|
||||
|
||||
# 检查数据库是否存在。如果没有就创建它。
|
||||
setup_db_required = False
|
||||
if not os.path.isfile(setting.SQLITE_PATH):
|
||||
if not os.path.isfile(config.SQLITE_PATH):
|
||||
setup_db_required = True
|
||||
|
||||
# with app.app_context():
|
||||
@@ -98,8 +98,8 @@ def requestCheck():
|
||||
|
||||
@app.after_request
|
||||
def requestAfter(response):
|
||||
response.headers['soft'] = setting.APP_NAME
|
||||
response.headers['mw-version'] = setting.APP_VERSION
|
||||
response.headers['soft'] = config.APP_NAME
|
||||
response.headers['mw-version'] = config.APP_VERSION
|
||||
return response
|
||||
|
||||
|
||||
@@ -111,17 +111,17 @@ def page_unauthorized(error):
|
||||
# 设置模板全局变量
|
||||
@app.context_processor
|
||||
def inject_global_variables():
|
||||
ver = setting.APP_VERSION;
|
||||
ver = config.APP_VERSION;
|
||||
if mw.isDebugMode():
|
||||
ver = ver + str(time.time())
|
||||
|
||||
data = utils_config.getGlobalVar()
|
||||
config = {
|
||||
g_config = {
|
||||
'version': ver,
|
||||
'title' : '面板',
|
||||
'ip' : '127.0.0.1'
|
||||
}
|
||||
return dict(config=config, data=data)
|
||||
return dict(config=g_config, data=data)
|
||||
|
||||
|
||||
# from flasgger import Swagger
|
||||
@@ -172,7 +172,7 @@ def inject_global_variables():
|
||||
|
||||
# Log the startup
|
||||
app.logger.info('########################################################')
|
||||
app.logger.info('Starting %s v%s...', setting.APP_NAME, setting.APP_VERSION)
|
||||
app.logger.info('Starting %s v%s...', config.APP_NAME, config.APP_VERSION)
|
||||
app.logger.info('########################################################')
|
||||
app.logger.debug("Python syspath: %s", sys.path)
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ def get_log_list():
|
||||
if search != '':
|
||||
pagination = Logs.query.filter_by(Logs.type.like(search) or Logs.log.like(search)).paginate(page=int(p), per_page=int(size))
|
||||
else:
|
||||
pagination = Logs.query.filter_by().paginate(page=int(p), per_page=int(size))
|
||||
pagination = Logs.query.filter_by().order_by(Logs.id.desc()).paginate(page=int(p), per_page=int(size))
|
||||
|
||||
rows = []
|
||||
for item in pagination.items:
|
||||
|
||||
@@ -13,6 +13,7 @@ from .initdb import *
|
||||
from .logs import addLog
|
||||
from .option import getOption,getOptionByJson,setOption
|
||||
from .sites import getSitesCount
|
||||
from .task import getTaskCount
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
# from flask_security import UserMixin, RoleMixin
|
||||
import setting
|
||||
import config
|
||||
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
|
||||
db = SQLAlchemy(
|
||||
engine_options={
|
||||
'pool_size': setting.CONFIG_DATABASE_CONNECTION_POOL_SIZE,
|
||||
'max_overflow': setting.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW
|
||||
'pool_size': config.CONFIG_DATABASE_CONNECTION_POOL_SIZE,
|
||||
'max_overflow': config.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW
|
||||
}
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ class Logs(db.Model):
|
||||
"""定义日志"""
|
||||
__tablename__ = 'logs'
|
||||
id = db.Column(db.Integer(), primary_key=True,autoincrement=True, comment="ID")
|
||||
uid = db.Column(db.Integer(), unique=True, nullable=False, comment="用户ID")
|
||||
uid = db.Column(db.Integer(), unique=False, nullable=False, comment="用户ID")
|
||||
type = db.Column(db.String(128), unique=False, nullable=False, comment="日志类型")
|
||||
log = db.Column(db.TEXT, unique=False, nullable=True, comment="日志内容")
|
||||
add_time = db.Column(db.TEXT, nullable=False, comment="添加时间")
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
from admin.model import db, Tasks
|
||||
|
||||
|
||||
|
||||
def getTaskCount(
|
||||
status: str | None = None
|
||||
) -> int:
|
||||
|
||||
return Tasks.query.filter_by().count()
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
from flask import Blueprint, render_template
|
||||
|
||||
blueprint = Blueprint('control', __name__, url_prefix='/control', template_folder='../../templates/default')
|
||||
blueprint = Blueprint('monitor', __name__, url_prefix='/monitor', template_folder='../../templates/default')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
def index():
|
||||
return render_template('control.html',)
|
||||
return render_template('monitor.html',)
|
||||
@@ -16,10 +16,10 @@ from admin import model
|
||||
import core.mw as mw
|
||||
|
||||
# 默认页面
|
||||
blueprint = Blueprint('config', __name__, url_prefix='/config', template_folder='../../templates')
|
||||
blueprint = Blueprint('setting', __name__, url_prefix='/setting', template_folder='../../templates')
|
||||
@blueprint.route('/index', endpoint='index')
|
||||
def index():
|
||||
return render_template('default/config.html')
|
||||
return render_template('default/setting.html')
|
||||
|
||||
|
||||
|
||||
@@ -37,3 +37,12 @@ def set_webname():
|
||||
model.setOption('title', webname)
|
||||
return mw.returnData(True, '面板别名保存成功!')
|
||||
|
||||
@blueprint.route('/set_ip', endpoint='set_ip', methods=['POST'])
|
||||
def set_ip():
|
||||
host_ip = request.form.get('host_ip', '')
|
||||
src_host_ip = model.getOption('server_ip')
|
||||
if host_ip != src_host_ip:
|
||||
model.setOption('server_ip', host_ip)
|
||||
return mw.returnJson(True, 'IP保存成功!')
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
from .dashboard import blueprint as DashboardModule
|
||||
from .site import blueprint as SiteModule
|
||||
from .task import blueprint as TaskModule
|
||||
from .config import blueprint as ConfigModule
|
||||
from .setting import blueprint as SettingModule
|
||||
from .logs import blueprint as LogsModule
|
||||
from .files import blueprint as FilesModule
|
||||
from .soft import blueprint as SoftModule
|
||||
from .plugins import blueprint as PluginsModule
|
||||
from .crontab import blueprint as CrontabModule
|
||||
from .firewall import blueprint as FirewallModule
|
||||
from .control import blueprint as ControlModule
|
||||
from .monitor import blueprint as MonitorModule
|
||||
from .system import blueprint as SystemModule
|
||||
|
||||
def get_submodules():
|
||||
@@ -33,7 +33,7 @@ def get_submodules():
|
||||
PluginsModule,
|
||||
CrontabModule,
|
||||
FirewallModule,
|
||||
ControlModule,
|
||||
MonitorModule,
|
||||
SystemModule,
|
||||
ConfigModule,
|
||||
SettingModule,
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user