Переход на Vue 3, в процессе
This commit is contained in:
@@ -85,36 +85,42 @@ class App {
|
|||||||
//sanitize
|
//sanitize
|
||||||
this.$root.sanitize = sanitizeHtml;
|
this.$root.sanitize = sanitizeHtml;
|
||||||
|
|
||||||
//global keyHooks
|
//global event hooks
|
||||||
this.keyHooks = [];
|
this.eventHooks = {};
|
||||||
this.keyHook = (event) => {
|
this.eventHook = (hookName, event) => {
|
||||||
for (const hook of this.keyHooks)
|
if (!this.eventHooks[hookName])
|
||||||
|
return;
|
||||||
|
for (const hook of this.eventHooks[hookName])
|
||||||
hook(event);
|
hook(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$root.addKeyHook = (hook) => {
|
this.$root.addEventHook = (hookName, hook) => {
|
||||||
if (this.keyHooks.indexOf(hook) < 0)
|
if (!this.eventHooks[hookName])
|
||||||
this.keyHooks.push(hook);
|
this.eventHooks[hookName] = [];
|
||||||
|
if (this.eventHooks[hookName].indexOf(hook) < 0)
|
||||||
|
this.eventHooks[hookName].push(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$root.removeKeyHook = (hook) => {
|
this.$root.removeEventHook = (hookName, hook) => {
|
||||||
const i = this.keyHooks.indexOf(hook);
|
if (!this.eventHooks[hookName])
|
||||||
|
return;
|
||||||
|
const i = this.eventHooks[hookName].indexOf(hook);
|
||||||
if (i >= 0)
|
if (i >= 0)
|
||||||
this.keyHooks.splice(i, 1);
|
this.eventHooks[hookName].splice(i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('keyup', (event) => {
|
document.addEventListener('keyup', (event) => {
|
||||||
this.keyHook(event);
|
this.eventHook('key', event);
|
||||||
});
|
});
|
||||||
document.addEventListener('keypress', (event) => {
|
document.addEventListener('keypress', (event) => {
|
||||||
this.keyHook(event);
|
this.eventHook('key', event);
|
||||||
});
|
});
|
||||||
document.addEventListener('keydown', (event) => {
|
document.addEventListener('keydown', (event) => {
|
||||||
this.keyHook(event);
|
this.eventHook('key', event);
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', (event) => {
|
||||||
this.$root.$emit('resize');
|
this.eventHook('resize', event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,9 @@
|
|||||||
:nodes="nodes"
|
:nodes="nodes"
|
||||||
node-key="key"
|
node-key="key"
|
||||||
tick-strategy="leaf"
|
tick-strategy="leaf"
|
||||||
:selected.sync="selected"
|
v-model:selected="selected"
|
||||||
:ticked.sync="ticked"
|
v-model:ticked="ticked"
|
||||||
:expanded.sync="expanded"
|
v-model:expanded="expanded"
|
||||||
selected-color="black"
|
selected-color="black"
|
||||||
:filter="search"
|
:filter="search"
|
||||||
no-nodes-label="Закладок пока нет"
|
no-nodes-label="Закладок пока нет"
|
||||||
|
|||||||
@@ -270,9 +270,9 @@ class ExternalLibs {
|
|||||||
created() {
|
created() {
|
||||||
this.oldStartLink = '';
|
this.oldStartLink = '';
|
||||||
this.justOpened = true;
|
this.justOpened = true;
|
||||||
this.$root.addKeyHook(this.keyHook);
|
this.$root.addEventHook('key', this.keyHook);
|
||||||
|
|
||||||
this.$root.$on('resize', async() => {
|
this.$root.addEventHook('resize', async() => {
|
||||||
await utils.sleep(200);
|
await utils.sleep(200);
|
||||||
this.frameResize();
|
this.frameResize();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ class Reader {
|
|||||||
this.reader = this.$store.state.reader;
|
this.reader = this.$store.state.reader;
|
||||||
this.config = this.$store.state.config;
|
this.config = this.$store.state.config;
|
||||||
|
|
||||||
this.$root.addKeyHook(this.keyHook);
|
this.$root.addEventHook('key', this.keyHook);
|
||||||
|
|
||||||
this.lastActivePage = false;
|
this.lastActivePage = false;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
:data="tableData"
|
:data="tableData"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="key"
|
row-key="key"
|
||||||
:pagination.sync="pagination"
|
v-model:pagination="pagination"
|
||||||
separator="cell"
|
separator="cell"
|
||||||
hide-bottom
|
hide-bottom
|
||||||
virtual-scroll
|
virtual-scroll
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class TextPage {
|
|||||||
await this.doPageAnimation();
|
await this.doPageAnimation();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
this.$root.$on('resize', async() => {
|
this.$root.addEventHook('resize', async() => {
|
||||||
this.$nextTick(this.onResize);
|
this.$nextTick(this.onResize);
|
||||||
await utils.sleep(500);
|
await utils.sleep(500);
|
||||||
this.$nextTick(this.onResize);
|
this.$nextTick(this.onResize);
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ class StdDialog {
|
|||||||
hotKeyCode = '';
|
hotKeyCode = '';
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
if (this.$root.addKeyHook) {
|
if (this.$root.addEventHook) {
|
||||||
this.$root.addKeyHook(this.keyHook);
|
this.$root.addEventHook('key', this.keyHook);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user