harrywan 86ff19b3d1
fix(plugin-layout): 打开相同path的链接会更新页签为新的 & 正确触发onActivated (#146)
* feat: script setup 支持 defineRouteMeta (#144)

* chore(release): publish

 - @fesjs/preset-built-in@2.1.4
 - @fesjs/fes@2.1.4

* fix: 打开相同path的链接会更新route & 第一次打开会触发onActivated (#145)

* fix: 打开相同path的链接会更新route & 第一次打开会触发onActivated

* fix: 优化

* chore(release): publish

 - @fesjs/plugin-layout@4.2.3

Co-authored-by: qlin <haizekuo@gmail.com>
2022-08-12 10:19:27 +08:00

75 lines
2.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="page">
<h4>Vuex</h4>
<input />
<div>
<button @click="increment">click me{{ doubleCount }}</button>
</div>
<div>
<button :disabled="disabled" @click="login">async login</button>
</div>
<div>
<button @click="fooBarIncrement">foo/bar{{ fooBarDoubleCount }}</button>
</div>
<div>{{ address }}</div>
</div>
</template>
<config>
{
"name": "store",
"title": "$store",
"keep-alive": true
}
</config>
<script>
import { computed, ref, onMounted, onUnmounted, onActivated, onDeactivated } from 'vue';
import { useStore } from 'vuex';
import { MUTATION_TYPES, GETTER_TYPES, ACTION_TYPES } from '@fesjs/fes';
export default {
setup() {
console.log('store.vue');
const store = useStore();
console.log('store==>', store);
const disabled = ref(false);
onMounted(() => {
console.log('onMounted');
});
onUnmounted(() => {
console.log('onUnmounted');
});
onActivated(() => {
console.log('onActivated');
});
onDeactivated(() => {
console.log('onDeactivated');
});
return {
address: computed(() => store.getters[GETTER_TYPES.user.address]),
doubleCount: computed(() => store.getters[GETTER_TYPES.counter.doubleCount]),
disabled,
increment: () => store.commit(MUTATION_TYPES.counter.increment),
login: () => {
disabled.value = true;
store.dispatch(ACTION_TYPES.user.login).then((res) => {
// eslint-disable-next-line no-alert
window.alert(res);
disabled.value = false;
});
},
fooBarIncrement: () => store.commit(MUTATION_TYPES.fooBar.increment),
fooBarDoubleCount: computed(() => store.getters[GETTER_TYPES.fooBar.doubleCount]),
};
},
};
</script>
<style scoped>
.page {
}
</style>