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

优化源代理逻辑

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