Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
落寞的温暖
dr_py
提交
72816e10
dr_py
项目概览
落寞的温暖
/
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,发现更多精彩内容 >>
提交
72816e10
编写于
9月 21, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加隐藏反馈
上级
5e5458a5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
75 addition
and
10 deletion
+75
-10
base/rules.db
base/rules.db
+0
-0
controllers/admin.py
controllers/admin.py
+17
-5
controllers/service.py
controllers/service.py
+41
-1
models/ruleclass.py
models/ruleclass.py
+10
-2
templates/layui_list.html
templates/layui_list.html
+7
-2
未找到文件。
base/rules.db
浏览文件 @
72816e10
无法预览此类型文件
controllers/admin.py
浏览文件 @
72816e10
...
...
@@ -6,7 +6,7 @@
import
os
from
flask
import
Blueprint
,
request
,
render_template
,
jsonify
,
make_response
from
controllers.service
import
storage_service
from
controllers.service
import
storage_service
,
rules_service
from
base.R
import
R
from
utils.update
import
getLocalVer
,
getOnlineVer
,
download_new_version
,
download_lives
,
copy_to_update
from
utils
import
parser
...
...
@@ -117,10 +117,22 @@ def admin_rule_state(state=0): # 管理员修改规则状态
if
not
verfy_token
():
return
R
.
error
(
'请登录后再试'
)
names
=
getParmas
(
'names'
)
print
(
names
,
type
(
names
))
# lsg = storage_service()
res_id
=
0
return
R
.
success
(
f
'修改成功,记录ID为:
{
res_id
}
'
)
if
not
names
:
return
R
.
success
(
f
'修改失败,没有传递names参数'
)
rule_list
=
names
.
split
(
','
)
rules
=
rules_service
()
# print(rules.query_all())
# print(rules.getState(rule_list[0]))
# print(rule_list)
success_list
=
[]
for
rule
in
rule_list
:
try
:
res_id
=
rules
.
setState
(
rule
,
state
)
success_list
.
append
(
f
'
{
rule
}
:
{
res_id
}
'
)
except
:
success_list
.
append
(
rule
)
return
R
.
success
(
f
'修改成功,服务器反馈信息为:
{
success_list
}
'
)
@
admin
.
route
(
'/force_update'
)
def
admin_force_update
():
...
...
controllers/service.py
浏览文件 @
72816e10
...
...
@@ -6,7 +6,9 @@
from
base.R
import
copy_utils
from
models.storage
import
Storage
from
models.ruleclass
import
RuleClass
from
utils.cfg
import
cfg
from
base.database
import
db
class
storage_service
(
object
):
...
...
@@ -66,4 +68,42 @@ class storage_service(object):
@
classmethod
def
clearItem
(
self
,
key
):
return
Storage
.
clearItem
(
key
)
\ No newline at end of file
return
Storage
.
clearItem
(
key
)
class
rules_service
(
object
):
@
staticmethod
def
query_all
():
# 查询所有
res
=
RuleClass
.
query
.
all
()
return
copy_utils
.
obj_to_list
(
res
)
@
classmethod
def
hasItem
(
self
,
key
):
return
RuleClass
.
hasItem
(
key
)
def
getState
(
self
,
key
):
res
=
RuleClass
.
query
.
filter
(
RuleClass
.
name
==
key
).
first
()
if
not
res
:
return
1
# print(res)
state
=
res
.
state
if
state
is
None
:
state
=
1
return
state
or
0
def
setState
(
self
,
key
,
state
=
0
):
res
=
RuleClass
.
query
.
filter
(
RuleClass
.
name
==
key
).
first
()
if
res
:
res
.
state
=
state
db
.
session
.
add
(
res
)
else
:
res
=
RuleClass
(
name
=
key
,
state
=
state
)
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
# 获取id
try
:
db
.
session
.
commit
()
return
res
.
id
except
Exception
as
e
:
print
(
f
'发生了错误:
{
e
}
'
)
return
None
\ No newline at end of file
models/ruleclass.py
浏览文件 @
72816e10
...
...
@@ -14,11 +14,19 @@ class RuleClass(db.Model):
class_name
=
db
.
Column
(
db
.
String
(
255
))
class_url
=
db
.
Column
(
db
.
String
(
255
))
cookie
=
db
.
Column
(
db
.
String
(
255
))
state
=
db
.
Column
(
db
.
Integer
,
default
=
0
)
state
=
db
.
Column
(
db
.
Integer
,
default
=
1
)
order
=
db
.
Column
(
db
.
Integer
,
default
=
0
)
create_date
=
db
.
Column
(
db
.
DateTime
,
index
=
True
,
default
=
datetime
.
now
)
write_date
=
db
.
Column
(
db
.
DateTime
,
index
=
True
,
default
=
datetime
.
now
,
onupdate
=
datetime
.
now
)
def
__repr__
(
self
):
return
"<RuleClass(name='%s', class_name='%s', class_url='%s',cookie='%s')>"
%
(
self
.
name
,
self
.
class_name
,
self
.
class_url
,
self
.
cookie
)
\ No newline at end of file
self
.
name
,
self
.
class_name
,
self
.
class_url
,
self
.
cookie
)
@
classmethod
def
hasItem
(
self
,
key
):
exists
=
db
.
session
.
query
(
self
).
filter
(
self
.
name
==
key
).
scalar
()
is
not
None
if
exists
:
return
True
else
:
return
False
\ No newline at end of file
templates/layui_list.html
浏览文件 @
72816e10
...
...
@@ -260,7 +260,12 @@ layui.use(['table', 'dropdown'], function(){
var
data
=
obj
.
data
;
//console.log(obj)
if
(
obj
.
event
===
'
del
'
){
let
obj_name
=
obj
.
data
.
api
.
match
(
/rule=
(
.*
)
/
)[
1
].
split
(
'
&
'
)[
0
];
let
obj_name
;
try
{
obj_name
=
obj
.
data
.
api
.
match
(
/rule=
(
.*
)
/
)[
1
].
split
(
'
&
'
)[
0
];
}
catch
(
e
){
obj_name
=
obj
.
data
.
key
;
}
layer
.
confirm
(
'
真的要隐藏规则
'
+
obj_name
+
'
么
'
,
function
(
index
){
console
.
log
(
obj
);
let
params
=
{
"
names
"
:[
obj_name
].
join
(
'
,
'
)};
...
...
@@ -277,7 +282,7 @@ layui.use(['table', 'dropdown'], function(){
}
});
// obj.del();
// obj.del();
//这是删除,隐藏规则是不需要删除规则的,最多也就刷新一下
layer
.
close
(
index
);
});
}
else
if
(
obj
.
event
===
'
edit
'
){
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录