mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-09 22:43:09 +08:00
🔨 Refactor: upgrade vue2 -> vue3
This commit is contained in:
37
src/renderer/store/index.ts
Normal file
37
src/renderer/store/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { reactive, InjectionKey, readonly, App, UnwrapRef } from 'vue'
|
||||
import { saveConfig } from '@/utils/dataSender'
|
||||
|
||||
export interface IState {
|
||||
defaultPicBed: string;
|
||||
}
|
||||
|
||||
export interface IStore {
|
||||
state: UnwrapRef<IState>
|
||||
setDefaultPicBed: (type: string) => void;
|
||||
}
|
||||
|
||||
export const storeKey: InjectionKey<IStore> = Symbol('store')
|
||||
|
||||
// state
|
||||
const state: IState = reactive({
|
||||
defaultPicBed: 'smms'
|
||||
})
|
||||
|
||||
// methods
|
||||
const setDefaultPicBed = (type: string) => {
|
||||
saveConfig({
|
||||
'picBed.current': type,
|
||||
'picBed.uploader': type
|
||||
})
|
||||
state.defaultPicBed = type
|
||||
console.log(state)
|
||||
}
|
||||
|
||||
export const store = {
|
||||
install (app: App) {
|
||||
app.provide(storeKey, {
|
||||
state: readonly(state),
|
||||
setDefaultPicBed
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user