feat: 项目结构调整|新增依赖
This commit is contained in:
22
src/renderer/store/counter.ts
Normal file
22
src/renderer/store/counter.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
export const useCounterStore = defineStore('counter', () => {
|
||||
const count = ref(0)
|
||||
|
||||
const doubleCount = computed(() => count.value * 2)
|
||||
|
||||
function increment() {
|
||||
count.value++
|
||||
}
|
||||
|
||||
function decrement() {
|
||||
count.value--
|
||||
}
|
||||
|
||||
function reset() {
|
||||
count.value = 0
|
||||
}
|
||||
|
||||
return { count, doubleCount, increment, decrement, reset }
|
||||
})
|
||||
25
src/renderer/store/sharedStore.ts
Normal file
25
src/renderer/store/sharedStore.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { isEqual } from 'lodash-es'
|
||||
|
||||
export const useSharedStore = defineStore('shared', {
|
||||
state: () => ({
|
||||
sharedData: {},
|
||||
}),
|
||||
|
||||
actions: {
|
||||
updateSharedData(data: any) {
|
||||
this.sharedData = Object.assign(this.sharedData, data)
|
||||
|
||||
const cloneData = JSON.parse(JSON.stringify(this.sharedData))
|
||||
|
||||
if (!isEqual(this.sharedData, data)) {
|
||||
// 同步状态到主进程
|
||||
try {
|
||||
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user