Skip to content

Commit

Permalink
gorse便捷功能
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Dec 21, 2024
1 parent 90850eb commit ca61f70
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/gorse/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<p class="bgw" onclick="pluginService('gorse');">服务</p>
<p onclick="pluginInitD('gorse');">自启动</p>
<p onclick="pluginConfigTpl('gorse',$('.plugin_version').attr('version'));">配置修改</p>
<p onclick="gorseCommonFunc();">常用功能</p>
<p onclick="pluginLogs('gorse','','run_log');">运行日志</p>
<p onclick="gorseReadme();">相关说明</p>

Expand Down
30 changes: 30 additions & 0 deletions plugins/gorse/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,34 @@ def initdUinstall():
def runLog():
return getServerDir() + '/logs.pl'

def getGorseInfo():
conf_file = getConf()
content = mw.readFile(conf_file)

rdata = {}

rep = r'dashboard_user_name\s*=\s*"(.*)"'
tmp = re.search(rep, content)
tmp = re.search(rep, content, re.M)
if tmp:
rdata['dashboard_user_name'] = tmp.groups()[0]


rep = r'dashboard_password\s*=\s*"(.*)"'
tmp = re.search(rep, content)
tmp = re.search(rep, content, re.M)
if tmp:
rdata['dashboard_password'] = tmp.groups()[0]

rep = r'http_port\s*=\s*(.*)'
tmp = re.search(rep, content)
tmp = re.search(rep, content, re.M)
if tmp:
rdata['http_port'] = tmp.groups()[0]

rdata['ip'] = mw.getHostAddr()
return mw.returnJson(True,'ok', rdata)

def installPreInspection():
redis_path = mw.getServerDir() + "/redis"
if not os.path.exists(redis_path):
Expand Down Expand Up @@ -347,5 +375,7 @@ def installPreInspection():
print(configTpl())
elif func == 'read_config_tpl':
print(readConfigTpl())
elif func == 'info':
print(getGorseInfo())
else:
print('error')
32 changes: 31 additions & 1 deletion plugins/gorse/js/gorse.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,38 @@ function gorsePostCallbak(method, version, args,callback){
}


function gorseReadme(){
function gorseCommonFunc(){
gorsePost('info', '', {}, function(rdata){
var rdata = $.parseJSON(rdata.data);
var info = rdata['data'];
var con = '<p class="conf_p">\
<span>用户名</span>\
<input class="bt-input-text mr5" type="text" value="' + info.dashboard_user_name + '">\
</p>';

con += '<p class="conf_p">\
<span>密码</span>\
<input class="bt-input-text mr5" type="text" value="' + info.dashboard_password +'">\
</p>';
con += '<p class="conf_p">\
<span>端口</span>\
<input class="bt-input-text mr5" type="text" value="' + info.http_port +'">\
</p>';

con += '<hr/><p class="conf_p" style="text-align:center;">\
<button id="open_url" class="btn btn-default btn-sm">打开Gorse</button>\
</p>';

$(".soft-man-con").html(con);
$('#open_url').click(function(){
var url = 'http://' + info.ip + ':' + info.http_port;
window.open(url);
copyText(url);
});
});
}

function gorseReadme(){

var readme = '<ul class="help-info-text c7">';
readme += '<li>参考官方</li>';
Expand Down

0 comments on commit ca61f70

Please sign in to comment.