修复新增域名报错

old
宇天 2019-12-03 18:33:31 +08:00
parent 6423ce7fd8
commit 7636afaf05
3 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "dns-host", "name": "dns-host",
"version": "1.0.0", "version": "1.0.1",
"description": "伪域名解析", "description": "伪域名解析",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -37,7 +37,6 @@ Anot({
watch: {}, watch: {},
methods: { methods: {
addRecord() { addRecord() {
log('---')
if (this.curr) { if (this.curr) {
this.records.unshift({ this.records.unshift({
record: '', record: '',
@ -61,9 +60,11 @@ Anot({
}) })
.then(val => { .then(val => {
this.domains.push(val) this.domains.push(val)
dict[val] = []
if (!this.curr) { if (!this.curr) {
this.toggleDomain(val) this.toggleDomain(val)
} }
this.save()
}) })
.catch(Anot.noop) .catch(Anot.noop)
}, },

View File

@ -43,7 +43,6 @@ ipcMain.on('dns-host', (ev, conn) => {
case 'set': case 'set':
clearTimeout(timer) clearTimeout(timer)
timer = setTimeout(() => { timer = setTimeout(() => {
fs.echo(JSON.stringify(conn.data), HOST_FILE)
var txt = '' var txt = ''
for (let k in conn.data) { for (let k in conn.data) {
for (let it of conn.data[k]) { for (let it of conn.data[k]) {
@ -57,6 +56,7 @@ ipcMain.on('dns-host', (ev, conn) => {
} }
txt += '\n\n' txt += '\n\n'
} }
fs.echo(JSON.stringify(conn.data), HOST_FILE)
fs.echo(txt, '/etc/hosts') fs.echo(txt, '/etc/hosts')
}, 1000) }, 1000)
break break