koel/resources/assets/js/stores/setting.ts

26 lines
470 B
TypeScript
Raw Normal View History

2022-04-15 17:00:08 +00:00
import { reactive } from 'vue'
2022-04-15 14:24:30 +00:00
import { http } from '@/services'
import { alerts } from '@/utils'
import stub from '@/stubs/settings'
export const settingStore = {
stub,
2022-04-15 17:00:08 +00:00
state: reactive<Settings>({
media_path: ''
}),
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
init (settings: Settings) {
Object.assign(this.state, settings)
2022-04-15 14:24:30 +00:00
},
get all () {
2022-04-15 17:00:08 +00:00
return this.state
2022-04-15 14:24:30 +00:00
},
async update (): Promise<void> {
await http.post('settings', this.all)
alerts.success('Settings saved.')
}
2022-04-15 17:00:08 +00:00
}