提交 5c561982 编写于 作者: H hjdhnx

优化源代理逻辑

上级 0a1ad630
...@@ -88,7 +88,8 @@ def admin_view_rule(name): ...@@ -88,7 +88,8 @@ def admin_view_rule(name):
rurl = burl.replace(oldsrc, newsrc) rurl = burl.replace(oldsrc, newsrc)
if burl != rurl: if burl != rurl:
jscode = parser.getJs(name, 'js') jscode = parser.getJs(name, 'js')
rjscode = render_template_string(jscode, env=env) # rjscode = render_template_string(jscode, env=env)
rjscode = render_template_string(jscode, **env)
if rjscode.strip() == jscode.strip(): # 无需渲染才代理 if rjscode.strip() == jscode.strip(): # 无需渲染才代理
return redirect(rurl) return redirect(rurl)
else: else:
......
...@@ -57,6 +57,9 @@ def search_one(rule, wd, before: str = ''): ...@@ -57,6 +57,9 @@ def search_one(rule, wd, before: str = ''):
try: try:
with open(js_path, encoding='utf-8') as f2: with open(js_path, encoding='utf-8') as f2:
jscode = f2.read() jscode = f2.read()
env = get_env()
if env:
jscode = render_template_string(jscode, **env)
jscode = before + jscode + end_code jscode = before + jscode + end_code
# print(jscode) # print(jscode)
ctx.eval(jscode) ctx.eval(jscode)
...@@ -240,7 +243,7 @@ def vod_home(): ...@@ -240,7 +243,7 @@ def vod_home():
jscode = f2.read() jscode = f2.read()
env = get_env() env = get_env()
if env: if env:
jscode = render_template_string(jscode,env=env) jscode = render_template_string(jscode,**env)
# print(jscode) # print(jscode)
jscode = before + jscode + end_code jscode = before + jscode + end_code
# print(jscode) # print(jscode)
......
muban.首图2.二级.tabs = '.nav-tabs.dpplay&&li'; muban.首图2.二级.tabs = '.nav-tabs.dpplay&&li';
var rule = Object.assign(muban.首图2,{ var rule = Object.assign(muban.首图2,{
title:'007影视', title:'007影视',
ali_token:'{{env.ali_token}}', ali_token:'{{ali_token}}',
host:'https://www.007ts.me', host:'https://www.007ts.me',
url:'/channel/fyclass-fypage.html', url:'/channel/fyclass-fypage.html',
searchUrl:'/search/**----------fypage---.html', searchUrl:'/search/**----------fypage---.html',
......
...@@ -15,6 +15,7 @@ def get_env(): ...@@ -15,6 +15,7 @@ def get_env():
# print(new_conf) # print(new_conf)
env = { env = {
'ali_token': new_conf.ALI_TOKEN, 'ali_token': new_conf.ALI_TOKEN,
'js_proxy':new_conf.JS_PROXY 'js_proxy':new_conf.JS_PROXY,
'fl':'{{fl}}' # 防止被依赖代理
} }
return env return env
\ No newline at end of file
...@@ -86,7 +86,8 @@ def toJs(jsPath,jsRoot='cache',env=None): ...@@ -86,7 +86,8 @@ def toJs(jsPath,jsRoot='cache',env=None):
with open(js_path, 'r', encoding='UTF-8') as fp: with open(js_path, 'r', encoding='UTF-8') as fp:
js = fp.read() js = fp.read()
if env: if env:
js = render_template_string(js,env=env) # js = render_template_string(js,env=env)
js = render_template_string(js,**env)
response = make_response(js) response = make_response(js)
response.headers['Content-Type'] = 'text/javascript; charset=utf-8' response.headers['Content-Type'] = 'text/javascript; charset=utf-8'
return response return response
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册