Переход на Vue 3
This commit is contained in:
@@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
import vueComponent from '../../vueComponent.js';
|
import vueComponent from '../../vueComponent.js';
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
@@ -104,8 +105,9 @@ const componentOptions = {
|
|||||||
this.settingsChanged();
|
this.settingsChanged();
|
||||||
},
|
},
|
||||||
form: function(newValue) {
|
form: function(newValue) {
|
||||||
if (this.inited)
|
if (this.inited) {
|
||||||
this.commit('reader/setSettings', newValue);
|
this.commit('reader/setSettings', _.cloneDeep(newValue));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fontBold: function(newValue) {
|
fontBold: function(newValue) {
|
||||||
this.fontWeight = (newValue ? 'bold' : '');
|
this.fontWeight = (newValue ? 'bold' : '');
|
||||||
@@ -172,7 +174,6 @@ class SettingsPage {
|
|||||||
selectedTab = 'profiles';
|
selectedTab = 'profiles';
|
||||||
selectedViewTab = 'mode';
|
selectedViewTab = 'mode';
|
||||||
selectedKeysTab = 'mouse';
|
selectedKeysTab = 'mouse';
|
||||||
form = {};
|
|
||||||
fontBold = false;
|
fontBold = false;
|
||||||
fontItalic = false;
|
fontItalic = false;
|
||||||
vertShift = 0;
|
vertShift = 0;
|
||||||
@@ -188,6 +189,19 @@ class SettingsPage {
|
|||||||
toolButtons = [];
|
toolButtons = [];
|
||||||
rstore = {};
|
rstore = {};
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const settingsProps = { form: ref({}) };
|
||||||
|
|
||||||
|
for (let prop in rstore.settingDefaults) {
|
||||||
|
settingsProps[prop] = ref(_.cloneDeep(rstore.settingDefaults[prop]));
|
||||||
|
watch(settingsProps[prop], (newValue) => {
|
||||||
|
settingsProps.form.value = Object.assign({}, settingsProps.form.value, {[prop]: newValue});
|
||||||
|
}, {deep: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
return settingsProps;
|
||||||
|
}
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.commit = this.$store.commit;
|
this.commit = this.$store.commit;
|
||||||
this.reader = this.$store.state.reader;
|
this.reader = this.$store.state.reader;
|
||||||
@@ -217,18 +231,8 @@ class SettingsPage {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
this.form = Object.assign({}, this.settings);
|
this.form = Object.assign({}, this.settings);
|
||||||
if (!this.unwatch)
|
for (const prop in rstore.settingDefaults) {
|
||||||
this.unwatch = {};
|
this[prop] = _.cloneDeep(this.form[prop]);
|
||||||
|
|
||||||
for (let prop in rstore.settingDefaults) {
|
|
||||||
if (this.unwatch && this.unwatch[prop])
|
|
||||||
this.unwatch[prop]();
|
|
||||||
|
|
||||||
this[prop] = this.form[prop];
|
|
||||||
|
|
||||||
this.unwatch[prop] = this.$watch(prop, (newValue) => {
|
|
||||||
this.form = Object.assign({}, this.form, {[prop]: newValue});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fontBold = (this.fontWeight == 'bold');
|
this.fontBold = (this.fontWeight == 'bold');
|
||||||
@@ -423,10 +427,6 @@ class SettingsPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeShowToolButton(buttonName) {
|
|
||||||
this.showToolButton = Object.assign({}, this.showToolButton, {[buttonName]: !this.showToolButton[buttonName]});
|
|
||||||
}
|
|
||||||
|
|
||||||
async addProfile() {
|
async addProfile() {
|
||||||
try {
|
try {
|
||||||
if (Object.keys(this.profiles).length >= 100) {
|
if (Object.keys(this.profiles).length >= 100) {
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
<div class="item row" v-for="item in toolButtons" :key="item.name" v-show="item.name != 'libs' || mode == 'liberama.top'">
|
<div class="item row" v-for="item in toolButtons" :key="item.name" v-show="item.name != 'libs' || mode == 'liberama.top'">
|
||||||
<div class="label-3"></div>
|
<div class="label-3"></div>
|
||||||
<div class="col row">
|
<div class="col row">
|
||||||
<q-checkbox size="xs" @input="changeShowToolButton(item.name)"
|
<q-checkbox size="xs" v-model="showToolButton[item.name]" :label="rstore.readerActions[item.name]"
|
||||||
:value="showToolButton[item.name]" :label="rstore.readerActions[item.name]"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
<slot></slot>
|
<slot></slot>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<q-icon
|
<q-icon
|
||||||
v-ripple="validate(value - step)"
|
v-ripple="validate(modelValue - step)"
|
||||||
:class="(validate(value - step) ? '' : 'disable')"
|
:class="(validate(modelValue - step) ? '' : 'disable')"
|
||||||
name="la la-minus-circle"
|
name="la la-minus-circle"
|
||||||
class="button"
|
class="button"
|
||||||
@click="minus"
|
@click="minus"
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #append>
|
<template #append>
|
||||||
<q-icon
|
<q-icon
|
||||||
v-ripple="validate(value + step)"
|
v-ripple="validate(modelValue + step)"
|
||||||
:class="(validate(value + step) ? '' : 'disable')"
|
:class="(validate(modelValue + step) ? '' : 'disable')"
|
||||||
name="la la-plus-circle"
|
name="la la-plus-circle"
|
||||||
class="button"
|
class="button"
|
||||||
@click="plus"
|
@click="plus"
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ export default function(componentClass) {
|
|||||||
computed[method] = {get: desc.get};
|
computed[method] = {get: desc.get};
|
||||||
if (desc.set)
|
if (desc.set)
|
||||||
computed[method].set = desc.set;
|
computed[method].set = desc.set;
|
||||||
} else if (['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated',
|
} else if ( ['beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated',//life cycle hooks
|
||||||
'deactivated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered'].includes(method)) {//life cycle hooks
|
'deactivated', 'beforeUnmount', 'unmounted', 'errorCaptured', 'renderTracked', 'renderTriggered',//life cycle hooks
|
||||||
|
'setup'].includes(method) ) {
|
||||||
comp[method] = obj[method];
|
comp[method] = obj[method];
|
||||||
} else if (method !== 'constructor') {//usual
|
} else if (method !== 'constructor') {//usual
|
||||||
methods[method] = obj[method];
|
methods[method] = obj[method];
|
||||||
|
|||||||
Reference in New Issue
Block a user