From 462e85dad03c0ea5b28a2646b9db6c36fd4af289 Mon Sep 17 00:00:00 2001 From: QiroNT Date: Sat, 10 Dec 2022 05:18:21 +0800 Subject: [PATCH] refactor(command): use dialog (#352) --- app.vue | 1 + components/command/CommandPanel.vue | 203 +++++++++++----------------- components/command/CommandRoot.vue | 7 - components/modal/ModalContainer.vue | 15 ++ composables/command.ts | 2 +- composables/dialog.ts | 12 ++ layouts/default.vue | 1 - 7 files changed, 110 insertions(+), 131 deletions(-) delete mode 100644 components/command/CommandRoot.vue diff --git a/app.vue b/app.vue index d8319048..d2ba216a 100644 --- a/app.vue +++ b/app.vue @@ -1,6 +1,7 @@ diff --git a/components/command/CommandRoot.vue b/components/command/CommandRoot.vue deleted file mode 100644 index 79a660b7..00000000 --- a/components/command/CommandRoot.vue +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/components/modal/ModalContainer.vue b/components/modal/ModalContainer.vue index 24f179c4..56e3dfb2 100644 --- a/components/modal/ModalContainer.vue +++ b/components/modal/ModalContainer.vue @@ -1,11 +1,23 @@ diff --git a/composables/command.ts b/composables/command.ts index 44cfe24b..34644ed6 100644 --- a/composables/command.ts +++ b/composables/command.ts @@ -281,7 +281,7 @@ export const provideGlobalCommands = () => { visible: () => users.value.length > 1, name: () => t('action.switch_account'), - description: t('command.switch_account_desc'), + description: () => t('command.switch_account_desc'), icon: 'i-ri:user-shared-line', onComplete: () => ({ diff --git a/composables/dialog.ts b/composables/dialog.ts index 9dbe5e82..0afd2df5 100644 --- a/composables/dialog.ts +++ b/composables/dialog.ts @@ -8,6 +8,8 @@ export const mediaPreviewIndex = ref(0) export const statusEdit = ref() export const dialogDraftKey = ref() +export const commandPanelInput = ref('') + export const isFirstVisit = useLocalStorage(STORAGE_KEY_FIRST_VISIT, !process.mock) export const isZenMode = useLocalStorage(STORAGE_KEY_ZEN_MODE, false) @@ -16,6 +18,7 @@ export const isPublishDialogOpen = ref(false) export const isMediaPreviewOpen = ref(false) export const isEditHistoryDialogOpen = ref(false) export const isPreviewHelpOpen = ref(isFirstVisit.value) +export const isCommandPanelOpen = ref(false) export const toggleZenMode = useToggle(isZenMode) @@ -72,3 +75,12 @@ export function openPreviewHelp() { export function closePreviewHelp() { isPreviewHelpOpen.value = false } + +export function openCommandPanel(isCommandMode = false) { + commandPanelInput.value = isCommandMode ? '>' : '' + isCommandPanelOpen.value = true +} + +export function closeCommandPanel() { + isCommandPanelOpen.value = false +} diff --git a/layouts/default.vue b/layouts/default.vue index 8a9b887f..0c62c1e7 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -51,6 +51,5 @@ -