Работа над ExternalLibs
This commit is contained in:
@@ -58,7 +58,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<q-btn rounded color="green-7" no-caps size="14px" @click="submitUrl">Открыть
|
<q-btn rounded color="green-7" no-caps size="14px" @click="submitUrl" :disabled="!bookUrl">Открыть
|
||||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть в читалке</q-tooltip>
|
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Открыть в читалке</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -139,14 +139,31 @@ export default @Component({
|
|||||||
},
|
},
|
||||||
rootLink: function() {
|
rootLink: function() {
|
||||||
this.updateSelectedLink();
|
this.updateSelectedLink();
|
||||||
this.updateStartLink();
|
|
||||||
},
|
},
|
||||||
selectedLink: function() {
|
selectedLink: function() {
|
||||||
this.updateStartLink();
|
this.updateStartLink();
|
||||||
},
|
},
|
||||||
defaultRootLink: function() {
|
defaultRootLink: function() {
|
||||||
this.updateBookmarkLink();
|
this.updateBookmarkLink();
|
||||||
|
},
|
||||||
|
bookUrl: function(newValue) {
|
||||||
|
const value = lu.addProtocol(newValue);
|
||||||
|
const subst = this.makeProxySubst(value, true);
|
||||||
|
if (value != subst) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.bookUrl = subst;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
bookmarkLink: function(newValue) {
|
||||||
|
const value = lu.addProtocol(newValue);
|
||||||
|
const subst = this.makeProxySubst(value, true);
|
||||||
|
if (value != subst) {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.bookmarkLink = subst;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
class ExternalLibs extends Vue {
|
class ExternalLibs extends Vue {
|
||||||
@@ -176,6 +193,8 @@ class ExternalLibs extends Vue {
|
|||||||
this.fullScreenActive = (document.fullscreenElement !== null);
|
this.fullScreenActive = (document.fullscreenElement !== null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.commitInProgress = false;
|
||||||
|
|
||||||
//this.commit = this.$store.commit;
|
//this.commit = this.$store.commit;
|
||||||
//this.commit('reader/setLibs', rstore.libsDefaults);
|
//this.commit('reader/setLibs', rstore.libsDefaults);
|
||||||
}
|
}
|
||||||
@@ -266,6 +285,7 @@ class ExternalLibs extends Vue {
|
|||||||
case 'hello': this.sendMessage({type: 'mes', data: 'ready'}); break;
|
case 'hello': this.sendMessage({type: 'mes', data: 'ready'}); break;
|
||||||
}
|
}
|
||||||
} else if (d.type == 'libs') {
|
} else if (d.type == 'libs') {
|
||||||
|
this.commitInProgress = false;
|
||||||
this.ready = true;
|
this.ready = true;
|
||||||
this.libs = _.cloneDeep(d.data);
|
this.libs = _.cloneDeep(d.data);
|
||||||
} else if (d.type == 'notify') {
|
} else if (d.type == 'notify') {
|
||||||
@@ -289,7 +309,20 @@ class ExternalLibs extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commitLibs(libs) {
|
commitLibs(libs) {
|
||||||
|
(async() => {
|
||||||
|
let i = 0;
|
||||||
|
while (this.commitInProgress && i < 50) {//1 сек
|
||||||
|
await utils.sleep(20);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.commitInProgress) {
|
||||||
|
this.commitInProgress = true;
|
||||||
this.sendMessage({type: 'libs', data: libs});
|
this.sendMessage({type: 'libs', data: libs});
|
||||||
|
} else {
|
||||||
|
throw new Error('Commit failed');
|
||||||
|
}
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLibs() {
|
loadLibs() {
|
||||||
@@ -308,11 +341,17 @@ class ExternalLibs extends Vue {
|
|||||||
doAction(event) {
|
doAction(event) {
|
||||||
switch (event.action) {
|
switch (event.action) {
|
||||||
case 'setLibs': this.commitLibs(event.data); break;
|
case 'setLibs': this.commitLibs(event.data); break;
|
||||||
case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break;
|
case 'setRootLink': this.rootLink = event.data; break;
|
||||||
case 'setSelectedLink':
|
case 'setSelectedLink':
|
||||||
|
this.rootLink = lu.getOrigin(event.data);
|
||||||
|
this.$nextTick(async() => {
|
||||||
|
let i = 0;
|
||||||
|
while (this.commitInProgress && i < 50) {//1 сек
|
||||||
|
await utils.sleep(20);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
this.selectedLink = event.data;
|
this.selectedLink = event.data;
|
||||||
this.rootLink = lu.getOrigin(this.selectedLink);
|
});
|
||||||
this.selectedLinkInput();
|
|
||||||
break;
|
break;
|
||||||
case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break;
|
case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break;
|
||||||
case 'addBookmark': this.addBookmark('add'); break;
|
case 'addBookmark': this.addBookmark('add'); break;
|
||||||
@@ -425,6 +464,7 @@ class ExternalLibs extends Vue {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.frameVisible = true;
|
this.frameVisible = true;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
if (this.$refs.frame)
|
||||||
this.$refs.frame.contentWindow.focus();
|
this.$refs.frame.contentWindow.focus();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -439,7 +479,7 @@ class ExternalLibs extends Vue {
|
|||||||
for (const [key, value] of Object.entries(proxySubst)) {
|
for (const [key, value] of Object.entries(proxySubst)) {
|
||||||
if (reverse && value == url.substring(0, value.length)) {
|
if (reverse && value == url.substring(0, value.length)) {
|
||||||
return key + url.substring(value.length);
|
return key + url.substring(value.length);
|
||||||
} else if (key == url.substring(0, key.length)) {
|
} else if (!reverse && key == url.substring(0, key.length)) {
|
||||||
return value + url.substring(key.length);
|
return value + url.substring(key.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +504,7 @@ class ExternalLibs extends Vue {
|
|||||||
submitUrl() {
|
submitUrl() {
|
||||||
if (this.bookUrl) {
|
if (this.bookUrl) {
|
||||||
this.sendMessage({type: 'submitUrl', data: {
|
this.sendMessage({type: 'submitUrl', data: {
|
||||||
url: this.makeProxySubst(lu.addProtocol(this.bookUrl), true),
|
url: this.bookUrl,
|
||||||
force: true
|
force: true
|
||||||
}});
|
}});
|
||||||
this.bookUrl = '';
|
this.bookUrl = '';
|
||||||
@@ -479,7 +519,7 @@ class ExternalLibs extends Vue {
|
|||||||
this.editBookmarkLink = this.bookmarkLink = link;
|
this.editBookmarkLink = this.bookmarkLink = link;
|
||||||
this.editBookmarkDesc = this.bookmarkDesc = desc;
|
this.editBookmarkDesc = this.bookmarkDesc = desc;
|
||||||
} else {
|
} else {
|
||||||
this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : '');
|
this.bookmarkLink = this.bookUrl;
|
||||||
this.bookmarkDesc = '';
|
this.bookmarkDesc = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user