renderer: add counter example
This commit is contained in:
1 parent
a51944e550
commit
4cf61b031a
2 files changed
+19
-7
No files matched your search
@@ -2,9 +2,13 @@
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useTheme } from 'vuetify'
|
import { useTheme } from 'vuetify'
|
||||||
import Utils from '@/renderer/utils'
|
import Utils from '@/renderer/utils'
|
||||||
|
import { useTempStore } from '@/renderer/store/temp'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
|
||||||
const { locale } = useI18n()
|
const { locale } = useI18n()
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
|
const { counterIncrease } = useTempStore()
|
||||||
|
const { counter } = storeToRefs(useTempStore())
|
||||||
|
|
||||||
const handleChangeTheme = (): void => {
|
const handleChangeTheme = (): void => {
|
||||||
theme.global.name.value = theme.global.current.value.dark ? 'light' : 'dark'
|
theme.global.name.value = theme.global.current.value.dark ? 'light' : 'dark'
|
||||||
@@ -21,6 +25,10 @@ const handleChangeLanguage = (): void => {
|
|||||||
const handleAbout = async (): Promise<void> => {
|
const handleAbout = async (): Promise<void> => {
|
||||||
await Utils.openExternal('https://github.com/jooy2/vutron')
|
await Utils.openExternal('https://github.com/jooy2/vutron')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCountIncrease = (): void => {
|
||||||
|
counterIncrease(1)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -32,21 +40,25 @@ const handleAbout = async (): Promise<void> => {
|
|||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
{{ $t('desc.welcome') }}
|
{{ $t('desc.welcome') }}
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="4">
|
<v-col cols="12"> Counter: {{ counter }} </v-col>
|
||||||
|
<v-col cols="33">
|
||||||
<v-btn block color="primary" @click="handleChangeTheme">
|
<v-btn block color="primary" @click="handleChangeTheme">
|
||||||
{{ $t('menu.change-theme') }}
|
{{ $t('menu.change-theme') }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="4">
|
<v-col cols="3">
|
||||||
<v-btn block color="primary" @click="handleChangeLanguage">
|
<v-btn block color="primary" @click="handleChangeLanguage">
|
||||||
{{ $t('menu.change-language') }}
|
{{ $t('menu.change-language') }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="4">
|
<v-col cols="3">
|
||||||
<v-btn block color="primary" @click="handleAbout">
|
<v-btn block color="primary" @click="handleAbout">
|
||||||
{{ $t('menu.about') }}
|
{{ $t('menu.about') }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
<v-col cols="3">
|
||||||
|
<v-btn block color="primary" @click="handleCountIncrease">Count + 1</v-btn>
|
||||||
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
@@ -2,14 +2,14 @@ import { defineStore } from 'pinia'
|
|||||||
|
|
||||||
export const useTempStore = defineStore('temp', {
|
export const useTempStore = defineStore('temp', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
text: 'Sample Text'
|
counter: 0
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getText: (state) => state.text
|
getCounter: (state): number => state.counter
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setText(text) {
|
counterIncrease(amount: number) {
|
||||||
this.text = text
|
this.counter += amount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user