Работа с keyHook, мелкий рефакторинг
This commit is contained in:
@@ -142,7 +142,8 @@ class App extends Vue {
|
|||||||
|
|
||||||
get rootRoute() {
|
get rootRoute() {
|
||||||
const m = this.$route.path.match(/^(\/[^/]*).*$/i);
|
const m = this.$route.path.match(/^(\/[^/]*).*$/i);
|
||||||
return (m ? m[1] : this.$route.path);
|
this.$root.rootRoute = (m ? m[1] : this.$route.path);
|
||||||
|
return this.$root.rootRoute;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemTitleClass(path) {
|
itemTitleClass(path) {
|
||||||
|
|||||||
@@ -32,11 +32,6 @@ class LoaderPage extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
//недостатки сторонних ui
|
|
||||||
this.$refs.input.$refs.input.addEventListener('keyup', (event) => {
|
|
||||||
if (event.key == 'Enter')
|
|
||||||
this.submitUrl();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activated() {
|
activated() {
|
||||||
@@ -55,6 +50,12 @@ class LoaderPage extends Vue {
|
|||||||
//loadUrl()
|
//loadUrl()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyHook(event) {
|
||||||
|
//недостатки сторонних ui
|
||||||
|
if (document.activeElement == this.$refs.input.$refs.input && event.type == 'keyup' && event.key == 'Enter')
|
||||||
|
this.submitUrl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<el-main>
|
<el-main>
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<component :is="componentActive"></component>
|
<component ref="page" :is="pageActive"></component>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</el-main>
|
</el-main>
|
||||||
</el-container>
|
</el-container>
|
||||||
@@ -93,7 +93,7 @@ class Reader extends Vue {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
get componentActive() {
|
get pageActive() {
|
||||||
let result = '';
|
let result = '';
|
||||||
|
|
||||||
if (this.loaderActive)
|
if (this.loaderActive)
|
||||||
@@ -107,7 +107,10 @@ class Reader extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyHook(event) {
|
keyHook(event) {
|
||||||
//console.log(this.componentActive);
|
if (this.$root.rootRoute == '/reader') {
|
||||||
|
if (this.$refs.page && this.$refs.page.keyHook)
|
||||||
|
this.$refs.page.keyHook(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user