Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
季末490
dr_py
提交
db02d263
dr_py
项目概览
季末490
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
db02d263
编写于
9月 21, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
配置已正常渲染是否隐藏的
上级
1251cd89
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
32 addition
and
3 deletion
+32
-3
base/rules.db
base/rules.db
+0
-0
controllers/home.py
controllers/home.py
+25
-2
controllers/service.py
controllers/service.py
+7
-1
未找到文件。
base/rules.db
浏览文件 @
db02d263
无法预览此类型文件
controllers/home.py
浏览文件 @
db02d263
...
...
@@ -8,7 +8,7 @@ import os
from
flask
import
Blueprint
,
abort
,
render_template
,
render_template_string
,
url_for
,
redirect
,
make_response
,
send_from_directory
from
controllers.service
import
storage_service
from
controllers.service
import
storage_service
,
rules_service
from
controllers.classes
import
getClasses
,
getClassInfo
from
utils.files
import
getPics
,
custom_merge
,
getAlist
,
get_live_url
,
get_multi_rules
,
getCustonDict
...
...
@@ -18,6 +18,7 @@ from base.R import R
from
utils.system
import
getHost
,
is_linux
from
utils.cfg
import
cfg
from
utils
import
parser
from
utils.ua
import
time
,
get_interval
from
utils.log
import
logger
from
utils.update
import
getLocalVer
,
getHotSuggest
from
js.rules
import
getJxs
...
...
@@ -176,6 +177,22 @@ def get_hot_search():
data
=
getHotSuggest
()
return
R
.
success
(
'获取成功'
,
data
)
def
merged_hide
(
merged_config
):
t1
=
time
()
store_rule
=
rules_service
()
hide_rules
=
store_rule
.
getHideRules
()
hide_rule_names
=
list
(
map
(
lambda
x
:
x
[
'name'
],
hide_rules
))
# print(hide_rule_names)
all_cnt
=
len
(
merged_config
[
'sites'
])
def
filter_show
(
x
):
name
=
x
[
'api'
].
split
(
'rule='
)[
1
].
split
(
'&'
)[
0
]
if
'rule='
in
x
[
'api'
]
else
x
[
'key'
]
# print(name)
return
name
not
in
hide_rule_names
merged_config
[
'sites'
]
=
list
(
filter
(
filter_show
,
merged_config
[
'sites'
]))
logger
.
info
(
f
'数据库筛选隐藏规则耗时
{
get_interval
(
t1
)
}
毫秒,共计
{
all_cnt
}
条规则,隐藏后可渲染
{
len
(
merged_config
[
"sites"
])
}
条规则'
)
@
home
.
route
(
'/config/<int:mode>'
)
def
config_render
(
mode
):
# print(dict(app.config))
...
...
@@ -206,8 +223,11 @@ def config_render(mode):
# html = render_template('config.txt',rules=getRules('js'),host=host,mode=mode,jxs=jxs,base64Encode=base64Encode,config=new_conf)
html
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
host
=
host
,
mode
=
mode
,
jxs
=
jxs
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
live_url
,
config
=
new_conf
)
merged_config
=
custom_merge
(
parseText
(
html
),
customConfig
)
# print(merged_config)
# print(merged_config['sites'])
merged_hide
(
merged_config
)
# response = make_response(html)
# print(len(merged_config['sites']))
response
=
make_response
(
json
.
dumps
(
merged_config
,
ensure_ascii
=
False
,
indent
=
1
))
# response = make_response(str(merged_config))
response
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
...
...
@@ -237,17 +257,20 @@ def config_gen():
with
open
(
'txt/pycms0.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
0
))
set_dict
=
custom_merge
(
parseText
(
set_local
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_local)
f
.
write
(
json
.
dumps
(
set_dict
,
ensure_ascii
=
False
,
indent
=
4
))
with
open
(
'txt/pycms1.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
1
))
set_dict
=
custom_merge
(
parseText
(
set_area
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_area)
f
.
write
(
json
.
dumps
(
set_dict
,
ensure_ascii
=
False
,
indent
=
4
))
with
open
(
'txt/pycms2.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
2
))
set_dict
=
custom_merge
(
parseText
(
set_online
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_online)
f
.
write
(
json
.
dumps
(
set_dict
,
ensure_ascii
=
False
,
indent
=
4
))
files
=
[
os
.
path
.
abspath
(
rf
'txt\pycms
{
i
}
.json'
)
for
i
in
range
(
3
)]
...
...
controllers/service.py
浏览文件 @
db02d263
...
...
@@ -92,6 +92,7 @@ class rules_service(object):
state
=
1
return
state
or
0
def
setState
(
self
,
key
,
state
=
0
):
res
=
RuleClass
.
query
.
filter
(
RuleClass
.
name
==
key
).
first
()
if
res
:
...
...
@@ -107,3 +108,8 @@ class rules_service(object):
except
Exception
as
e
:
print
(
f
'发生了错误:
{
e
}
'
)
return
None
@
staticmethod
def
getHideRules
():
res
=
RuleClass
.
query
.
filter
(
RuleClass
.
state
==
0
).
all
()
return
copy_utils
.
obj_to_list
(
res
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录