mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
配置项增加HOSTS修改
This commit is contained in:
@@ -1096,12 +1096,15 @@ def get_site_torrents(request):
|
||||
|
||||
|
||||
def get_config_api(request):
|
||||
file_path = os.path.join(BASE_DIR, 'db/ptools.toml')
|
||||
res = pt_spider.generate_config_file()
|
||||
if res.code != 0:
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg=res.msg
|
||||
).to_dict(), safe=False)
|
||||
if request.GET.get('name') == 'ptools.toml':
|
||||
file_path = os.path.join(BASE_DIR, 'db/ptools.toml')
|
||||
res = pt_spider.generate_config_file()
|
||||
if res.code != 0:
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg=res.msg
|
||||
).to_dict(), safe=False)
|
||||
if request.GET.get('name') == 'hosts':
|
||||
file_path = '/etc/hosts'
|
||||
try:
|
||||
with open(file_path, 'rb') as f:
|
||||
response = HttpResponse(f)
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
</div>
|
||||
|
||||
<div style="width: 100%;margin-top: 5px;">
|
||||
<el-radio-group v-model="name" @input="get_config_settings">
|
||||
<el-radio-button label="ptools.toml"></el-radio-button>
|
||||
<el-radio-button label="hosts"></el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-input v-model="settings" type="textarea" autosize="{minRows: 30}" autocorrect="off"
|
||||
class="settings"></el-input>
|
||||
</div>
|
||||
@@ -46,6 +50,7 @@
|
||||
data() {
|
||||
return {
|
||||
settings: '',
|
||||
name: 'ptools.toml',
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
@@ -57,7 +62,7 @@
|
||||
methods: {
|
||||
get_config_settings() {
|
||||
axios.get(
|
||||
"{% url 'get_config_api' %}"
|
||||
"{% url 'get_config_api' %}" + '?name=' + this.name
|
||||
).then(res => {
|
||||
console.log('获取数据列表成功', res)
|
||||
{#let data = res.data#}
|
||||
|
||||
Reference in New Issue
Block a user