refactor: separate dialog and edit drafts

This commit is contained in:
三咲智子 2022-11-28 15:55:57 +08:00
parent 7f7eccdd07
commit b8cadca717
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
5 changed files with 12 additions and 13 deletions

View file

@ -4,6 +4,7 @@ import { STORAGE_KEY_FIRST_VISIT, STORAGE_KEY_ZEN_MODE } from '~/constants'
export const imagePreview = ref({ src: '', alt: '' })
export const statusEdit = ref<StatusEdit>()
export const dialogDraftKey = ref<string>()
export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, true)
export const isZenMode = useLocalStorage(STORAGE_KEY_ZEN_MODE, false)
export const toggleZenMode = useToggle(isZenMode)
@ -18,9 +19,10 @@ export function openSigninDialog() {
isSigninDialogOpen.value = true
}
export function openPublishDialog(draft?: Draft) {
export function openPublishDialog(draftKey = 'dialog', draft?: Draft) {
dialogDraftKey.value = draftKey
if (draft)
dialogDraft.draft.value = draft
currentUserDrafts.value[draftKey] = draft
isPublishDialogOpen.value = true
}