Merge pull request #125 from thsrite/main

This commit is contained in:
jxxghp 2023-08-15 17:46:55 +08:00 committed by GitHub
commit ce62355197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -158,7 +158,6 @@ class CloudflareSpeedTest(_PluginBase):
else: else:
# 替换优选ip # 替换优选ip
err_hosts = customHosts.get("err_hosts") err_hosts = customHosts.get("err_hosts")
enable = customHosts.get("enable")
# 处理ip # 处理ip
new_hosts = [] new_hosts = []
@ -166,16 +165,16 @@ class CloudflareSpeedTest(_PluginBase):
if host and host != '\n': if host and host != '\n':
host_arr = str(host).split() host_arr = str(host).split()
if host_arr[0] == self._cf_ip: if host_arr[0] == self._cf_ip:
new_hosts.append(host.replace(self._cf_ip, best_ip)) new_hosts.append(host.replace(self._cf_ip, best_ip).replace("\n", "") + "\n")
else: else:
new_hosts.append(host) new_hosts.append(host.replace("\n", "") + "\n")
# 更新自定义Hosts # 更新自定义Hosts
self.update_config( self.update_config(
{ {
"hosts": new_hosts, "hosts": ''.join(new_hosts),
"err_hosts": err_hosts, "err_hosts": err_hosts,
"enable": enable "enabled": True
}, "CustomHosts" }, "CustomHosts"
) )
@ -405,207 +404,207 @@ class CloudflareSpeedTest(_PluginBase):
拼装插件配置页面需要返回两块数据1页面配置2数据结构 拼装插件配置页面需要返回两块数据1页面配置2数据结构
""" """
return [ return [
{ {
'component': 'VForm', 'component': 'VForm',
'content': [ 'content': [
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'cf_ip', 'model': 'cf_ip',
'label': '优选IP', 'label': '优选IP',
'placeholder': '121.121.121.121' 'placeholder': '121.121.121.121'
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'cron', 'model': 'cron',
'label': '优选周期', 'label': '优选周期',
'placeholder': '0 0 0 ? *' 'placeholder': '0 0 0 ? *'
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'version', 'model': 'version',
'readonly': True, 'readonly': True,
'label': 'CloudflareSpeedTest版本', 'label': 'CloudflareSpeedTest版本',
'placeholder': '暂未安装' 'placeholder': '暂未安装'
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'ipv4', 'model': 'ipv4',
'label': 'IPv4', 'label': 'IPv4',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'ipv6', 'model': 'ipv6',
'label': 'IPv6', 'label': 'IPv6',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'check', 'model': 'check',
'label': '自动校准', 'label': '自动校准',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'onlyonce', 'model': 'onlyonce',
'label': '立即运行一次', 'label': '立即运行一次',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 're_install', 'model': 're_install',
'label': '重装后运行', 'label': '重装后运行',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 4 'md': 4
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'notify', 'model': 'notify',
'label': '运行时通知', 'label': '运行时通知',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextField', 'component': 'VTextField',
'props': { 'props': {
'model': 'additional_args', 'model': 'additional_args',
'label': '高级参数', 'label': '高级参数',
'placeholder': '-dd' 'placeholder': '-dd'
} }
} }
] ]
} }
] ]
} }
] ]
} }
], { ], {
"cf_ip": "", "cf_ip": "",
"cron": "", "cron": "",
"version": "", "version": "",
"ipv4": True, "ipv4": True,
"ipv6": False, "ipv6": False,
"check": False, "check": False,
"onlyonce": False, "onlyonce": False,
"re_install": False, "re_install": False,
"notify": True, "notify": True,
"additional_args": "" "additional_args": ""
} }
def get_page(self) -> List[dict]: def get_page(self) -> List[dict]:
pass pass