Fix: setting bugs on Vue

This commit is contained in:
Cutls 2019-06-26 00:33:32 +09:00
parent 3ee4cf27d5
commit 546b34275d

View File

@ -23,13 +23,22 @@ var tlView = new Vue({
data: { config: tlConstruction }, data: { config: tlConstruction },
methods: { methods: {
complete: function (i, val) { complete: function (i, val) {
var ls = tlView.config[i].storage; var ls = tlView.config[i];
if (!val) { if (val) {
var id = tlView.config[i].id; localStorage.setItem(ls.storage, val)
var val = $("#" + id).val() } else {
if (!ls.data) {
ls = [ls]
} else {
ls = ls.data
}
for (var j = 0; j < ls.length; j++) {
M.toast({ html: 'Complete', displayLength: 3000 })
var id = ls[j].id;
var val = $("#" + id).val()
localStorage.setItem(ls[j].storage, val)
}
} }
M.toast({ html: 'Complete', displayLength: 3000 })
localStorage.setItem(ls, val)
return true return true
} }
} }
@ -39,13 +48,22 @@ var postView = new Vue({
data: { config: postConstruction, kirishima: localStorage.getItem('kirishima') }, data: { config: postConstruction, kirishima: localStorage.getItem('kirishima') },
methods: { methods: {
complete: function (i, val) { complete: function (i, val) {
var ls = postView.config[i].storage; var ls = postView.config[i];
M.toast({ html: 'Complete', displayLength: 3000 }) if (val) {
if (!val) { localStorage.setItem(ls.storage, val)
var id = postView.config[i].id; } else {
var val = $("#" + id).val() if (!ls.data) {
ls = [ls]
} else {
ls = ls.data
}
for (var j = 0; j < ls.length; j++) {
M.toast({ html: 'Complete', displayLength: 3000 })
var id = ls[j].id;
var val = $("#" + id).val()
localStorage.setItem(ls[j].storage, val)
}
} }
localStorage.setItem(ls, val)
return true return true
} }
} }
@ -95,16 +113,29 @@ function load() {
} }
var max = tlView.config.length; var max = tlView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = tlView.config[i].storage; if (ls) {
if (localStorage.getItem(ls)) { if (localStorage.getItem(ls)) {
tlView.config[i].setValue = localStorage.getItem(ls) tlView.config[i].setValue = localStorage.getItem(ls)
}
} else {
ls = tlView.config[i].data
for (var j = 0; j < ls.length; j++) {
tlView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage)
}
} }
} }
var max = postView.config.length; var max = postView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = postView.config[i].storage; var ls = postView.config[i].storage;
if (localStorage.getItem(ls)) { if (ls) {
postView.config[i].setValue = localStorage.getItem(ls) if (localStorage.getItem(ls)) {
postView.config[i].setValue = localStorage.getItem(ls)
}
} else {
ls = postView.config[i].data
for (var j = 0; j < ls.length; j++) {
postView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage)
}
} }
} }
if (localStorage.getItem("imas")) { if (localStorage.getItem("imas")) {