提交 0e311df6 编写于 作者: H hjdhnx

修复源代理导致的筛选失效问题

上级 f0a224a5
无法预览此类型文件
......@@ -89,7 +89,12 @@ def admin_view_rule(name):
if burl != rurl:
jscode = parser.getJs(name, 'js')
# rjscode = render_template_string(jscode, env=env)
rjscode = render_template_string(jscode, **env)
rjscode = jscode
for k in env:
# print(f'${k}', f'{env[k]}')
if f'${k}' in rjscode:
rjscode = rjscode.replace(f'${k}', f'{env[k]}')
# rjscode = render_template_string(jscode, **env)
if rjscode.strip() == jscode.strip(): # 无需渲染才代理
return redirect(rurl)
else:
......
......@@ -710,6 +710,7 @@ class CMS:
if fl is None:
fl = {}
# print(f'fl:{fl}')
if self.filter_def and isinstance(self.filter_def,dict):
try:
if self.filter_def.get(fyclass) and isinstance(self.filter_def[fyclass],dict):
......@@ -740,8 +741,8 @@ class CMS:
url += self.filter_url
else: # 第二种情况直接替换关键字为待拼接的结果后面渲染,适用于 ----fypage.html的情况
url = url.replace('fyfilter', self.filter_url)
# print(f'url渲染:{url}')
url = render_template_string(url,fl=fl)
# fl_url = render_template_string(self.filter_url,fl=fl)
# if not 'fyfilter' in url: # 第一种情况,默认不写fyfilter关键字,视为直接拼接在链接后面当参数
# if not url.endswith('&') and not fl_url.startswith('&'):
......
......@@ -60,7 +60,11 @@ def search_one(rule, wd, before: str = '',env:dict=None,app=None):
if env:
# 渲染字符串文本 render_template_string 必须带 flask的上下文
with app.app_context():
jscode = render_template_string(jscode, **env)
for k in env:
# print(f'${k}', f'{env[k]}')
if f'${k}' in jscode:
jscode = jscode.replace(f'${k}', f'{env[k]}')
# jscode = render_template_string(jscode, **env)
# if '007' in rule:
# print(rule,jscode)
jscode = before + jscode + end_code
......@@ -253,8 +257,13 @@ def vod_home():
with open(js_path,encoding='utf-8') as f2:
jscode = f2.read()
env = get_env()
if env:
jscode = render_template_string(jscode,**env)
for k in env:
# print(f'${k}',f'{env[k]}')
if f'${k}' in jscode:
jscode = jscode.replace(f'${k}',f'{env[k]}')
# print(env)
# if env:
# jscode = render_template_string(jscode,**env)
# print(jscode)
jscode = before + jscode + end_code
# print(jscode)
......
......@@ -8,7 +8,7 @@ var rule = {
quickSearch:1,
filterable:1,
// 分类链接fypage参数支持1个()表达式
url:'/?pg=fypage&class=fyclass&douban={{douban}}',
url:'/?pg=fypage&class=fyclass&douban=$douban',
filter_url:'fl={{fl}}',
headers:{
"Host": "frodo.douban.com",
......
3.9.25beta5
\ No newline at end of file
3.9.26
\ No newline at end of file
......@@ -87,7 +87,11 @@ def toJs(jsPath,jsRoot='cache',env=None):
js = fp.read()
if env:
# js = render_template_string(js,env=env)
js = render_template_string(js,**env)
for k in env:
# print(f'${k}', f'{env[k]}')
if f'${k}' in js:
js = js.replace(f'${k}', f'{env[k]}')
# 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.
先完成此消息的编辑!
想要评论请 注册