配置项增加HOSTS修改

This commit is contained in:
ngfchl
2023-01-04 20:47:38 +08:00
parent 3c50d23aeb
commit 8af923dc33
2 changed files with 15 additions and 7 deletions

View File

@@ -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)

View File

@@ -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#}