From 6df4bbdb680b2370c473aba7ef3a9858fa032364 Mon Sep 17 00:00:00 2001
From: midoks
Date: Sat, 19 Nov 2022 12:33:42 +0800
Subject: [PATCH] up
---
class/core/config_api.py | 12 ++++++++++++
class/core/mw.py | 11 +++++++----
route/static/app/config.js | 21 +++++++++++++++++++++
route/templates/default/config.html | 8 +++++---
4 files changed, 45 insertions(+), 7 deletions(-)
diff --git a/class/core/config_api.py b/class/core/config_api.py
index 1b69459e7..558ef9c35 100755
--- a/class/core/config_api.py
+++ b/class/core/config_api.py
@@ -158,6 +158,18 @@ class config_api:
mw.setHostAddr(host_ip)
return mw.returnJson(True, 'IP保存成功!')
+ def setWwwDirApi(self):
+ sites_path = request.form.get('sites_path', '')
+ if sites_path != mw.getWwwDir():
+ mw.setWwwDir(sites_path)
+ return mw.returnJson(True, '修改默认建站目录成功!')
+
+ def setBackupDirApi(self):
+ backup_path = request.form.get('backup_path', '')
+ if backup_path != mw.getBackupDir():
+ mw.setBackupDir(backup_path)
+ return mw.returnJson(True, '修改默认备份目录成功!')
+
def setApi(self):
webname = request.form.get('webname', '')
port = request.form.get('port', '')
diff --git a/class/core/mw.py b/class/core/mw.py
index dbb062e31..dcb79e8cc 100755
--- a/class/core/mw.py
+++ b/class/core/mw.py
@@ -88,10 +88,6 @@ def getLogsDir():
return getRootDir() + '/wwwlogs'
-def getBackupDir():
- return getRootDir() + '/backup'
-
-
def getWwwDir():
file = getRunDir() + '/data/site.pl'
if os.path.exists(file):
@@ -104,6 +100,13 @@ def setWwwDir(wdir):
return writeFile(file, wdir)
+def getBackupDir():
+ file = getRunDir() + '/data/backup.pl'
+ if os.path.exists(file):
+ return readFile(file).strip()
+ return getRootDir() + '/backup'
+
+
def setBackupDir(bdir):
file = getRunDir() + '/data/backup.pl'
return writeFile(file, bdir)
diff --git a/route/static/app/config.js b/route/static/app/config.js
index 5430f85fb..2b463bef8 100755
--- a/route/static/app/config.js
+++ b/route/static/app/config.js
@@ -49,6 +49,27 @@ $('input[name="port"]').change(function(){
});
});
+$('input[name="sites_path"]').change(function(){
+ var sites_path = $(this).val();
+ $('.btn_sites_path').removeAttr('disabled');
+ $('.btn_sites_path').unbind().click(function(){
+ $.post('/config/set_www_dir','sites_path='+sites_path, function(rdata){
+ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
+ },'json');
+ });
+});
+
+
+$('input[name="backup_path"]').change(function(){
+ var backup_path = $(this).val();
+ $('.backup_path').removeAttr('disabled');
+ $('.btn_sites_path').unbind().click(function(){
+ $.post('/config/set_backup_dir','backup_path='+backup_path, function(rdata){
+ showMsg(rdata.msg,function(){window.location.reload();},{icon:rdata.status?1:2},2000);
+ },'json');
+ });
+});
+
/** op **/
diff --git a/route/templates/default/config.html b/route/templates/default/config.html
index 18c1180b2..bc05590e5 100755
--- a/route/templates/default/config.html
+++ b/route/templates/default/config.html
@@ -64,14 +64,14 @@
服务器IP
-
+
默认为外网IP,若您在本地虚拟机测试,请填写虚拟机内网IP!
面板端口
-
+
建议端口范围7200 - 65535
@@ -93,12 +93,14 @@
默认建站目录
+
新创建的站点,默认将保存到该目录的下级目录!
默认备份目录
+
网站和数据库的备份目录!
@@ -121,7 +123,7 @@
设置面板密码
- 保存
+