From 27445a02921ab1c18f12a4637fef4997582f2f65 Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Thu, 16 Jan 2025 22:31:38 +0800 Subject: [PATCH] chore: tweaks --- .../plugin-toc/src/client/components/Toc.ts | 5 +---- .../src/client/components/Catalog.ts | 5 +---- .../src/client/components/CodeTabs.ts | 9 +++------ .../src/client/components/Tabs.ts | 9 +++------ .../src/client/components/RevealJs.ts | 15 ++++++++++++--- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/plugins/development/plugin-toc/src/client/components/Toc.ts b/plugins/development/plugin-toc/src/client/components/Toc.ts index 1a011f9f23..da0512118f 100644 --- a/plugins/development/plugin-toc/src/client/components/Toc.ts +++ b/plugins/development/plugin-toc/src/client/components/Toc.ts @@ -104,10 +104,7 @@ export const Toc = defineComponent({ name: 'Toc', props: { - headers: { - type: Array as PropType, - default: undefined, - }, + headers: Array as PropType, options: { type: Object as PropType>, diff --git a/plugins/features/plugin-catalog/src/client/components/Catalog.ts b/plugins/features/plugin-catalog/src/client/components/Catalog.ts index 5479e8429d..fec27dde90 100644 --- a/plugins/features/plugin-catalog/src/client/components/Catalog.ts +++ b/plugins/features/plugin-catalog/src/client/components/Catalog.ts @@ -46,10 +46,7 @@ export default defineComponent({ * * @default current route base */ - base: { - type: String, - default: '', - }, + base: String, /** * Max level of catalog diff --git a/plugins/markdown/plugin-markdown-tab/src/client/components/CodeTabs.ts b/plugins/markdown/plugin-markdown-tab/src/client/components/CodeTabs.ts index af2050a298..26c2d50b24 100644 --- a/plugins/markdown/plugin-markdown-tab/src/client/components/CodeTabs.ts +++ b/plugins/markdown/plugin-markdown-tab/src/client/components/CodeTabs.ts @@ -49,10 +49,7 @@ export const CodeTabs = defineComponent({ * * 标签页 id */ - tabId: { - type: String, - default: '', - }, + tabId: String, }, slots: Object as SlotsType<{ @@ -111,7 +108,7 @@ export const CodeTabs = defineComponent({ const getInitialIndex = (): number => { if (props.tabId) { const valueIndex = props.data.findIndex( - ({ id }) => codeTabStore.value[props.tabId] === id, + ({ id }) => codeTabStore.value[props.tabId!] === id, ) if (valueIndex !== -1) return valueIndex @@ -124,7 +121,7 @@ export const CodeTabs = defineComponent({ activeIndex.value = getInitialIndex() watch( - () => codeTabStore.value[props.tabId], + () => props.tabId && codeTabStore.value[props.tabId], (newValue, oldValue) => { if (props.tabId && newValue !== oldValue) { const index = props.data.findIndex(({ id }) => id === newValue) diff --git a/plugins/markdown/plugin-markdown-tab/src/client/components/Tabs.ts b/plugins/markdown/plugin-markdown-tab/src/client/components/Tabs.ts index 430ab54936..a9891995ff 100644 --- a/plugins/markdown/plugin-markdown-tab/src/client/components/Tabs.ts +++ b/plugins/markdown/plugin-markdown-tab/src/client/components/Tabs.ts @@ -51,10 +51,7 @@ export const Tabs = defineComponent({ * * 标签页 id */ - tabId: { - type: String, - default: '', - }, + tabId: String, }, slots: Object as SlotsType<{ @@ -112,7 +109,7 @@ export const Tabs = defineComponent({ const getInitialIndex = (): number => { if (props.tabId) { const valueIndex = props.data.findIndex( - ({ id }) => tabStore.value[props.tabId] === id, + ({ id }) => tabStore.value[props.tabId!] === id, ) if (valueIndex !== -1) return valueIndex @@ -125,7 +122,7 @@ export const Tabs = defineComponent({ activeIndex.value = getInitialIndex() watch( - () => tabStore.value[props.tabId], + () => props.tabId && tabStore.value[props.tabId], (newValue, oldValue) => { if (props.tabId && newValue !== oldValue) { const index = props.data.findIndex(({ id }) => id === newValue) diff --git a/plugins/markdown/plugin-revealjs/src/client/components/RevealJs.ts b/plugins/markdown/plugin-revealjs/src/client/components/RevealJs.ts index b7fe6253a9..c059b96bdb 100644 --- a/plugins/markdown/plugin-revealjs/src/client/components/RevealJs.ts +++ b/plugins/markdown/plugin-revealjs/src/client/components/RevealJs.ts @@ -29,21 +29,30 @@ export const RevealJs = defineComponent({ * * 幻灯片 id */ - id: { type: String, required: true }, + id: { + type: String, + required: true, + }, /** * Presentation code * * 幻灯片代码 */ - code: { type: String, required: true }, + code: { + type: String, + required: true, + }, /** * Presentation theme * * 幻灯片主题 */ - theme: { type: String as PropType, default: 'auto' }, + theme: { + type: String as PropType, + default: 'auto', + }, }, setup(props) {