diff --git a/package.json b/package.json index 4354b3ea..b66481d1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "@formkit/themes": "1.0.0-beta.10", "@formkit/vue": "1.0.0-beta.10", "@halo-dev/admin-shared": "workspace:*", - "@halo-dev/api-client": "^0.0.14", + "@halo-dev/api-client": "^0.0.15", "@halo-dev/components": "workspace:*", "@halo-dev/richtext-editor": "^0.0.0-alpha.5", "@tiptap/extension-character-count": "2.0.0-beta.31", diff --git a/packages/shared/package.json b/packages/shared/package.json index 642ab407..3919a845 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -38,7 +38,7 @@ "homepage": "https://github.com/halo-dev/halo-admin/tree/next/shared/components#readme", "license": "MIT", "dependencies": { - "@halo-dev/api-client": "^0.0.14", + "@halo-dev/api-client": "^0.0.15", "@halo-dev/components": "workspace:*", "axios": "^0.27.2", "lodash.merge": "^4.6.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86fb0c96..8f05b8f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,7 +13,7 @@ importers: '@formkit/themes': 1.0.0-beta.10 '@formkit/vue': 1.0.0-beta.10 '@halo-dev/admin-shared': workspace:* - '@halo-dev/api-client': ^0.0.14 + '@halo-dev/api-client': ^0.0.15 '@halo-dev/components': workspace:* '@halo-dev/richtext-editor': ^0.0.0-alpha.5 '@iconify-json/vscode-icons': ^1.1.11 @@ -92,7 +92,7 @@ importers: '@formkit/themes': 1.0.0-beta.10_tailwindcss@3.1.8 '@formkit/vue': 1.0.0-beta.10_wwmyxdjqen5bmh3tr2meig5lki '@halo-dev/admin-shared': link:packages/shared - '@halo-dev/api-client': 0.0.14 + '@halo-dev/api-client': 0.0.15 '@halo-dev/components': link:packages/components '@halo-dev/richtext-editor': 0.0.0-alpha.5_vue@3.2.37 '@tiptap/extension-character-count': 2.0.0-beta.31 @@ -194,14 +194,14 @@ importers: packages/shared: specifiers: - '@halo-dev/api-client': ^0.0.14 + '@halo-dev/api-client': ^0.0.15 '@halo-dev/components': workspace:* '@types/lodash.merge': ^4.6.7 axios: ^0.27.2 lodash.merge: ^4.6.2 vite-plugin-dts: ^1.4.1 dependencies: - '@halo-dev/api-client': 0.0.14 + '@halo-dev/api-client': 0.0.15 '@halo-dev/components': link:../components axios: 0.27.2 lodash.merge: 4.6.2 @@ -2129,8 +2129,8 @@ packages: - windicss dev: false - /@halo-dev/api-client/0.0.14: - resolution: {integrity: sha512-Qh0/l2f5e8lxBgAU2brN28F3CzZTlxGUGY0puUGbuDRYqEENbQ5pGTHG3CzuiG4it4Pn16xSTCXICO6M9m9X4A==} + /@halo-dev/api-client/0.0.15: + resolution: {integrity: sha512-RCQXU2s5IJJ3pUORg0n2b/CYbDox/Jm4aXB2J9ZbKod3vdS3HM6X33iVXc/pyuxRjucijly3WyLkiTZ0bkwLbg==} dev: false /@halo-dev/richtext-editor/0.0.0-alpha.5_vue@3.2.37: diff --git a/src/modules/contents/posts/PostList.vue b/src/modules/contents/posts/PostList.vue index f7e096cb..6b4f29e6 100644 --- a/src/modules/contents/posts/PostList.vue +++ b/src/modules/contents/posts/PostList.vue @@ -54,8 +54,8 @@ const checkedAll = ref(false); const selectedPostNames = ref([]); const { users } = useUserFetch(); -const { categories } = usePostCategory(); -const { tags } = usePostTag(); +const { categories } = usePostCategory({ fetchOnMounted: true }); +const { tags } = usePostTag({ fetchOnMounted: true }); const dialog = useDialog(); const handleFetchPosts = async () => { diff --git a/src/modules/contents/posts/categories/CategoryList.vue b/src/modules/contents/posts/categories/CategoryList.vue index 2ecdad35..0689ff2d 100644 --- a/src/modules/contents/posts/categories/CategoryList.vue +++ b/src/modules/contents/posts/categories/CategoryList.vue @@ -40,7 +40,7 @@ const { loading, handleFetchCategories, handleDelete, -} = usePostCategory(); +} = usePostCategory({ fetchOnMounted: true }); const handleUpdateInBatch = useDebounceFn(async () => { const categoriesTreeToUpdate = resetCategoriesTreePriority( diff --git a/src/modules/contents/posts/categories/composables/use-post-category.ts b/src/modules/contents/posts/categories/composables/use-post-category.ts index 8d774ecc..e15124e9 100644 --- a/src/modules/contents/posts/categories/composables/use-post-category.ts +++ b/src/modules/contents/posts/categories/composables/use-post-category.ts @@ -14,7 +14,11 @@ interface usePostCategoryReturn { handleDelete: (category: CategoryTree) => void; } -export function usePostCategory(): usePostCategoryReturn { +export function usePostCategory(options?: { + fetchOnMounted: boolean; +}): usePostCategoryReturn { + const { fetchOnMounted } = options || {}; + const categories = ref([] as Category[]); const categoriesTree = ref([] as CategoryTree[]); const loading = ref(false); @@ -59,7 +63,9 @@ export function usePostCategory(): usePostCategoryReturn { }); }; - onMounted(handleFetchCategories); + onMounted(() => { + fetchOnMounted && handleFetchCategories(); + }); return { categories, diff --git a/src/modules/contents/posts/components/PostSettingModal.vue b/src/modules/contents/posts/components/PostSettingModal.vue index d42aa55b..57810a51 100644 --- a/src/modules/contents/posts/components/PostSettingModal.vue +++ b/src/modules/contents/posts/components/PostSettingModal.vue @@ -67,7 +67,7 @@ const saving = ref(false); const publishing = ref(false); const publishCanceling = ref(false); -const { categories } = usePostCategory(); +const { categories } = usePostCategory({ fetchOnMounted: true }); const categoriesMap = computed(() => { return categories.value.map((category) => { return { @@ -77,7 +77,7 @@ const categoriesMap = computed(() => { }); }); -const { tags } = usePostTag(); +const { tags } = usePostTag({ fetchOnMounted: true }); const tagsMap = computed(() => { return tags.value.map((tag) => { return { diff --git a/src/modules/contents/posts/tags/TagList.vue b/src/modules/contents/posts/tags/TagList.vue index 0f5421ed..f31b5ae3 100644 --- a/src/modules/contents/posts/tags/TagList.vue +++ b/src/modules/contents/posts/tags/TagList.vue @@ -40,7 +40,9 @@ const viewTypes = [ const viewType = ref("list"); -const { tags, loading, handleFetchTags, handleDelete } = usePostTag(); +const { tags, loading, handleFetchTags, handleDelete } = usePostTag({ + fetchOnMounted: true, +}); const editingModal = ref(false); const selectedTag = ref(null); diff --git a/src/modules/contents/posts/tags/composables/use-post-tag.ts b/src/modules/contents/posts/tags/composables/use-post-tag.ts index 434c6c88..e704b3a2 100644 --- a/src/modules/contents/posts/tags/composables/use-post-tag.ts +++ b/src/modules/contents/posts/tags/composables/use-post-tag.ts @@ -11,7 +11,11 @@ interface usePostTagReturn { handleDelete: (tag: Tag) => void; } -export function usePostTag(): usePostTagReturn { +export function usePostTag(options?: { + fetchOnMounted: boolean; +}): usePostTagReturn { + const { fetchOnMounted } = options || {}; + const tags = ref([] as Tag[]); const loading = ref(false); @@ -53,7 +57,9 @@ export function usePostTag(): usePostTagReturn { }); }; - onMounted(handleFetchTags); + onMounted(() => { + fetchOnMounted && handleFetchTags(); + }); return { tags, diff --git a/src/modules/interface/menus/components/MenuItemEditingModal.vue b/src/modules/interface/menus/components/MenuItemEditingModal.vue index d4c45b04..6f30c778 100644 --- a/src/modules/interface/menus/components/MenuItemEditingModal.vue +++ b/src/modules/interface/menus/components/MenuItemEditingModal.vue @@ -1,12 +1,14 @@