feat: add requests library as a global shared dependency

pull/6132/head
Ryan Wang 2024-06-25 12:31:44 +08:00
parent ecc0a70249
commit c74187c066
156 changed files with 1866 additions and 1964 deletions

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { watch, type Ref, ref, nextTick } from "vue"; import { watch, type Ref, ref, nextTick } from "vue";
interface SnapshotContent { interface SnapshotContent {
@ -20,10 +20,9 @@ export function useContentSnapshot(
if (!snapshotName.value) { if (!snapshotName.value) {
return; return;
} }
const { data } = const { data } = await coreApiClient.content.snapshot.getSnapshot({
await apiClient.extension.snapshot.getContentHaloRunV1alpha1Snapshot({ name: snapshotName.value,
name: snapshotName.value, });
});
version.value = data.metadata.version || 0; version.value = data.metadata.version || 0;
}; };

View File

@ -1,11 +1,11 @@
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
export function useDashboardStats() { export function useDashboardStats() {
const { data } = useQuery({ const { data } = useQuery({
queryKey: ["dashboard-stats"], queryKey: ["dashboard-stats"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.stats.getStats(); const { data } = await consoleApiClient.system.getStats();
return data; return data;
}, },
}); });

View File

@ -3,7 +3,7 @@ import type { DirectiveBinding } from "vue";
import { createPinia } from "pinia"; import { createPinia } from "pinia";
import App from "./App.vue"; import App from "./App.vue";
import router from "./router"; import router from "./router";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
// setup // setup
import "@/setup/setupStyles"; import "@/setup/setupStyles";
import { setupComponents } from "@/setup/setupComponents"; import { setupComponents } from "@/setup/setupComponents";
@ -20,19 +20,22 @@ import {
setupCoreModules, setupCoreModules,
setupPluginModules, setupPluginModules,
} from "@console/setup/setupModules"; } from "@console/setup/setupModules";
import { setupApiClient } from "@/setup/setupApiClient";
const app = createApp(App); const app = createApp(App);
setupComponents(app); setupComponents(app);
setupI18n(app); setupI18n(app);
setupVueQuery(app); setupVueQuery(app);
setupApiClient();
app.use(createPinia()); app.use(createPinia());
async function loadUserPermissions() { async function loadUserPermissions() {
const { data: currentPermissions } = await apiClient.user.getPermissions({ const { data: currentPermissions } =
name: "-", await consoleApiClient.user.getPermissions({
}); name: "-",
});
const roleStore = useRoleStore(); const roleStore = useRoleStore();
roleStore.$patch({ roleStore.$patch({
permissions: currentPermissions, permissions: currentPermissions,

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue"; import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
import LazyImage from "@/components/image/LazyImage.vue"; import LazyImage from "@/components/image/LazyImage.vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { isImage } from "@/utils/image"; import { isImage } from "@/utils/image";
import type { Attachment, Group } from "@halo-dev/api-client"; import type { Attachment, Group } from "@halo-dev/api-client";
import { import {
@ -129,18 +129,16 @@ provide<Ref<Set<Attachment>>>("selectedAttachments", selectedAttachments);
const handleMove = async (group: Group) => { const handleMove = async (group: Group) => {
try { try {
const promises = Array.from(selectedAttachments.value).map((attachment) => { const promises = Array.from(selectedAttachments.value).map((attachment) => {
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment( return coreApiClient.storage.attachment.patchAttachment({
{ name: attachment.metadata.name,
name: attachment.metadata.name, jsonPatchInner: [
jsonPatchInner: [ {
{ op: "add",
op: "add", path: "/spec/groupName",
path: "/spec/groupName", value: group.metadata.name,
value: group.metadata.name, },
}, ],
], });
}
);
}); });
await Promise.all(promises); await Promise.all(promises);
@ -232,8 +230,8 @@ onMounted(() => {
if (!nameQuery.value) { if (!nameQuery.value) {
return; return;
} }
apiClient.extension.storage.attachment coreApiClient.storage.attachment
.getStorageHaloRunV1alpha1Attachment({ .getAttachment({
name: nameQuery.value, name: nameQuery.value,
}) })
.then((response) => { .then((response) => {

View File

@ -10,7 +10,7 @@ import LazyImage from "@/components/image/LazyImage.vue";
import type { Attachment } from "@halo-dev/api-client"; import type { Attachment } from "@halo-dev/api-client";
import prettyBytes from "pretty-bytes"; import prettyBytes from "pretty-bytes";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { isImage } from "@/utils/image"; import { isImage } from "@/utils/image";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { useFetchAttachmentGroup } from "../composables/use-attachment-group"; import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
@ -47,10 +47,9 @@ const { data: policy } = useQuery({
return; return;
} }
const { data } = const { data } = await coreApiClient.storage.policy.getPolicy({
await apiClient.extension.storage.policy.getStorageHaloRunV1alpha1Policy({ name: policyName.value,
name: policyName.value, });
});
return data; return data;
}, },

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { Group } from "@halo-dev/api-client"; import type { Group } from "@halo-dev/api-client";
import { import {
Dialog, Dialog,
@ -49,29 +49,28 @@ const handleDelete = () => {
} }
// TODO: // TODO:
const { data } = await apiClient.attachment.searchAttachments({ const { data } =
fieldSelector: [`spec.groupName=${props.group.metadata.name}`], await consoleApiClient.storage.attachment.searchAttachments({
page: 0, fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
size: 0, page: 0,
}); size: 0,
});
await apiClient.extension.storage.group.deleteStorageHaloRunV1alpha1Group( await coreApiClient.storage.group.deleteGroup({
{ name: props.group.metadata.name } name: props.group.metadata.name,
); });
// move attachments to none group // move attachments to none group
const moveToUnGroupRequests = data.items.map((attachment) => { const moveToUnGroupRequests = data.items.map((attachment) => {
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment( return coreApiClient.storage.attachment.patchAttachment({
{ name: attachment.metadata.name,
name: attachment.metadata.name, jsonPatchInner: [
jsonPatchInner: [ {
{ op: "remove",
op: "remove", path: "/spec/groupName",
path: "/spec/groupName", },
}, ],
], });
}
);
}); });
await Promise.all(moveToUnGroupRequests); await Promise.all(moveToUnGroupRequests);
@ -105,20 +104,21 @@ const handleDeleteWithAttachments = () => {
} }
// TODO: // TODO:
const { data } = await apiClient.attachment.searchAttachments({ const { data } =
fieldSelector: [`spec.groupName=${props.group.metadata.name}`], await consoleApiClient.storage.attachment.searchAttachments({
page: 0, fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
size: 0, page: 0,
size: 0,
});
await coreApiClient.storage.group.deleteGroup({
name: props.group.metadata.name,
}); });
await apiClient.extension.storage.group.deleteStorageHaloRunV1alpha1Group(
{ name: props.group.metadata.name }
);
const deleteAttachmentRequests = data.items.map((attachment) => { const deleteAttachmentRequests = data.items.map((attachment) => {
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment( return coreApiClient.storage.attachment.deleteAttachment({
{ name: attachment.metadata.name } name: attachment.metadata.name,
); });
}); });
await Promise.all(deleteAttachmentRequests); await Promise.all(deleteAttachmentRequests);

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { Group } from "@halo-dev/api-client"; import type { Group } from "@halo-dev/api-client";
import { Toast, VButton, VModal, VSpace } from "@halo-dev/components"; import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
@ -45,18 +45,14 @@ const handleSave = async () => {
try { try {
isSubmitting.value = true; isSubmitting.value = true;
if (props.group) { if (props.group) {
await apiClient.extension.storage.group.updateStorageHaloRunV1alpha1Group( await coreApiClient.storage.group.updateGroup({
{ name: formState.value.metadata.name,
name: formState.value.metadata.name, group: formState.value,
group: formState.value, });
}
);
} else { } else {
await apiClient.extension.storage.group.createStorageHaloRunV1alpha1Group( await coreApiClient.storage.group.createGroup({
{ group: formState.value,
group: formState.value, });
}
);
} }
Toast.success(t("core.common.toast.save_success")); Toast.success(t("core.common.toast.save_success"));

View File

@ -15,7 +15,7 @@ import type { Attachment } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import prettyBytes from "pretty-bytes"; import prettyBytes from "pretty-bytes";
import { useFetchAttachmentPolicy } from "../composables/use-attachment-policy"; import { useFetchAttachmentPolicy } from "../composables/use-attachment-policy";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
@ -65,11 +65,9 @@ const handleDelete = () => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment( await coreApiClient.storage.attachment.deleteAttachment({
{ name: props.attachment.metadata.name,
name: props.attachment.metadata.name, });
}
);
selectedAttachments.value.delete(props.attachment); selectedAttachments.value.delete(props.attachment);

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import type { Policy, PolicyTemplate } from "@halo-dev/api-client"; import type { Policy, PolicyTemplate } from "@halo-dev/api-client";
import { import {
@ -50,7 +50,7 @@ const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
}; };
const handleDelete = async (policy: Policy) => { const handleDelete = async (policy: Policy) => {
const { data } = await apiClient.attachment.searchAttachments({ const { data } = await consoleApiClient.storage.attachment.searchAttachments({
fieldSelector: [`spec.policyName=${policy.metadata.name}`], fieldSelector: [`spec.policyName=${policy.metadata.name}`],
}); });
@ -76,9 +76,9 @@ const handleDelete = async (policy: Policy) => {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.extension.storage.policy.deleteStorageHaloRunV1alpha1Policy( await coreApiClient.storage.policy.deletePolicy({
{ name: policy.metadata.name } name: policy.metadata.name,
); });
Toast.success(t("core.common.toast.delete_success")); Toast.success(t("core.common.toast.delete_success"));
handleFetchPolicies(); handleFetchPolicies();

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import { useSettingFormConvert } from "@console/composables/use-setting-form";
import type { Policy } from "@halo-dev/api-client"; import type { Policy } from "@halo-dev/api-client";
import { Toast, VButton, VLoading, VModal, VSpace } from "@halo-dev/components"; import { Toast, VButton, VLoading, VModal, VSpace } from "@halo-dev/components";
@ -66,11 +66,9 @@ const { data: policyTemplate } = useQuery({
cacheTime: 0, cacheTime: 0,
queryFn: async () => { queryFn: async () => {
const { data } = const { data } =
await apiClient.extension.storage.policyTemplate.getStorageHaloRunV1alpha1PolicyTemplate( await coreApiClient.storage.policyTemplate.getPolicyTemplate({
{ name: formState.value.spec.templateName,
name: formState.value.spec.templateName, });
}
);
return data; return data;
}, },
retry: 0, retry: 0,
@ -88,7 +86,7 @@ const { data: setting, isLoading } = useQuery({
throw new Error("No setting found"); throw new Error("No setting found");
} }
const { data } = await apiClient.extension.setting.getV1alpha1Setting({ const { data } = await coreApiClient.setting.getSetting({
name: policyTemplate.value.spec.settingName, name: policyTemplate.value.spec.settingName,
}); });
@ -118,7 +116,7 @@ const { data: configMap } = useQuery({
if (!policy.value?.spec.configMapName) { if (!policy.value?.spec.configMapName) {
throw new Error("No configMap found"); throw new Error("No configMap found");
} }
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({ const { data } = await coreApiClient.configMap.getConfigMap({
name: policy.value?.spec.configMapName, name: policy.value?.spec.configMapName,
}); });
return data; return data;
@ -141,29 +139,26 @@ const handleSave = async () => {
const configMapToUpdate = convertToSave(); const configMapToUpdate = convertToSave();
if (isUpdateMode) { if (isUpdateMode) {
await apiClient.extension.configMap.updateV1alpha1ConfigMap({ await coreApiClient.configMap.updateConfigMap({
name: configMap.value.metadata.name, name: configMap.value.metadata.name,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });
await apiClient.extension.storage.policy.updateStorageHaloRunV1alpha1Policy( await coreApiClient.storage.policy.updatePolicy({
{ name: formState.value.metadata.name,
name: formState.value.metadata.name, policy: formState.value,
policy: formState.value, });
}
);
} else { } else {
const { data: newConfigMap } = const { data: newConfigMap } =
await apiClient.extension.configMap.createV1alpha1ConfigMap({ await coreApiClient.configMap.createConfigMap({
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });
formState.value.spec.configMapName = newConfigMap.metadata.name; formState.value.spec.configMapName = newConfigMap.metadata.name;
await apiClient.extension.storage.policy.createStorageHaloRunV1alpha1Policy(
{ await coreApiClient.storage.policy.createPolicy({
policy: formState.value, policy: formState.value,
} });
);
} }
Toast.success(t("core.common.toast.save_success")); Toast.success(t("core.common.toast.save_success"));

View File

@ -1,6 +1,6 @@
import type { Ref } from "vue"; import type { Ref } from "vue";
import type { Group } from "@halo-dev/api-client"; import type { Group } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
interface useFetchAttachmentGroupReturn { interface useFetchAttachmentGroupReturn {
@ -13,13 +13,10 @@ export function useFetchAttachmentGroup(): useFetchAttachmentGroupReturn {
const { data, isLoading, refetch } = useQuery<Group[]>({ const { data, isLoading, refetch } = useQuery<Group[]>({
queryKey: ["attachment-groups"], queryKey: ["attachment-groups"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.storage.group.listGroup({
await apiClient.extension.storage.group.listStorageHaloRunV1alpha1Group( labelSelector: ["!halo.run/hidden"],
{ sort: ["metadata.creationTimestamp,asc"],
labelSelector: ["!halo.run/hidden"], });
sort: ["metadata.creationTimestamp,asc"],
}
);
return data.items; return data.items;
}, },

View File

@ -1,6 +1,6 @@
import type { Ref } from "vue"; import type { Ref } from "vue";
import type { Policy, PolicyTemplate } from "@halo-dev/api-client"; import type { Policy, PolicyTemplate } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
interface useFetchAttachmentPolicyReturn { interface useFetchAttachmentPolicyReturn {
@ -19,8 +19,7 @@ export function useFetchAttachmentPolicy(): useFetchAttachmentPolicyReturn {
const { data, isLoading, refetch } = useQuery<Policy[]>({ const { data, isLoading, refetch } = useQuery<Policy[]>({
queryKey: ["attachment-policies"], queryKey: ["attachment-policies"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.storage.policy.listPolicy();
await apiClient.extension.storage.policy.listStorageHaloRunV1alpha1Policy();
return data.items; return data.items;
}, },
refetchInterval(data) { refetchInterval(data) {
@ -43,7 +42,7 @@ export function useFetchAttachmentPolicyTemplate(): useFetchAttachmentPolicyTemp
queryKey: ["attachment-policy-templates"], queryKey: ["attachment-policy-templates"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } =
await apiClient.extension.storage.policyTemplate.listStorageHaloRunV1alpha1PolicyTemplate(); await coreApiClient.storage.policyTemplate.listPolicyTemplate();
return data.items; return data.items;
}, },
}); });

View File

@ -1,6 +1,6 @@
import type { Attachment } from "@halo-dev/api-client"; import type { Attachment } from "@halo-dev/api-client";
import { computed, nextTick, type Ref, ref, watch } from "vue"; import { computed, nextTick, type Ref, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { Dialog, Toast } from "@halo-dev/components"; import { Dialog, Toast } from "@halo-dev/components";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -77,15 +77,16 @@ export function useAttachmentControl(filterOptions: {
}) })
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const { data } = await apiClient.attachment.searchAttachments({ const { data } =
fieldSelector, await consoleApiClient.storage.attachment.searchAttachments({
page: page.value, fieldSelector,
size: size.value, page: page.value,
ungrouped: isUnGrouped, size: size.value,
accepts: accepts?.value, ungrouped: isUnGrouped,
keyword: keyword?.value, accepts: accepts?.value,
sort: [sort?.value as string].filter(Boolean), keyword: keyword?.value,
}); sort: [sort?.value as string].filter(Boolean),
});
total.value = data.total; total.value = data.total;
hasPrevious.value = data.hasPrevious; hasPrevious.value = data.hasPrevious;
@ -158,11 +159,9 @@ export function useAttachmentControl(filterOptions: {
try { try {
const promises = Array.from(selectedAttachments.value).map( const promises = Array.from(selectedAttachments.value).map(
(attachment) => { (attachment) => {
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment( return coreApiClient.storage.attachment.deleteAttachment({
{ name: attachment.metadata.name,
name: attachment.metadata.name, });
}
);
} }
); );
await Promise.all(promises); await Promise.all(promises);

View File

@ -15,7 +15,7 @@ import {
import CommentListItem from "./components/CommentListItem.vue"; import CommentListItem from "./components/CommentListItem.vue";
import type { ListedComment } from "@halo-dev/api-client"; import type { ListedComment } from "@halo-dev/api-client";
import { computed, ref, watch } from "vue"; import { computed, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue"; import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
@ -101,7 +101,7 @@ const {
}) })
.filter(Boolean) as string[]; .filter(Boolean) as string[];
const { data } = await apiClient.comment.listComments({ const { data } = await consoleApiClient.content.comment.listComments({
fieldSelector, fieldSelector,
page: page.value, page: page.value,
size: size.value, size: size.value,
@ -165,11 +165,9 @@ const handleDeleteInBatch = async () => {
onConfirm: async () => { onConfirm: async () => {
try { try {
const promises = selectedCommentNames.value.map((name) => { const promises = selectedCommentNames.value.map((name) => {
return apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment( return coreApiClient.content.comment.deleteComment({
{ name,
name, });
}
);
}); });
await Promise.all(promises); await Promise.all(promises);
selectedCommentNames.value = []; selectedCommentNames.value = [];
@ -200,24 +198,22 @@ const handleApproveInBatch = async () => {
}); });
const promises = commentsToUpdate?.map((comment) => { const promises = commentsToUpdate?.map((comment) => {
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment( return coreApiClient.content.comment.patchComment({
{ name: comment.comment.metadata.name,
name: comment.comment.metadata.name, jsonPatchInner: [
jsonPatchInner: [ {
{ op: "add",
op: "add", path: "/spec/approved",
path: "/spec/approved", value: true,
value: true, },
}, {
{ op: "add",
op: "add", path: "/spec/approvedTime",
path: "/spec/approvedTime", // TODO: see https://github.com/halo-dev/halo/pull/2746
// TODO: see https://github.com/halo-dev/halo/pull/2746 value: new Date().toISOString(),
value: new Date().toISOString(), },
}, ],
], });
}
);
}); });
await Promise.all(promises || []); await Promise.all(promises || []);
selectedCommentNames.value = []; selectedCommentNames.value = [];

View File

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { usePluginModuleStore } from "@/stores/plugin"; import { usePluginModuleStore } from "@/stores/plugin";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import type { import type {
@ -65,7 +65,7 @@ const handleDelete = async () => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment({ await coreApiClient.content.comment.deleteComment({
name: props.comment?.comment?.metadata.name as string, name: props.comment?.comment?.metadata.name as string,
}); });
@ -90,7 +90,7 @@ const handleApproveReplyInBatch = async () => {
return !reply.reply.spec.approved; return !reply.reply.spec.approved;
}); });
const promises = repliesToUpdate?.map((reply) => { const promises = repliesToUpdate?.map((reply) => {
return apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({ return coreApiClient.content.reply.patchReply({
name: reply.reply.metadata.name, name: reply.reply.metadata.name,
jsonPatchInner: [ jsonPatchInner: [
{ {
@ -121,7 +121,7 @@ const handleApproveReplyInBatch = async () => {
const handleApprove = async () => { const handleApprove = async () => {
try { try {
await apiClient.extension.comment.patchContentHaloRunV1alpha1Comment({ await coreApiClient.content.comment.patchComment({
name: props.comment.comment.metadata.name, name: props.comment.comment.metadata.name,
jsonPatchInner: [ jsonPatchInner: [
{ {
@ -157,7 +157,7 @@ const {
showReplies, showReplies,
], ],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.reply.listReplies({ const { data } = await consoleApiClient.content.reply.listReplies({
commentName: props.comment.comment.metadata.name, commentName: props.comment.comment.metadata.name,
page: 0, page: 0,
size: 0, size: 0,
@ -176,7 +176,7 @@ const {
const { mutateAsync: updateCommentLastReadTimeMutate } = useMutation({ const { mutateAsync: updateCommentLastReadTimeMutate } = useMutation({
mutationKey: ["update-comment-last-read-time"], mutationKey: ["update-comment-last-read-time"],
mutationFn: async () => { mutationFn: async () => {
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment( return coreApiClient.content.comment.patchComment(
{ {
name: props.comment.comment.metadata.name, name: props.comment.comment.metadata.name,
jsonPatchInner: [ jsonPatchInner: [

View File

@ -18,7 +18,7 @@ import { Picker } from "emoji-mart";
import i18n from "@emoji-mart/data/i18n/zh.json"; import i18n from "@emoji-mart/data/i18n/zh.json";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
const { t } = useI18n(); const { t } = useI18n();
@ -62,7 +62,7 @@ const handleCreateReply = async () => {
formState.value.content = formState.value.raw; formState.value.content = formState.value.raw;
await apiClient.comment.createReply({ await consoleApiClient.content.comment.createReply({
name: props.comment?.comment.metadata.name as string, name: props.comment?.comment.metadata.name as string,
replyRequest: formState.value, replyRequest: formState.value,
}); });

View File

@ -12,7 +12,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { ListedComment, ListedReply } from "@halo-dev/api-client"; import type { ListedComment, ListedReply } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { computed, inject, ref, type Ref } from "vue"; import { computed, inject, ref, type Ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
@ -54,7 +54,7 @@ const handleDelete = async () => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.reply.deleteContentHaloRunV1alpha1Reply({ await coreApiClient.content.reply.deleteReply({
name: props.reply?.reply.metadata.name as string, name: props.reply?.reply.metadata.name as string,
}); });
@ -70,7 +70,7 @@ const handleDelete = async () => {
const handleApprove = async () => { const handleApprove = async () => {
try { try {
await apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({ await coreApiClient.content.reply.patchReply({
name: props.reply.reply.metadata.name, name: props.reply.reply.metadata.name,
jsonPatchInner: [ jsonPatchInner: [
{ {

View File

@ -19,7 +19,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client"; import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
@ -46,7 +46,7 @@ const {
} = useQuery<ListedSinglePage[]>({ } = useQuery<ListedSinglePage[]>({
queryKey: ["deleted-singlePages", page, size, keyword], queryKey: ["deleted-singlePages", page, size, keyword],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePages({ const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector: [`content.halo.run/deleted=true`], labelSelector: [`content.halo.run/deleted=true`],
page: page.value, page: page.value,
size: size.value, size: size.value,
@ -92,11 +92,9 @@ const handleDeletePermanently = async (singlePage: SinglePage) => {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage( await coreApiClient.content.singlePage.deleteSinglePage({
{ name: singlePage.metadata.name,
name: singlePage.metadata.name, });
}
);
await refetch(); await refetch();
Toast.success(t("core.common.toast.delete_success")); Toast.success(t("core.common.toast.delete_success"));
@ -114,11 +112,9 @@ const handleDeletePermanentlyInBatch = async () => {
onConfirm: async () => { onConfirm: async () => {
await Promise.all( await Promise.all(
selectedPageNames.value.map((name) => { selectedPageNames.value.map((name) => {
return apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage( return coreApiClient.content.singlePage.deleteSinglePage({
{ name,
name, });
}
);
}) })
); );
await refetch(); await refetch();
@ -138,12 +134,10 @@ const handleRecovery = async (singlePage: SinglePage) => {
onConfirm: async () => { onConfirm: async () => {
const singlePageToUpdate = cloneDeep(singlePage); const singlePageToUpdate = cloneDeep(singlePage);
singlePageToUpdate.spec.deleted = false; singlePageToUpdate.spec.deleted = false;
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( await coreApiClient.content.singlePage.updateSinglePage({
{ name: singlePageToUpdate.metadata.name,
name: singlePageToUpdate.metadata.name, singlePage: singlePageToUpdate,
singlePage: singlePageToUpdate, });
}
);
await refetch(); await refetch();
Toast.success(t("core.common.toast.recovery_success")); Toast.success(t("core.common.toast.recovery_success"));
@ -170,18 +164,16 @@ const handleRecoveryInBatch = async () => {
return Promise.resolve(); return Promise.resolve();
} }
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( return coreApiClient.content.singlePage.updateSinglePage({
{ name: singlePage.metadata.name,
name: singlePage.metadata.name, singlePage: {
singlePage: { ...singlePage,
...singlePage, spec: {
spec: { ...singlePage.spec,
...singlePage.spec, deleted: false,
deleted: false,
},
}, },
} },
); });
}) })
); );
await refetch(); await refetch();

View File

@ -24,7 +24,11 @@ import {
toRef, toRef,
watch, watch,
} from "vue"; } from "vue";
import { apiClient } from "@/utils/api-client"; import {
consoleApiClient,
coreApiClient,
ucApiClient,
} from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { randomUUID } from "@/utils/id"; import { randomUUID } from "@/utils/id";
@ -156,10 +160,11 @@ const handleSave = async (options?: { mute?: boolean }) => {
).data; ).data;
} }
const { data } = await apiClient.singlePage.updateSinglePageContent({ const { data } =
name: formState.value.page.metadata.name, await consoleApiClient.content.singlePage.updateSinglePageContent({
content: formState.value.content, name: formState.value.page.metadata.name,
}); content: formState.value.content,
});
formState.value.page = data; formState.value.page = data;
isTitleChanged.value = false; isTitleChanged.value = false;
@ -167,9 +172,10 @@ const handleSave = async (options?: { mute?: boolean }) => {
// Clear new page content cache // Clear new page content cache
handleClearCache(); handleClearCache();
const { data } = await apiClient.singlePage.draftSinglePage({ const { data } =
singlePageRequest: formState.value, await consoleApiClient.content.singlePage.draftSinglePage({
}); singlePageRequest: formState.value,
});
formState.value.page = data; formState.value.page = data;
routeQueryName.value = data.metadata.name; routeQueryName.value = data.metadata.name;
} }
@ -205,12 +211,12 @@ const handlePublish = async () => {
).data; ).data;
} }
await apiClient.singlePage.updateSinglePageContent({ await consoleApiClient.content.singlePage.updateSinglePageContent({
name: singlePageName, name: singlePageName,
content: formState.value.content, content: formState.value.content,
}); });
await apiClient.singlePage.publishSinglePage({ await consoleApiClient.content.singlePage.publishSinglePage({
name: singlePageName, name: singlePageName,
}); });
@ -221,7 +227,7 @@ const handlePublish = async () => {
} }
} else { } else {
formState.value.page.spec.publish = true; formState.value.page.spec.publish = true;
await apiClient.singlePage.draftSinglePage({ await consoleApiClient.content.singlePage.draftSinglePage({
singlePageRequest: formState.value, singlePageRequest: formState.value,
}); });
@ -254,9 +260,10 @@ const handleFetchContent = async () => {
if (!formState.value.page.spec.headSnapshot) { if (!formState.value.page.spec.headSnapshot) {
return; return;
} }
const { data } = await apiClient.singlePage.fetchSinglePageHeadContent({ const { data } =
name: formState.value.page.metadata.name, await consoleApiClient.content.singlePage.fetchSinglePageHeadContent({
}); name: formState.value.page.metadata.name,
});
formState.value.content = Object.assign(formState.value.content, data); formState.value.content = Object.assign(formState.value.content, data);
@ -305,7 +312,7 @@ const handleFetchContent = async () => {
// SinglePage settings // SinglePage settings
const handleOpenSettingModal = async () => { const handleOpenSettingModal = async () => {
const { data: latestSinglePage } = const { data: latestSinglePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ await coreApiClient.content.singlePage.getSinglePage({
name: formState.value.page.metadata.name, name: formState.value.page.metadata.name,
}); });
formState.value.page = latestSinglePage; formState.value.page = latestSinglePage;
@ -335,7 +342,7 @@ onMounted(async () => {
if (routeQueryName.value) { if (routeQueryName.value) {
const { data: singlePage } = const { data: singlePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ await coreApiClient.content.singlePage.getSinglePage({
name: routeQueryName.value, name: routeQueryName.value,
}); });
formState.value.page = singlePage; formState.value.page = singlePage;
@ -412,7 +419,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
await handleSave(); await handleSave();
} }
const { data } = await apiClient.uc.attachment.createAttachmentForPost( const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
{ {
file, file,
singlePageName: formState.value.page.metadata.name, singlePageName: formState.value.page.metadata.name,

View File

@ -19,7 +19,7 @@ import SinglePageSettingModal from "./components/SinglePageSettingModal.vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { computed, provide, ref, watch } from "vue"; import { computed, provide, ref, watch } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client"; import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { singlePageLabels } from "@/constants/labels"; import { singlePageLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -114,7 +114,7 @@ const {
); );
} }
const { data } = await apiClient.singlePage.listSinglePages({ const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector, labelSelector,
page: page.value, page: page.value,
size: size.value, size: size.value,
@ -143,10 +143,9 @@ const {
}); });
const handleOpenSettingModal = async (singlePage: SinglePage) => { const handleOpenSettingModal = async (singlePage: SinglePage) => {
const { data } = const { data } = await coreApiClient.content.singlePage.getSinglePage({
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ name: singlePage.metadata.name,
name: singlePage.metadata.name, });
});
selectedSinglePage.value = data; selectedSinglePage.value = data;
settingModal.value = true; settingModal.value = true;
}; };
@ -165,10 +164,9 @@ const handleSelectPrevious = async () => {
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
); );
if (index > 0) { if (index > 0) {
const { data } = const { data } = await coreApiClient.content.singlePage.getSinglePage({
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ name: singlePages.value[index - 1].page.metadata.name,
name: singlePages.value[index - 1].page.metadata.name, });
});
selectedSinglePage.value = data; selectedSinglePage.value = data;
return; return;
} }
@ -188,10 +186,9 @@ const handleSelectNext = async () => {
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
); );
if (index < singlePages.value.length - 1) { if (index < singlePages.value.length - 1) {
const { data } = const { data } = await coreApiClient.content.singlePage.getSinglePage({
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ name: singlePages.value[index + 1].page.metadata.name,
name: singlePages.value[index + 1].page.metadata.name, });
});
selectedSinglePage.value = data; selectedSinglePage.value = data;
return; return;
} }
@ -240,18 +237,16 @@ const handleDeleteInBatch = async () => {
return Promise.resolve(); return Promise.resolve();
} }
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( return coreApiClient.content.singlePage.updateSinglePage({
{ name: page.metadata.name,
name: page.metadata.name, singlePage: {
singlePage: { ...page,
...page, spec: {
spec: { ...page.spec,
...page.spec, deleted: true,
deleted: true,
},
}, },
} },
); });
}) })
); );
await refetch(); await refetch();

View File

@ -11,7 +11,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed, watch } from "vue"; import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue"; import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
@ -28,10 +28,9 @@ const singlePageName = computed(() => route.query.name as string);
const { data: singlePage } = useQuery({ const { data: singlePage } = useQuery({
queryKey: ["singlePage-by-name", singlePageName], queryKey: ["singlePage-by-name", singlePageName],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.content.singlePage.getSinglePage({
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ name: singlePageName.value,
name: singlePageName.value, });
});
return data; return data;
}, },
enabled: computed(() => !!singlePageName.value), enabled: computed(() => !!singlePageName.value),
@ -40,9 +39,10 @@ const { data: singlePage } = useQuery({
const { data: snapshots, isLoading } = useQuery({ const { data: snapshots, isLoading } = useQuery({
queryKey: ["singlePage-snapshots-by-singlePage-name", singlePageName], queryKey: ["singlePage-snapshots-by-singlePage-name", singlePageName],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePageSnapshots({ const { data } =
name: singlePageName.value, await consoleApiClient.content.singlePage.listSinglePageSnapshots({
}); name: singlePageName.value,
});
return data; return data;
}, },
refetchInterval(data) { refetchInterval(data) {
@ -99,7 +99,7 @@ function handleCleanup() {
} }
for (let i = 0; i < snapshotsToDelete?.length; i++) { for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.singlePage.deleteSinglePageContent({ await consoleApiClient.content.singlePage.deleteSinglePageContent({
name: singlePageName.value, name: singlePageName.value,
snapshotName: snapshotsToDelete[i].metadata.name, snapshotName: snapshotsToDelete[i].metadata.name,
}); });

View File

@ -14,7 +14,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client"; import type { ListedSinglePage, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { RouterLink } from "vue-router"; import { RouterLink } from "vue-router";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
@ -72,12 +72,11 @@ const isPublishing = computed(() => {
const { mutate: changeVisibleMutation } = useMutation({ const { mutate: changeVisibleMutation } = useMutation({
mutationFn: async (singlePage: SinglePage) => { mutationFn: async (singlePage: SinglePage) => {
const { data } = const { data } = await coreApiClient.content.singlePage.getSinglePage({
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ name: singlePage.metadata.name,
name: singlePage.metadata.name, });
});
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE"; data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( await coreApiClient.content.singlePage.updateSinglePage(
{ {
name: singlePage.metadata.name, name: singlePage.metadata.name,
singlePage: data, singlePage: data,
@ -107,12 +106,10 @@ const handleDelete = async () => {
onConfirm: async () => { onConfirm: async () => {
const singlePageToUpdate = cloneDeep(props.singlePage.page); const singlePageToUpdate = cloneDeep(props.singlePage.page);
singlePageToUpdate.spec.deleted = true; singlePageToUpdate.spec.deleted = true;
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( await coreApiClient.content.singlePage.updateSinglePage({
{ name: props.singlePage.page.metadata.name,
name: props.singlePage.page.metadata.name, singlePage: singlePageToUpdate,
singlePage: singlePageToUpdate, });
}
);
await queryClient.invalidateQueries({ queryKey: ["singlePages"] }); await queryClient.invalidateQueries({ queryKey: ["singlePages"] });
Toast.success(t("core.common.toast.delete_success")); Toast.success(t("core.common.toast.delete_success"));

View File

@ -2,7 +2,7 @@
import AnnotationsForm from "@/components/form/AnnotationsForm.vue"; import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { singlePageLabels } from "@/constants/labels"; import { singlePageLabels } from "@/constants/labels";
import { FormType } from "@/types/slug"; import { FormType } from "@/types/slug";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { toDatetimeLocal, toISOString } from "@/utils/date"; import { toDatetimeLocal, toISOString } from "@/utils/date";
import { randomUUID } from "@/utils/id"; import { randomUUID } from "@/utils/id";
import useSlugify from "@console/composables/use-slugify"; import useSlugify from "@console/composables/use-slugify";
@ -134,11 +134,9 @@ const handleSave = async () => {
const { data } = isUpdateMode const { data } = isUpdateMode
? await singlePageUpdateMutate(formState.value) ? await singlePageUpdateMutate(formState.value)
: await apiClient.extension.singlePage.createContentHaloRunV1alpha1SinglePage( : await coreApiClient.content.singlePage.createSinglePage({
{ singlePage: formState.value,
singlePage: formState.value, });
}
);
formState.value = data; formState.value = data;
emit("saved", data); emit("saved", data);
@ -183,13 +181,10 @@ const handlePublish = async () => {
singlePageToUpdate.spec.headSnapshot; singlePageToUpdate.spec.headSnapshot;
singlePageToUpdate.spec.publish = true; singlePageToUpdate.spec.publish = true;
const { data } = const { data } = await coreApiClient.content.singlePage.updateSinglePage({
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( name: formState.value.metadata.name,
{ singlePage: singlePageToUpdate,
name: formState.value.metadata.name, });
singlePage: singlePageToUpdate,
}
);
formState.value = data; formState.value = data;
@ -210,20 +205,17 @@ const handleUnpublish = async () => {
publishCanceling.value = true; publishCanceling.value = true;
const { data: singlePage } = const { data: singlePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({ await coreApiClient.content.singlePage.getSinglePage({
name: formState.value.metadata.name, name: formState.value.metadata.name,
}); });
const singlePageToUpdate = cloneDeep(singlePage); const singlePageToUpdate = cloneDeep(singlePage);
singlePageToUpdate.spec.publish = false; singlePageToUpdate.spec.publish = false;
const { data } = const { data } = await coreApiClient.content.singlePage.updateSinglePage({
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( name: formState.value.metadata.name,
{ singlePage: singlePageToUpdate,
name: formState.value.metadata.name, });
singlePage: singlePageToUpdate,
}
);
formState.value = data; formState.value = data;

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { computed, toRefs } from "vue"; import { computed, toRefs } from "vue";
import { Toast, VLoading } from "@halo-dev/components"; import { Toast, VLoading } from "@halo-dev/components";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue"; import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -25,10 +25,11 @@ const { data: snapshot, isLoading } = useQuery({
throw new Error("singlePageName and snapshotName are required"); throw new Error("singlePageName and snapshotName are required");
} }
const { data } = await apiClient.singlePage.fetchSinglePageContent({ const { data } =
name: singlePageName.value, await consoleApiClient.content.singlePage.fetchSinglePageContent({
snapshotName: snapshotName.value, name: singlePageName.value,
}); snapshotName: snapshotName.value,
});
return data; return data;
}, },
onError(err) { onError(err) {

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ListedSnapshotDto, SinglePage } from "@halo-dev/api-client"; import type { ListedSnapshotDto, SinglePage } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components"; import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import { computed } from "vue"; import { computed } from "vue";
@ -29,12 +29,14 @@ async function handleRestore() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.singlePage.revertToSpecifiedSnapshotForSinglePage({ await consoleApiClient.content.singlePage.revertToSpecifiedSnapshotForSinglePage(
name: props.singlePage?.metadata.name as string, {
revertSnapshotForSingleParam: { name: props.singlePage?.metadata.name as string,
snapshotName: props.snapshot.metadata.name, revertSnapshotForSingleParam: {
}, snapshotName: props.snapshot.metadata.name,
}); },
}
);
await queryClient.invalidateQueries({ await queryClient.invalidateQueries({
queryKey: ["singlePage-snapshots-by-singlePage-name"], queryKey: ["singlePage-snapshots-by-singlePage-name"],
}); });
@ -50,7 +52,7 @@ function handleDelete() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.singlePage.deleteSinglePageContent({ await consoleApiClient.content.singlePage.deleteSinglePageContent({
name: props.singlePage?.metadata.name as string, name: props.singlePage?.metadata.name as string,
snapshotName: props.snapshot.metadata.name, snapshotName: props.snapshot.metadata.name,
}); });

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useMutation } from "@tanstack/vue-query"; import { useMutation } from "@tanstack/vue-query";
import type { SinglePage } from "@halo-dev/api-client"; import type { SinglePage } from "@halo-dev/api-client";
import { Toast } from "@halo-dev/components"; import { Toast } from "@halo-dev/components";
@ -10,13 +10,11 @@ export function usePageUpdateMutate() {
mutationKey: ["singlePage-update"], mutationKey: ["singlePage-update"],
mutationFn: async (page: SinglePage) => { mutationFn: async (page: SinglePage) => {
const { data: latestSinglePage } = const { data: latestSinglePage } =
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage( await coreApiClient.content.singlePage.getSinglePage({
{ name: page.metadata.name,
name: page.metadata.name, });
}
);
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage( return coreApiClient.content.singlePage.updateSinglePage(
{ {
name: page.metadata.name, name: page.metadata.name,
singlePage: { singlePage: {

View File

@ -1,13 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import { VCard, IconPages } from "@halo-dev/components"; import { VCard, IconPages } from "@halo-dev/components";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { singlePageLabels } from "@/constants/labels"; import { singlePageLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
const { data: total } = useQuery({ const { data: total } = useQuery({
queryKey: ["widget-singlePage-count"], queryKey: ["widget-singlePage-count"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.singlePage.listSinglePages({ const { data } = await consoleApiClient.content.singlePage.listSinglePages({
labelSelector: [ labelSelector: [
`${singlePageLabels.DELETED}=false`, `${singlePageLabels.DELETED}=false`,
`${singlePageLabels.PUBLISHED}=true`, `${singlePageLabels.PUBLISHED}=true`,

View File

@ -20,7 +20,7 @@ import {
import PostTag from "./tags/components/PostTag.vue"; import PostTag from "./tags/components/PostTag.vue";
import { ref, watch } from "vue"; import { ref, watch } from "vue";
import type { ListedPost, Post } from "@halo-dev/api-client"; import type { ListedPost, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
@ -47,7 +47,7 @@ const {
} = useQuery<ListedPost[]>({ } = useQuery<ListedPost[]>({
queryKey: ["deleted-posts", page, size, keyword], queryKey: ["deleted-posts", page, size, keyword],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.post.listPosts({ const { data } = await consoleApiClient.content.post.listPosts({
labelSelector: [`content.halo.run/deleted=true`], labelSelector: [`content.halo.run/deleted=true`],
page: page.value, page: page.value,
size: size.value, size: size.value,
@ -92,7 +92,7 @@ const handleDeletePermanently = async (post: Post) => {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.extension.post.deleteContentHaloRunV1alpha1Post({ await coreApiClient.content.post.deletePost({
name: post.metadata.name, name: post.metadata.name,
}); });
await refetch(); await refetch();
@ -112,7 +112,7 @@ const handleDeletePermanentlyInBatch = async () => {
onConfirm: async () => { onConfirm: async () => {
await Promise.all( await Promise.all(
selectedPostNames.value.map((name) => { selectedPostNames.value.map((name) => {
return apiClient.extension.post.deleteContentHaloRunV1alpha1Post({ return coreApiClient.content.post.deletePost({
name, name,
}); });
}) })
@ -134,7 +134,7 @@ const handleRecovery = async (post: Post) => {
onConfirm: async () => { onConfirm: async () => {
const postToUpdate = cloneDeep(post); const postToUpdate = cloneDeep(post);
postToUpdate.spec.deleted = false; postToUpdate.spec.deleted = false;
await apiClient.extension.post.updateContentHaloRunV1alpha1Post({ await coreApiClient.content.post.updatePost({
name: postToUpdate.metadata.name, name: postToUpdate.metadata.name,
post: postToUpdate, post: postToUpdate,
}); });
@ -165,7 +165,7 @@ const handleRecoveryInBatch = async () => {
return Promise.resolve(); return Promise.resolve();
} }
return apiClient.extension.post.updateContentHaloRunV1alpha1Post({ return coreApiClient.content.post.updatePost({
name: post.metadata.name, name: post.metadata.name,
post: { post: {
...post, ...post,

View File

@ -24,7 +24,11 @@ import {
toRef, toRef,
watch, watch,
} from "vue"; } from "vue";
import { apiClient } from "@/utils/api-client"; import {
consoleApiClient,
coreApiClient,
ucApiClient,
} from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { randomUUID } from "@/utils/id"; import { randomUUID } from "@/utils/id";
@ -169,7 +173,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
).data; ).data;
} }
const { data } = await apiClient.post.updatePostContent({ const { data } = await consoleApiClient.content.post.updatePostContent({
name: formState.value.post.metadata.name, name: formState.value.post.metadata.name,
content: formState.value.content, content: formState.value.content,
}); });
@ -181,7 +185,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
// Clear new post content cache // Clear new post content cache
handleClearCache(); handleClearCache();
const { data } = await apiClient.post.draftPost({ const { data } = await consoleApiClient.content.post.draftPost({
postRequest: formState.value, postRequest: formState.value,
}); });
formState.value.post = data; formState.value.post = data;
@ -218,12 +222,12 @@ const handlePublish = async () => {
).data; ).data;
} }
await apiClient.post.updatePostContent({ await consoleApiClient.content.post.updatePostContent({
name: postName, name: postName,
content: formState.value.content, content: formState.value.content,
}); });
await apiClient.post.publishPost({ await consoleApiClient.content.post.publishPost({
name: postName, name: postName,
}); });
@ -233,11 +237,11 @@ const handlePublish = async () => {
router.back(); router.back();
} }
} else { } else {
const { data } = await apiClient.post.draftPost({ const { data } = await consoleApiClient.content.post.draftPost({
postRequest: formState.value, postRequest: formState.value,
}); });
await apiClient.post.publishPost({ await consoleApiClient.content.post.publishPost({
name: data.metadata.name, name: data.metadata.name,
}); });
@ -273,7 +277,7 @@ const handleFetchContent = async () => {
return; return;
} }
const { data } = await apiClient.post.fetchPostHeadContent({ const { data } = await consoleApiClient.content.post.fetchPostHeadContent({
name: formState.value.post.metadata.name, name: formState.value.post.metadata.name,
}); });
@ -326,10 +330,9 @@ const handleFetchContent = async () => {
}; };
const handleOpenSettingModal = async () => { const handleOpenSettingModal = async () => {
const { data: latestPost } = const { data: latestPost } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: formState.value.post.metadata.name,
name: formState.value.post.metadata.name, });
});
formState.value.post = latestPost; formState.value.post = latestPost;
settingModal.value = true; settingModal.value = true;
}; };
@ -360,10 +363,9 @@ onMounted(async () => {
if (name.value) { if (name.value) {
// fetch post // fetch post
const { data: post } = const { data: post } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: name.value as string,
name: name.value as string, });
});
formState.value.post = post; formState.value.post = post;
// fetch post content // fetch post content
@ -440,7 +442,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
await handleSave(); await handleSave();
} }
const { data } = await apiClient.uc.attachment.createAttachmentForPost( const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
{ {
file, file,
postName: formState.value.post.metadata.name, postName: formState.value.post.metadata.name,

View File

@ -19,7 +19,7 @@ import PostSettingModal from "./components/PostSettingModal.vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { computed, provide, ref, watch } from "vue"; import { computed, provide, ref, watch } from "vue";
import type { ListedPost, Post } from "@halo-dev/api-client"; import type { ListedPost, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { postLabels } from "@/constants/labels"; import { postLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -135,7 +135,7 @@ const {
labelSelector.push(selectedPublishStatus.value); labelSelector.push(selectedPublishStatus.value);
} }
const { data } = await apiClient.post.listPosts({ const { data } = await consoleApiClient.content.post.listPosts({
labelSelector, labelSelector,
fieldSelector, fieldSelector,
page: page.value, page: page.value,
@ -183,11 +183,9 @@ const {
}); });
const handleOpenSettingModal = async (post: Post) => { const handleOpenSettingModal = async (post: Post) => {
const { data } = await apiClient.extension.post.getContentHaloRunV1alpha1Post( const { data } = await coreApiClient.content.post.getPost({
{ name: post.metadata.name,
name: post.metadata.name, });
}
);
selectedPost.value = data; selectedPost.value = data;
settingModal.value = true; settingModal.value = true;
}; };
@ -206,10 +204,9 @@ const handleSelectPrevious = async () => {
); );
if (index > 0) { if (index > 0) {
const { data: previousPost } = const { data: previousPost } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: posts.value[index - 1].post.metadata.name,
name: posts.value[index - 1].post.metadata.name, });
});
selectedPost.value = previousPost; selectedPost.value = previousPost;
return; return;
} }
@ -227,10 +224,9 @@ const handleSelectNext = async () => {
(post) => post.post.metadata.name === selectedPost.value?.metadata.name (post) => post.post.metadata.name === selectedPost.value?.metadata.name
); );
if (index < posts.value.length - 1) { if (index < posts.value.length - 1) {
const { data: nextPost } = const { data: nextPost } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: posts.value[index + 1].post.metadata.name,
name: posts.value[index + 1].post.metadata.name, });
});
selectedPost.value = nextPost; selectedPost.value = nextPost;
return; return;
} }
@ -271,7 +267,7 @@ const handleDeleteInBatch = async () => {
onConfirm: async () => { onConfirm: async () => {
await Promise.all( await Promise.all(
selectedPostNames.value.map((name) => { selectedPostNames.value.map((name) => {
return apiClient.post.recyclePost({ return consoleApiClient.content.post.recyclePost({
name, name,
}); });
}) })

View File

@ -11,7 +11,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed, watch } from "vue"; import { computed, watch } from "vue";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue"; import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
@ -28,10 +28,9 @@ const postName = computed(() => route.query.name as string);
const { data: post } = useQuery({ const { data: post } = useQuery({
queryKey: ["post-by-name", postName], queryKey: ["post-by-name", postName],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: postName.value,
name: postName.value, });
});
return data; return data;
}, },
enabled: computed(() => !!postName.value), enabled: computed(() => !!postName.value),
@ -40,7 +39,7 @@ const { data: post } = useQuery({
const { data: snapshots, isLoading } = useQuery({ const { data: snapshots, isLoading } = useQuery({
queryKey: ["post-snapshots-by-post-name", postName], queryKey: ["post-snapshots-by-post-name", postName],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.post.listPostSnapshots({ const { data } = await consoleApiClient.content.post.listPostSnapshots({
name: postName.value, name: postName.value,
}); });
return data; return data;
@ -99,7 +98,7 @@ function handleCleanup() {
} }
for (let i = 0; i < snapshotsToDelete?.length; i++) { for (let i = 0; i < snapshotsToDelete?.length; i++) {
await apiClient.post.deletePostContent({ await consoleApiClient.content.post.deletePostContent({
name: postName.value, name: postName.value,
snapshotName: snapshotsToDelete[i].metadata.name, snapshotName: snapshotsToDelete[i].metadata.name,
}); });

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs // core libs
import { ref } from "vue"; import { ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
// components // components
import { import {
@ -40,7 +40,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
try { try {
batchUpdating.value = true; batchUpdating.value = true;
const promises = categoriesToUpdate.map((category) => const promises = categoriesToUpdate.map((category) =>
apiClient.extension.category.updateContentHaloRunV1alpha1Category({ coreApiClient.content.category.updateCategory({
name: category.metadata.name, name: category.metadata.name,
category: category, category: category,
}) })

View File

@ -1,9 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs
import { computed, nextTick, onMounted, ref } from "vue";
import { coreApiClient } from "@halo-dev/api-client";
// components
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import AnnotationsForm from "@/components/form/AnnotationsForm.vue"; import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { FormType } from "@/types/slug"; import { FormType } from "@/types/slug";
import { apiClient } from "@/utils/api-client";
import useSlugify from "@console/composables/use-slugify"; import useSlugify from "@console/composables/use-slugify";
import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme"; import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme";
import type { Category } from "@halo-dev/api-client"; import type { Category } from "@halo-dev/api-client";
@ -16,7 +20,6 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import { computed, nextTick, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
const props = withDefaults( const props = withDefaults(
@ -87,7 +90,7 @@ const handleSaveCategory = async () => {
try { try {
saving.value = true; saving.value = true;
if (isUpdateMode) { if (isUpdateMode) {
await apiClient.extension.category.updateContentHaloRunV1alpha1Category({ await coreApiClient.content.category.updateCategory({
name: formState.value.metadata.name, name: formState.value.metadata.name,
category: formState.value, category: formState.value,
}); });
@ -96,10 +99,9 @@ const handleSaveCategory = async () => {
let parentCategory: Category | undefined = undefined; let parentCategory: Category | undefined = undefined;
if (selectedParentCategory.value) { if (selectedParentCategory.value) {
const { data } = const { data } = await coreApiClient.content.category.getCategory({
await apiClient.extension.category.getContentHaloRunV1alpha1Category({ name: selectedParentCategory.value,
name: selectedParentCategory.value, });
});
parentCategory = data; parentCategory = data;
} }
@ -110,11 +112,9 @@ const handleSaveCategory = async () => {
formState.value.spec.priority = priority; formState.value.spec.priority = priority;
const { data: createdCategory } = const { data: createdCategory } =
await apiClient.extension.category.createContentHaloRunV1alpha1Category( await coreApiClient.content.category.createCategory({
{ category: formState.value,
category: formState.value, });
}
);
if (parentCategory) { if (parentCategory) {
parentCategory.spec.children = Array.from( parentCategory.spec.children = Array.from(
@ -124,12 +124,10 @@ const handleSaveCategory = async () => {
]) ])
); );
await apiClient.extension.category.updateContentHaloRunV1alpha1Category( await coreApiClient.content.category.updateCategory({
{ name: selectedParentCategory.value,
name: selectedParentCategory.value, category: parentCategory,
category: parentCategory, });
}
);
} }
} }

View File

@ -1,5 +1,4 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import type { Category } from "@halo-dev/api-client"; import type { Category } from "@halo-dev/api-client";
@ -17,6 +16,7 @@ import type { PropType } from "vue";
import { ref } from "vue"; import { ref } from "vue";
import { VueDraggable } from "vue-draggable-plus"; import { VueDraggable } from "vue-draggable-plus";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { coreApiClient } from "@halo-dev/api-client";
import GridiconsLinkBreak from "~icons/gridicons/link-break"; import GridiconsLinkBreak from "~icons/gridicons/link-break";
import { convertCategoryTreeToCategory, type CategoryTree } from "../utils"; import { convertCategoryTreeToCategory, type CategoryTree } from "../utils";
import CategoryEditingModal from "./CategoryEditingModal.vue"; import CategoryEditingModal from "./CategoryEditingModal.vue";
@ -69,11 +69,9 @@ const handleDelete = async (category: CategoryTree) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.category.deleteContentHaloRunV1alpha1Category( await coreApiClient.content.category.deleteCategory({
{ name: category.metadata.name,
name: category.metadata.name, });
}
);
Toast.success(t("core.common.toast.delete_success")); Toast.success(t("core.common.toast.delete_success"));

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { Category } from "@halo-dev/api-client"; import type { Category } from "@halo-dev/api-client";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { ref } from "vue"; import { ref } from "vue";
@ -23,12 +23,11 @@ export function usePostCategory(): usePostCategoryReturn {
} = useQuery({ } = useQuery({
queryKey: ["post-categories"], queryKey: ["post-categories"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.content.category.listCategory({
await apiClient.extension.category.listContentHaloRunV1alpha1Category({ page: 0,
page: 0, size: 0,
size: 0, sort: ["metadata.creationTimestamp,desc"],
sort: ["metadata.creationTimestamp,desc"], });
});
return data.items; return data.items;
}, },

View File

@ -9,7 +9,7 @@ import {
import type { ListedPost, Post } from "@halo-dev/api-client"; import type { ListedPost, Post } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { computed, inject, markRaw, ref, toRefs } from "vue"; import { computed, inject, markRaw, ref, toRefs } from "vue";
@ -58,7 +58,7 @@ const handleDelete = async () => {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.post.recyclePost({ await consoleApiClient.content.post.recyclePost({
name: props.post.post.metadata.name, name: props.post.post.metadata.name,
}); });
await queryClient.invalidateQueries({ queryKey: ["posts"] }); await queryClient.invalidateQueries({ queryKey: ["posts"] });
@ -77,7 +77,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
component: markRaw(VDropdownItem), component: markRaw(VDropdownItem),
label: t("core.common.buttons.publish"), label: t("core.common.buttons.publish"),
action: async () => { action: async () => {
await apiClient.post.publishPost({ await consoleApiClient.content.post.publishPost({
name: props.post.post.metadata.name, name: props.post.post.metadata.name,
}); });
@ -125,7 +125,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
}, },
label: t("core.common.buttons.cancel_publish"), label: t("core.common.buttons.cancel_publish"),
action: async () => { action: async () => {
await apiClient.post.unpublishPost({ await consoleApiClient.content.post.unpublishPost({
name: props.post.post.metadata.name, name: props.post.post.metadata.name,
}); });

View File

@ -8,7 +8,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { computed, nextTick, ref, watch } from "vue"; import { computed, nextTick, ref, watch } from "vue";
import type { Post } from "@halo-dev/api-client"; import type { Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme"; import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme";
import { postLabels } from "@/constants/labels"; import { postLabels } from "@/constants/labels";
import { randomUUID } from "@/utils/id"; import { randomUUID } from "@/utils/id";
@ -137,7 +137,7 @@ const handleSave = async () => {
const { data } = isUpdateMode.value const { data } = isUpdateMode.value
? await postUpdateMutate(formState.value) ? await postUpdateMutate(formState.value)
: await apiClient.extension.post.createContentHaloRunV1alpha1Post({ : await coreApiClient.content.post.createPost({
post: formState.value, post: formState.value,
}); });
@ -166,7 +166,7 @@ const handlePublish = async () => {
await postUpdateMutate(formState.value); await postUpdateMutate(formState.value);
const { data } = await apiClient.post.publishPost({ const { data } = await consoleApiClient.content.post.publishPost({
name: formState.value.metadata.name, name: formState.value.metadata.name,
}); });
@ -188,7 +188,7 @@ const handleUnpublish = async () => {
try { try {
publishCanceling.value = true; publishCanceling.value = true;
await apiClient.post.unpublishPost({ await consoleApiClient.content.post.unpublishPost({
name: formState.value.metadata.name, name: formState.value.metadata.name,
}); });

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { computed, toRefs } from "vue"; import { computed, toRefs } from "vue";
import { Toast, VLoading } from "@halo-dev/components"; import { Toast, VLoading } from "@halo-dev/components";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue"; import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -25,7 +25,7 @@ const { data: snapshot, isLoading } = useQuery({
throw new Error("postName and snapshotName are required"); throw new Error("postName and snapshotName are required");
} }
const { data } = await apiClient.post.fetchPostContent({ const { data } = await consoleApiClient.content.post.fetchPostContent({
name: postName.value, name: postName.value,
snapshotName: snapshotName.value, snapshotName: snapshotName.value,
}); });

View File

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ListedSnapshotDto, Post } from "@halo-dev/api-client"; import type { ListedSnapshotDto, Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components"; import { Dialog, Toast, VButton, VStatusDot, VTag } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import { computed } from "vue"; import { computed } from "vue";
@ -29,7 +29,7 @@ async function handleRestore() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.post.revertToSpecifiedSnapshotForPost({ await consoleApiClient.content.post.revertToSpecifiedSnapshotForPost({
name: props.post?.metadata.name as string, name: props.post?.metadata.name as string,
revertSnapshotForPostParam: { revertSnapshotForPostParam: {
snapshotName: props.snapshot.metadata.name, snapshotName: props.snapshot.metadata.name,
@ -50,7 +50,7 @@ function handleDelete() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.post.deletePostContent({ await consoleApiClient.content.post.deletePostContent({
name: props.post?.metadata.name as string, name: props.post?.metadata.name as string,
snapshotName: props.snapshot.metadata.name, snapshotName: props.snapshot.metadata.name,
}); });

View File

@ -2,7 +2,7 @@
import { postLabels } from "@/constants/labels"; import { postLabels } from "@/constants/labels";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { IconTimerLine, VEntityField } from "@halo-dev/components"; import { IconTimerLine, VEntityField } from "@halo-dev/components";
import type { ListedPost } from "packages/api-client/dist"; import type { ListedPost } from "@halo-dev/api-client";
withDefaults( withDefaults(
defineProps<{ defineProps<{

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { ListedPost, Post } from "@halo-dev/api-client"; import type { ListedPost, Post } from "@halo-dev/api-client";
import { IconEye, IconEyeOff, Toast, VEntityField } from "@halo-dev/components"; import { IconEye, IconEyeOff, Toast, VEntityField } from "@halo-dev/components";
import { useMutation, useQueryClient } from "@tanstack/vue-query"; import { useMutation, useQueryClient } from "@tanstack/vue-query";
@ -17,12 +17,11 @@ withDefaults(
const { mutate: changeVisibleMutation } = useMutation({ const { mutate: changeVisibleMutation } = useMutation({
mutationFn: async (post: Post) => { mutationFn: async (post: Post) => {
const { data } = const { data } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: post.metadata.name,
name: post.metadata.name, });
});
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE"; data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
await apiClient.extension.post.updateContentHaloRunV1alpha1Post( await coreApiClient.content.post.updatePost(
{ {
name: post.metadata.name, name: post.metadata.name,
post: data, post: data,

View File

@ -1,6 +1,6 @@
import { useMutation } from "@tanstack/vue-query"; import { useMutation } from "@tanstack/vue-query";
import type { Post } from "@halo-dev/api-client"; import type { Post } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { Toast } from "@halo-dev/components"; import { Toast } from "@halo-dev/components";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -10,12 +10,11 @@ export function usePostUpdateMutate() {
return useMutation({ return useMutation({
mutationKey: ["post-update"], mutationKey: ["post-update"],
mutationFn: async (post: Post) => { mutationFn: async (post: Post) => {
const { data: latestPost } = const { data: latestPost } = await coreApiClient.content.post.getPost({
await apiClient.extension.post.getContentHaloRunV1alpha1Post({ name: post.metadata.name,
name: post.metadata.name, });
});
return await apiClient.extension.post.updateContentHaloRunV1alpha1Post( return await coreApiClient.content.post.updatePost(
{ {
name: post.metadata.name, name: post.metadata.name,
post: { post: {

View File

@ -16,7 +16,7 @@ import {
import HasPermission from "@/components/permission/HasPermission.vue"; import HasPermission from "@/components/permission/HasPermission.vue";
import TagEditingModal from "./components/TagEditingModal.vue"; import TagEditingModal from "./components/TagEditingModal.vue";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { usePostTag } from "./composables/use-post-tag"; import { usePostTag } from "./composables/use-post-tag";
import TagListItem from "./components/TagListItem.vue"; import TagListItem from "./components/TagListItem.vue";
import SearchInput from "@/components/input/SearchInput.vue"; import SearchInput from "@/components/input/SearchInput.vue";
@ -142,11 +142,9 @@ const queryName = useRouteQuery("name");
onMounted(async () => { onMounted(async () => {
if (queryName.value) { if (queryName.value) {
const { data } = await apiClient.extension.tag.getContentHaloRunV1alpha1Tag( const { data } = await coreApiClient.content.tag.getTag({
{ name: queryName.value as string,
name: queryName.value as string, });
}
);
selectedTag.value = data; selectedTag.value = data;
editingModal.value = true; editingModal.value = true;
} }

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs // core libs
import { computed, nextTick, ref, watch } from "vue"; import { computed, nextTick, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
// components // components
import { import {
@ -91,12 +91,12 @@ const handleSaveTag = async () => {
try { try {
saving.value = true; saving.value = true;
if (isUpdateMode.value) { if (isUpdateMode.value) {
await apiClient.extension.tag.updateContentHaloRunV1alpha1Tag({ await coreApiClient.content.tag.updateTag({
name: formState.value.metadata.name, name: formState.value.metadata.name,
tag: formState.value, tag: formState.value,
}); });
} else { } else {
await apiClient.extension.tag.createContentHaloRunV1alpha1Tag({ await coreApiClient.content.tag.createTag({
tag: formState.value, tag: formState.value,
}); });
} }

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { Tag } from "@halo-dev/api-client"; import type { Tag } from "@halo-dev/api-client";
import { ref, watch, type Ref } from "vue"; import { ref, watch, type Ref } from "vue";
import { Dialog, Toast } from "@halo-dev/components"; import { Dialog, Toast } from "@halo-dev/components";
@ -39,7 +39,7 @@ export function usePostTag(filterOptions?: {
} = useQuery({ } = useQuery({
queryKey: ["post-tags", sort, page, size, keyword], queryKey: ["post-tags", sort, page, size, keyword],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.tag.listPostTags({ const { data } = await consoleApiClient.content.tag.listPostTags({
page: page?.value || 0, page: page?.value || 0,
size: size?.value || 0, size: size?.value || 0,
sort: [sort?.value as string].filter(Boolean) || [ sort: [sort?.value as string].filter(Boolean) || [
@ -71,7 +71,7 @@ export function usePostTag(filterOptions?: {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({ await coreApiClient.content.tag.deleteTag({
name: tag.metadata.name, name: tag.metadata.name,
}); });
@ -97,7 +97,7 @@ export function usePostTag(filterOptions?: {
try { try {
await Promise.all( await Promise.all(
tagNames.map((tagName) => { tagNames.map((tagName) => {
apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({ coreApiClient.content.tag.deleteTag({
name: tagName, name: tagName,
}); });
}) })

View File

@ -7,7 +7,7 @@ import {
IconExternalLinkLine, IconExternalLinkLine,
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { ListedPost } from "@halo-dev/api-client"; import type { ListedPost } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { postLabels } from "@/constants/labels"; import { postLabels } from "@/constants/labels";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
@ -16,7 +16,7 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
const { data } = useQuery<ListedPost[]>({ const { data } = useQuery<ListedPost[]>({
queryKey: ["widget-recent-posts"], queryKey: ["widget-recent-posts"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.post.listPosts({ const { data } = await consoleApiClient.content.post.listPosts({
labelSelector: [ labelSelector: [
`${postLabels.DELETED}=false`, `${postLabels.DELETED}=false`,
`${postLabels.PUBLISHED}=true`, `${postLabels.PUBLISHED}=true`,

View File

@ -18,7 +18,7 @@ import {
import { markRaw, ref, type Component } from "vue"; import { markRaw, ref, type Component } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import ThemePreviewModal from "@console/modules/interface/themes/components/preview/ThemePreviewModal.vue"; import ThemePreviewModal from "@console/modules/interface/themes/components/preview/ThemePreviewModal.vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue"; import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
@ -143,7 +143,7 @@ const actions: Action[] = [
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.indices.buildPostIndices(); await consoleApiClient.content.indices.buildPostIndices();
Toast.success( Toast.success(
t( t(
"core.dashboard.widgets.presets.quicklink.actions.refresh_search_engine.success_message" "core.dashboard.widgets.presets.quicklink.actions.refresh_search_engine.success_message"
@ -170,7 +170,7 @@ const actions: Action[] = [
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.cache.evictCache({ name: "page" }); await consoleApiClient.cache.evictCache({ name: "page" });
Toast.success( Toast.success(
t( t(
"core.dashboard.widgets.presets.quicklink.actions.evict_page_cache.success_message" "core.dashboard.widgets.presets.quicklink.actions.evict_page_cache.success_message"

View File

@ -15,7 +15,7 @@ import MenuItemEditingModal from "./components/MenuItemEditingModal.vue";
import MenuItemListItem from "./components/MenuItemListItem.vue"; import MenuItemListItem from "./components/MenuItemListItem.vue";
import MenuList from "./components/MenuList.vue"; import MenuList from "./components/MenuList.vue";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { Menu, MenuItem } from "@halo-dev/api-client"; import type { Menu, MenuItem } from "@halo-dev/api-client";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import type { MenuTreeItem } from "./utils"; import type { MenuTreeItem } from "./utils";
@ -51,7 +51,7 @@ const {
} }
const menuItemNames = selectedMenu.value.spec.menuItems.filter(Boolean); const menuItemNames = selectedMenu.value.spec.menuItems.filter(Boolean);
const { data } = await apiClient.extension.menuItem.listV1alpha1MenuItem({ const { data } = await coreApiClient.menuItem.listMenuItem({
page: 0, page: 0,
size: 0, size: 0,
fieldSelector: [`name=(${menuItemNames.join(",")})`], fieldSelector: [`name=(${menuItemNames.join(",")})`],
@ -72,8 +72,8 @@ const {
}); });
const handleOpenEditingModal = (menuItem: MenuTreeItem) => { const handleOpenEditingModal = (menuItem: MenuTreeItem) => {
apiClient.extension.menuItem coreApiClient.menuItem
.getV1alpha1MenuItem({ .getMenuItem({
name: menuItem.metadata.name, name: menuItem.metadata.name,
}) })
.then((response) => { .then((response) => {
@ -106,7 +106,7 @@ const onMenuItemSaved = async (menuItem: MenuItem) => {
menuItem.metadata.name, menuItem.metadata.name,
]; ];
await apiClient.extension.menu.updateV1alpha1Menu({ await coreApiClient.menu.updateMenu({
name: menuToUpdate.metadata.name, name: menuToUpdate.metadata.name,
menu: menuToUpdate, menu: menuToUpdate,
}); });
@ -124,7 +124,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
try { try {
batchUpdating.value = true; batchUpdating.value = true;
const promises = menuItemsToUpdate.map((menuItem) => const promises = menuItemsToUpdate.map((menuItem) =>
apiClient.extension.menuItem.updateV1alpha1MenuItem({ coreApiClient.menuItem.updateMenuItem({
name: menuItem.metadata.name, name: menuItem.metadata.name,
menuItem, menuItem,
}) })
@ -147,7 +147,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.extension.menuItem.deleteV1alpha1MenuItem({ await coreApiClient.menuItem.deleteMenuItem({
name: menuItem.metadata.name, name: menuItem.metadata.name,
}); });
@ -155,7 +155,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
if (childrenNames.length) { if (childrenNames.length) {
const deleteChildrenRequests = childrenNames.map((name) => const deleteChildrenRequests = childrenNames.map((name) =>
apiClient.extension.menuItem.deleteV1alpha1MenuItem({ coreApiClient.menuItem.deleteMenuItem({
name, name,
}) })
); );
@ -170,7 +170,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
menuToUpdate.spec.menuItems = menuToUpdate.spec.menuItems?.filter( menuToUpdate.spec.menuItems = menuToUpdate.spec.menuItems?.filter(
(name) => ![menuItem.metadata.name, ...childrenNames].includes(name) (name) => ![menuItem.metadata.name, ...childrenNames].includes(name)
); );
await apiClient.extension.menu.updateV1alpha1Menu({ await coreApiClient.menu.updateMenu({
name: menuToUpdate.metadata.name, name: menuToUpdate.metadata.name,
menu: menuToUpdate, menu: menuToUpdate,
}); });

View File

@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import type { Menu } from "@halo-dev/api-client"; import type { Menu } from "@halo-dev/api-client";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
@ -51,12 +51,12 @@ const handleSaveMenu = async () => {
try { try {
saving.value = true; saving.value = true;
if (props.menu) { if (props.menu) {
await apiClient.extension.menu.updateV1alpha1Menu({ await coreApiClient.menu.updateMenu({
name: formState.value.metadata.name, name: formState.value.metadata.name,
menu: formState.value, menu: formState.value,
}); });
} else { } else {
const { data } = await apiClient.extension.menu.createV1alpha1Menu({ const { data } = await coreApiClient.menu.createMenu({
menu: formState.value, menu: formState.value,
}); });
emit("created", data); emit("created", data);

View File

@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import { computed, nextTick, onMounted, ref } from "vue"; import { computed, nextTick, onMounted, ref } from "vue";
import type { Menu, MenuItem, Ref } from "@halo-dev/api-client"; import type { Menu, MenuItem, Ref } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import AnnotationsForm from "@/components/form/AnnotationsForm.vue"; import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -87,23 +87,21 @@ const handleSaveMenuItem = async () => {
} }
if (isUpdateMode) { if (isUpdateMode) {
const { data } = const { data } = await coreApiClient.menuItem.updateMenuItem({
await apiClient.extension.menuItem.updateV1alpha1MenuItem({ name: formState.value.metadata.name,
name: formState.value.metadata.name, menuItem: formState.value,
menuItem: formState.value, });
});
emit("saved", data); emit("saved", data);
} else { } else {
const { data } = const { data } = await coreApiClient.menuItem.createMenuItem({
await apiClient.extension.menuItem.createV1alpha1MenuItem({ menuItem: formState.value,
menuItem: formState.value, });
});
// if parent menu item is selected, add the new menu item to the parent menu item // if parent menu item is selected, add the new menu item to the parent menu item
if (selectedParentMenuItem.value) { if (selectedParentMenuItem.value) {
const { data: menuItemToUpdate } = const { data: menuItemToUpdate } =
await apiClient.extension.menuItem.getV1alpha1MenuItem({ await coreApiClient.menuItem.getMenuItem({
name: selectedParentMenuItem.value, name: selectedParentMenuItem.value,
}); });
@ -112,7 +110,7 @@ const handleSaveMenuItem = async () => {
data.metadata.name, data.metadata.name,
]; ];
await apiClient.extension.menuItem.updateV1alpha1MenuItem({ await coreApiClient.menuItem.updateMenuItem({
name: menuItemToUpdate.metadata.name, name: menuItemToUpdate.metadata.name,
menuItem: menuItemToUpdate, menuItem: menuItemToUpdate,
}); });

View File

@ -16,7 +16,7 @@ import {
import MenuEditingModal from "./MenuEditingModal.vue"; import MenuEditingModal from "./MenuEditingModal.vue";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import type { Menu } from "@halo-dev/api-client"; import type { Menu } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -48,7 +48,7 @@ const {
} = useQuery<Menu[]>({ } = useQuery<Menu[]>({
queryKey: ["menus"], queryKey: ["menus"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.menu.listV1alpha1Menu({ const { data } = await coreApiClient.menu.listMenu({
page: 0, page: 0,
size: 0, size: 0,
}); });
@ -87,12 +87,12 @@ const handleDeleteMenu = async (menu: Menu) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.menu.deleteV1alpha1Menu({ await coreApiClient.menu.deleteMenu({
name: menu.metadata.name, name: menu.metadata.name,
}); });
const deleteItemsPromises = menu.spec.menuItems?.map((item) => const deleteItemsPromises = menu.spec.menuItems?.map((item) =>
apiClient.extension.menuItem.deleteV1alpha1MenuItem({ coreApiClient.menuItem.deleteMenuItem({
name: item, name: item,
}) })
); );
@ -138,7 +138,7 @@ onMounted(async () => {
const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({ const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
queryKey: ["primary-menu-name"], queryKey: ["primary-menu-name"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({ const { data } = await coreApiClient.configMap.getConfigMap({
name: "system", name: "system",
}); });
@ -153,17 +153,16 @@ const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
}); });
const handleSetPrimaryMenu = async (menu: Menu) => { const handleSetPrimaryMenu = async (menu: Menu) => {
const { data: systemConfigMap } = const { data: systemConfigMap } = await coreApiClient.configMap.getConfigMap({
await apiClient.extension.configMap.getV1alpha1ConfigMap({ name: "system",
name: "system", });
});
if (systemConfigMap.data) { if (systemConfigMap.data) {
const menuConfigToUpdate = JSON.parse(systemConfigMap.data?.menu || "{}"); const menuConfigToUpdate = JSON.parse(systemConfigMap.data?.menu || "{}");
menuConfigToUpdate.primary = menu.metadata.name; menuConfigToUpdate.primary = menu.metadata.name;
systemConfigMap.data["menu"] = JSON.stringify(menuConfigToUpdate); systemConfigMap.data["menu"] = JSON.stringify(menuConfigToUpdate);
await apiClient.extension.configMap.updateV1alpha1ConfigMap({ await coreApiClient.configMap.updateConfigMap({
name: "system", name: "system",
configMap: systemConfigMap, configMap: systemConfigMap,
}); });

View File

@ -1,6 +1,4 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client";
import type { Theme } from "@halo-dev/api-client";
import { import {
Dialog, Dialog,
IconMore, IconMore,
@ -14,6 +12,9 @@ import {
VStatusDot, VStatusDot,
VTag, VTag,
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { inject, ref } from "vue"; import { inject, ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -39,7 +40,7 @@ async function handleClearCache() {
return; return;
} }
await apiClient.theme.invalidateCache({ await consoleApiClient.theme.theme.invalidateCache({
name: selectedTheme.value?.metadata.name, name: selectedTheme.value?.metadata.name,
}); });
@ -60,7 +61,7 @@ const handleReloadTheme = async () => {
return; return;
} }
await apiClient.theme.reload({ await consoleApiClient.theme.theme.reload({
name: selectedTheme.value.metadata.name as string, name: selectedTheme.value.metadata.name as string,
}); });

View File

@ -10,7 +10,7 @@ import type { Ref } from "vue";
import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client"; import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client";
// hooks // hooks
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import { useSettingFormConvert } from "@console/composables/use-setting-form";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
@ -29,7 +29,7 @@ const saving = ref(false);
const { data: configMap, suspense } = useQuery<ConfigMap>({ const { data: configMap, suspense } = useQuery<ConfigMap>({
queryKey: ["theme-configMap", selectedTheme], queryKey: ["theme-configMap", selectedTheme],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.fetchThemeConfig({ const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
name: selectedTheme?.value?.metadata.name as string, name: selectedTheme?.value?.metadata.name as string,
}); });
return data; return data;
@ -55,7 +55,7 @@ const handleSaveConfigMap = async () => {
return; return;
} }
await apiClient.theme.updateThemeConfig({ await consoleApiClient.theme.theme.updateThemeConfig({
name: selectedTheme?.value?.metadata.name, name: selectedTheme?.value?.metadata.name,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });

View File

@ -10,7 +10,7 @@ import {
VSpace, VSpace,
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { toRefs, ref, inject, type Ref } from "vue"; import { toRefs, ref, inject, type Ref } from "vue";
import { useThemeLifeCycle } from "../composables/use-theme"; import { useThemeLifeCycle } from "../composables/use-theme";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
@ -63,13 +63,12 @@ const handleCreateTheme = async () => {
try { try {
creating.value = true; creating.value = true;
const { data } = const { data } = await coreApiClient.theme.theme.createTheme({
await apiClient.extension.theme.createThemeHaloRunV1alpha1Theme({ theme: props.theme,
theme: props.theme, });
});
// create theme settings // create theme settings
apiClient.theme.reload({ name: data.metadata.name }); consoleApiClient.theme.theme.reload({ name: data.metadata.name });
activeTabId.value = "installed"; activeTabId.value = "installed";

View File

@ -10,7 +10,7 @@ import ThemePreviewModal from "../preview/ThemePreviewModal.vue";
import ThemeListItem from "../ThemeListItem.vue"; import ThemeListItem from "../ThemeListItem.vue";
import { inject, ref, type Ref } from "vue"; import { inject, ref, type Ref } from "vue";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
@ -31,7 +31,7 @@ const {
} = useQuery<Theme[]>({ } = useQuery<Theme[]>({
queryKey: ["installed-themes"], queryKey: ["installed-themes"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.listThemes({ const { data } = await consoleApiClient.theme.theme.listThemes({
page: 0, page: 0,
size: 0, size: 0,
uninstalled: false, uninstalled: false,

View File

@ -11,7 +11,7 @@ import { inject } from "vue";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { ref } from "vue"; import { ref } from "vue";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
const { t } = useI18n(); const { t } = useI18n();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@ -54,7 +54,7 @@ const handleCatchExistsException = async (
throw new Error("File is required"); throw new Error("File is required");
} }
await apiClient.theme.upgradeTheme({ await consoleApiClient.theme.theme.upgradeTheme({
name: error.themeName, name: error.themeName,
file: file, file: file,
}); });

View File

@ -2,7 +2,7 @@
import { VButton, VEmpty, VSpace, VLoading } from "@halo-dev/components"; import { VButton, VEmpty, VSpace, VLoading } from "@halo-dev/components";
import ThemeListItem from "../ThemeListItem.vue"; import ThemeListItem from "../ThemeListItem.vue";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
const { const {
@ -13,7 +13,7 @@ const {
} = useQuery<Theme[]>({ } = useQuery<Theme[]>({
queryKey: ["not-installed-themes"], queryKey: ["not-installed-themes"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.listThemes({ const { data } = await consoleApiClient.theme.theme.listThemes({
page: 0, page: 0,
size: 0, size: 0,
uninstalled: true, uninstalled: true,

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton } from "@halo-dev/components"; import { Dialog, Toast, VButton } from "@halo-dev/components";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import type { Ref } from "vue"; import type { Ref } from "vue";
@ -26,7 +26,7 @@ const handleDownloadTheme = async () => {
try { try {
downloading.value = true; downloading.value = true;
await apiClient.theme.installThemeFromUri({ await consoleApiClient.theme.theme.installThemeFromUri({
installFromUriRequest: { installFromUriRequest: {
uri: remoteDownloadUrl.value, uri: remoteDownloadUrl.value,
}, },
@ -64,7 +64,7 @@ const handleCatchExistsException = async (
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.theme.upgradeThemeFromUri({ await consoleApiClient.theme.theme.upgradeThemeFromUri({
name: error.themeName, name: error.themeName,
upgradeFromUriRequest: { upgradeFromUriRequest: {
uri: remoteDownloadUrl.value, uri: remoteDownloadUrl.value,

View File

@ -2,7 +2,7 @@
import { Dialog, Toast, VDropdown, VDropdownItem } from "@halo-dev/components"; import { Dialog, Toast, VDropdown, VDropdownItem } from "@halo-dev/components";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
const { t } = useI18n(); const { t } = useI18n();
@ -27,7 +27,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.theme.deleteThemeHaloRunV1alpha1Theme({ await coreApiClient.theme.theme.deleteTheme({
name: props.theme.metadata.name, name: props.theme.metadata.name,
}); });
@ -36,7 +36,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
const { settingName, configMapName } = props.theme.spec; const { settingName, configMapName } = props.theme.spec;
if (settingName) { if (settingName) {
await apiClient.extension.setting.deleteV1alpha1Setting( await coreApiClient.setting.deleteSetting(
{ {
name: settingName, name: settingName,
}, },
@ -47,7 +47,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
} }
if (configMapName) { if (configMapName) {
await apiClient.extension.configMap.deleteV1alpha1ConfigMap( await coreApiClient.configMap.deleteConfigMap(
{ {
name: configMapName, name: configMapName,
}, },

View File

@ -2,7 +2,7 @@
import ThemePreviewListItem from "./ThemePreviewListItem.vue"; import ThemePreviewListItem from "./ThemePreviewListItem.vue";
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import { useSettingFormConvert } from "@console/composables/use-setting-form";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
import { apiClient, axiosInstance } from "@/utils/api-client"; import { axiosInstance, consoleApiClient } from "@halo-dev/api-client";
import type { import type {
ConfigMap, ConfigMap,
Setting, Setting,
@ -62,7 +62,7 @@ const selectedTheme = ref<Theme>();
const { data: themes } = useQuery<Theme[]>({ const { data: themes } = useQuery<Theme[]>({
queryKey: ["themes"], queryKey: ["themes"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.listThemes({ const { data } = await consoleApiClient.theme.theme.listThemes({
page: 0, page: 0,
size: 0, size: 0,
uninstalled: false, uninstalled: false,
@ -129,7 +129,7 @@ const settingsVisible = ref(false);
const { data: setting } = useQuery<Setting>({ const { data: setting } = useQuery<Setting>({
queryKey: ["theme-setting", selectedTheme], queryKey: ["theme-setting", selectedTheme],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.fetchThemeSetting({ const { data } = await consoleApiClient.theme.theme.fetchThemeSetting({
name: selectedTheme?.value?.metadata.name as string, name: selectedTheme?.value?.metadata.name as string,
}); });
@ -154,7 +154,7 @@ const { data: setting } = useQuery<Setting>({
const { data: configMap, refetch: handleFetchConfigMap } = useQuery<ConfigMap>({ const { data: configMap, refetch: handleFetchConfigMap } = useQuery<ConfigMap>({
queryKey: ["theme-configMap", selectedTheme], queryKey: ["theme-configMap", selectedTheme],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.fetchThemeConfig({ const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
name: selectedTheme?.value?.metadata.name as string, name: selectedTheme?.value?.metadata.name as string,
}); });
return data; return data;
@ -180,7 +180,7 @@ const handleSaveConfigMap = async () => {
return; return;
} }
await apiClient.theme.updateThemeConfig({ await consoleApiClient.theme.theme.updateThemeConfig({
name: selectedTheme?.value?.metadata.name, name: selectedTheme?.value?.metadata.name,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });

View File

@ -1,6 +1,6 @@
import { apiClient } from "@/utils/api-client";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast } from "@halo-dev/components"; import { Dialog, Toast } from "@halo-dev/components";
import { useFileDialog } from "@vueuse/core"; import { useFileDialog } from "@vueuse/core";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
@ -53,7 +53,7 @@ export function useThemeLifeCycle(
try { try {
if (!theme.value) return; if (!theme.value) return;
await apiClient.theme.activateTheme({ await consoleApiClient.theme.theme.activateTheme({
name: theme.value?.metadata.name, name: theme.value?.metadata.name,
}); });
@ -84,7 +84,7 @@ export function useThemeLifeCycle(
return; return;
} }
await apiClient.theme.resetThemeConfig({ await consoleApiClient.theme.theme.resetThemeConfig({
name: theme.value.metadata.name as string, name: theme.value.metadata.name as string,
}); });
@ -157,7 +157,7 @@ export function useThemeConfigFile(theme: Ref<Theme | undefined>) {
return; return;
} }
const { data } = await apiClient.theme.fetchThemeConfig({ const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
name: theme?.value?.metadata.name as string, name: theme?.value?.metadata.name as string,
}); });
if (!data) { if (!data) {
@ -250,14 +250,14 @@ export function useThemeConfigFile(theme: Ref<Theme | undefined>) {
if (!theme.value) { if (!theme.value) {
return; return;
} }
const { data } = await apiClient.theme.fetchThemeConfig({ const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
name: theme.value.metadata.name as string, name: theme.value.metadata.name as string,
}); });
if (!data || !data.data) { if (!data || !data.data) {
return; return;
} }
const combinedConfigData = combinedConfigMap(data.data, importData); const combinedConfigData = combinedConfigMap(data.data, importData);
await apiClient.theme.updateThemeConfig({ await consoleApiClient.theme.theme.updateThemeConfig({
name: theme.value.metadata.name, name: theme.value.metadata.name,
configMap: { configMap: {
...data, ...data,

View File

@ -40,7 +40,7 @@ import type { Setting, SettingForm, Theme } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { useRouteQuery } from "@vueuse/router"; import { useRouteQuery } from "@vueuse/router";
@ -85,7 +85,7 @@ provide<Ref<Theme | undefined>>("selectedTheme", selectedTheme);
const { data: setting } = useQuery<Setting>({ const { data: setting } = useQuery<Setting>({
queryKey: ["theme-setting", selectedTheme], queryKey: ["theme-setting", selectedTheme],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.theme.fetchThemeSetting({ const { data } = await consoleApiClient.theme.theme.fetchThemeSetting({
name: selectedTheme.value?.metadata.name as string, name: selectedTheme.value?.metadata.name as string,
}); });
return data; return data;

View File

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref, toRaw } from "vue"; import { computed, ref, toRaw } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import type { AuthProvider, Setting } from "@halo-dev/api-client"; import type { AuthProvider, Setting } from "@halo-dev/api-client";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
@ -32,12 +32,9 @@ const activeTab = ref<string>("detail");
const { data: authProvider } = useQuery<AuthProvider>({ const { data: authProvider } = useQuery<AuthProvider>({
queryKey: ["auth-provider", route.params.name], queryKey: ["auth-provider", route.params.name],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.auth.authProvider.getAuthProvider({
await apiClient.extension.authProvider.getAuthHaloRunV1alpha1AuthProvider( name: route.params.name as string,
{ });
name: route.params.name as string,
}
);
return data; return data;
}, },
onSuccess(data) { onSuccess(data) {
@ -63,7 +60,7 @@ const { data: setting, refetch: handleFetchSettings } = useQuery<Setting>({
authProvider.value?.spec.settingRef?.name, authProvider.value?.spec.settingRef?.name,
], ],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.setting.getV1alpha1Setting( const { data } = await coreApiClient.setting.getSetting(
{ {
name: authProvider.value?.spec.settingRef?.name as string, name: authProvider.value?.spec.settingRef?.name as string,
}, },
@ -82,7 +79,7 @@ const { data: configMap, refetch: handleFetchConfigMap } = useQuery({
authProvider.value?.spec.configMapRef?.name, authProvider.value?.spec.configMapRef?.name,
], ],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap( const { data } = await coreApiClient.configMap.getConfigMap(
{ {
name: authProvider.value?.spec.configMapRef?.name as string, name: authProvider.value?.spec.configMapRef?.name as string,
}, },
@ -96,7 +93,7 @@ const { data: configMap, refetch: handleFetchConfigMap } = useQuery({
onError: async () => { onError: async () => {
const data = {}; const data = {};
data[group.value] = ""; data[group.value] = "";
await apiClient.extension.configMap.createV1alpha1ConfigMap({ await coreApiClient.configMap.createConfigMap({
configMap: { configMap: {
apiVersion: "v1alpha1", apiVersion: "v1alpha1",
data: data, data: data,
@ -128,7 +125,7 @@ const handleSaveConfigMap = async () => {
return; return;
} }
await apiClient.extension.configMap.updateV1alpha1ConfigMap({ await coreApiClient.configMap.updateConfigMap({
name: authProvider.value.spec.configMapRef?.name as string, name: authProvider.value.spec.configMapRef?.name as string,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });

View File

@ -6,7 +6,7 @@ import {
VLoading, VLoading,
} from "@halo-dev/components"; } from "@halo-dev/components";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { AuthProvider, ListedAuthProvider } from "@halo-dev/api-client"; import type { AuthProvider, ListedAuthProvider } from "@halo-dev/api-client";
import AuthProviderListItem from "./components/AuthProviderListItem.vue"; import AuthProviderListItem from "./components/AuthProviderListItem.vue";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
@ -18,7 +18,8 @@ const authProviders = ref<ListedAuthProvider[]>([]);
const { isLoading, refetch } = useQuery<ListedAuthProvider[]>({ const { isLoading, refetch } = useQuery<ListedAuthProvider[]>({
queryKey: ["auth-providers"], queryKey: ["auth-providers"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.authProvider.listAuthProviders(); const { data } =
await consoleApiClient.auth.authProvider.listAuthProviders();
return data; return data;
}, },
onSuccess(data) { onSuccess(data) {
@ -50,7 +51,7 @@ async function onSortUpdate() {
updating.value = true; updating.value = true;
const { data: rawAuthProviders } = const { data: rawAuthProviders } =
await apiClient.extension.authProvider.listAuthHaloRunV1alpha1AuthProvider(); await coreApiClient.auth.authProvider.listAuthProvider();
const authProviderNames = authProviders.value.map((item) => item.name); const authProviderNames = authProviders.value.map((item) => item.name);
@ -67,12 +68,10 @@ async function onSortUpdate() {
.filter(Boolean) as AuthProvider[]; .filter(Boolean) as AuthProvider[];
for (const authProvider of sortedAuthProviders) { for (const authProvider of sortedAuthProviders) {
await apiClient.extension.authProvider.updateAuthHaloRunV1alpha1AuthProvider( await coreApiClient.auth.authProvider.updateAuthProvider({
{ name: authProvider.metadata.name,
name: authProvider.metadata.name, authProvider: authProvider,
authProvider: authProvider, });
}
);
} }
} finally { } finally {
await refetch(); await refetch();

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import type { ListedAuthProvider } from "@halo-dev/api-client"; import type { ListedAuthProvider } from "@halo-dev/api-client";
import { import {
Dialog, Dialog,
@ -33,13 +33,13 @@ const handleChangeStatus = async () => {
onConfirm: async () => { onConfirm: async () => {
try { try {
if (props.authProvider.enabled) { if (props.authProvider.enabled) {
await apiClient.authProvider.disableAuthProvider({ await consoleApiClient.auth.authProvider.disableAuthProvider({
name: props.authProvider.name, name: props.authProvider.name,
}); });
Toast.success(t("core.common.toast.inactive_success")); Toast.success(t("core.common.toast.inactive_success"));
} else { } else {
await apiClient.authProvider.enableAuthProvider({ await consoleApiClient.auth.authProvider.enableAuthProvider({
name: props.authProvider.name, name: props.authProvider.name,
}); });
Toast.success(t("core.common.toast.active_success")); Toast.success(t("core.common.toast.active_success"));

View File

@ -11,7 +11,7 @@ import {
import type { Backup } from "@halo-dev/api-client"; import type { Backup } from "@halo-dev/api-client";
import { relativeTimeTo, formatDatetime } from "@/utils/date"; import { relativeTimeTo, formatDatetime } from "@/utils/date";
import { computed, markRaw } from "vue"; import { computed, markRaw } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQueryClient } from "@tanstack/vue-query"; import { useQueryClient } from "@tanstack/vue-query";
import prettyBytes from "pretty-bytes"; import prettyBytes from "pretty-bytes";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -96,7 +96,7 @@ function handleDelete() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.extension.backup.deleteMigrationHaloRunV1alpha1Backup({ await coreApiClient.migration.backup.deleteBackup({
name: props.backup.metadata.name, name: props.backup.metadata.name,
}); });

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { Dialog, Toast } from "@halo-dev/components"; import { Dialog, Toast } from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import dayjs from "dayjs"; import dayjs from "dayjs";
@ -9,10 +9,9 @@ export function useBackupFetch() {
return useQuery({ return useQuery({
queryKey: ["backups"], queryKey: ["backups"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.migration.backup.listBackup({
await apiClient.extension.backup.listMigrationHaloRunV1alpha1Backup({ sort: ["metadata.creationTimestamp,desc"],
sort: ["metadata.creationTimestamp,desc"], });
});
return data; return data;
}, },
refetchInterval(data) { refetchInterval(data) {
@ -51,7 +50,7 @@ export function useBackup() {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
async onConfirm() { async onConfirm() {
await apiClient.extension.backup.createMigrationHaloRunV1alpha1Backup({ await coreApiClient.migration.backup.createBackup({
backup: { backup: {
apiVersion: "migration.halo.run/v1alpha1", apiVersion: "migration.halo.run/v1alpha1",
kind: "Backup", kind: "Backup",

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { import {
Dialog, Dialog,
Toast, Toast,
@ -17,7 +17,7 @@ import { ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useBackupFetch } from "../composables/use-backup"; import { useBackupFetch } from "../composables/use-backup";
import BackupListItem from "../components/BackupListItem.vue"; import BackupListItem from "../components/BackupListItem.vue";
import type { Backup } from "packages/api-client/dist"; import type { Backup } from "@halo-dev/api-client";
const { t } = useI18n(); const { t } = useI18n();
const { data: backups } = useBackupFetch(); const { data: backups } = useBackupFetch();
@ -58,7 +58,7 @@ const remoteDownloadUrl = ref("");
const { isLoading: downloading, mutate: handleRemoteDownload } = useMutation({ const { isLoading: downloading, mutate: handleRemoteDownload } = useMutation({
mutationKey: ["remote-download-restore"], mutationKey: ["remote-download-restore"],
mutationFn: async () => { mutationFn: async () => {
return await apiClient.migration.restoreBackup({ return await consoleApiClient.migration.restoreBackup({
downloadUrl: remoteDownloadUrl.value, downloadUrl: remoteDownloadUrl.value,
}); });
}, },
@ -74,7 +74,7 @@ function handleRestoreFromBackup(backup: Backup) {
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
showCancel: false, showCancel: false,
async onConfirm() { async onConfirm() {
await apiClient.migration.restoreBackup({ await consoleApiClient.migration.restoreBackup({
backupName: backup.metadata.name, backupName: backup.metadata.name,
}); });
setTimeout(() => { setTimeout(() => {

View File

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { GlobalInfo, Info, Startup } from "@/types"; import type { GlobalInfo, Info, Startup } from "@/types";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { useThemeStore } from "@console/stores/theme"; import { useThemeStore } from "@console/stores/theme";
@ -64,7 +64,7 @@ const { data: startup } = useQuery<Startup>({
const { data: plugins, isLoading: isPluginsLoading } = useQuery<Plugin[]>({ const { data: plugins, isLoading: isPluginsLoading } = useQuery<Plugin[]>({
queryKey: ["enabled-plugins"], queryKey: ["enabled-plugins"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.plugin.listPlugins({ const { data } = await consoleApiClient.plugin.plugin.listPlugins({
page: 0, page: 0,
size: 0, size: 0,
enabled: true, enabled: true,

View File

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs // core libs
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed, provide, ref } from "vue"; import { computed, provide, ref } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
@ -44,10 +44,9 @@ provide<Ref<string>>("activeTab", activeTab);
const { data: plugin } = useQuery({ const { data: plugin } = useQuery({
queryKey: ["plugin", route.params.name], queryKey: ["plugin", route.params.name],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } = await coreApiClient.plugin.plugin.getPlugin({
await apiClient.extension.plugin.getPluginHaloRunV1alpha1Plugin({ name: route.params.name as string,
name: route.params.name as string, });
});
return data; return data;
}, },
async onSuccess(data) { async onSuccess(data) {
@ -65,7 +64,7 @@ provide<Ref<Plugin | undefined>>("plugin", plugin);
const { data: setting } = useQuery({ const { data: setting } = useQuery({
queryKey: ["plugin-setting", plugin], queryKey: ["plugin-setting", plugin],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.plugin.fetchPluginSetting({ const { data } = await consoleApiClient.plugin.plugin.fetchPluginSetting({
name: plugin.value?.metadata.name as string, name: plugin.value?.metadata.name as string,
}); });
return data; return data;

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client"; import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client";
import { import {
@ -56,7 +56,7 @@ const total = ref(0);
const { data, isLoading, isFetching, refetch } = useQuery<Plugin[]>({ const { data, isLoading, isFetching, refetch } = useQuery<Plugin[]>({
queryKey: ["plugins", keyword, selectedEnabledValue, selectedSortValue], queryKey: ["plugins", keyword, selectedEnabledValue, selectedSortValue],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.plugin.listPlugins({ const { data } = await consoleApiClient.plugin.plugin.listPlugins({
page: 0, page: 0,
size: 0, size: 0,
keyword: keyword.value, keyword: keyword.value,

View File

@ -10,10 +10,14 @@ import {
import type { Ref } from "vue"; import type { Ref } from "vue";
import { computed, inject, markRaw, ref, toRefs } from "vue"; import { computed, inject, markRaw, ref, toRefs } from "vue";
import { usePluginLifeCycle } from "../composables/use-plugin"; import { usePluginLifeCycle } from "../composables/use-plugin";
import { type Plugin, PluginStatusPhaseEnum } from "@halo-dev/api-client"; import {
type Plugin,
PluginStatusPhaseEnum,
consoleApiClient,
} from "@halo-dev/api-client";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { apiClient } from "@/utils/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useEntityFieldItemExtensionPoint } from "@console/composables/use-entity-extension-points"; import { useEntityFieldItemExtensionPoint } from "@console/composables/use-entity-extension-points";
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points"; import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
@ -61,7 +65,7 @@ const handleResetSettingConfig = async () => {
return; return;
} }
await apiClient.plugin.resetPluginConfig({ await consoleApiClient.plugin.plugin.resetPluginConfig({
name: plugin.value.metadata.name as string, name: plugin.value.metadata.name as string,
}); });

View File

@ -10,7 +10,7 @@ import type { UppyFile } from "@uppy/core";
import type { ErrorResponse } from "@uppy/core"; import type { ErrorResponse } from "@uppy/core";
import type { PluginInstallationErrorResponse } from "../../types"; import type { PluginInstallationErrorResponse } from "../../types";
import { PLUGIN_ALREADY_EXISTS_TYPE } from "../../constants"; import { PLUGIN_ALREADY_EXISTS_TYPE } from "../../constants";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import AppDownloadAlert from "@/components/common/AppDownloadAlert.vue"; import AppDownloadAlert from "@/components/common/AppDownloadAlert.vue";
const emit = defineEmits<{ const emit = defineEmits<{
@ -64,7 +64,7 @@ const handleShowActiveModalAfterInstall = (plugin: Plugin) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.plugin.changePluginRunningState({ await consoleApiClient.plugin.plugin.changePluginRunningState({
name: plugin.metadata.name, name: plugin.metadata.name,
pluginRunningStateRequest: { pluginRunningStateRequest: {
enable: true, enable: true,
@ -93,7 +93,7 @@ const handleCatchExistsException = async (
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.plugin.upgradePlugin({ await consoleApiClient.plugin.plugin.upgradePlugin({
name: error.pluginName, name: error.pluginName,
file: file, file: file,
}); });

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Dialog, Toast, VButton } from "@halo-dev/components"; import { Dialog, Toast, VButton } from "@halo-dev/components";
import type { Plugin } from "@halo-dev/api-client"; import type { Plugin } from "@halo-dev/api-client";
import type { Ref } from "vue"; import type { Ref } from "vue";
@ -33,7 +33,7 @@ const handleDownloadPlugin = async () => {
try { try {
downloading.value = true; downloading.value = true;
if (pluginToUpgrade.value) { if (pluginToUpgrade.value) {
await apiClient.plugin.upgradePluginFromUri({ await consoleApiClient.plugin.plugin.upgradePluginFromUri({
name: pluginToUpgrade.value.metadata.name, name: pluginToUpgrade.value.metadata.name,
upgradeFromUriRequest: { upgradeFromUriRequest: {
uri: remoteDownloadUrl.value, uri: remoteDownloadUrl.value,
@ -45,11 +45,12 @@ const handleDownloadPlugin = async () => {
return; return;
} }
const { data: plugin } = await apiClient.plugin.installPluginFromUri({ const { data: plugin } =
installFromUriRequest: { await consoleApiClient.plugin.plugin.installPluginFromUri({
uri: remoteDownloadUrl.value, installFromUriRequest: {
}, uri: remoteDownloadUrl.value,
}); },
});
emit("close-modal"); emit("close-modal");
queryClient.invalidateQueries({ queryKey: ["plugins"] }); queryClient.invalidateQueries({ queryKey: ["plugins"] });
@ -80,7 +81,7 @@ const handleShowActiveModalAfterInstall = (plugin: Plugin) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.plugin.changePluginRunningState({ await consoleApiClient.plugin.plugin.changePluginRunningState({
name: plugin.metadata.name, name: plugin.metadata.name,
pluginRunningStateRequest: { pluginRunningStateRequest: {
enable: true, enable: true,
@ -108,7 +109,7 @@ const handleCatchExistsException = async (
confirmText: t("core.common.buttons.confirm"), confirmText: t("core.common.buttons.confirm"),
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
await apiClient.plugin.upgradePluginFromUri({ await consoleApiClient.plugin.plugin.upgradePluginFromUri({
name: error.pluginName, name: error.pluginName,
upgradeFromUriRequest: { upgradeFromUriRequest: {
uri: remoteDownloadUrl.value, uri: remoteDownloadUrl.value,

View File

@ -1,7 +1,12 @@
import type { ComputedRef, Ref } from "vue"; import type { ComputedRef, Ref } from "vue";
import { computed } from "vue"; import { computed } from "vue";
import { type Plugin, PluginStatusPhaseEnum } from "@halo-dev/api-client"; import {
import { apiClient } from "@/utils/api-client"; type Plugin,
PluginStatusPhaseEnum,
coreApiClient,
consoleApiClient,
} from "@halo-dev/api-client";
import { Dialog, Toast } from "@halo-dev/components"; import { Dialog, Toast } from "@halo-dev/components";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useMutation } from "@tanstack/vue-query"; import { useMutation } from "@tanstack/vue-query";
@ -75,7 +80,7 @@ export function usePluginLifeCycle(
const { enabled } = plugin.value.spec; const { enabled } = plugin.value.spec;
return await apiClient.plugin.changePluginRunningState({ return await consoleApiClient.plugin.plugin.changePluginRunningState({
name: plugin.value.metadata.name, name: plugin.value.metadata.name,
pluginRunningStateRequest: { pluginRunningStateRequest: {
enable: !enabled, enable: !enabled,
@ -116,14 +121,14 @@ export function usePluginLifeCycle(
if (!plugin.value) return; if (!plugin.value) return;
try { try {
await apiClient.plugin.changePluginRunningState({ await consoleApiClient.plugin.plugin.changePluginRunningState({
name: plugin.value.metadata.name, name: plugin.value.metadata.name,
pluginRunningStateRequest: { pluginRunningStateRequest: {
enable: false, enable: false,
}, },
}); });
await apiClient.extension.plugin.deletePluginHaloRunV1alpha1Plugin({ await coreApiClient.plugin.plugin.deletePlugin({
name: plugin.value.metadata.name, name: plugin.value.metadata.name,
}); });
@ -132,7 +137,7 @@ export function usePluginLifeCycle(
const { settingName, configMapName } = plugin.value.spec; const { settingName, configMapName } = plugin.value.spec;
if (settingName) { if (settingName) {
await apiClient.extension.setting.deleteV1alpha1Setting( await coreApiClient.setting.deleteSetting(
{ {
name: settingName, name: settingName,
}, },
@ -143,7 +148,7 @@ export function usePluginLifeCycle(
} }
if (configMapName) { if (configMapName) {
await apiClient.extension.configMap.deleteV1alpha1ConfigMap( await coreApiClient.configMap.deleteConfigMap(
{ {
name: configMapName, name: configMapName,
}, },
@ -193,22 +198,20 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
onConfirm: async () => { onConfirm: async () => {
try { try {
for (let i = 0; i < names.value.length; i++) { for (let i = 0; i < names.value.length; i++) {
await apiClient.extension.plugin.deletePluginHaloRunV1alpha1Plugin({ await coreApiClient.plugin.plugin.deletePlugin({
name: names.value[i], name: names.value[i],
}); });
if (deleteExtensions) { if (deleteExtensions) {
const { data: plugin } = const { data: plugin } =
await apiClient.extension.plugin.getPluginHaloRunV1alpha1Plugin( await coreApiClient.plugin.plugin.getPlugin({
{ name: names.value[i],
name: names.value[i], });
}
);
const { settingName, configMapName } = plugin.spec; const { settingName, configMapName } = plugin.spec;
if (settingName) { if (settingName) {
await apiClient.extension.setting.deleteV1alpha1Setting( await coreApiClient.setting.deleteSetting(
{ {
name: settingName, name: settingName,
}, },
@ -219,7 +222,7 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
} }
if (configMapName) { if (configMapName) {
await apiClient.extension.configMap.deleteV1alpha1ConfigMap( await coreApiClient.configMap.deleteConfigMap(
{ {
name: configMapName, name: configMapName,
}, },
@ -249,7 +252,7 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
onConfirm: async () => { onConfirm: async () => {
try { try {
for (let i = 0; i < names.value.length; i++) { for (let i = 0; i < names.value.length; i++) {
await apiClient.plugin.changePluginRunningState({ await consoleApiClient.plugin.plugin.changePluginRunningState({
name: names.value[i], name: names.value[i],
pluginRunningStateRequest: { pluginRunningStateRequest: {
enable: enabled, enable: enabled,

View File

@ -8,7 +8,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { computed, inject } from "vue"; import { computed, inject } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { import {
PluginStatusPhaseEnum, PluginStatusPhaseEnum,
type Plugin, type Plugin,
@ -33,7 +33,7 @@ interface RoleTemplateGroup {
const { data: pluginRoleTemplates } = useQuery({ const { data: pluginRoleTemplates } = useQuery({
queryKey: ["plugin-roles", plugin?.value?.metadata.name], queryKey: ["plugin-roles", plugin?.value?.metadata.name],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [ labelSelector: [

View File

@ -4,7 +4,7 @@ import { inject, ref, type Ref, computed } from "vue";
// hooks // hooks
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import { useSettingFormConvert } from "@console/composables/use-setting-form";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
// components // components
import { Toast, VButton } from "@halo-dev/components"; import { Toast, VButton } from "@halo-dev/components";
@ -27,7 +27,7 @@ const saving = ref(false);
const { data: configMap } = useQuery<ConfigMap>({ const { data: configMap } = useQuery<ConfigMap>({
queryKey: ["plugin-configMap", plugin], queryKey: ["plugin-configMap", plugin],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.plugin.fetchPluginConfig({ const { data } = await consoleApiClient.plugin.plugin.fetchPluginConfig({
name: plugin?.value?.metadata.name as string, name: plugin?.value?.metadata.name as string,
}); });
return data; return data;
@ -51,7 +51,7 @@ const handleSaveConfigMap = async () => {
return; return;
} }
await apiClient.plugin.updatePluginConfig({ await consoleApiClient.plugin.plugin.updatePluginConfig({
name: plugin.value.metadata.name, name: plugin.value.metadata.name,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });

View File

@ -12,7 +12,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { computed, ref, watch } from "vue"; import { computed, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { pluginLabels, roleLabels } from "@/constants/labels"; import { pluginLabels, roleLabels } from "@/constants/labels";
import { rbacAnnotations } from "@/constants/annotations"; import { rbacAnnotations } from "@/constants/annotations";
import { useRoleForm, useRoleTemplateSelection } from "@/composables/use-role"; import { useRoleForm, useRoleTemplateSelection } from "@/composables/use-role";
@ -20,7 +20,7 @@ import { SUPER_ROLE_NAME } from "@/constants/constants";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import type { Role } from "packages/api-client/dist"; import type { Role } from "@halo-dev/api-client";
import { resolveDeepDependencies } from "@/utils/role"; import { resolveDeepDependencies } from "@/utils/role";
const route = useRoute(); const route = useRoute();
@ -31,7 +31,7 @@ const tabActiveId = ref("detail");
const { data: roleTemplates } = useQuery({ const { data: roleTemplates } = useQuery({
queryKey: ["role-templates"], queryKey: ["role-templates"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"], labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
@ -84,7 +84,7 @@ watch(
const { refetch } = useQuery<Role>({ const { refetch } = useQuery<Role>({
queryKey: ["role", route.params.name], queryKey: ["role", route.params.name],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.getV1alpha1Role({ const { data } = await coreApiClient.role.getRole({
name: route.params.name as string, name: route.params.name as string,
}); });
return data; return data;

View File

@ -26,7 +26,7 @@ import { rbacAnnotations } from "@/constants/annotations";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
// libs // libs
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import Fuse from "fuse.js"; import Fuse from "fuse.js";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { roleLabels } from "@/constants/labels"; import { roleLabels } from "@/constants/labels";
@ -46,7 +46,7 @@ let fuse: Fuse<Role> | undefined = undefined;
const { data: roleTemplates } = useQuery({ const { data: roleTemplates } = useQuery({
queryKey: ["role-templates"], queryKey: ["role-templates"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"], labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
@ -62,7 +62,7 @@ const {
} = useQuery<RoleList>({ } = useQuery<RoleList>({
queryKey: ["roles"], queryKey: ["roles"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [`!${roleLabels.TEMPLATE}`], labelSelector: [`!${roleLabels.TEMPLATE}`],
@ -154,7 +154,7 @@ const handleCloneRole = async (role: Role) => {
// //
if (role.metadata.name === SUPER_ROLE_NAME) { if (role.metadata.name === SUPER_ROLE_NAME) {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"], labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
@ -183,7 +183,7 @@ const handleDelete = async (role: Role) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.role.deleteV1alpha1Role({ await coreApiClient.role.deleteRole({
name: role.metadata.name, name: role.metadata.name,
}); });

View File

@ -9,7 +9,7 @@ import { cloneDeep } from "lodash-es";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
import { pluginLabels, roleLabels } from "@/constants/labels"; import { pluginLabels, roleLabels } from "@/constants/labels";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
const { t } = useI18n(); const { t } = useI18n();
@ -32,7 +32,7 @@ const modal = ref<InstanceType<typeof VModal> | null>(null);
const { data: roleTemplates } = useQuery({ const { data: roleTemplates } = useQuery({
queryKey: ["role-templates"], queryKey: ["role-templates"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.role.listV1alpha1Role({ const { data } = await coreApiClient.role.listRole({
page: 0, page: 0,
size: 0, size: 0,
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"], labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],

View File

@ -11,7 +11,7 @@ import {
} from "@halo-dev/components"; } from "@halo-dev/components";
import type { Setting, SettingForm } from "@halo-dev/api-client"; import type { Setting, SettingForm } from "@halo-dev/api-client";
import { useQuery } from "@tanstack/vue-query"; import { useQuery } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import type { Raw } from "vue"; import type { Raw } from "vue";
import type { Component } from "vue"; import type { Component } from "vue";
@ -44,7 +44,7 @@ provide<Ref<string>>("activeTab", activeTab);
const { data: setting } = useQuery({ const { data: setting } = useQuery({
queryKey: ["system-setting"], queryKey: ["system-setting"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.setting.getV1alpha1Setting({ const { data } = await coreApiClient.setting.getSetting({
name: "system", name: "system",
}); });
return data; return data;

View File

@ -5,7 +5,7 @@ import type { NotifierDescriptor, Setting } from "@halo-dev/api-client";
import type { Ref } from "vue"; import type { Ref } from "vue";
import { inject } from "vue"; import { inject } from "vue";
import { ref } from "vue"; import { ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { computed } from "vue"; import { computed } from "vue";
import { toRaw } from "vue"; import { toRaw } from "vue";
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core"; import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
@ -27,7 +27,7 @@ const name = computed(
const { data: setting } = useQuery<Setting | undefined>({ const { data: setting } = useQuery<Setting | undefined>({
queryKey: ["notifier-setting", notifierDescriptor], queryKey: ["notifier-setting", notifierDescriptor],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.setting.getV1alpha1Setting({ const { data } = await coreApiClient.setting.getSetting({
name: notifierDescriptor.value?.spec?.senderSettingRef?.name as string, name: notifierDescriptor.value?.spec?.senderSettingRef?.name as string,
}); });
return data; return data;
@ -40,9 +40,10 @@ const configMapData = ref<Record<string, unknown>>({});
useQuery<Record<string, unknown>>({ useQuery<Record<string, unknown>>({
queryKey: ["notifier-configMap", notifierDescriptor], queryKey: ["notifier-configMap", notifierDescriptor],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.notifier.fetchSenderConfig({ const { data } =
name: name.value, await consoleApiClient.notification.notifier.fetchSenderConfig({
}); name: name.value,
});
return data as Record<string, unknown>; return data as Record<string, unknown>;
}, },
onSuccess(data) { onSuccess(data) {
@ -61,10 +62,11 @@ const formSchema = computed(() => {
const { isLoading: isMutating, mutate } = useMutation({ const { isLoading: isMutating, mutate } = useMutation({
mutationKey: ["save-notifier-configMap", notifierDescriptor], mutationKey: ["save-notifier-configMap", notifierDescriptor],
mutationFn: async () => { mutationFn: async () => {
const { data } = await apiClient.notifier.saveSenderConfig({ const { data } =
name: name.value, await consoleApiClient.notification.notifier.saveSenderConfig({
body: configMapData.value, name: name.value,
}); body: configMapData.value,
});
return data; return data;
}, },
onSuccess() { onSuccess() {

View File

@ -1,15 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useQuery } from "@tanstack/vue-query"; import type { NotifierDescriptor } from "@halo-dev/api-client";
import NotificationSetting from "./NotificationSetting.vue"; import { coreApiClient } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client";
import { markRaw, ref } from "vue";
import type { Raw } from "vue";
import type { Component } from "vue";
import { provide } from "vue";
import { VTabbar } from "@halo-dev/components"; import { VTabbar } from "@halo-dev/components";
import { computed } from "vue"; import { useQuery } from "@tanstack/vue-query";
import type { ComputedRef } from "vue"; import type { Component, ComputedRef, Raw } from "vue";
import type { NotifierDescriptor } from "packages/api-client/dist"; import { computed, markRaw, provide, ref } from "vue";
import NotificationSetting from "./NotificationSetting.vue";
interface Tab { interface Tab {
id: string; id: string;
@ -25,7 +21,7 @@ const { data: notifierDescriptors } = useQuery({
queryKey: ["notifier-descriptors"], queryKey: ["notifier-descriptors"],
queryFn: async () => { queryFn: async () => {
const { data } = const { data } =
await apiClient.extension.notifierDescriptors.listNotificationHaloRunV1alpha1NotifierDescriptor(); await coreApiClient.notification.notifierDescriptor.listNotifierDescriptor();
return data.items; return data.items;
}, },
onSuccess(data) { onSuccess(data) {

View File

@ -11,7 +11,7 @@ import { useSettingFormConvert } from "@console/composables/use-setting-form";
import { useSystemConfigMapStore } from "@console/stores/system-configmap"; import { useSystemConfigMapStore } from "@console/stores/system-configmap";
import type { ConfigMap, Setting } from "@halo-dev/api-client"; import type { ConfigMap, Setting } from "@halo-dev/api-client";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { useGlobalInfoStore } from "@/stores/global-info"; import { useGlobalInfoStore } from "@/stores/global-info";
@ -28,7 +28,7 @@ const saving = ref(false);
const { data: configMap } = useQuery<ConfigMap>({ const { data: configMap } = useQuery<ConfigMap>({
queryKey: ["system-configMap"], queryKey: ["system-configMap"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({ const { data } = await coreApiClient.configMap.getConfigMap({
name: SYSTEM_CONFIGMAP_NAME, name: SYSTEM_CONFIGMAP_NAME,
}); });
return data; return data;
@ -52,7 +52,7 @@ const handleSaveConfigMap = async () => {
return; return;
} }
const { data } = await apiClient.extension.configMap.updateV1alpha1ConfigMap({ const { data } = await coreApiClient.configMap.updateConfigMap({
name: SYSTEM_CONFIGMAP_NAME, name: SYSTEM_CONFIGMAP_NAME,
configMap: configMapToUpdate, configMap: configMapToUpdate,
}); });

View File

@ -2,7 +2,7 @@
import UserAvatar from "@/components/user-avatar/UserAvatar.vue"; import UserAvatar from "@/components/user-avatar/UserAvatar.vue";
import { usePluginModuleStore } from "@/stores/plugin"; import { usePluginModuleStore } from "@/stores/plugin";
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { usePermission } from "@/utils/permission"; import { usePermission } from "@/utils/permission";
import { import {
VButton, VButton,
@ -44,7 +44,7 @@ const {
} = useQuery({ } = useQuery({
queryKey: ["user-detail", params.name], queryKey: ["user-detail", params.name],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.user.getUserDetail({ const { data } = await consoleApiClient.user.getUserDetail({
name: params.name as string, name: params.name as string,
}); });
return data; return data;

View File

@ -25,7 +25,7 @@ import UserEditingModal from "./components/UserEditingModal.vue";
import UserPasswordChangeModal from "./components/UserPasswordChangeModal.vue"; import UserPasswordChangeModal from "./components/UserPasswordChangeModal.vue";
import GrantPermissionModal from "./components/GrantPermissionModal.vue"; import GrantPermissionModal from "./components/GrantPermissionModal.vue";
import { computed, onMounted, ref, watch } from "vue"; import { computed, onMounted, ref, watch } from "vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import type { ListedUser, User } from "@halo-dev/api-client"; import type { ListedUser, User } from "@halo-dev/api-client";
import { rbacAnnotations } from "@/constants/annotations"; import { rbacAnnotations } from "@/constants/annotations";
import { formatDatetime } from "@/utils/date"; import { formatDatetime } from "@/utils/date";
@ -99,7 +99,7 @@ const {
selectedRoleValue, selectedRoleValue,
], ],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.user.listUsers({ const { data } = await consoleApiClient.user.listUsers({
page: page.value, page: page.value,
size: size.value, size: size.value,
keyword: keyword.value, keyword: keyword.value,
@ -136,7 +136,7 @@ const handleDelete = async (user: User) => {
cancelText: t("core.common.buttons.cancel"), cancelText: t("core.common.buttons.cancel"),
onConfirm: async () => { onConfirm: async () => {
try { try {
await apiClient.extension.user.deleteV1alpha1User({ await coreApiClient.user.deleteUser({
name: user.metadata.name, name: user.metadata.name,
}); });
@ -163,7 +163,7 @@ const handleDeleteInBatch = async () => {
); );
await Promise.all( await Promise.all(
userNamesToDelete.map((name) => { userNamesToDelete.map((name) => {
return apiClient.extension.user.deleteV1alpha1User({ return coreApiClient.user.deleteUser({
name, name,
}); });
}) })

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import type { User } from "@halo-dev/api-client"; import type { User } from "@halo-dev/api-client";
import { VButton, VModal, VSpace } from "@halo-dev/components"; import { VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
@ -25,7 +25,7 @@ const isSubmitting = ref(false);
const handleGrantPermission = async () => { const handleGrantPermission = async () => {
try { try {
isSubmitting.value = true; isSubmitting.value = true;
await apiClient.user.grantPermission({ await consoleApiClient.user.grantPermission({
name: props.user?.metadata.name as string, name: props.user?.metadata.name as string,
grantRequest: { grantRequest: {
roles: [selectedRole.value], roles: [selectedRole.value],

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs // core libs
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import type { CreateUserRequest } from "@halo-dev/api-client"; import type { CreateUserRequest } from "@halo-dev/api-client";
// components // components
@ -46,7 +46,7 @@ const handleCreateUser = async () => {
formState.value.roles = [selectedRole.value]; formState.value.roles = [selectedRole.value];
} }
await apiClient.user.createUser({ await consoleApiClient.user.createUser({
createUserRequest: formState.value, createUserRequest: formState.value,
}); });

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs // core libs
import { nextTick, ref } from "vue"; import { nextTick, ref } from "vue";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { User } from "@halo-dev/api-client"; import type { User } from "@halo-dev/api-client";
// components // components
@ -54,7 +54,7 @@ const handleUpdateUser = async () => {
try { try {
isSubmitting.value = true; isSubmitting.value = true;
await apiClient.extension.user.updateV1alpha1User({ await coreApiClient.user.updateUser({
name: formState.value.metadata.name, name: formState.value.metadata.name,
user: formState.value, user: formState.value,
}); });

View File

@ -3,7 +3,7 @@ import { VButton, VModal, VSpace } from "@halo-dev/components";
import SubmitButton from "@/components/button/SubmitButton.vue"; import SubmitButton from "@/components/button/SubmitButton.vue";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import type { User } from "@halo-dev/api-client"; import type { User } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { cloneDeep } from "lodash-es"; import { cloneDeep } from "lodash-es";
import { setFocus } from "@/formkit/utils/focus"; import { setFocus } from "@/formkit/utils/focus";
@ -45,7 +45,7 @@ const handleChangePassword = async () => {
const changePasswordRequest = cloneDeep(formState.value); const changePasswordRequest = cloneDeep(formState.value);
delete changePasswordRequest.password_confirm; delete changePasswordRequest.password_confirm;
await apiClient.user.changeAnyonePassword({ await consoleApiClient.user.changeAnyonePassword({
name: props.user?.metadata.name || "", name: props.user?.metadata.name || "",
changePasswordRequest, changePasswordRequest,
}); });

View File

@ -1,7 +1,7 @@
import type { Ref } from "vue"; import type { Ref } from "vue";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import type { User } from "@halo-dev/api-client"; import type { User } from "@halo-dev/api-client";
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
interface useUserFetchReturn { interface useUserFetchReturn {
users: Ref<User[]>; users: Ref<User[]>;
@ -22,7 +22,7 @@ export function useUserFetch(options?: {
const handleFetchUsers = async () => { const handleFetchUsers = async () => {
try { try {
loading.value = true; loading.value = true;
const { data } = await apiClient.extension.user.listV1alpha1User({ const { data } = await coreApiClient.user.listUser({
fieldSelector: [`name!=${ANONYMOUSUSER_NAME}`], fieldSelector: [`name!=${ANONYMOUSUSER_NAME}`],
}); });
users.value = data.items; users.value = data.items;

View File

@ -1,6 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useUserStore } from "@/stores/user"; import { useUserStore } from "@/stores/user";
import { apiClient } from "@/utils/api-client"; import { ucApiClient } from "@halo-dev/api-client";
import { relativeTimeTo } from "@/utils/date"; import { relativeTimeTo } from "@/utils/date";
import { import {
VButton, VButton,
@ -24,12 +24,13 @@ const {
} = useQuery({ } = useQuery({
queryKey: ["user-notifications"], queryKey: ["user-notifications"],
queryFn: async () => { queryFn: async () => {
const { data } = await apiClient.notification.listUserNotifications({ const { data } =
username: currentUser?.metadata.name as string, await ucApiClient.notification.notification.listUserNotifications({
page: 1, username: currentUser?.metadata.name as string,
size: 20, page: 1,
fieldSelector: ["spec.unread=true"], size: 20,
}); fieldSelector: ["spec.unread=true"],
});
return data.items; return data.items;
}, },

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { coreApiClient } from "@halo-dev/api-client";
import type { ConfigMap } from "@halo-dev/api-client"; import type { ConfigMap } from "@halo-dev/api-client";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
@ -14,13 +14,12 @@ export const useSystemConfigMapStore = defineStore({
actions: { actions: {
async fetchSystemConfigMap() { async fetchSystemConfigMap() {
try { try {
const { data } = const { data } = await coreApiClient.configMap.getConfigMap(
await apiClient.extension.configMap.getV1alpha1ConfigMap( {
{ name: "system",
name: "system", },
}, { mute: true }
{ mute: true } );
);
this.configMap = data; this.configMap = data;
} catch (error) { } catch (error) {
console.error("Failed to fetch system configMap", error); console.error("Failed to fetch system configMap", error);

View File

@ -1,4 +1,4 @@
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import type { Theme } from "@halo-dev/api-client"; import type { Theme } from "@halo-dev/api-client";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { ref } from "vue"; import { ref } from "vue";
@ -15,7 +15,7 @@ export const useThemeStore = defineStore("theme", () => {
} }
try { try {
const { data } = await apiClient.theme.fetchActivatedTheme({ const { data } = await consoleApiClient.theme.theme.fetchActivatedTheme({
mute: true, mute: true,
}); });

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { publicApiClient } from "@halo-dev/api-client";
import { Toast, VButton } from "@halo-dev/components"; import { Toast, VButton } from "@halo-dev/components";
import { ref } from "vue"; import { ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -16,7 +16,7 @@ const loading = ref(false);
async function onSubmit(data: ResetPasswordForm) { async function onSubmit(data: ResetPasswordForm) {
try { try {
loading.value = true; loading.value = true;
await apiClient.common.user.sendPasswordResetEmail({ await publicApiClient.user.sendPasswordResetEmail({
passwordResetEmailRequest: { passwordResetEmailRequest: {
email: data.email, email: data.email,
username: data.username, username: data.username,

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Toast, VButton } from "@halo-dev/components"; import { Toast, VButton } from "@halo-dev/components";
import { ref } from "vue"; import { ref } from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
@ -23,7 +23,7 @@ const formState = ref<SystemInitializationRequest>({
const handleSubmit = async () => { const handleSubmit = async () => {
loading.value = true; loading.value = true;
await apiClient.system.initialize({ await consoleApiClient.system.initialize({
systemInitializationRequest: formState.value, systemInitializationRequest: formState.value,
}); });

View File

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { apiClient } from "@/utils/api-client"; import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
import { VLoading } from "@halo-dev/components"; import { VLoading } from "@halo-dev/components";
import { useMutation } from "@tanstack/vue-query"; import { useMutation } from "@tanstack/vue-query";
import { import {
@ -27,7 +27,7 @@ const globalInfoStore = useGlobalInfoStore();
const { mutateAsync: pluginInstallMutate } = useMutation({ const { mutateAsync: pluginInstallMutate } = useMutation({
mutationKey: ["plugin-install"], mutationKey: ["plugin-install"],
mutationFn: async (plugin: Plugin) => { mutationFn: async (plugin: Plugin) => {
const { data } = await apiClient.plugin.installPlugin( const { data } = await consoleApiClient.plugin.plugin.installPlugin(
{ {
source: "PRESET", source: "PRESET",
presetName: plugin.metadata.name as string, presetName: plugin.metadata.name as string,
@ -48,7 +48,7 @@ const { mutateAsync: pluginInstallMutate } = useMutation({
const { mutateAsync: pluginStartMutate } = useMutation({ const { mutateAsync: pluginStartMutate } = useMutation({
mutationKey: ["plugin-start"], mutationKey: ["plugin-start"],
mutationFn: async (plugin: Plugin) => { mutationFn: async (plugin: Plugin) => {
return await apiClient.plugin.changePluginRunningState( return await consoleApiClient.plugin.plugin.changePluginRunningState(
{ {
name: plugin.metadata.name, name: plugin.metadata.name,
pluginRunningStateRequest: { pluginRunningStateRequest: {
@ -69,39 +69,41 @@ async function setupInitialData() {
processing.value = true; processing.value = true;
// Create category / tag / post // Create category / tag / post
await apiClient.extension.category.createContentHaloRunV1alpha1Category({ await coreApiClient.content.category.createCategory({
category: category as Category, category: category as Category,
}); });
await apiClient.extension.tag.createContentHaloRunV1alpha1Tag({ await coreApiClient.content.tag.createTag({
tag: tag as Tag, tag: tag as Tag,
}); });
const { data: postData } = await apiClient.post.draftPost({ const { data: postData } = await consoleApiClient.content.post.draftPost({
postRequest: post as PostRequest, postRequest: post as PostRequest,
}); });
await apiClient.post.publishPost({ name: postData.metadata.name }); await consoleApiClient.content.post.publishPost({
name: postData.metadata.name,
});
// Create singlePage // Create singlePage
const { data: singlePageData } = await apiClient.singlePage.draftSinglePage( const { data: singlePageData } =
{ await consoleApiClient.content.singlePage.draftSinglePage({
singlePageRequest: singlePage as SinglePageRequest, singlePageRequest: singlePage as SinglePageRequest,
} });
);
await apiClient.singlePage.publishSinglePage({ await consoleApiClient.content.singlePage.publishSinglePage({
name: singlePageData.metadata.name, name: singlePageData.metadata.name,
}); });
// Create menu and menu items // Create menu and menu items
const menuItemPromises = menuItems.map((item) => { const menuItemPromises = menuItems.map((item) => {
return apiClient.extension.menuItem.createV1alpha1MenuItem({ return coreApiClient.menuItem.createMenuItem({
menuItem: item, menuItem: item,
}); });
}); });
await Promise.all(menuItemPromises); await Promise.all(menuItemPromises);
await apiClient.extension.menu.createV1alpha1Menu({ menu: menu }); await coreApiClient.menu.createMenu({ menu: menu });
// Install preset plugins // Install preset plugins
const { data: presetPlugins } = await apiClient.plugin.listPluginPresets(); const { data: presetPlugins } =
await consoleApiClient.plugin.plugin.listPluginPresets();
for (let i = 0; i < presetPlugins.length; i++) { for (let i = 0; i < presetPlugins.length; i++) {
const presetPlugin = presetPlugins[i]; const presetPlugin = presetPlugins[i];
@ -114,7 +116,7 @@ async function setupInitialData() {
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} finally { } finally {
await apiClient.extension.configMap.createV1alpha1ConfigMap({ await coreApiClient.configMap.createConfigMap({
configMap: { configMap: {
metadata: { metadata: {
name: "system-states", name: "system-states",

View File

@ -9,8 +9,8 @@
"dev:uc": "vite --host --config ./vite.uc.config.ts", "dev:uc": "vite --host --config ./vite.uc.config.ts",
"dev:console": "vite --host --config ./vite.config.ts", "dev:console": "vite --host --config ./vite.config.ts",
"build": "run-s build:console build:uc", "build": "run-s build:console build:uc",
"build:uc": "vue-tsc --noEmit && vite build --config ./vite.uc.config.ts", "build:uc": "vue-tsc --noEmit -p tsconfig.app.json --composite false && vite build --config ./vite.uc.config.ts",
"build:console": "vue-tsc --noEmit && vite build --config ./vite.config.ts", "build:console": "vue-tsc --noEmit -p tsconfig.app.json --composite false && vite build --config ./vite.config.ts",
"build:packages": "pnpm --filter \"./packages/**\" build", "build:packages": "pnpm --filter \"./packages/**\" build",
"preview": "vite preview --port 5050", "preview": "vite preview --port 5050",
"api-client:gen": "pnpm --filter \"./packages/api-client\" gen", "api-client:gen": "pnpm --filter \"./packages/api-client\" gen",
@ -76,7 +76,7 @@
"@vueuse/integrations": "^10.9.0", "@vueuse/integrations": "^10.9.0",
"@vueuse/router": "^10.9.0", "@vueuse/router": "^10.9.0",
"@vueuse/shared": "^10.9.0", "@vueuse/shared": "^10.9.0",
"axios": "^1.6.7", "axios": "^1.7.2",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
"colorjs.io": "^0.4.3", "colorjs.io": "^0.4.3",
"cropperjs": "^1.5.13", "cropperjs": "^1.5.13",

View File

@ -2,23 +2,66 @@
Halo 2.0 的 JavaScript API 客户端请求库。使用 [OpenAPI Generator](https://openapi-generator.tech/) 生成。 Halo 2.0 的 JavaScript API 客户端请求库。使用 [OpenAPI Generator](https://openapi-generator.tech/) 生成。
## 开发环境 ## 使用
```bash ```javascript
pnpm install import {
coreApiClient,
consoleApiClient,
ucApiClient,
publicApiClient,
createCoreApiClient,
createConsoleApiClient,
createUcApiClient,
createPublicApiClient,
axiosInstance
} from "@halo-dev/api-client"
``` ```
```bash - coreApiClient: 为 Halo 所有自定义模型的 CRUD 接口封装的 api client。
# 根据 OpenAPI 3.0 生成类型和网络请求的代码,此步骤需要启动 Halo 2.0 后端。 - consoleApiClient: 为 Halo 针对 Console 提供的接口封装的 api client。
pnpm gen - ucApiClient: 为 Halo 针对 UC 提供的接口封装的 api client。
- publicApiClient: 为 Halo 所有公开访问的接口封装的 api client。
- createCoreApiClient: 用于创建自定义模型的 CRUD 接口封装的 api client需要传入 baseURL 和 axios 实例。
- createConsoleApiClient: 用于创建 Console 接口封装的 api client需要传入 baseURL 和 axios 实例。
- createUcApiClient: 用于创建 UC 接口封装的 api client需要传入 baseURL 和 axios 实例。
- createPublicApiClient: 用于创建公开访问接口封装的 api client需要传入 baseURL 和 axios 实例。
- axiosInstance: 内部默认创建的 axios 实例。
### 在插件中使用
```shell
pnpm install @halo-dev/api-client axios
``` ```
```bash 由于已经在 Console 和 UC 项目中引入并设置好了 Axios 拦截器,所以直接使用即可:
pnpm build
```javascript
import { coreApiClient } from "@halo-dev/api-client"
coreApiClient.content.post.listContentHaloRunV1alpha1Post().then(response => {
// handle response
})
``` ```
## 发布版本 此外,在最新的 `@halo-dev/ui-plugin-bundler-kit@2.17.0` 中,已经排除了 `@halo-dev/api-client`、`axios` 依赖,所以最终产物中的相关依赖会自动使用 Halo 本身提供的依赖,无需关心最终产物大小。
```bash ### 在外部项目中使用
pnpm release
```shell
pnpm install @halo-dev/api-client axios
```
```javascript
import axios from "axios"
const axiosInstance = axios.create({
baseURL: "http://localhost:8090"
})
const coreApiClient = createCoreApiClient(axiosInstance)
coreApiClient.content.post.listContentHaloRunV1alpha1Post().then(response => {
// handle response
})
``` ```

View File

@ -0,0 +1,447 @@
import axios, { AxiosInstance } from "axios";
import {
AnnotationSettingV1alpha1Api,
AttachmentV1alpha1Api,
AttachmentV1alpha1ConsoleApi,
AttachmentV1alpha1UcApi,
AuthProviderV1alpha1Api,
AuthProviderV1alpha1ConsoleApi,
BackupV1alpha1Api,
CacheV1alpha1ConsoleApi,
CategoryV1alpha1Api,
CommentV1alpha1Api,
CommentV1alpha1ConsoleApi,
CommentV1alpha1PublicApi,
ConfigMapV1alpha1Api,
CounterV1alpha1Api,
ExtensionDefinitionV1alpha1Api,
ExtensionPointDefinitionV1alpha1Api,
GroupV1alpha1Api,
IndicesV1alpha1ConsoleApi,
LoginApi,
MenuItemV1alpha1Api,
MenuV1alpha1Api,
MenuV1alpha1PublicApi,
MetricsV1alpha1PublicApi,
MigrationV1alpha1ConsoleApi,
NotificationTemplateV1alpha1Api,
NotificationV1alpha1Api,
NotificationV1alpha1UcApi,
NotifierDescriptorV1alpha1Api,
NotifierV1alpha1ConsoleApi,
PersonalAccessTokenV1alpha1Api,
PersonalAccessTokenV1alpha1UcApi,
PluginV1alpha1Api,
PluginV1alpha1ConsoleApi,
PolicyTemplateV1alpha1Api,
PolicyV1alpha1Api,
PostV1alpha1Api,
PostV1alpha1ConsoleApi,
PostV1alpha1PublicApi,
PostV1alpha1UcApi,
ReasonTypeV1alpha1Api,
ReasonV1alpha1Api,
ReplyV1alpha1Api,
ReplyV1alpha1ConsoleApi,
ReverseProxyV1alpha1Api,
RoleBindingV1alpha1Api,
RoleV1alpha1Api,
SearchEngineV1alpha1Api,
SecretV1alpha1Api,
SettingV1alpha1Api,
SinglePageV1alpha1Api,
SinglePageV1alpha1ConsoleApi,
SnapshotV1alpha1Api,
SnapshotV1alpha1UcApi,
SubscriptionV1alpha1Api,
SystemV1alpha1ConsoleApi,
SystemV1alpha1PublicApi,
TagV1alpha1Api,
TagV1alpha1ConsoleApi,
ThemeV1alpha1Api,
ThemeV1alpha1ConsoleApi,
TwoFactorAuthV1alpha1UcApi,
UserConnectionV1alpha1Api,
UserV1alpha1Api,
UserV1alpha1ConsoleApi,
UserV1alpha1PublicApi,
} from "../src";
const defaultAxiosInstance = axios.create({
withCredentials: true,
});
defaultAxiosInstance.defaults.headers.common["X-Requested-With"] =
"XMLHttpRequest";
/**
* Create a core api client
*
* This is the API client for the CRUD interface that is automatically generated for Halo's core extensions.
*
* @see <https://github.com/halo-dev/rfcs/tree/main/extension>
* @param baseURL Halo backend base URL
* @param axiosInstance Axios instance
* @returns Core api client
* @example
* const axiosInstance = axios.create({
* baseURL: "https://demo.halo.run",
* withCredentials: true,
* })
*
* axiosInstance.interceptors.request.use((config) => {
* // do something before request
* return config;
* }, (error) => {
* // do something with request error
* return Promise.reject(error);
* });
*
* const coreApiClient = createCoreApiClient(axiosInstance);
*
* coreApiClient.content.post.listContentHaloRunV1alpha1Post().then(response => {
* // handle response
* })
*/
function createCoreApiClient(axiosInstance: AxiosInstance) {
const baseURL = axiosInstance.defaults.baseURL;
return {
// core
annotationSetting: new AnnotationSettingV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
menu: new MenuV1alpha1Api(undefined, baseURL, axiosInstance),
menuItem: new MenuItemV1alpha1Api(undefined, baseURL, axiosInstance),
setting: new SettingV1alpha1Api(undefined, baseURL, axiosInstance),
configMap: new ConfigMapV1alpha1Api(undefined, baseURL, axiosInstance),
secret: new SecretV1alpha1Api(undefined, baseURL, axiosInstance),
user: new UserV1alpha1Api(undefined, baseURL, axiosInstance),
role: new RoleV1alpha1Api(undefined, baseURL, axiosInstance),
roleBinding: new RoleBindingV1alpha1Api(undefined, baseURL, axiosInstance),
// content.halo.run
content: {
category: new CategoryV1alpha1Api(undefined, baseURL, axiosInstance),
comment: new CommentV1alpha1Api(undefined, baseURL, axiosInstance),
post: new PostV1alpha1Api(undefined, baseURL, axiosInstance),
reply: new ReplyV1alpha1Api(undefined, baseURL, axiosInstance),
singlePage: new SinglePageV1alpha1Api(undefined, baseURL, axiosInstance),
snapshot: new SnapshotV1alpha1Api(undefined, baseURL, axiosInstance),
tag: new TagV1alpha1Api(undefined, baseURL, axiosInstance),
},
// auth.halo.run
auth: {
authProvider: new AuthProviderV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
userConnection: new UserConnectionV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
},
// storage.halo.run
storage: {
attachment: new AttachmentV1alpha1Api(undefined, baseURL, axiosInstance),
group: new GroupV1alpha1Api(undefined, baseURL, axiosInstance),
policy: new PolicyV1alpha1Api(undefined, baseURL, axiosInstance),
policyTemplate: new PolicyTemplateV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
},
// plugin.halo.run
plugin: {
extensionDefinition: new ExtensionDefinitionV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
extensionPointDefinition: new ExtensionPointDefinitionV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
plugin: new PluginV1alpha1Api(undefined, baseURL, axiosInstance),
reverseProxy: new ReverseProxyV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
searchEngine: new SearchEngineV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
},
// metrics.halo.run
metrics: {
counter: new CounterV1alpha1Api(undefined, baseURL, axiosInstance),
},
// theme.halo.run
theme: {
theme: new ThemeV1alpha1Api(undefined, baseURL, axiosInstance),
},
// notification.halo.run
notification: {
notification: new NotificationV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
notificationTemplate: new NotificationTemplateV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
notifierDescriptor: new NotifierDescriptorV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
reason: new ReasonV1alpha1Api(undefined, baseURL, axiosInstance),
reasonType: new ReasonTypeV1alpha1Api(undefined, baseURL, axiosInstance),
subscription: new SubscriptionV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
},
// migration.halo.run
migration: {
backup: new BackupV1alpha1Api(undefined, baseURL, axiosInstance),
},
// security.halo.run
security: {
personalAccessToken: new PersonalAccessTokenV1alpha1Api(
undefined,
baseURL,
axiosInstance
),
},
};
}
/**
* Create a console api client
*
* Console api client is used for console related operations
*
* @param baseURL Halo backend base URL
* @param axiosInstance Axios instance
* @returns Console api client
* @example
* const axiosInstance = axios.create({
* baseURL: "https://demo.halo.run",
* withCredentials: true,
* })
*
* axiosInstance.interceptors.request.use((config) => {
* // do something before request
* return config;
* }, (error) => {
* // do something with request error
* return Promise.reject(error);
* });
*
* const consoleApiClient = createConsoleApiClient(axiosInstance);
*
* consoleApiClient.content.post.listPosts().then(response => {
* // handle response
* })
*/
function createConsoleApiClient(axiosInstance: AxiosInstance) {
const baseURL = axiosInstance.defaults.baseURL;
return {
user: new UserV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
system: new SystemV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
migration: new MigrationV1alpha1ConsoleApi(
undefined,
baseURL,
axiosInstance
),
cache: new CacheV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
login: new LoginApi(undefined, baseURL, axiosInstance),
storage: {
attachment: new AttachmentV1alpha1ConsoleApi(
undefined,
baseURL,
axiosInstance
),
},
auth: {
authProvider: new AuthProviderV1alpha1ConsoleApi(
undefined,
baseURL,
axiosInstance
),
},
content: {
comment: new CommentV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
reply: new ReplyV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
indices: new IndicesV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
post: new PostV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
singlePage: new SinglePageV1alpha1ConsoleApi(
undefined,
baseURL,
axiosInstance
),
tag: new TagV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
},
notification: {
notifier: new NotifierV1alpha1ConsoleApi(
undefined,
baseURL,
axiosInstance
),
},
plugin: {
plugin: new PluginV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
},
theme: {
theme: new ThemeV1alpha1ConsoleApi(undefined, baseURL, axiosInstance),
},
};
}
/**
* Create a uc api client
*
* Uc api client is used for user content related operations
*
* @param baseURL Halo backend base URL
* @param axiosInstance Axios instance
* @returns Uc api client
* @example
* const axiosInstance = axios.create({
* baseURL: "https://demo.halo.run",
* withCredentials: true,
* })
*
* axiosInstance.interceptors.request.use((config) => {
* // do something before request
* return config;
* }, (error) => {
* // do something with request error
* return Promise.reject(error);
* });
*
* const ucApiClient = createUcApiClient(axiosInstance);
*
* ucApiClient.content.post.listMyPosts().then(response => {
* // handle response
* })
*/
function createUcApiClient(axiosInstance: AxiosInstance) {
const baseURL = axiosInstance.defaults.baseURL;
return {
storage: {
attachment: new AttachmentV1alpha1UcApi(
undefined,
baseURL,
axiosInstance
),
},
content: {
post: new PostV1alpha1UcApi(undefined, baseURL, axiosInstance),
snapshot: new SnapshotV1alpha1UcApi(undefined, baseURL, axiosInstance),
},
security: {
twoFactor: new TwoFactorAuthV1alpha1UcApi(
undefined,
baseURL,
axiosInstance
),
personalAccessToken: new PersonalAccessTokenV1alpha1UcApi(
undefined,
baseURL,
axiosInstance
),
},
notification: {
notification: new NotificationV1alpha1UcApi(
undefined,
baseURL,
axiosInstance
),
},
};
}
/**
* Create a public api client
*
* Public api client is used for public content related operations, no need authentication
*
* @param baseURL Halo backend base URL
* @param axiosInstance Axios instance
* @returns Public api client
* @example
* const axiosInstance = axios.create({
* baseURL: "https://demo.halo.run",
* withCredentials: true,
* })
*
* axiosInstance.interceptors.request.use((config) => {
* // do something before request
* return config;
* }, (error) => {
* // do something with request error
* return Promise.reject(error);
* });
*
* const publicApiClient = createPublicApiClient(axiosInstance);
*
* publicApiClient.content.post.searchPost({ keyword: "foo" }).then(response => {
* // handle response
* })
*/
function createPublicApiClient(axiosInstance: AxiosInstance) {
const baseURL = axiosInstance.defaults.baseURL;
return {
menu: new MenuV1alpha1PublicApi(undefined, baseURL, axiosInstance),
stats: new SystemV1alpha1PublicApi(undefined, baseURL, axiosInstance),
user: new UserV1alpha1PublicApi(undefined, baseURL, axiosInstance),
content: {
post: new PostV1alpha1PublicApi(undefined, baseURL, axiosInstance),
comment: new CommentV1alpha1PublicApi(undefined, baseURL, axiosInstance),
},
metrics: {
metrics: new MetricsV1alpha1PublicApi(undefined, baseURL, axiosInstance),
},
};
}
const defaultCoreApiClient = createCoreApiClient(defaultAxiosInstance);
const defaultConsoleApiClient = createConsoleApiClient(defaultAxiosInstance);
const defaultUcApiClient = createUcApiClient(defaultAxiosInstance);
const defaultPublicApiClient = createPublicApiClient(defaultAxiosInstance);
export {
defaultAxiosInstance as axiosInstance,
defaultConsoleApiClient as consoleApiClient,
defaultCoreApiClient as coreApiClient,
createConsoleApiClient,
createCoreApiClient,
createPublicApiClient,
createUcApiClient,
defaultPublicApiClient as publicApiClient,
defaultUcApiClient as ucApiClient,
};

Some files were not shown because too many files have changed in this diff Show More