31 lines
878 B
TypeScript
31 lines
878 B
TypeScript
import type { PageDataValue } from '#layers/types/api/pageData'
|
|
|
|
export const usePageDataStore = defineStore('pageData', () => {
|
|
// 초기 상태를 함수로 정의
|
|
const getInitialState = () => ({
|
|
pageData: null as PageDataValue | null,
|
|
pageLayoutType: null as 'default' | 'promotion' | null,
|
|
pageName: null as PageDataValue['page_name'] | null,
|
|
pageNameEn: null as PageDataValue['page_name_en'] | null,
|
|
})
|
|
|
|
const state = reactive(getInitialState())
|
|
|
|
const setPageData = (response: PageDataValue) => {
|
|
state.pageData = response
|
|
state.pageLayoutType = getLayoutType(state.pageData)
|
|
state.pageName = state.pageData?.page_name
|
|
state.pageNameEn = state.pageData?.page_name_en
|
|
}
|
|
|
|
const clearPageData = () => {
|
|
Object.assign(state, getInitialState())
|
|
}
|
|
|
|
return {
|
|
...toRefs(state),
|
|
setPageData,
|
|
clearPageData,
|
|
}
|
|
})
|