diff --git a/web/admin/site/proxy.py b/web/admin/site/proxy.py index 83d29f78d..2574a681e 100644 --- a/web/admin/site/proxy.py +++ b/web/admin/site/proxy.py @@ -42,10 +42,11 @@ def set_proxy(): host = request.form.get('host', '') name = request.form.get('name', '') open_proxy = request.form.get('open_proxy', '') + open_cors = request.form.get('open_cors','') open_cache = request.form.get('open_cache', '') cache_time = request.form.get('cache_time', '') proxy_id = request.form.get('id', '') - return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy, open_cache,cache_time, proxy_id) + return MwSites.instance().setProxy(site_name,site_from,to,host,name,open_proxy,open_cors,open_cache,cache_time, proxy_id) # 设置代理状态 @blueprint.route('/set_proxy_status', endpoint='set_proxy_status', methods=['POST']) diff --git a/web/static/app/site.js b/web/static/app/site.js index b3d35aeef..00ac4d4fe 100755 --- a/web/static/app/site.js +++ b/web/static/app/site.js @@ -1617,15 +1617,20 @@ function toProxy(siteName, type, obj) { btn: ['提交','关闭'], content: "
\
\ - 开启代理\ + 开启代理\
\ \ \
\ - 是否缓存\ + 是否缓存\ \ \
\ +
\ + 是否跨域\ + \ + \ +
\
\
\
\ @@ -1666,13 +1671,21 @@ function toProxy(siteName, type, obj) { success:function(){ if (typeof(obj) != 'undefined'){ - // console.log(obj); + console.log(obj); $('input[name="name"]').val(obj['name']).attr('readonly','readonly').addClass('disabled'); if (obj['open_cache'] == 'on'){ $("input[name='open_cache']").prop("checked",true); $('#cache_time').show(); } + if (obj['open_cors'] == 'on'){ + $("input[name='open_cors']").prop("checked",true); + } + + if (obj['open_proxy'] == 'on'){ + $("input[name='open_proxy']").prop("checked",true); + } + $('input[name="from"]').val(obj['from']); $('input[name="to"]').val(obj['to']); @@ -1722,6 +1735,15 @@ function toProxy(siteName, type, obj) { $("input[name='open_cache']").prop("checked",true); } }); + + $('#open_cors').click(function(){ + var status = $("input[name='open_cors']").prop("checked")==true?1:0; + if(status==1){ + $("input[name='open_cors']").prop("checked",false); + }else{ + $("input[name='open_cors']").prop("checked",true); + } + }); }, yes:function(index,layer_ro){ var data = $('#form_proxy').serializeArray(); diff --git a/web/utils/site.py b/web/utils/site.py index 407b9a150..b86f08263 100644 --- a/web/utils/site.py +++ b/web/utils/site.py @@ -1479,7 +1479,7 @@ class sites(object): mw.writeFile(vhost_file, content) # 设置 网站 反向代理列表 - def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cache, cache_time, proxy_id): + def setProxy(self, site_name, site_from, to, host, name, open_proxy, open_cors, open_cache, cache_time, proxy_id): from urllib.parse import urlparse if site_name == "" or site_from == "" or to == "" or host == "" or name == "": return mw.returnData(False, "必填项不能为空") @@ -1593,8 +1593,9 @@ location ^~ {from} {\n\ "to": to, "host": host, "open_cache": open_cache, - "open_proxy": open_proxy, "cache_time": cache_time, + "open_proxy": open_proxy, + "open_cors": open_cors, "id": proxy_id, }) else: @@ -1610,8 +1611,9 @@ location ^~ {from} {\n\ data[dindex]['to'] = to data[dindex]['host'] = host data[dindex]['open_cache'] = open_cache - data[dindex]['open_proxy'] = open_proxy data[dindex]['cache_time'] = cache_time + data[dindex]['open_proxy'] = open_proxy + data[dindex]['open_cors'] = open_cors if open_proxy != 'on': os.rename(conf_proxy, conf_bk)