mirror of https://github.com/halo-dev/halo
feat: add requests library as a global shared dependency
parent
ecc0a70249
commit
c74187c066
|
@ -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";
|
||||
|
||||
interface SnapshotContent {
|
||||
|
@ -20,10 +20,9 @@ export function useContentSnapshot(
|
|||
if (!snapshotName.value) {
|
||||
return;
|
||||
}
|
||||
const { data } =
|
||||
await apiClient.extension.snapshot.getContentHaloRunV1alpha1Snapshot({
|
||||
name: snapshotName.value,
|
||||
});
|
||||
const { data } = await coreApiClient.content.snapshot.getSnapshot({
|
||||
name: snapshotName.value,
|
||||
});
|
||||
version.value = data.metadata.version || 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
|
||||
export function useDashboardStats() {
|
||||
const { data } = useQuery({
|
||||
queryKey: ["dashboard-stats"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.stats.getStats();
|
||||
const { data } = await consoleApiClient.system.getStats();
|
||||
return data;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { DirectiveBinding } from "vue";
|
|||
import { createPinia } from "pinia";
|
||||
import App from "./App.vue";
|
||||
import router from "./router";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
// setup
|
||||
import "@/setup/setupStyles";
|
||||
import { setupComponents } from "@/setup/setupComponents";
|
||||
|
@ -20,19 +20,22 @@ import {
|
|||
setupCoreModules,
|
||||
setupPluginModules,
|
||||
} from "@console/setup/setupModules";
|
||||
import { setupApiClient } from "@/setup/setupApiClient";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
setupComponents(app);
|
||||
setupI18n(app);
|
||||
setupVueQuery(app);
|
||||
setupApiClient();
|
||||
|
||||
app.use(createPinia());
|
||||
|
||||
async function loadUserPermissions() {
|
||||
const { data: currentPermissions } = await apiClient.user.getPermissions({
|
||||
name: "-",
|
||||
});
|
||||
const { data: currentPermissions } =
|
||||
await consoleApiClient.user.getPermissions({
|
||||
name: "-",
|
||||
});
|
||||
const roleStore = useRoleStore();
|
||||
roleStore.$patch({
|
||||
permissions: currentPermissions,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.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 type { Attachment, Group } from "@halo-dev/api-client";
|
||||
import {
|
||||
|
@ -129,18 +129,16 @@ provide<Ref<Set<Attachment>>>("selectedAttachments", selectedAttachments);
|
|||
const handleMove = async (group: Group) => {
|
||||
try {
|
||||
const promises = Array.from(selectedAttachments.value).map((attachment) => {
|
||||
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment(
|
||||
{
|
||||
name: attachment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/groupName",
|
||||
value: group.metadata.name,
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
return coreApiClient.storage.attachment.patchAttachment({
|
||||
name: attachment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/groupName",
|
||||
value: group.metadata.name,
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
@ -232,8 +230,8 @@ onMounted(() => {
|
|||
if (!nameQuery.value) {
|
||||
return;
|
||||
}
|
||||
apiClient.extension.storage.attachment
|
||||
.getStorageHaloRunV1alpha1Attachment({
|
||||
coreApiClient.storage.attachment
|
||||
.getAttachment({
|
||||
name: nameQuery.value,
|
||||
})
|
||||
.then((response) => {
|
||||
|
|
|
@ -10,7 +10,7 @@ import LazyImage from "@/components/image/LazyImage.vue";
|
|||
import type { Attachment } from "@halo-dev/api-client";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
import { computed, ref } from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import { isImage } from "@/utils/image";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
|
||||
|
@ -47,10 +47,9 @@ const { data: policy } = useQuery({
|
|||
return;
|
||||
}
|
||||
|
||||
const { data } =
|
||||
await apiClient.extension.storage.policy.getStorageHaloRunV1alpha1Policy({
|
||||
name: policyName.value,
|
||||
});
|
||||
const { data } = await coreApiClient.storage.policy.getPolicy({
|
||||
name: policyName.value,
|
||||
});
|
||||
|
||||
return data;
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 {
|
||||
Dialog,
|
||||
|
@ -49,29 +49,28 @@ const handleDelete = () => {
|
|||
}
|
||||
|
||||
// TODO: 后续将修改为在后端进行批量操作处理
|
||||
const { data } = await apiClient.attachment.searchAttachments({
|
||||
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
|
||||
page: 0,
|
||||
size: 0,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.storage.attachment.searchAttachments({
|
||||
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
|
||||
page: 0,
|
||||
size: 0,
|
||||
});
|
||||
|
||||
await apiClient.extension.storage.group.deleteStorageHaloRunV1alpha1Group(
|
||||
{ name: props.group.metadata.name }
|
||||
);
|
||||
await coreApiClient.storage.group.deleteGroup({
|
||||
name: props.group.metadata.name,
|
||||
});
|
||||
|
||||
// move attachments to none group
|
||||
const moveToUnGroupRequests = data.items.map((attachment) => {
|
||||
return apiClient.extension.storage.attachment.patchStorageHaloRunV1alpha1Attachment(
|
||||
{
|
||||
name: attachment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "remove",
|
||||
path: "/spec/groupName",
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
return coreApiClient.storage.attachment.patchAttachment({
|
||||
name: attachment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "remove",
|
||||
path: "/spec/groupName",
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(moveToUnGroupRequests);
|
||||
|
@ -105,20 +104,21 @@ const handleDeleteWithAttachments = () => {
|
|||
}
|
||||
|
||||
// TODO: 后续将修改为在后端进行批量操作处理
|
||||
const { data } = await apiClient.attachment.searchAttachments({
|
||||
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
|
||||
page: 0,
|
||||
size: 0,
|
||||
const { data } =
|
||||
await consoleApiClient.storage.attachment.searchAttachments({
|
||||
fieldSelector: [`spec.groupName=${props.group.metadata.name}`],
|
||||
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) => {
|
||||
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
|
||||
{ name: attachment.metadata.name }
|
||||
);
|
||||
return coreApiClient.storage.attachment.deleteAttachment({
|
||||
name: attachment.metadata.name,
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(deleteAttachmentRequests);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
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 { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
@ -45,18 +45,14 @@ const handleSave = async () => {
|
|||
try {
|
||||
isSubmitting.value = true;
|
||||
if (props.group) {
|
||||
await apiClient.extension.storage.group.updateStorageHaloRunV1alpha1Group(
|
||||
{
|
||||
name: formState.value.metadata.name,
|
||||
group: formState.value,
|
||||
}
|
||||
);
|
||||
await coreApiClient.storage.group.updateGroup({
|
||||
name: formState.value.metadata.name,
|
||||
group: formState.value,
|
||||
});
|
||||
} else {
|
||||
await apiClient.extension.storage.group.createStorageHaloRunV1alpha1Group(
|
||||
{
|
||||
group: formState.value,
|
||||
}
|
||||
);
|
||||
await coreApiClient.storage.group.createGroup({
|
||||
group: formState.value,
|
||||
});
|
||||
}
|
||||
|
||||
Toast.success(t("core.common.toast.save_success"));
|
||||
|
|
|
@ -15,7 +15,7 @@ import type { Attachment } from "@halo-dev/api-client";
|
|||
import { formatDatetime } from "@/utils/date";
|
||||
import prettyBytes from "pretty-bytes";
|
||||
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 { useI18n } from "vue-i18n";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
|
@ -65,11 +65,9 @@ const handleDelete = () => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
|
||||
{
|
||||
name: props.attachment.metadata.name,
|
||||
}
|
||||
);
|
||||
await coreApiClient.storage.attachment.deleteAttachment({
|
||||
name: props.attachment.metadata.name,
|
||||
});
|
||||
|
||||
selectedAttachments.value.delete(props.attachment);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
import type { Policy, PolicyTemplate } from "@halo-dev/api-client";
|
||||
import {
|
||||
|
@ -50,7 +50,7 @@ const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
|
|||
};
|
||||
|
||||
const handleDelete = async (policy: Policy) => {
|
||||
const { data } = await apiClient.attachment.searchAttachments({
|
||||
const { data } = await consoleApiClient.storage.attachment.searchAttachments({
|
||||
fieldSelector: [`spec.policyName=${policy.metadata.name}`],
|
||||
});
|
||||
|
||||
|
@ -76,9 +76,9 @@ const handleDelete = async (policy: Policy) => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.extension.storage.policy.deleteStorageHaloRunV1alpha1Policy(
|
||||
{ name: policy.metadata.name }
|
||||
);
|
||||
await coreApiClient.storage.policy.deletePolicy({
|
||||
name: policy.metadata.name,
|
||||
});
|
||||
|
||||
Toast.success(t("core.common.toast.delete_success"));
|
||||
handleFetchPolicies();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
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 type { Policy } from "@halo-dev/api-client";
|
||||
import { Toast, VButton, VLoading, VModal, VSpace } from "@halo-dev/components";
|
||||
|
@ -66,11 +66,9 @@ const { data: policyTemplate } = useQuery({
|
|||
cacheTime: 0,
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.storage.policyTemplate.getStorageHaloRunV1alpha1PolicyTemplate(
|
||||
{
|
||||
name: formState.value.spec.templateName,
|
||||
}
|
||||
);
|
||||
await coreApiClient.storage.policyTemplate.getPolicyTemplate({
|
||||
name: formState.value.spec.templateName,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
retry: 0,
|
||||
|
@ -88,7 +86,7 @@ const { data: setting, isLoading } = useQuery({
|
|||
throw new Error("No setting found");
|
||||
}
|
||||
|
||||
const { data } = await apiClient.extension.setting.getV1alpha1Setting({
|
||||
const { data } = await coreApiClient.setting.getSetting({
|
||||
name: policyTemplate.value.spec.settingName,
|
||||
});
|
||||
|
||||
|
@ -118,7 +116,7 @@ const { data: configMap } = useQuery({
|
|||
if (!policy.value?.spec.configMapName) {
|
||||
throw new Error("No configMap found");
|
||||
}
|
||||
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({
|
||||
const { data } = await coreApiClient.configMap.getConfigMap({
|
||||
name: policy.value?.spec.configMapName,
|
||||
});
|
||||
return data;
|
||||
|
@ -141,29 +139,26 @@ const handleSave = async () => {
|
|||
const configMapToUpdate = convertToSave();
|
||||
|
||||
if (isUpdateMode) {
|
||||
await apiClient.extension.configMap.updateV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.updateConfigMap({
|
||||
name: configMap.value.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
||||
await apiClient.extension.storage.policy.updateStorageHaloRunV1alpha1Policy(
|
||||
{
|
||||
name: formState.value.metadata.name,
|
||||
policy: formState.value,
|
||||
}
|
||||
);
|
||||
await coreApiClient.storage.policy.updatePolicy({
|
||||
name: formState.value.metadata.name,
|
||||
policy: formState.value,
|
||||
});
|
||||
} else {
|
||||
const { data: newConfigMap } =
|
||||
await apiClient.extension.configMap.createV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.createConfigMap({
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
||||
formState.value.spec.configMapName = newConfigMap.metadata.name;
|
||||
await apiClient.extension.storage.policy.createStorageHaloRunV1alpha1Policy(
|
||||
{
|
||||
policy: formState.value,
|
||||
}
|
||||
);
|
||||
|
||||
await coreApiClient.storage.policy.createPolicy({
|
||||
policy: formState.value,
|
||||
});
|
||||
}
|
||||
|
||||
Toast.success(t("core.common.toast.save_success"));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { Ref } from "vue";
|
||||
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";
|
||||
|
||||
interface useFetchAttachmentGroupReturn {
|
||||
|
@ -13,13 +13,10 @@ export function useFetchAttachmentGroup(): useFetchAttachmentGroupReturn {
|
|||
const { data, isLoading, refetch } = useQuery<Group[]>({
|
||||
queryKey: ["attachment-groups"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.storage.group.listStorageHaloRunV1alpha1Group(
|
||||
{
|
||||
labelSelector: ["!halo.run/hidden"],
|
||||
sort: ["metadata.creationTimestamp,asc"],
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.storage.group.listGroup({
|
||||
labelSelector: ["!halo.run/hidden"],
|
||||
sort: ["metadata.creationTimestamp,asc"],
|
||||
});
|
||||
|
||||
return data.items;
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { Ref } from "vue";
|
||||
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";
|
||||
|
||||
interface useFetchAttachmentPolicyReturn {
|
||||
|
@ -19,8 +19,7 @@ export function useFetchAttachmentPolicy(): useFetchAttachmentPolicyReturn {
|
|||
const { data, isLoading, refetch } = useQuery<Policy[]>({
|
||||
queryKey: ["attachment-policies"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.storage.policy.listStorageHaloRunV1alpha1Policy();
|
||||
const { data } = await coreApiClient.storage.policy.listPolicy();
|
||||
return data.items;
|
||||
},
|
||||
refetchInterval(data) {
|
||||
|
@ -43,7 +42,7 @@ export function useFetchAttachmentPolicyTemplate(): useFetchAttachmentPolicyTemp
|
|||
queryKey: ["attachment-policy-templates"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.storage.policyTemplate.listStorageHaloRunV1alpha1PolicyTemplate();
|
||||
await coreApiClient.storage.policyTemplate.listPolicyTemplate();
|
||||
return data.items;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { Attachment } from "@halo-dev/api-client";
|
||||
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 { useQuery } from "@tanstack/vue-query";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -77,15 +77,16 @@ export function useAttachmentControl(filterOptions: {
|
|||
})
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
const { data } = await apiClient.attachment.searchAttachments({
|
||||
fieldSelector,
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
ungrouped: isUnGrouped,
|
||||
accepts: accepts?.value,
|
||||
keyword: keyword?.value,
|
||||
sort: [sort?.value as string].filter(Boolean),
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.storage.attachment.searchAttachments({
|
||||
fieldSelector,
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
ungrouped: isUnGrouped,
|
||||
accepts: accepts?.value,
|
||||
keyword: keyword?.value,
|
||||
sort: [sort?.value as string].filter(Boolean),
|
||||
});
|
||||
|
||||
total.value = data.total;
|
||||
hasPrevious.value = data.hasPrevious;
|
||||
|
@ -158,11 +159,9 @@ export function useAttachmentControl(filterOptions: {
|
|||
try {
|
||||
const promises = Array.from(selectedAttachments.value).map(
|
||||
(attachment) => {
|
||||
return apiClient.extension.storage.attachment.deleteStorageHaloRunV1alpha1Attachment(
|
||||
{
|
||||
name: attachment.metadata.name,
|
||||
}
|
||||
);
|
||||
return coreApiClient.storage.attachment.deleteAttachment({
|
||||
name: attachment.metadata.name,
|
||||
});
|
||||
}
|
||||
);
|
||||
await Promise.all(promises);
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
import CommentListItem from "./components/CommentListItem.vue";
|
||||
import type { ListedComment } from "@halo-dev/api-client";
|
||||
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 { useI18n } from "vue-i18n";
|
||||
import UserFilterDropdown from "@/components/filter/UserFilterDropdown.vue";
|
||||
|
@ -101,7 +101,7 @@ const {
|
|||
})
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
const { data } = await apiClient.comment.listComments({
|
||||
const { data } = await consoleApiClient.content.comment.listComments({
|
||||
fieldSelector,
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
|
@ -165,11 +165,9 @@ const handleDeleteInBatch = async () => {
|
|||
onConfirm: async () => {
|
||||
try {
|
||||
const promises = selectedCommentNames.value.map((name) => {
|
||||
return apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment(
|
||||
{
|
||||
name,
|
||||
}
|
||||
);
|
||||
return coreApiClient.content.comment.deleteComment({
|
||||
name,
|
||||
});
|
||||
});
|
||||
await Promise.all(promises);
|
||||
selectedCommentNames.value = [];
|
||||
|
@ -200,24 +198,22 @@ const handleApproveInBatch = async () => {
|
|||
});
|
||||
|
||||
const promises = commentsToUpdate?.map((comment) => {
|
||||
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment(
|
||||
{
|
||||
name: comment.comment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/approved",
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/approvedTime",
|
||||
// TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746
|
||||
value: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
}
|
||||
);
|
||||
return coreApiClient.content.comment.patchComment({
|
||||
name: comment.comment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/approved",
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
op: "add",
|
||||
path: "/spec/approvedTime",
|
||||
// TODO: 暂时由前端设置发布时间。see https://github.com/halo-dev/halo/pull/2746
|
||||
value: new Date().toISOString(),
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
await Promise.all(promises || []);
|
||||
selectedCommentNames.value = [];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
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 { usePermission } from "@/utils/permission";
|
||||
import type {
|
||||
|
@ -65,7 +65,7 @@ const handleDelete = async () => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.comment.deleteContentHaloRunV1alpha1Comment({
|
||||
await coreApiClient.content.comment.deleteComment({
|
||||
name: props.comment?.comment?.metadata.name as string,
|
||||
});
|
||||
|
||||
|
@ -90,7 +90,7 @@ const handleApproveReplyInBatch = async () => {
|
|||
return !reply.reply.spec.approved;
|
||||
});
|
||||
const promises = repliesToUpdate?.map((reply) => {
|
||||
return apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({
|
||||
return coreApiClient.content.reply.patchReply({
|
||||
name: reply.reply.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ const handleApproveReplyInBatch = async () => {
|
|||
|
||||
const handleApprove = async () => {
|
||||
try {
|
||||
await apiClient.extension.comment.patchContentHaloRunV1alpha1Comment({
|
||||
await coreApiClient.content.comment.patchComment({
|
||||
name: props.comment.comment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
|
@ -157,7 +157,7 @@ const {
|
|||
showReplies,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.reply.listReplies({
|
||||
const { data } = await consoleApiClient.content.reply.listReplies({
|
||||
commentName: props.comment.comment.metadata.name,
|
||||
page: 0,
|
||||
size: 0,
|
||||
|
@ -176,7 +176,7 @@ const {
|
|||
const { mutateAsync: updateCommentLastReadTimeMutate } = useMutation({
|
||||
mutationKey: ["update-comment-last-read-time"],
|
||||
mutationFn: async () => {
|
||||
return apiClient.extension.comment.patchContentHaloRunV1alpha1Comment(
|
||||
return coreApiClient.content.comment.patchComment(
|
||||
{
|
||||
name: props.comment.comment.metadata.name,
|
||||
jsonPatchInner: [
|
||||
|
|
|
@ -18,7 +18,7 @@ import { Picker } from "emoji-mart";
|
|||
import i18n from "@emoji-mart/data/i18n/zh.json";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { setFocus } from "@/formkit/utils/focus";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -62,7 +62,7 @@ const handleCreateReply = async () => {
|
|||
|
||||
formState.value.content = formState.value.raw;
|
||||
|
||||
await apiClient.comment.createReply({
|
||||
await consoleApiClient.content.comment.createReply({
|
||||
name: props.comment?.comment.metadata.name as string,
|
||||
replyRequest: formState.value,
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import type { ListedComment, ListedReply } from "@halo-dev/api-client";
|
||||
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 { useI18n } from "vue-i18n";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
|
@ -54,7 +54,7 @@ const handleDelete = async () => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.reply.deleteContentHaloRunV1alpha1Reply({
|
||||
await coreApiClient.content.reply.deleteReply({
|
||||
name: props.reply?.reply.metadata.name as string,
|
||||
});
|
||||
|
||||
|
@ -70,7 +70,7 @@ const handleDelete = async () => {
|
|||
|
||||
const handleApprove = async () => {
|
||||
try {
|
||||
await apiClient.extension.reply.patchContentHaloRunV1alpha1Reply({
|
||||
await coreApiClient.content.reply.patchReply({
|
||||
name: props.reply.reply.metadata.name,
|
||||
jsonPatchInner: [
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { ref, watch } from "vue";
|
||||
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 { cloneDeep } from "lodash-es";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
|
@ -46,7 +46,7 @@ const {
|
|||
} = useQuery<ListedSinglePage[]>({
|
||||
queryKey: ["deleted-singlePages", page, size, keyword],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.singlePage.listSinglePages({
|
||||
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
|
||||
labelSelector: [`content.halo.run/deleted=true`],
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
|
@ -92,11 +92,9 @@ const handleDeletePermanently = async (singlePage: SinglePage) => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: singlePage.metadata.name,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.singlePage.deleteSinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
});
|
||||
await refetch();
|
||||
|
||||
Toast.success(t("core.common.toast.delete_success"));
|
||||
|
@ -114,11 +112,9 @@ const handleDeletePermanentlyInBatch = async () => {
|
|||
onConfirm: async () => {
|
||||
await Promise.all(
|
||||
selectedPageNames.value.map((name) => {
|
||||
return apiClient.extension.singlePage.deleteContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name,
|
||||
}
|
||||
);
|
||||
return coreApiClient.content.singlePage.deleteSinglePage({
|
||||
name,
|
||||
});
|
||||
})
|
||||
);
|
||||
await refetch();
|
||||
|
@ -138,12 +134,10 @@ const handleRecovery = async (singlePage: SinglePage) => {
|
|||
onConfirm: async () => {
|
||||
const singlePageToUpdate = cloneDeep(singlePage);
|
||||
singlePageToUpdate.spec.deleted = false;
|
||||
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: singlePageToUpdate.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: singlePageToUpdate.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
});
|
||||
await refetch();
|
||||
|
||||
Toast.success(t("core.common.toast.recovery_success"));
|
||||
|
@ -170,18 +164,16 @@ const handleRecoveryInBatch = async () => {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: singlePage.metadata.name,
|
||||
singlePage: {
|
||||
...singlePage,
|
||||
spec: {
|
||||
...singlePage.spec,
|
||||
deleted: false,
|
||||
},
|
||||
return coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
singlePage: {
|
||||
...singlePage,
|
||||
spec: {
|
||||
...singlePage.spec,
|
||||
deleted: false,
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
await refetch();
|
||||
|
|
|
@ -24,7 +24,11 @@ import {
|
|||
toRef,
|
||||
watch,
|
||||
} from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import {
|
||||
consoleApiClient,
|
||||
coreApiClient,
|
||||
ucApiClient,
|
||||
} from "@halo-dev/api-client";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
import { useRouter } from "vue-router";
|
||||
import { randomUUID } from "@/utils/id";
|
||||
|
@ -156,10 +160,11 @@ const handleSave = async (options?: { mute?: boolean }) => {
|
|||
).data;
|
||||
}
|
||||
|
||||
const { data } = await apiClient.singlePage.updateSinglePageContent({
|
||||
name: formState.value.page.metadata.name,
|
||||
content: formState.value.content,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.content.singlePage.updateSinglePageContent({
|
||||
name: formState.value.page.metadata.name,
|
||||
content: formState.value.content,
|
||||
});
|
||||
|
||||
formState.value.page = data;
|
||||
isTitleChanged.value = false;
|
||||
|
@ -167,9 +172,10 @@ const handleSave = async (options?: { mute?: boolean }) => {
|
|||
// Clear new page content cache
|
||||
handleClearCache();
|
||||
|
||||
const { data } = await apiClient.singlePage.draftSinglePage({
|
||||
singlePageRequest: formState.value,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.content.singlePage.draftSinglePage({
|
||||
singlePageRequest: formState.value,
|
||||
});
|
||||
formState.value.page = data;
|
||||
routeQueryName.value = data.metadata.name;
|
||||
}
|
||||
|
@ -205,12 +211,12 @@ const handlePublish = async () => {
|
|||
).data;
|
||||
}
|
||||
|
||||
await apiClient.singlePage.updateSinglePageContent({
|
||||
await consoleApiClient.content.singlePage.updateSinglePageContent({
|
||||
name: singlePageName,
|
||||
content: formState.value.content,
|
||||
});
|
||||
|
||||
await apiClient.singlePage.publishSinglePage({
|
||||
await consoleApiClient.content.singlePage.publishSinglePage({
|
||||
name: singlePageName,
|
||||
});
|
||||
|
||||
|
@ -221,7 +227,7 @@ const handlePublish = async () => {
|
|||
}
|
||||
} else {
|
||||
formState.value.page.spec.publish = true;
|
||||
await apiClient.singlePage.draftSinglePage({
|
||||
await consoleApiClient.content.singlePage.draftSinglePage({
|
||||
singlePageRequest: formState.value,
|
||||
});
|
||||
|
||||
|
@ -254,9 +260,10 @@ const handleFetchContent = async () => {
|
|||
if (!formState.value.page.spec.headSnapshot) {
|
||||
return;
|
||||
}
|
||||
const { data } = await apiClient.singlePage.fetchSinglePageHeadContent({
|
||||
name: formState.value.page.metadata.name,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.content.singlePage.fetchSinglePageHeadContent({
|
||||
name: formState.value.page.metadata.name,
|
||||
});
|
||||
|
||||
formState.value.content = Object.assign(formState.value.content, data);
|
||||
|
||||
|
@ -305,7 +312,7 @@ const handleFetchContent = async () => {
|
|||
// SinglePage settings
|
||||
const handleOpenSettingModal = async () => {
|
||||
const { data: latestSinglePage } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: formState.value.page.metadata.name,
|
||||
});
|
||||
formState.value.page = latestSinglePage;
|
||||
|
@ -335,7 +342,7 @@ onMounted(async () => {
|
|||
|
||||
if (routeQueryName.value) {
|
||||
const { data: singlePage } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: routeQueryName.value,
|
||||
});
|
||||
formState.value.page = singlePage;
|
||||
|
@ -412,7 +419,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
|
|||
await handleSave();
|
||||
}
|
||||
|
||||
const { data } = await apiClient.uc.attachment.createAttachmentForPost(
|
||||
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
|
||||
{
|
||||
file,
|
||||
singlePageName: formState.value.page.metadata.name,
|
||||
|
|
|
@ -19,7 +19,7 @@ import SinglePageSettingModal from "./components/SinglePageSettingModal.vue";
|
|||
import type { Ref } from "vue";
|
||||
import { computed, provide, ref, watch } from "vue";
|
||||
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 { useQuery } from "@tanstack/vue-query";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -114,7 +114,7 @@ const {
|
|||
);
|
||||
}
|
||||
|
||||
const { data } = await apiClient.singlePage.listSinglePages({
|
||||
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
|
||||
labelSelector,
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
|
@ -143,10 +143,9 @@ const {
|
|||
});
|
||||
|
||||
const handleOpenSettingModal = async (singlePage: SinglePage) => {
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
});
|
||||
const { data } = await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
});
|
||||
selectedSinglePage.value = data;
|
||||
settingModal.value = true;
|
||||
};
|
||||
|
@ -165,10 +164,9 @@ const handleSelectPrevious = async () => {
|
|||
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
|
||||
);
|
||||
if (index > 0) {
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
name: singlePages.value[index - 1].page.metadata.name,
|
||||
});
|
||||
const { data } = await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: singlePages.value[index - 1].page.metadata.name,
|
||||
});
|
||||
selectedSinglePage.value = data;
|
||||
return;
|
||||
}
|
||||
|
@ -188,10 +186,9 @@ const handleSelectNext = async () => {
|
|||
singlePage.page.metadata.name === selectedSinglePage.value?.metadata.name
|
||||
);
|
||||
if (index < singlePages.value.length - 1) {
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
name: singlePages.value[index + 1].page.metadata.name,
|
||||
});
|
||||
const { data } = await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: singlePages.value[index + 1].page.metadata.name,
|
||||
});
|
||||
selectedSinglePage.value = data;
|
||||
return;
|
||||
}
|
||||
|
@ -240,18 +237,16 @@ const handleDeleteInBatch = async () => {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: page.metadata.name,
|
||||
singlePage: {
|
||||
...page,
|
||||
spec: {
|
||||
...page.spec,
|
||||
deleted: true,
|
||||
},
|
||||
return coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: page.metadata.name,
|
||||
singlePage: {
|
||||
...page,
|
||||
spec: {
|
||||
...page.spec,
|
||||
deleted: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
await refetch();
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
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 { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
|
@ -28,10 +28,9 @@ const singlePageName = computed(() => route.query.name as string);
|
|||
const { data: singlePage } = useQuery({
|
||||
queryKey: ["singlePage-by-name", singlePageName],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
name: singlePageName.value,
|
||||
});
|
||||
const { data } = await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: singlePageName.value,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
enabled: computed(() => !!singlePageName.value),
|
||||
|
@ -40,9 +39,10 @@ const { data: singlePage } = useQuery({
|
|||
const { data: snapshots, isLoading } = useQuery({
|
||||
queryKey: ["singlePage-snapshots-by-singlePage-name", singlePageName],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.singlePage.listSinglePageSnapshots({
|
||||
name: singlePageName.value,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.content.singlePage.listSinglePageSnapshots({
|
||||
name: singlePageName.value,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
refetchInterval(data) {
|
||||
|
@ -99,7 +99,7 @@ function handleCleanup() {
|
|||
}
|
||||
|
||||
for (let i = 0; i < snapshotsToDelete?.length; i++) {
|
||||
await apiClient.singlePage.deleteSinglePageContent({
|
||||
await consoleApiClient.content.singlePage.deleteSinglePageContent({
|
||||
name: singlePageName.value,
|
||||
snapshotName: snapshotsToDelete[i].metadata.name,
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { computed, ref } from "vue";
|
||||
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 { RouterLink } from "vue-router";
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
@ -72,12 +72,11 @@ const isPublishing = computed(() => {
|
|||
|
||||
const { mutate: changeVisibleMutation } = useMutation({
|
||||
mutationFn: async (singlePage: SinglePage) => {
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
});
|
||||
const { data } = await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: singlePage.metadata.name,
|
||||
});
|
||||
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
|
||||
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
await coreApiClient.content.singlePage.updateSinglePage(
|
||||
{
|
||||
name: singlePage.metadata.name,
|
||||
singlePage: data,
|
||||
|
@ -107,12 +106,10 @@ const handleDelete = async () => {
|
|||
onConfirm: async () => {
|
||||
const singlePageToUpdate = cloneDeep(props.singlePage.page);
|
||||
singlePageToUpdate.spec.deleted = true;
|
||||
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: props.singlePage.page.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: props.singlePage.page.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
});
|
||||
await queryClient.invalidateQueries({ queryKey: ["singlePages"] });
|
||||
|
||||
Toast.success(t("core.common.toast.delete_success"));
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import AnnotationsForm from "@/components/form/AnnotationsForm.vue";
|
||||
import { singlePageLabels } from "@/constants/labels";
|
||||
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 { randomUUID } from "@/utils/id";
|
||||
import useSlugify from "@console/composables/use-slugify";
|
||||
|
@ -134,11 +134,9 @@ const handleSave = async () => {
|
|||
|
||||
const { data } = isUpdateMode
|
||||
? await singlePageUpdateMutate(formState.value)
|
||||
: await apiClient.extension.singlePage.createContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
singlePage: formState.value,
|
||||
}
|
||||
);
|
||||
: await coreApiClient.content.singlePage.createSinglePage({
|
||||
singlePage: formState.value,
|
||||
});
|
||||
|
||||
formState.value = data;
|
||||
emit("saved", data);
|
||||
|
@ -183,13 +181,10 @@ const handlePublish = async () => {
|
|||
singlePageToUpdate.spec.headSnapshot;
|
||||
singlePageToUpdate.spec.publish = true;
|
||||
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: formState.value.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: formState.value.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
});
|
||||
|
||||
formState.value = data;
|
||||
|
||||
|
@ -210,20 +205,17 @@ const handleUnpublish = async () => {
|
|||
publishCanceling.value = true;
|
||||
|
||||
const { data: singlePage } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage({
|
||||
await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: formState.value.metadata.name,
|
||||
});
|
||||
|
||||
const singlePageToUpdate = cloneDeep(singlePage);
|
||||
singlePageToUpdate.spec.publish = false;
|
||||
|
||||
const { data } =
|
||||
await apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: formState.value.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.content.singlePage.updateSinglePage({
|
||||
name: formState.value.metadata.name,
|
||||
singlePage: singlePageToUpdate,
|
||||
});
|
||||
|
||||
formState.value = data;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
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 { Toast, VLoading } from "@halo-dev/components";
|
||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
|
@ -25,10 +25,11 @@ const { data: snapshot, isLoading } = useQuery({
|
|||
throw new Error("singlePageName and snapshotName are required");
|
||||
}
|
||||
|
||||
const { data } = await apiClient.singlePage.fetchSinglePageContent({
|
||||
name: singlePageName.value,
|
||||
snapshotName: snapshotName.value,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.content.singlePage.fetchSinglePageContent({
|
||||
name: singlePageName.value,
|
||||
snapshotName: snapshotName.value,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onError(err) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
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 { useQueryClient } from "@tanstack/vue-query";
|
||||
import { computed } from "vue";
|
||||
|
@ -29,12 +29,14 @@ async function handleRestore() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.singlePage.revertToSpecifiedSnapshotForSinglePage({
|
||||
name: props.singlePage?.metadata.name as string,
|
||||
revertSnapshotForSingleParam: {
|
||||
snapshotName: props.snapshot.metadata.name,
|
||||
},
|
||||
});
|
||||
await consoleApiClient.content.singlePage.revertToSpecifiedSnapshotForSinglePage(
|
||||
{
|
||||
name: props.singlePage?.metadata.name as string,
|
||||
revertSnapshotForSingleParam: {
|
||||
snapshotName: props.snapshot.metadata.name,
|
||||
},
|
||||
}
|
||||
);
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["singlePage-snapshots-by-singlePage-name"],
|
||||
});
|
||||
|
@ -50,7 +52,7 @@ function handleDelete() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.singlePage.deleteSinglePageContent({
|
||||
await consoleApiClient.content.singlePage.deleteSinglePageContent({
|
||||
name: props.singlePage?.metadata.name as string,
|
||||
snapshotName: props.snapshot.metadata.name,
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import { useMutation } from "@tanstack/vue-query";
|
||||
import type { SinglePage } from "@halo-dev/api-client";
|
||||
import { Toast } from "@halo-dev/components";
|
||||
|
@ -10,13 +10,11 @@ export function usePageUpdateMutate() {
|
|||
mutationKey: ["singlePage-update"],
|
||||
mutationFn: async (page: SinglePage) => {
|
||||
const { data: latestSinglePage } =
|
||||
await apiClient.extension.singlePage.getContentHaloRunV1alpha1SinglePage(
|
||||
{
|
||||
name: page.metadata.name,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.singlePage.getSinglePage({
|
||||
name: page.metadata.name,
|
||||
});
|
||||
|
||||
return apiClient.extension.singlePage.updateContentHaloRunV1alpha1SinglePage(
|
||||
return coreApiClient.content.singlePage.updateSinglePage(
|
||||
{
|
||||
name: page.metadata.name,
|
||||
singlePage: {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<script lang="ts" setup>
|
||||
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 { useQuery } from "@tanstack/vue-query";
|
||||
|
||||
const { data: total } = useQuery({
|
||||
queryKey: ["widget-singlePage-count"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.singlePage.listSinglePages({
|
||||
const { data } = await consoleApiClient.content.singlePage.listSinglePages({
|
||||
labelSelector: [
|
||||
`${singlePageLabels.DELETED}=false`,
|
||||
`${singlePageLabels.PUBLISHED}=true`,
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
import PostTag from "./tags/components/PostTag.vue";
|
||||
import { ref, watch } from "vue";
|
||||
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 { usePermission } from "@/utils/permission";
|
||||
import { cloneDeep } from "lodash-es";
|
||||
|
@ -47,7 +47,7 @@ const {
|
|||
} = useQuery<ListedPost[]>({
|
||||
queryKey: ["deleted-posts", page, size, keyword],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.post.listPosts({
|
||||
const { data } = await consoleApiClient.content.post.listPosts({
|
||||
labelSelector: [`content.halo.run/deleted=true`],
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
|
@ -92,7 +92,7 @@ const handleDeletePermanently = async (post: Post) => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.extension.post.deleteContentHaloRunV1alpha1Post({
|
||||
await coreApiClient.content.post.deletePost({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
await refetch();
|
||||
|
@ -112,7 +112,7 @@ const handleDeletePermanentlyInBatch = async () => {
|
|||
onConfirm: async () => {
|
||||
await Promise.all(
|
||||
selectedPostNames.value.map((name) => {
|
||||
return apiClient.extension.post.deleteContentHaloRunV1alpha1Post({
|
||||
return coreApiClient.content.post.deletePost({
|
||||
name,
|
||||
});
|
||||
})
|
||||
|
@ -134,7 +134,7 @@ const handleRecovery = async (post: Post) => {
|
|||
onConfirm: async () => {
|
||||
const postToUpdate = cloneDeep(post);
|
||||
postToUpdate.spec.deleted = false;
|
||||
await apiClient.extension.post.updateContentHaloRunV1alpha1Post({
|
||||
await coreApiClient.content.post.updatePost({
|
||||
name: postToUpdate.metadata.name,
|
||||
post: postToUpdate,
|
||||
});
|
||||
|
@ -165,7 +165,7 @@ const handleRecoveryInBatch = async () => {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return apiClient.extension.post.updateContentHaloRunV1alpha1Post({
|
||||
return coreApiClient.content.post.updatePost({
|
||||
name: post.metadata.name,
|
||||
post: {
|
||||
...post,
|
||||
|
|
|
@ -24,7 +24,11 @@ import {
|
|||
toRef,
|
||||
watch,
|
||||
} from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import {
|
||||
consoleApiClient,
|
||||
coreApiClient,
|
||||
ucApiClient,
|
||||
} from "@halo-dev/api-client";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
import { useRouter } from "vue-router";
|
||||
import { randomUUID } from "@/utils/id";
|
||||
|
@ -169,7 +173,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
|
|||
).data;
|
||||
}
|
||||
|
||||
const { data } = await apiClient.post.updatePostContent({
|
||||
const { data } = await consoleApiClient.content.post.updatePostContent({
|
||||
name: formState.value.post.metadata.name,
|
||||
content: formState.value.content,
|
||||
});
|
||||
|
@ -181,7 +185,7 @@ const handleSave = async (options?: { mute?: boolean }) => {
|
|||
// Clear new post content cache
|
||||
handleClearCache();
|
||||
|
||||
const { data } = await apiClient.post.draftPost({
|
||||
const { data } = await consoleApiClient.content.post.draftPost({
|
||||
postRequest: formState.value,
|
||||
});
|
||||
formState.value.post = data;
|
||||
|
@ -218,12 +222,12 @@ const handlePublish = async () => {
|
|||
).data;
|
||||
}
|
||||
|
||||
await apiClient.post.updatePostContent({
|
||||
await consoleApiClient.content.post.updatePostContent({
|
||||
name: postName,
|
||||
content: formState.value.content,
|
||||
});
|
||||
|
||||
await apiClient.post.publishPost({
|
||||
await consoleApiClient.content.post.publishPost({
|
||||
name: postName,
|
||||
});
|
||||
|
||||
|
@ -233,11 +237,11 @@ const handlePublish = async () => {
|
|||
router.back();
|
||||
}
|
||||
} else {
|
||||
const { data } = await apiClient.post.draftPost({
|
||||
const { data } = await consoleApiClient.content.post.draftPost({
|
||||
postRequest: formState.value,
|
||||
});
|
||||
|
||||
await apiClient.post.publishPost({
|
||||
await consoleApiClient.content.post.publishPost({
|
||||
name: data.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -273,7 +277,7 @@ const handleFetchContent = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const { data } = await apiClient.post.fetchPostHeadContent({
|
||||
const { data } = await consoleApiClient.content.post.fetchPostHeadContent({
|
||||
name: formState.value.post.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -326,10 +330,9 @@ const handleFetchContent = async () => {
|
|||
};
|
||||
|
||||
const handleOpenSettingModal = async () => {
|
||||
const { data: latestPost } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: formState.value.post.metadata.name,
|
||||
});
|
||||
const { data: latestPost } = await coreApiClient.content.post.getPost({
|
||||
name: formState.value.post.metadata.name,
|
||||
});
|
||||
formState.value.post = latestPost;
|
||||
settingModal.value = true;
|
||||
};
|
||||
|
@ -360,10 +363,9 @@ onMounted(async () => {
|
|||
|
||||
if (name.value) {
|
||||
// fetch post
|
||||
const { data: post } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: name.value as string,
|
||||
});
|
||||
const { data: post } = await coreApiClient.content.post.getPost({
|
||||
name: name.value as string,
|
||||
});
|
||||
formState.value.post = post;
|
||||
|
||||
// fetch post content
|
||||
|
@ -440,7 +442,7 @@ async function handleUploadImage(file: File, options?: AxiosRequestConfig) {
|
|||
await handleSave();
|
||||
}
|
||||
|
||||
const { data } = await apiClient.uc.attachment.createAttachmentForPost(
|
||||
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost(
|
||||
{
|
||||
file,
|
||||
postName: formState.value.post.metadata.name,
|
||||
|
|
|
@ -19,7 +19,7 @@ import PostSettingModal from "./components/PostSettingModal.vue";
|
|||
import type { Ref } from "vue";
|
||||
import { computed, provide, ref, watch } from "vue";
|
||||
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 { useQuery } from "@tanstack/vue-query";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -135,7 +135,7 @@ const {
|
|||
labelSelector.push(selectedPublishStatus.value);
|
||||
}
|
||||
|
||||
const { data } = await apiClient.post.listPosts({
|
||||
const { data } = await consoleApiClient.content.post.listPosts({
|
||||
labelSelector,
|
||||
fieldSelector,
|
||||
page: page.value,
|
||||
|
@ -183,11 +183,9 @@ const {
|
|||
});
|
||||
|
||||
const handleOpenSettingModal = async (post: Post) => {
|
||||
const { data } = await apiClient.extension.post.getContentHaloRunV1alpha1Post(
|
||||
{
|
||||
name: post.metadata.name,
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.content.post.getPost({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
selectedPost.value = data;
|
||||
settingModal.value = true;
|
||||
};
|
||||
|
@ -206,10 +204,9 @@ const handleSelectPrevious = async () => {
|
|||
);
|
||||
|
||||
if (index > 0) {
|
||||
const { data: previousPost } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: posts.value[index - 1].post.metadata.name,
|
||||
});
|
||||
const { data: previousPost } = await coreApiClient.content.post.getPost({
|
||||
name: posts.value[index - 1].post.metadata.name,
|
||||
});
|
||||
selectedPost.value = previousPost;
|
||||
return;
|
||||
}
|
||||
|
@ -227,10 +224,9 @@ const handleSelectNext = async () => {
|
|||
(post) => post.post.metadata.name === selectedPost.value?.metadata.name
|
||||
);
|
||||
if (index < posts.value.length - 1) {
|
||||
const { data: nextPost } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: posts.value[index + 1].post.metadata.name,
|
||||
});
|
||||
const { data: nextPost } = await coreApiClient.content.post.getPost({
|
||||
name: posts.value[index + 1].post.metadata.name,
|
||||
});
|
||||
selectedPost.value = nextPost;
|
||||
return;
|
||||
}
|
||||
|
@ -271,7 +267,7 @@ const handleDeleteInBatch = async () => {
|
|||
onConfirm: async () => {
|
||||
await Promise.all(
|
||||
selectedPostNames.value.map((name) => {
|
||||
return apiClient.post.recyclePost({
|
||||
return consoleApiClient.content.post.recyclePost({
|
||||
name,
|
||||
});
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
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 { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
|
@ -28,10 +28,9 @@ const postName = computed(() => route.query.name as string);
|
|||
const { data: post } = useQuery({
|
||||
queryKey: ["post-by-name", postName],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: postName.value,
|
||||
});
|
||||
const { data } = await coreApiClient.content.post.getPost({
|
||||
name: postName.value,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
enabled: computed(() => !!postName.value),
|
||||
|
@ -40,7 +39,7 @@ const { data: post } = useQuery({
|
|||
const { data: snapshots, isLoading } = useQuery({
|
||||
queryKey: ["post-snapshots-by-post-name", postName],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.post.listPostSnapshots({
|
||||
const { data } = await consoleApiClient.content.post.listPostSnapshots({
|
||||
name: postName.value,
|
||||
});
|
||||
return data;
|
||||
|
@ -99,7 +98,7 @@ function handleCleanup() {
|
|||
}
|
||||
|
||||
for (let i = 0; i < snapshotsToDelete?.length; i++) {
|
||||
await apiClient.post.deletePostContent({
|
||||
await consoleApiClient.content.post.deletePostContent({
|
||||
name: postName.value,
|
||||
snapshotName: snapshotsToDelete[i].metadata.name,
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
import { ref } from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
|
||||
// components
|
||||
import {
|
||||
|
@ -40,7 +40,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
|
|||
try {
|
||||
batchUpdating.value = true;
|
||||
const promises = categoriesToUpdate.map((category) =>
|
||||
apiClient.extension.category.updateContentHaloRunV1alpha1Category({
|
||||
coreApiClient.content.category.updateCategory({
|
||||
name: category.metadata.name,
|
||||
category: category,
|
||||
})
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
<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 AnnotationsForm from "@/components/form/AnnotationsForm.vue";
|
||||
import { setFocus } from "@/formkit/utils/focus";
|
||||
import { FormType } from "@/types/slug";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import useSlugify from "@console/composables/use-slugify";
|
||||
import { useThemeCustomTemplates } from "@console/modules/interface/themes/composables/use-theme";
|
||||
import type { Category } from "@halo-dev/api-client";
|
||||
|
@ -16,7 +20,6 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
import { cloneDeep } from "lodash-es";
|
||||
import { computed, nextTick, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const props = withDefaults(
|
||||
|
@ -87,7 +90,7 @@ const handleSaveCategory = async () => {
|
|||
try {
|
||||
saving.value = true;
|
||||
if (isUpdateMode) {
|
||||
await apiClient.extension.category.updateContentHaloRunV1alpha1Category({
|
||||
await coreApiClient.content.category.updateCategory({
|
||||
name: formState.value.metadata.name,
|
||||
category: formState.value,
|
||||
});
|
||||
|
@ -96,10 +99,9 @@ const handleSaveCategory = async () => {
|
|||
let parentCategory: Category | undefined = undefined;
|
||||
|
||||
if (selectedParentCategory.value) {
|
||||
const { data } =
|
||||
await apiClient.extension.category.getContentHaloRunV1alpha1Category({
|
||||
name: selectedParentCategory.value,
|
||||
});
|
||||
const { data } = await coreApiClient.content.category.getCategory({
|
||||
name: selectedParentCategory.value,
|
||||
});
|
||||
parentCategory = data;
|
||||
}
|
||||
|
||||
|
@ -110,11 +112,9 @@ const handleSaveCategory = async () => {
|
|||
formState.value.spec.priority = priority;
|
||||
|
||||
const { data: createdCategory } =
|
||||
await apiClient.extension.category.createContentHaloRunV1alpha1Category(
|
||||
{
|
||||
category: formState.value,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.category.createCategory({
|
||||
category: formState.value,
|
||||
});
|
||||
|
||||
if (parentCategory) {
|
||||
parentCategory.spec.children = Array.from(
|
||||
|
@ -124,12 +124,10 @@ const handleSaveCategory = async () => {
|
|||
])
|
||||
);
|
||||
|
||||
await apiClient.extension.category.updateContentHaloRunV1alpha1Category(
|
||||
{
|
||||
name: selectedParentCategory.value,
|
||||
category: parentCategory,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.category.updateCategory({
|
||||
name: selectedParentCategory.value,
|
||||
category: parentCategory,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<script lang="ts" setup>
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
import type { Category } from "@halo-dev/api-client";
|
||||
|
@ -17,6 +16,7 @@ import type { PropType } from "vue";
|
|||
import { ref } from "vue";
|
||||
import { VueDraggable } from "vue-draggable-plus";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import GridiconsLinkBreak from "~icons/gridicons/link-break";
|
||||
import { convertCategoryTreeToCategory, type CategoryTree } from "../utils";
|
||||
import CategoryEditingModal from "./CategoryEditingModal.vue";
|
||||
|
@ -69,11 +69,9 @@ const handleDelete = async (category: CategoryTree) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.category.deleteContentHaloRunV1alpha1Category(
|
||||
{
|
||||
name: category.metadata.name,
|
||||
}
|
||||
);
|
||||
await coreApiClient.content.category.deleteCategory({
|
||||
name: category.metadata.name,
|
||||
});
|
||||
|
||||
Toast.success(t("core.common.toast.delete_success"));
|
||||
|
||||
|
|
|
@ -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 { Ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
|
@ -23,12 +23,11 @@ export function usePostCategory(): usePostCategoryReturn {
|
|||
} = useQuery({
|
||||
queryKey: ["post-categories"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.category.listContentHaloRunV1alpha1Category({
|
||||
page: 0,
|
||||
size: 0,
|
||||
sort: ["metadata.creationTimestamp,desc"],
|
||||
});
|
||||
const { data } = await coreApiClient.content.category.listCategory({
|
||||
page: 0,
|
||||
size: 0,
|
||||
sort: ["metadata.creationTimestamp,desc"],
|
||||
});
|
||||
|
||||
return data.items;
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
import type { ListedPost, Post } from "@halo-dev/api-client";
|
||||
import { useI18n } from "vue-i18n";
|
||||
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 type { Ref } from "vue";
|
||||
import { computed, inject, markRaw, ref, toRefs } from "vue";
|
||||
|
@ -58,7 +58,7 @@ const handleDelete = async () => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.post.recyclePost({
|
||||
await consoleApiClient.content.post.recyclePost({
|
||||
name: props.post.post.metadata.name,
|
||||
});
|
||||
await queryClient.invalidateQueries({ queryKey: ["posts"] });
|
||||
|
@ -77,7 +77,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
|
|||
component: markRaw(VDropdownItem),
|
||||
label: t("core.common.buttons.publish"),
|
||||
action: async () => {
|
||||
await apiClient.post.publishPost({
|
||||
await consoleApiClient.content.post.publishPost({
|
||||
name: props.post.post.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -125,7 +125,7 @@ const { operationItems } = useOperationItemExtensionPoint<ListedPost>(
|
|||
},
|
||||
label: t("core.common.buttons.cancel_publish"),
|
||||
action: async () => {
|
||||
await apiClient.post.unpublishPost({
|
||||
await consoleApiClient.content.post.unpublishPost({
|
||||
name: props.post.post.metadata.name,
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
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 { postLabels } from "@/constants/labels";
|
||||
import { randomUUID } from "@/utils/id";
|
||||
|
@ -137,7 +137,7 @@ const handleSave = async () => {
|
|||
|
||||
const { data } = isUpdateMode.value
|
||||
? await postUpdateMutate(formState.value)
|
||||
: await apiClient.extension.post.createContentHaloRunV1alpha1Post({
|
||||
: await coreApiClient.content.post.createPost({
|
||||
post: formState.value,
|
||||
});
|
||||
|
||||
|
@ -166,7 +166,7 @@ const handlePublish = async () => {
|
|||
|
||||
await postUpdateMutate(formState.value);
|
||||
|
||||
const { data } = await apiClient.post.publishPost({
|
||||
const { data } = await consoleApiClient.content.post.publishPost({
|
||||
name: formState.value.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -188,7 +188,7 @@ const handleUnpublish = async () => {
|
|||
try {
|
||||
publishCanceling.value = true;
|
||||
|
||||
await apiClient.post.unpublishPost({
|
||||
await consoleApiClient.content.post.unpublishPost({
|
||||
name: formState.value.metadata.name,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
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 { Toast, VLoading } from "@halo-dev/components";
|
||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
|
@ -25,7 +25,7 @@ const { data: snapshot, isLoading } = useQuery({
|
|||
throw new Error("postName and snapshotName are required");
|
||||
}
|
||||
|
||||
const { data } = await apiClient.post.fetchPostContent({
|
||||
const { data } = await consoleApiClient.content.post.fetchPostContent({
|
||||
name: postName.value,
|
||||
snapshotName: snapshotName.value,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
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 { useQueryClient } from "@tanstack/vue-query";
|
||||
import { computed } from "vue";
|
||||
|
@ -29,7 +29,7 @@ async function handleRestore() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.post.revertToSpecifiedSnapshotForPost({
|
||||
await consoleApiClient.content.post.revertToSpecifiedSnapshotForPost({
|
||||
name: props.post?.metadata.name as string,
|
||||
revertSnapshotForPostParam: {
|
||||
snapshotName: props.snapshot.metadata.name,
|
||||
|
@ -50,7 +50,7 @@ function handleDelete() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.post.deletePostContent({
|
||||
await consoleApiClient.content.post.deletePostContent({
|
||||
name: props.post?.metadata.name as string,
|
||||
snapshotName: props.snapshot.metadata.name,
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { postLabels } from "@/constants/labels";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
import { IconTimerLine, VEntityField } from "@halo-dev/components";
|
||||
import type { ListedPost } from "packages/api-client/dist";
|
||||
import type { ListedPost } from "@halo-dev/api-client";
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { IconEye, IconEyeOff, Toast, VEntityField } from "@halo-dev/components";
|
||||
import { useMutation, useQueryClient } from "@tanstack/vue-query";
|
||||
|
@ -17,12 +17,11 @@ withDefaults(
|
|||
|
||||
const { mutate: changeVisibleMutation } = useMutation({
|
||||
mutationFn: async (post: Post) => {
|
||||
const { data } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
const { data } = await coreApiClient.content.post.getPost({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
data.spec.visible = data.spec.visible === "PRIVATE" ? "PUBLIC" : "PRIVATE";
|
||||
await apiClient.extension.post.updateContentHaloRunV1alpha1Post(
|
||||
await coreApiClient.content.post.updatePost(
|
||||
{
|
||||
name: post.metadata.name,
|
||||
post: data,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useMutation } from "@tanstack/vue-query";
|
||||
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 { useI18n } from "vue-i18n";
|
||||
|
||||
|
@ -10,12 +10,11 @@ export function usePostUpdateMutate() {
|
|||
return useMutation({
|
||||
mutationKey: ["post-update"],
|
||||
mutationFn: async (post: Post) => {
|
||||
const { data: latestPost } =
|
||||
await apiClient.extension.post.getContentHaloRunV1alpha1Post({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
const { data: latestPost } = await coreApiClient.content.post.getPost({
|
||||
name: post.metadata.name,
|
||||
});
|
||||
|
||||
return await apiClient.extension.post.updateContentHaloRunV1alpha1Post(
|
||||
return await coreApiClient.content.post.updatePost(
|
||||
{
|
||||
name: post.metadata.name,
|
||||
post: {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
import HasPermission from "@/components/permission/HasPermission.vue";
|
||||
import TagEditingModal from "./components/TagEditingModal.vue";
|
||||
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 TagListItem from "./components/TagListItem.vue";
|
||||
import SearchInput from "@/components/input/SearchInput.vue";
|
||||
|
@ -142,11 +142,9 @@ const queryName = useRouteQuery("name");
|
|||
|
||||
onMounted(async () => {
|
||||
if (queryName.value) {
|
||||
const { data } = await apiClient.extension.tag.getContentHaloRunV1alpha1Tag(
|
||||
{
|
||||
name: queryName.value as string,
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.content.tag.getTag({
|
||||
name: queryName.value as string,
|
||||
});
|
||||
selectedTag.value = data;
|
||||
editingModal.value = true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
|
||||
// components
|
||||
import {
|
||||
|
@ -91,12 +91,12 @@ const handleSaveTag = async () => {
|
|||
try {
|
||||
saving.value = true;
|
||||
if (isUpdateMode.value) {
|
||||
await apiClient.extension.tag.updateContentHaloRunV1alpha1Tag({
|
||||
await coreApiClient.content.tag.updateTag({
|
||||
name: formState.value.metadata.name,
|
||||
tag: formState.value,
|
||||
});
|
||||
} else {
|
||||
await apiClient.extension.tag.createContentHaloRunV1alpha1Tag({
|
||||
await coreApiClient.content.tag.createTag({
|
||||
tag: formState.value,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 { ref, watch, type Ref } from "vue";
|
||||
import { Dialog, Toast } from "@halo-dev/components";
|
||||
|
@ -39,7 +39,7 @@ export function usePostTag(filterOptions?: {
|
|||
} = useQuery({
|
||||
queryKey: ["post-tags", sort, page, size, keyword],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.tag.listPostTags({
|
||||
const { data } = await consoleApiClient.content.tag.listPostTags({
|
||||
page: page?.value || 0,
|
||||
size: size?.value || 0,
|
||||
sort: [sort?.value as string].filter(Boolean) || [
|
||||
|
@ -71,7 +71,7 @@ export function usePostTag(filterOptions?: {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({
|
||||
await coreApiClient.content.tag.deleteTag({
|
||||
name: tag.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -97,7 +97,7 @@ export function usePostTag(filterOptions?: {
|
|||
try {
|
||||
await Promise.all(
|
||||
tagNames.map((tagName) => {
|
||||
apiClient.extension.tag.deleteContentHaloRunV1alpha1Tag({
|
||||
coreApiClient.content.tag.deleteTag({
|
||||
name: tagName,
|
||||
});
|
||||
})
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
IconExternalLinkLine,
|
||||
} from "@halo-dev/components";
|
||||
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 { postLabels } from "@/constants/labels";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
|
@ -16,7 +16,7 @@ import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
|||
const { data } = useQuery<ListedPost[]>({
|
||||
queryKey: ["widget-recent-posts"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.post.listPosts({
|
||||
const { data } = await consoleApiClient.content.post.listPosts({
|
||||
labelSelector: [
|
||||
`${postLabels.DELETED}=false`,
|
||||
`${postLabels.PUBLISHED}=true`,
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
import { markRaw, ref, type Component } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
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 { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||
|
||||
|
@ -143,7 +143,7 @@ const actions: Action[] = [
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.indices.buildPostIndices();
|
||||
await consoleApiClient.content.indices.buildPostIndices();
|
||||
Toast.success(
|
||||
t(
|
||||
"core.dashboard.widgets.presets.quicklink.actions.refresh_search_engine.success_message"
|
||||
|
@ -170,7 +170,7 @@ const actions: Action[] = [
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.cache.evictCache({ name: "page" });
|
||||
await consoleApiClient.cache.evictCache({ name: "page" });
|
||||
Toast.success(
|
||||
t(
|
||||
"core.dashboard.widgets.presets.quicklink.actions.evict_page_cache.success_message"
|
||||
|
|
|
@ -15,7 +15,7 @@ import MenuItemEditingModal from "./components/MenuItemEditingModal.vue";
|
|||
import MenuItemListItem from "./components/MenuItemListItem.vue";
|
||||
import MenuList from "./components/MenuList.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 { cloneDeep } from "lodash-es";
|
||||
import type { MenuTreeItem } from "./utils";
|
||||
|
@ -51,7 +51,7 @@ const {
|
|||
}
|
||||
|
||||
const menuItemNames = selectedMenu.value.spec.menuItems.filter(Boolean);
|
||||
const { data } = await apiClient.extension.menuItem.listV1alpha1MenuItem({
|
||||
const { data } = await coreApiClient.menuItem.listMenuItem({
|
||||
page: 0,
|
||||
size: 0,
|
||||
fieldSelector: [`name=(${menuItemNames.join(",")})`],
|
||||
|
@ -72,8 +72,8 @@ const {
|
|||
});
|
||||
|
||||
const handleOpenEditingModal = (menuItem: MenuTreeItem) => {
|
||||
apiClient.extension.menuItem
|
||||
.getV1alpha1MenuItem({
|
||||
coreApiClient.menuItem
|
||||
.getMenuItem({
|
||||
name: menuItem.metadata.name,
|
||||
})
|
||||
.then((response) => {
|
||||
|
@ -106,7 +106,7 @@ const onMenuItemSaved = async (menuItem: MenuItem) => {
|
|||
menuItem.metadata.name,
|
||||
];
|
||||
|
||||
await apiClient.extension.menu.updateV1alpha1Menu({
|
||||
await coreApiClient.menu.updateMenu({
|
||||
name: menuToUpdate.metadata.name,
|
||||
menu: menuToUpdate,
|
||||
});
|
||||
|
@ -124,7 +124,7 @@ const handleUpdateInBatch = useDebounceFn(async () => {
|
|||
try {
|
||||
batchUpdating.value = true;
|
||||
const promises = menuItemsToUpdate.map((menuItem) =>
|
||||
apiClient.extension.menuItem.updateV1alpha1MenuItem({
|
||||
coreApiClient.menuItem.updateMenuItem({
|
||||
name: menuItem.metadata.name,
|
||||
menuItem,
|
||||
})
|
||||
|
@ -147,7 +147,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.extension.menuItem.deleteV1alpha1MenuItem({
|
||||
await coreApiClient.menuItem.deleteMenuItem({
|
||||
name: menuItem.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -155,7 +155,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
|
|||
|
||||
if (childrenNames.length) {
|
||||
const deleteChildrenRequests = childrenNames.map((name) =>
|
||||
apiClient.extension.menuItem.deleteV1alpha1MenuItem({
|
||||
coreApiClient.menuItem.deleteMenuItem({
|
||||
name,
|
||||
})
|
||||
);
|
||||
|
@ -170,7 +170,7 @@ const handleDelete = async (menuItem: MenuTreeItem) => {
|
|||
menuToUpdate.spec.menuItems = menuToUpdate.spec.menuItems?.filter(
|
||||
(name) => ![menuItem.metadata.name, ...childrenNames].includes(name)
|
||||
);
|
||||
await apiClient.extension.menu.updateV1alpha1Menu({
|
||||
await coreApiClient.menu.updateMenu({
|
||||
name: menuToUpdate.metadata.name,
|
||||
menu: menuToUpdate,
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
|||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
import type { Menu } from "@halo-dev/api-client";
|
||||
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 { useI18n } from "vue-i18n";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
|
@ -51,12 +51,12 @@ const handleSaveMenu = async () => {
|
|||
try {
|
||||
saving.value = true;
|
||||
if (props.menu) {
|
||||
await apiClient.extension.menu.updateV1alpha1Menu({
|
||||
await coreApiClient.menu.updateMenu({
|
||||
name: formState.value.metadata.name,
|
||||
menu: formState.value,
|
||||
});
|
||||
} else {
|
||||
const { data } = await apiClient.extension.menu.createV1alpha1Menu({
|
||||
const { data } = await coreApiClient.menu.createMenu({
|
||||
menu: formState.value,
|
||||
});
|
||||
emit("created", data);
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Toast, VButton, VModal, VSpace } from "@halo-dev/components";
|
|||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
import { computed, nextTick, onMounted, ref } from "vue";
|
||||
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 AnnotationsForm from "@/components/form/AnnotationsForm.vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -87,23 +87,21 @@ const handleSaveMenuItem = async () => {
|
|||
}
|
||||
|
||||
if (isUpdateMode) {
|
||||
const { data } =
|
||||
await apiClient.extension.menuItem.updateV1alpha1MenuItem({
|
||||
name: formState.value.metadata.name,
|
||||
menuItem: formState.value,
|
||||
});
|
||||
const { data } = await coreApiClient.menuItem.updateMenuItem({
|
||||
name: formState.value.metadata.name,
|
||||
menuItem: formState.value,
|
||||
});
|
||||
|
||||
emit("saved", data);
|
||||
} else {
|
||||
const { data } =
|
||||
await apiClient.extension.menuItem.createV1alpha1MenuItem({
|
||||
menuItem: formState.value,
|
||||
});
|
||||
const { data } = await coreApiClient.menuItem.createMenuItem({
|
||||
menuItem: formState.value,
|
||||
});
|
||||
|
||||
// if parent menu item is selected, add the new menu item to the parent menu item
|
||||
if (selectedParentMenuItem.value) {
|
||||
const { data: menuItemToUpdate } =
|
||||
await apiClient.extension.menuItem.getV1alpha1MenuItem({
|
||||
await coreApiClient.menuItem.getMenuItem({
|
||||
name: selectedParentMenuItem.value,
|
||||
});
|
||||
|
||||
|
@ -112,7 +110,7 @@ const handleSaveMenuItem = async () => {
|
|||
data.metadata.name,
|
||||
];
|
||||
|
||||
await apiClient.extension.menuItem.updateV1alpha1MenuItem({
|
||||
await coreApiClient.menuItem.updateMenuItem({
|
||||
name: menuItemToUpdate.metadata.name,
|
||||
menuItem: menuItemToUpdate,
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
import MenuEditingModal from "./MenuEditingModal.vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
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 { usePermission } from "@/utils/permission";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -48,7 +48,7 @@ const {
|
|||
} = useQuery<Menu[]>({
|
||||
queryKey: ["menus"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.menu.listV1alpha1Menu({
|
||||
const { data } = await coreApiClient.menu.listMenu({
|
||||
page: 0,
|
||||
size: 0,
|
||||
});
|
||||
|
@ -87,12 +87,12 @@ const handleDeleteMenu = async (menu: Menu) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.menu.deleteV1alpha1Menu({
|
||||
await coreApiClient.menu.deleteMenu({
|
||||
name: menu.metadata.name,
|
||||
});
|
||||
|
||||
const deleteItemsPromises = menu.spec.menuItems?.map((item) =>
|
||||
apiClient.extension.menuItem.deleteV1alpha1MenuItem({
|
||||
coreApiClient.menuItem.deleteMenuItem({
|
||||
name: item,
|
||||
})
|
||||
);
|
||||
|
@ -138,7 +138,7 @@ onMounted(async () => {
|
|||
const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
|
||||
queryKey: ["primary-menu-name"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({
|
||||
const { data } = await coreApiClient.configMap.getConfigMap({
|
||||
name: "system",
|
||||
});
|
||||
|
||||
|
@ -153,17 +153,16 @@ const { data: primaryMenuName, refetch: refetchPrimaryMenuName } = useQuery({
|
|||
});
|
||||
|
||||
const handleSetPrimaryMenu = async (menu: Menu) => {
|
||||
const { data: systemConfigMap } =
|
||||
await apiClient.extension.configMap.getV1alpha1ConfigMap({
|
||||
name: "system",
|
||||
});
|
||||
const { data: systemConfigMap } = await coreApiClient.configMap.getConfigMap({
|
||||
name: "system",
|
||||
});
|
||||
|
||||
if (systemConfigMap.data) {
|
||||
const menuConfigToUpdate = JSON.parse(systemConfigMap.data?.menu || "{}");
|
||||
menuConfigToUpdate.primary = menu.metadata.name;
|
||||
systemConfigMap.data["menu"] = JSON.stringify(menuConfigToUpdate);
|
||||
|
||||
await apiClient.extension.configMap.updateV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.updateConfigMap({
|
||||
name: "system",
|
||||
configMap: systemConfigMap,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<script lang="ts" setup>
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import type { Theme } from "@halo-dev/api-client";
|
||||
import {
|
||||
Dialog,
|
||||
IconMore,
|
||||
|
@ -14,6 +12,9 @@ import {
|
|||
VStatusDot,
|
||||
VTag,
|
||||
} 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 { inject, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -39,7 +40,7 @@ async function handleClearCache() {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.theme.invalidateCache({
|
||||
await consoleApiClient.theme.theme.invalidateCache({
|
||||
name: selectedTheme.value?.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -60,7 +61,7 @@ const handleReloadTheme = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.theme.reload({
|
||||
await consoleApiClient.theme.theme.reload({
|
||||
name: selectedTheme.value.metadata.name as string,
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import type { Ref } from "vue";
|
|||
import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client";
|
||||
|
||||
// hooks
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
|
@ -29,7 +29,7 @@ const saving = ref(false);
|
|||
const { data: configMap, suspense } = useQuery<ConfigMap>({
|
||||
queryKey: ["theme-configMap", selectedTheme],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.fetchThemeConfig({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
|
||||
name: selectedTheme?.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
@ -55,7 +55,7 @@ const handleSaveConfigMap = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.theme.updateThemeConfig({
|
||||
await consoleApiClient.theme.theme.updateThemeConfig({
|
||||
name: selectedTheme?.value?.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
VSpace,
|
||||
} from "@halo-dev/components";
|
||||
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 { useThemeLifeCycle } from "../composables/use-theme";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
|
@ -63,13 +63,12 @@ const handleCreateTheme = async () => {
|
|||
try {
|
||||
creating.value = true;
|
||||
|
||||
const { data } =
|
||||
await apiClient.extension.theme.createThemeHaloRunV1alpha1Theme({
|
||||
theme: props.theme,
|
||||
});
|
||||
const { data } = await coreApiClient.theme.theme.createTheme({
|
||||
theme: props.theme,
|
||||
});
|
||||
|
||||
// create theme settings
|
||||
apiClient.theme.reload({ name: data.metadata.name });
|
||||
consoleApiClient.theme.theme.reload({ name: data.metadata.name });
|
||||
|
||||
activeTabId.value = "installed";
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import ThemePreviewModal from "../preview/ThemePreviewModal.vue";
|
|||
import ThemeListItem from "../ThemeListItem.vue";
|
||||
import { inject, ref, type Ref } from "vue";
|
||||
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 { useThemeStore } from "@console/stores/theme";
|
||||
|
||||
|
@ -31,7 +31,7 @@ const {
|
|||
} = useQuery<Theme[]>({
|
||||
queryKey: ["installed-themes"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.listThemes({
|
||||
const { data } = await consoleApiClient.theme.theme.listThemes({
|
||||
page: 0,
|
||||
size: 0,
|
||||
uninstalled: false,
|
||||
|
|
|
@ -11,7 +11,7 @@ import { inject } from "vue";
|
|||
import type { Ref } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useThemeStore } from "@console/stores/theme";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
|
||||
const { t } = useI18n();
|
||||
const queryClient = useQueryClient();
|
||||
|
@ -54,7 +54,7 @@ const handleCatchExistsException = async (
|
|||
throw new Error("File is required");
|
||||
}
|
||||
|
||||
await apiClient.theme.upgradeTheme({
|
||||
await consoleApiClient.theme.theme.upgradeTheme({
|
||||
name: error.themeName,
|
||||
file: file,
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { VButton, VEmpty, VSpace, VLoading } from "@halo-dev/components";
|
||||
import ThemeListItem from "../ThemeListItem.vue";
|
||||
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";
|
||||
|
||||
const {
|
||||
|
@ -13,7 +13,7 @@ const {
|
|||
} = useQuery<Theme[]>({
|
||||
queryKey: ["not-installed-themes"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.listThemes({
|
||||
const { data } = await consoleApiClient.theme.theme.listThemes({
|
||||
page: 0,
|
||||
size: 0,
|
||||
uninstalled: true,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { useQueryClient } from "@tanstack/vue-query";
|
||||
import type { Ref } from "vue";
|
||||
|
@ -26,7 +26,7 @@ const handleDownloadTheme = async () => {
|
|||
try {
|
||||
downloading.value = true;
|
||||
|
||||
await apiClient.theme.installThemeFromUri({
|
||||
await consoleApiClient.theme.theme.installThemeFromUri({
|
||||
installFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ const handleCatchExistsException = async (
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.theme.upgradeThemeFromUri({
|
||||
await consoleApiClient.theme.theme.upgradeThemeFromUri({
|
||||
name: error.themeName,
|
||||
upgradeFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { Dialog, Toast, VDropdown, VDropdownItem } from "@halo-dev/components";
|
||||
import type { Theme } from "@halo-dev/api-client";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import { useQueryClient } from "@tanstack/vue-query";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -27,7 +27,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.theme.deleteThemeHaloRunV1alpha1Theme({
|
||||
await coreApiClient.theme.theme.deleteTheme({
|
||||
name: props.theme.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -36,7 +36,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
|
|||
const { settingName, configMapName } = props.theme.spec;
|
||||
|
||||
if (settingName) {
|
||||
await apiClient.extension.setting.deleteV1alpha1Setting(
|
||||
await coreApiClient.setting.deleteSetting(
|
||||
{
|
||||
name: settingName,
|
||||
},
|
||||
|
@ -47,7 +47,7 @@ const handleUninstall = async (deleteExtensions?: boolean) => {
|
|||
}
|
||||
|
||||
if (configMapName) {
|
||||
await apiClient.extension.configMap.deleteV1alpha1ConfigMap(
|
||||
await coreApiClient.configMap.deleteConfigMap(
|
||||
{
|
||||
name: configMapName,
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import ThemePreviewListItem from "./ThemePreviewListItem.vue";
|
||||
import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
||||
import { useThemeStore } from "@console/stores/theme";
|
||||
import { apiClient, axiosInstance } from "@/utils/api-client";
|
||||
import { axiosInstance, consoleApiClient } from "@halo-dev/api-client";
|
||||
import type {
|
||||
ConfigMap,
|
||||
Setting,
|
||||
|
@ -62,7 +62,7 @@ const selectedTheme = ref<Theme>();
|
|||
const { data: themes } = useQuery<Theme[]>({
|
||||
queryKey: ["themes"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.listThemes({
|
||||
const { data } = await consoleApiClient.theme.theme.listThemes({
|
||||
page: 0,
|
||||
size: 0,
|
||||
uninstalled: false,
|
||||
|
@ -129,7 +129,7 @@ const settingsVisible = ref(false);
|
|||
const { data: setting } = useQuery<Setting>({
|
||||
queryKey: ["theme-setting", selectedTheme],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.fetchThemeSetting({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeSetting({
|
||||
name: selectedTheme?.value?.metadata.name as string,
|
||||
});
|
||||
|
||||
|
@ -154,7 +154,7 @@ const { data: setting } = useQuery<Setting>({
|
|||
const { data: configMap, refetch: handleFetchConfigMap } = useQuery<ConfigMap>({
|
||||
queryKey: ["theme-configMap", selectedTheme],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.fetchThemeConfig({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
|
||||
name: selectedTheme?.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
@ -180,7 +180,7 @@ const handleSaveConfigMap = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.theme.updateThemeConfig({
|
||||
await consoleApiClient.theme.theme.updateThemeConfig({
|
||||
name: selectedTheme?.value?.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { apiClient } from "@/utils/api-client";
|
||||
import { useThemeStore } from "@console/stores/theme";
|
||||
import type { Theme } from "@halo-dev/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { Dialog, Toast } from "@halo-dev/components";
|
||||
import { useFileDialog } from "@vueuse/core";
|
||||
import { storeToRefs } from "pinia";
|
||||
|
@ -53,7 +53,7 @@ export function useThemeLifeCycle(
|
|||
try {
|
||||
if (!theme.value) return;
|
||||
|
||||
await apiClient.theme.activateTheme({
|
||||
await consoleApiClient.theme.theme.activateTheme({
|
||||
name: theme.value?.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -84,7 +84,7 @@ export function useThemeLifeCycle(
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.theme.resetThemeConfig({
|
||||
await consoleApiClient.theme.theme.resetThemeConfig({
|
||||
name: theme.value.metadata.name as string,
|
||||
});
|
||||
|
||||
|
@ -157,7 +157,7 @@ export function useThemeConfigFile(theme: Ref<Theme | undefined>) {
|
|||
return;
|
||||
}
|
||||
|
||||
const { data } = await apiClient.theme.fetchThemeConfig({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
|
||||
name: theme?.value?.metadata.name as string,
|
||||
});
|
||||
if (!data) {
|
||||
|
@ -250,14 +250,14 @@ export function useThemeConfigFile(theme: Ref<Theme | undefined>) {
|
|||
if (!theme.value) {
|
||||
return;
|
||||
}
|
||||
const { data } = await apiClient.theme.fetchThemeConfig({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({
|
||||
name: theme.value.metadata.name as string,
|
||||
});
|
||||
if (!data || !data.data) {
|
||||
return;
|
||||
}
|
||||
const combinedConfigData = combinedConfigMap(data.data, importData);
|
||||
await apiClient.theme.updateThemeConfig({
|
||||
await consoleApiClient.theme.theme.updateThemeConfig({
|
||||
name: theme.value.metadata.name,
|
||||
configMap: {
|
||||
...data,
|
||||
|
|
|
@ -40,7 +40,7 @@ import type { Setting, SettingForm, Theme } from "@halo-dev/api-client";
|
|||
import { usePermission } from "@/utils/permission";
|
||||
import { useThemeStore } from "@console/stores/theme";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import { useRouteQuery } from "@vueuse/router";
|
||||
|
@ -85,7 +85,7 @@ provide<Ref<Theme | undefined>>("selectedTheme", selectedTheme);
|
|||
const { data: setting } = useQuery<Setting>({
|
||||
queryKey: ["theme-setting", selectedTheme],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.theme.fetchThemeSetting({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchThemeSetting({
|
||||
name: selectedTheme.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
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 type { AuthProvider, Setting } from "@halo-dev/api-client";
|
||||
import { useRoute } from "vue-router";
|
||||
|
@ -32,12 +32,9 @@ const activeTab = ref<string>("detail");
|
|||
const { data: authProvider } = useQuery<AuthProvider>({
|
||||
queryKey: ["auth-provider", route.params.name],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.authProvider.getAuthHaloRunV1alpha1AuthProvider(
|
||||
{
|
||||
name: route.params.name as string,
|
||||
}
|
||||
);
|
||||
const { data } = await coreApiClient.auth.authProvider.getAuthProvider({
|
||||
name: route.params.name as string,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess(data) {
|
||||
|
@ -63,7 +60,7 @@ const { data: setting, refetch: handleFetchSettings } = useQuery<Setting>({
|
|||
authProvider.value?.spec.settingRef?.name,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.setting.getV1alpha1Setting(
|
||||
const { data } = await coreApiClient.setting.getSetting(
|
||||
{
|
||||
name: authProvider.value?.spec.settingRef?.name as string,
|
||||
},
|
||||
|
@ -82,7 +79,7 @@ const { data: configMap, refetch: handleFetchConfigMap } = useQuery({
|
|||
authProvider.value?.spec.configMapRef?.name,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap(
|
||||
const { data } = await coreApiClient.configMap.getConfigMap(
|
||||
{
|
||||
name: authProvider.value?.spec.configMapRef?.name as string,
|
||||
},
|
||||
|
@ -96,7 +93,7 @@ const { data: configMap, refetch: handleFetchConfigMap } = useQuery({
|
|||
onError: async () => {
|
||||
const data = {};
|
||||
data[group.value] = "";
|
||||
await apiClient.extension.configMap.createV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.createConfigMap({
|
||||
configMap: {
|
||||
apiVersion: "v1alpha1",
|
||||
data: data,
|
||||
|
@ -128,7 +125,7 @@ const handleSaveConfigMap = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.extension.configMap.updateV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.updateConfigMap({
|
||||
name: authProvider.value.spec.configMapRef?.name as string,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
VLoading,
|
||||
} from "@halo-dev/components";
|
||||
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 AuthProviderListItem from "./components/AuthProviderListItem.vue";
|
||||
import { computed, ref } from "vue";
|
||||
|
@ -18,7 +18,8 @@ const authProviders = ref<ListedAuthProvider[]>([]);
|
|||
const { isLoading, refetch } = useQuery<ListedAuthProvider[]>({
|
||||
queryKey: ["auth-providers"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.authProvider.listAuthProviders();
|
||||
const { data } =
|
||||
await consoleApiClient.auth.authProvider.listAuthProviders();
|
||||
return data;
|
||||
},
|
||||
onSuccess(data) {
|
||||
|
@ -50,7 +51,7 @@ async function onSortUpdate() {
|
|||
updating.value = true;
|
||||
|
||||
const { data: rawAuthProviders } =
|
||||
await apiClient.extension.authProvider.listAuthHaloRunV1alpha1AuthProvider();
|
||||
await coreApiClient.auth.authProvider.listAuthProvider();
|
||||
|
||||
const authProviderNames = authProviders.value.map((item) => item.name);
|
||||
|
||||
|
@ -67,12 +68,10 @@ async function onSortUpdate() {
|
|||
.filter(Boolean) as AuthProvider[];
|
||||
|
||||
for (const authProvider of sortedAuthProviders) {
|
||||
await apiClient.extension.authProvider.updateAuthHaloRunV1alpha1AuthProvider(
|
||||
{
|
||||
name: authProvider.metadata.name,
|
||||
authProvider: authProvider,
|
||||
}
|
||||
);
|
||||
await coreApiClient.auth.authProvider.updateAuthProvider({
|
||||
name: authProvider.metadata.name,
|
||||
authProvider: authProvider,
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
await refetch();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 {
|
||||
Dialog,
|
||||
|
@ -33,13 +33,13 @@ const handleChangeStatus = async () => {
|
|||
onConfirm: async () => {
|
||||
try {
|
||||
if (props.authProvider.enabled) {
|
||||
await apiClient.authProvider.disableAuthProvider({
|
||||
await consoleApiClient.auth.authProvider.disableAuthProvider({
|
||||
name: props.authProvider.name,
|
||||
});
|
||||
|
||||
Toast.success(t("core.common.toast.inactive_success"));
|
||||
} else {
|
||||
await apiClient.authProvider.enableAuthProvider({
|
||||
await consoleApiClient.auth.authProvider.enableAuthProvider({
|
||||
name: props.authProvider.name,
|
||||
});
|
||||
Toast.success(t("core.common.toast.active_success"));
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
import type { Backup } from "@halo-dev/api-client";
|
||||
import { relativeTimeTo, formatDatetime } from "@/utils/date";
|
||||
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 prettyBytes from "pretty-bytes";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -96,7 +96,7 @@ function handleDelete() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.extension.backup.deleteMigrationHaloRunV1alpha1Backup({
|
||||
await coreApiClient.migration.backup.deleteBackup({
|
||||
name: props.backup.metadata.name,
|
||||
});
|
||||
|
||||
|
|
|
@ -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 { useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import dayjs from "dayjs";
|
||||
|
@ -9,10 +9,9 @@ export function useBackupFetch() {
|
|||
return useQuery({
|
||||
queryKey: ["backups"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.backup.listMigrationHaloRunV1alpha1Backup({
|
||||
sort: ["metadata.creationTimestamp,desc"],
|
||||
});
|
||||
const { data } = await coreApiClient.migration.backup.listBackup({
|
||||
sort: ["metadata.creationTimestamp,desc"],
|
||||
});
|
||||
return data;
|
||||
},
|
||||
refetchInterval(data) {
|
||||
|
@ -51,7 +50,7 @@ export function useBackup() {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
async onConfirm() {
|
||||
await apiClient.extension.backup.createMigrationHaloRunV1alpha1Backup({
|
||||
await coreApiClient.migration.backup.createBackup({
|
||||
backup: {
|
||||
apiVersion: "migration.halo.run/v1alpha1",
|
||||
kind: "Backup",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import {
|
||||
Dialog,
|
||||
Toast,
|
||||
|
@ -17,7 +17,7 @@ import { ref } from "vue";
|
|||
import { useI18n } from "vue-i18n";
|
||||
import { useBackupFetch } from "../composables/use-backup";
|
||||
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 { data: backups } = useBackupFetch();
|
||||
|
@ -58,7 +58,7 @@ const remoteDownloadUrl = ref("");
|
|||
const { isLoading: downloading, mutate: handleRemoteDownload } = useMutation({
|
||||
mutationKey: ["remote-download-restore"],
|
||||
mutationFn: async () => {
|
||||
return await apiClient.migration.restoreBackup({
|
||||
return await consoleApiClient.migration.restoreBackup({
|
||||
downloadUrl: remoteDownloadUrl.value,
|
||||
});
|
||||
},
|
||||
|
@ -74,7 +74,7 @@ function handleRestoreFromBackup(backup: Backup) {
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
showCancel: false,
|
||||
async onConfirm() {
|
||||
await apiClient.migration.restoreBackup({
|
||||
await consoleApiClient.migration.restoreBackup({
|
||||
backupName: backup.metadata.name,
|
||||
});
|
||||
setTimeout(() => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
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 { usePermission } from "@/utils/permission";
|
||||
import { useThemeStore } from "@console/stores/theme";
|
||||
|
@ -64,7 +64,7 @@ const { data: startup } = useQuery<Startup>({
|
|||
const { data: plugins, isLoading: isPluginsLoading } = useQuery<Plugin[]>({
|
||||
queryKey: ["enabled-plugins"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.plugin.listPlugins({
|
||||
const { data } = await consoleApiClient.plugin.plugin.listPlugins({
|
||||
page: 0,
|
||||
size: 0,
|
||||
enabled: true,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient, coreApiClient } from "@halo-dev/api-client";
|
||||
import { computed, provide, ref } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
|
@ -44,10 +44,9 @@ provide<Ref<string>>("activeTab", activeTab);
|
|||
const { data: plugin } = useQuery({
|
||||
queryKey: ["plugin", route.params.name],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.plugin.getPluginHaloRunV1alpha1Plugin({
|
||||
name: route.params.name as string,
|
||||
});
|
||||
const { data } = await coreApiClient.plugin.plugin.getPlugin({
|
||||
name: route.params.name as string,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
async onSuccess(data) {
|
||||
|
@ -65,7 +64,7 @@ provide<Ref<Plugin | undefined>>("plugin", plugin);
|
|||
const { data: setting } = useQuery({
|
||||
queryKey: ["plugin-setting", plugin],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.plugin.fetchPluginSetting({
|
||||
const { data } = await consoleApiClient.plugin.plugin.fetchPluginSetting({
|
||||
name: plugin.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
import { PluginStatusPhaseEnum, type Plugin } from "@halo-dev/api-client";
|
||||
import {
|
||||
|
@ -56,7 +56,7 @@ const total = ref(0);
|
|||
const { data, isLoading, isFetching, refetch } = useQuery<Plugin[]>({
|
||||
queryKey: ["plugins", keyword, selectedEnabledValue, selectedSortValue],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.plugin.listPlugins({
|
||||
const { data } = await consoleApiClient.plugin.plugin.listPlugins({
|
||||
page: 0,
|
||||
size: 0,
|
||||
keyword: keyword.value,
|
||||
|
|
|
@ -10,10 +10,14 @@ import {
|
|||
import type { Ref } from "vue";
|
||||
import { computed, inject, markRaw, ref, toRefs } from "vue";
|
||||
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 { usePermission } from "@/utils/permission";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useEntityFieldItemExtensionPoint } from "@console/composables/use-entity-extension-points";
|
||||
import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points";
|
||||
|
@ -61,7 +65,7 @@ const handleResetSettingConfig = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.plugin.resetPluginConfig({
|
||||
await consoleApiClient.plugin.plugin.resetPluginConfig({
|
||||
name: plugin.value.metadata.name as string,
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import type { UppyFile } from "@uppy/core";
|
|||
import type { ErrorResponse } from "@uppy/core";
|
||||
import type { PluginInstallationErrorResponse } from "../../types";
|
||||
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";
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
@ -64,7 +64,7 @@ const handleShowActiveModalAfterInstall = (plugin: Plugin) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.plugin.changePluginRunningState({
|
||||
await consoleApiClient.plugin.plugin.changePluginRunningState({
|
||||
name: plugin.metadata.name,
|
||||
pluginRunningStateRequest: {
|
||||
enable: true,
|
||||
|
@ -93,7 +93,7 @@ const handleCatchExistsException = async (
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.plugin.upgradePlugin({
|
||||
await consoleApiClient.plugin.plugin.upgradePlugin({
|
||||
name: error.pluginName,
|
||||
file: file,
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 type { Plugin } from "@halo-dev/api-client";
|
||||
import type { Ref } from "vue";
|
||||
|
@ -33,7 +33,7 @@ const handleDownloadPlugin = async () => {
|
|||
try {
|
||||
downloading.value = true;
|
||||
if (pluginToUpgrade.value) {
|
||||
await apiClient.plugin.upgradePluginFromUri({
|
||||
await consoleApiClient.plugin.plugin.upgradePluginFromUri({
|
||||
name: pluginToUpgrade.value.metadata.name,
|
||||
upgradeFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
|
@ -45,11 +45,12 @@ const handleDownloadPlugin = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const { data: plugin } = await apiClient.plugin.installPluginFromUri({
|
||||
installFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
},
|
||||
});
|
||||
const { data: plugin } =
|
||||
await consoleApiClient.plugin.plugin.installPluginFromUri({
|
||||
installFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
},
|
||||
});
|
||||
|
||||
emit("close-modal");
|
||||
queryClient.invalidateQueries({ queryKey: ["plugins"] });
|
||||
|
@ -80,7 +81,7 @@ const handleShowActiveModalAfterInstall = (plugin: Plugin) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.plugin.changePluginRunningState({
|
||||
await consoleApiClient.plugin.plugin.changePluginRunningState({
|
||||
name: plugin.metadata.name,
|
||||
pluginRunningStateRequest: {
|
||||
enable: true,
|
||||
|
@ -108,7 +109,7 @@ const handleCatchExistsException = async (
|
|||
confirmText: t("core.common.buttons.confirm"),
|
||||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
await apiClient.plugin.upgradePluginFromUri({
|
||||
await consoleApiClient.plugin.plugin.upgradePluginFromUri({
|
||||
name: error.pluginName,
|
||||
upgradeFromUriRequest: {
|
||||
uri: remoteDownloadUrl.value,
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
import type { ComputedRef, Ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { type Plugin, PluginStatusPhaseEnum } from "@halo-dev/api-client";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import {
|
||||
type Plugin,
|
||||
PluginStatusPhaseEnum,
|
||||
coreApiClient,
|
||||
consoleApiClient,
|
||||
} from "@halo-dev/api-client";
|
||||
|
||||
import { Dialog, Toast } from "@halo-dev/components";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useMutation } from "@tanstack/vue-query";
|
||||
|
@ -75,7 +80,7 @@ export function usePluginLifeCycle(
|
|||
|
||||
const { enabled } = plugin.value.spec;
|
||||
|
||||
return await apiClient.plugin.changePluginRunningState({
|
||||
return await consoleApiClient.plugin.plugin.changePluginRunningState({
|
||||
name: plugin.value.metadata.name,
|
||||
pluginRunningStateRequest: {
|
||||
enable: !enabled,
|
||||
|
@ -116,14 +121,14 @@ export function usePluginLifeCycle(
|
|||
if (!plugin.value) return;
|
||||
|
||||
try {
|
||||
await apiClient.plugin.changePluginRunningState({
|
||||
await consoleApiClient.plugin.plugin.changePluginRunningState({
|
||||
name: plugin.value.metadata.name,
|
||||
pluginRunningStateRequest: {
|
||||
enable: false,
|
||||
},
|
||||
});
|
||||
|
||||
await apiClient.extension.plugin.deletePluginHaloRunV1alpha1Plugin({
|
||||
await coreApiClient.plugin.plugin.deletePlugin({
|
||||
name: plugin.value.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -132,7 +137,7 @@ export function usePluginLifeCycle(
|
|||
const { settingName, configMapName } = plugin.value.spec;
|
||||
|
||||
if (settingName) {
|
||||
await apiClient.extension.setting.deleteV1alpha1Setting(
|
||||
await coreApiClient.setting.deleteSetting(
|
||||
{
|
||||
name: settingName,
|
||||
},
|
||||
|
@ -143,7 +148,7 @@ export function usePluginLifeCycle(
|
|||
}
|
||||
|
||||
if (configMapName) {
|
||||
await apiClient.extension.configMap.deleteV1alpha1ConfigMap(
|
||||
await coreApiClient.configMap.deleteConfigMap(
|
||||
{
|
||||
name: configMapName,
|
||||
},
|
||||
|
@ -193,22 +198,20 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
|
|||
onConfirm: async () => {
|
||||
try {
|
||||
for (let i = 0; i < names.value.length; i++) {
|
||||
await apiClient.extension.plugin.deletePluginHaloRunV1alpha1Plugin({
|
||||
await coreApiClient.plugin.plugin.deletePlugin({
|
||||
name: names.value[i],
|
||||
});
|
||||
|
||||
if (deleteExtensions) {
|
||||
const { data: plugin } =
|
||||
await apiClient.extension.plugin.getPluginHaloRunV1alpha1Plugin(
|
||||
{
|
||||
name: names.value[i],
|
||||
}
|
||||
);
|
||||
await coreApiClient.plugin.plugin.getPlugin({
|
||||
name: names.value[i],
|
||||
});
|
||||
|
||||
const { settingName, configMapName } = plugin.spec;
|
||||
|
||||
if (settingName) {
|
||||
await apiClient.extension.setting.deleteV1alpha1Setting(
|
||||
await coreApiClient.setting.deleteSetting(
|
||||
{
|
||||
name: settingName,
|
||||
},
|
||||
|
@ -219,7 +222,7 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
|
|||
}
|
||||
|
||||
if (configMapName) {
|
||||
await apiClient.extension.configMap.deleteV1alpha1ConfigMap(
|
||||
await coreApiClient.configMap.deleteConfigMap(
|
||||
{
|
||||
name: configMapName,
|
||||
},
|
||||
|
@ -249,7 +252,7 @@ export function usePluginBatchOperations(names: Ref<string[]>) {
|
|||
onConfirm: async () => {
|
||||
try {
|
||||
for (let i = 0; i < names.value.length; i++) {
|
||||
await apiClient.plugin.changePluginRunningState({
|
||||
await consoleApiClient.plugin.plugin.changePluginRunningState({
|
||||
name: names.value[i],
|
||||
pluginRunningStateRequest: {
|
||||
enable: enabled,
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import type { Ref } from "vue";
|
||||
import { computed, inject } from "vue";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import {
|
||||
PluginStatusPhaseEnum,
|
||||
type Plugin,
|
||||
|
@ -33,7 +33,7 @@ interface RoleTemplateGroup {
|
|||
const { data: pluginRoleTemplates } = useQuery({
|
||||
queryKey: ["plugin-roles", plugin?.value?.metadata.name],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [
|
||||
|
|
|
@ -4,7 +4,7 @@ import { inject, ref, type Ref, computed } from "vue";
|
|||
|
||||
// hooks
|
||||
import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
|
||||
// components
|
||||
import { Toast, VButton } from "@halo-dev/components";
|
||||
|
@ -27,7 +27,7 @@ const saving = ref(false);
|
|||
const { data: configMap } = useQuery<ConfigMap>({
|
||||
queryKey: ["plugin-configMap", plugin],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.plugin.fetchPluginConfig({
|
||||
const { data } = await consoleApiClient.plugin.plugin.fetchPluginConfig({
|
||||
name: plugin?.value?.metadata.name as string,
|
||||
});
|
||||
return data;
|
||||
|
@ -51,7 +51,7 @@ const handleSaveConfigMap = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
await apiClient.plugin.updatePluginConfig({
|
||||
await consoleApiClient.plugin.plugin.updatePluginConfig({
|
||||
name: plugin.value.metadata.name,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import { useRoute } from "vue-router";
|
||||
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 { rbacAnnotations } from "@/constants/annotations";
|
||||
import { useRoleForm, useRoleTemplateSelection } from "@/composables/use-role";
|
||||
|
@ -20,7 +20,7 @@ import { SUPER_ROLE_NAME } from "@/constants/constants";
|
|||
import { useI18n } from "vue-i18n";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
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";
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -31,7 +31,7 @@ const tabActiveId = ref("detail");
|
|||
const { data: roleTemplates } = useQuery({
|
||||
queryKey: ["role-templates"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
|
||||
|
@ -84,7 +84,7 @@ watch(
|
|||
const { refetch } = useQuery<Role>({
|
||||
queryKey: ["role", route.params.name],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.getV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.getRole({
|
||||
name: route.params.name as string,
|
||||
});
|
||||
return data;
|
||||
|
|
|
@ -26,7 +26,7 @@ import { rbacAnnotations } from "@/constants/annotations";
|
|||
import { formatDatetime } from "@/utils/date";
|
||||
|
||||
// libs
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import Fuse from "fuse.js";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
import { roleLabels } from "@/constants/labels";
|
||||
|
@ -46,7 +46,7 @@ let fuse: Fuse<Role> | undefined = undefined;
|
|||
const { data: roleTemplates } = useQuery({
|
||||
queryKey: ["role-templates"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
|
||||
|
@ -62,7 +62,7 @@ const {
|
|||
} = useQuery<RoleList>({
|
||||
queryKey: ["roles"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [`!${roleLabels.TEMPLATE}`],
|
||||
|
@ -154,7 +154,7 @@ const handleCloneRole = async (role: Role) => {
|
|||
|
||||
// 如果是超级管理员角色,那么需要获取到所有角色模板并填充到表单
|
||||
if (role.metadata.name === SUPER_ROLE_NAME) {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
|
||||
|
@ -183,7 +183,7 @@ const handleDelete = async (role: Role) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.role.deleteV1alpha1Role({
|
||||
await coreApiClient.role.deleteRole({
|
||||
name: role.metadata.name,
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import { cloneDeep } from "lodash-es";
|
|||
import { setFocus } from "@/formkit/utils/focus";
|
||||
import { pluginLabels, roleLabels } from "@/constants/labels";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -32,7 +32,7 @@ const modal = ref<InstanceType<typeof VModal> | null>(null);
|
|||
const { data: roleTemplates } = useQuery({
|
||||
queryKey: ["role-templates"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.role.listV1alpha1Role({
|
||||
const { data } = await coreApiClient.role.listRole({
|
||||
page: 0,
|
||||
size: 0,
|
||||
labelSelector: [`${roleLabels.TEMPLATE}=true`, "!halo.run/hidden"],
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "@halo-dev/components";
|
||||
import type { Setting, SettingForm } from "@halo-dev/api-client";
|
||||
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 type { Raw } from "vue";
|
||||
import type { Component } from "vue";
|
||||
|
@ -44,7 +44,7 @@ provide<Ref<string>>("activeTab", activeTab);
|
|||
const { data: setting } = useQuery({
|
||||
queryKey: ["system-setting"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.setting.getV1alpha1Setting({
|
||||
const { data } = await coreApiClient.setting.getSetting({
|
||||
name: "system",
|
||||
});
|
||||
return data;
|
||||
|
|
|
@ -5,7 +5,7 @@ import type { NotifierDescriptor, Setting } from "@halo-dev/api-client";
|
|||
import type { Ref } from "vue";
|
||||
import { inject } 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 { toRaw } from "vue";
|
||||
import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
|
||||
|
@ -27,7 +27,7 @@ const name = computed(
|
|||
const { data: setting } = useQuery<Setting | undefined>({
|
||||
queryKey: ["notifier-setting", notifierDescriptor],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.setting.getV1alpha1Setting({
|
||||
const { data } = await coreApiClient.setting.getSetting({
|
||||
name: notifierDescriptor.value?.spec?.senderSettingRef?.name as string,
|
||||
});
|
||||
return data;
|
||||
|
@ -40,9 +40,10 @@ const configMapData = ref<Record<string, unknown>>({});
|
|||
useQuery<Record<string, unknown>>({
|
||||
queryKey: ["notifier-configMap", notifierDescriptor],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.notifier.fetchSenderConfig({
|
||||
name: name.value,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.notification.notifier.fetchSenderConfig({
|
||||
name: name.value,
|
||||
});
|
||||
return data as Record<string, unknown>;
|
||||
},
|
||||
onSuccess(data) {
|
||||
|
@ -61,10 +62,11 @@ const formSchema = computed(() => {
|
|||
const { isLoading: isMutating, mutate } = useMutation({
|
||||
mutationKey: ["save-notifier-configMap", notifierDescriptor],
|
||||
mutationFn: async () => {
|
||||
const { data } = await apiClient.notifier.saveSenderConfig({
|
||||
name: name.value,
|
||||
body: configMapData.value,
|
||||
});
|
||||
const { data } =
|
||||
await consoleApiClient.notification.notifier.saveSenderConfig({
|
||||
name: name.value,
|
||||
body: configMapData.value,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onSuccess() {
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<script lang="ts" setup>
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import NotificationSetting from "./NotificationSetting.vue";
|
||||
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 type { NotifierDescriptor } from "@halo-dev/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
import { VTabbar } from "@halo-dev/components";
|
||||
import { computed } from "vue";
|
||||
import type { ComputedRef } from "vue";
|
||||
import type { NotifierDescriptor } from "packages/api-client/dist";
|
||||
import { useQuery } from "@tanstack/vue-query";
|
||||
import type { Component, ComputedRef, Raw } from "vue";
|
||||
import { computed, markRaw, provide, ref } from "vue";
|
||||
import NotificationSetting from "./NotificationSetting.vue";
|
||||
|
||||
interface Tab {
|
||||
id: string;
|
||||
|
@ -25,7 +21,7 @@ const { data: notifierDescriptors } = useQuery({
|
|||
queryKey: ["notifier-descriptors"],
|
||||
queryFn: async () => {
|
||||
const { data } =
|
||||
await apiClient.extension.notifierDescriptors.listNotificationHaloRunV1alpha1NotifierDescriptor();
|
||||
await coreApiClient.notification.notifierDescriptor.listNotifierDescriptor();
|
||||
return data.items;
|
||||
},
|
||||
onSuccess(data) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { useSettingFormConvert } from "@console/composables/use-setting-form";
|
|||
import { useSystemConfigMapStore } from "@console/stores/system-configmap";
|
||||
import type { ConfigMap, Setting } from "@halo-dev/api-client";
|
||||
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 { useGlobalInfoStore } from "@/stores/global-info";
|
||||
|
||||
|
@ -28,7 +28,7 @@ const saving = ref(false);
|
|||
const { data: configMap } = useQuery<ConfigMap>({
|
||||
queryKey: ["system-configMap"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.extension.configMap.getV1alpha1ConfigMap({
|
||||
const { data } = await coreApiClient.configMap.getConfigMap({
|
||||
name: SYSTEM_CONFIGMAP_NAME,
|
||||
});
|
||||
return data;
|
||||
|
@ -52,7 +52,7 @@ const handleSaveConfigMap = async () => {
|
|||
return;
|
||||
}
|
||||
|
||||
const { data } = await apiClient.extension.configMap.updateV1alpha1ConfigMap({
|
||||
const { data } = await coreApiClient.configMap.updateConfigMap({
|
||||
name: SYSTEM_CONFIGMAP_NAME,
|
||||
configMap: configMapToUpdate,
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import UserAvatar from "@/components/user-avatar/UserAvatar.vue";
|
||||
import { usePluginModuleStore } from "@/stores/plugin";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { consoleApiClient } from "@halo-dev/api-client";
|
||||
import { usePermission } from "@/utils/permission";
|
||||
import {
|
||||
VButton,
|
||||
|
@ -44,7 +44,7 @@ const {
|
|||
} = useQuery({
|
||||
queryKey: ["user-detail", params.name],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.user.getUserDetail({
|
||||
const { data } = await consoleApiClient.user.getUserDetail({
|
||||
name: params.name as string,
|
||||
});
|
||||
return data;
|
||||
|
|
|
@ -25,7 +25,7 @@ import UserEditingModal from "./components/UserEditingModal.vue";
|
|||
import UserPasswordChangeModal from "./components/UserPasswordChangeModal.vue";
|
||||
import GrantPermissionModal from "./components/GrantPermissionModal.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 { rbacAnnotations } from "@/constants/annotations";
|
||||
import { formatDatetime } from "@/utils/date";
|
||||
|
@ -99,7 +99,7 @@ const {
|
|||
selectedRoleValue,
|
||||
],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.user.listUsers({
|
||||
const { data } = await consoleApiClient.user.listUsers({
|
||||
page: page.value,
|
||||
size: size.value,
|
||||
keyword: keyword.value,
|
||||
|
@ -136,7 +136,7 @@ const handleDelete = async (user: User) => {
|
|||
cancelText: t("core.common.buttons.cancel"),
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await apiClient.extension.user.deleteV1alpha1User({
|
||||
await coreApiClient.user.deleteUser({
|
||||
name: user.metadata.name,
|
||||
});
|
||||
|
||||
|
@ -163,7 +163,7 @@ const handleDeleteInBatch = async () => {
|
|||
);
|
||||
await Promise.all(
|
||||
userNamesToDelete.map((name) => {
|
||||
return apiClient.extension.user.deleteV1alpha1User({
|
||||
return coreApiClient.user.deleteUser({
|
||||
name,
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { VButton, VModal, VSpace } from "@halo-dev/components";
|
||||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
|
@ -25,7 +25,7 @@ const isSubmitting = ref(false);
|
|||
const handleGrantPermission = async () => {
|
||||
try {
|
||||
isSubmitting.value = true;
|
||||
await apiClient.user.grantPermission({
|
||||
await consoleApiClient.user.grantPermission({
|
||||
name: props.user?.metadata.name as string,
|
||||
grantRequest: {
|
||||
roles: [selectedRole.value],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
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";
|
||||
|
||||
// components
|
||||
|
@ -46,7 +46,7 @@ const handleCreateUser = async () => {
|
|||
formState.value.roles = [selectedRole.value];
|
||||
}
|
||||
|
||||
await apiClient.user.createUser({
|
||||
await consoleApiClient.user.createUser({
|
||||
createUserRequest: formState.value,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="ts" setup>
|
||||
// core libs
|
||||
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";
|
||||
|
||||
// components
|
||||
|
@ -54,7 +54,7 @@ const handleUpdateUser = async () => {
|
|||
try {
|
||||
isSubmitting.value = true;
|
||||
|
||||
await apiClient.extension.user.updateV1alpha1User({
|
||||
await coreApiClient.user.updateUser({
|
||||
name: formState.value.metadata.name,
|
||||
user: formState.value,
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import { VButton, VModal, VSpace } from "@halo-dev/components";
|
|||
import SubmitButton from "@/components/button/SubmitButton.vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
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 { setFocus } from "@/formkit/utils/focus";
|
||||
|
||||
|
@ -45,7 +45,7 @@ const handleChangePassword = async () => {
|
|||
const changePasswordRequest = cloneDeep(formState.value);
|
||||
delete changePasswordRequest.password_confirm;
|
||||
|
||||
await apiClient.user.changeAnyonePassword({
|
||||
await consoleApiClient.user.changeAnyonePassword({
|
||||
name: props.user?.metadata.name || "",
|
||||
changePasswordRequest,
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { Ref } from "vue";
|
||||
import { onMounted, ref } from "vue";
|
||||
import type { User } from "@halo-dev/api-client";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { coreApiClient } from "@halo-dev/api-client";
|
||||
|
||||
interface useUserFetchReturn {
|
||||
users: Ref<User[]>;
|
||||
|
@ -22,7 +22,7 @@ export function useUserFetch(options?: {
|
|||
const handleFetchUsers = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const { data } = await apiClient.extension.user.listV1alpha1User({
|
||||
const { data } = await coreApiClient.user.listUser({
|
||||
fieldSelector: [`name!=${ANONYMOUSUSER_NAME}`],
|
||||
});
|
||||
users.value = data.items;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { apiClient } from "@/utils/api-client";
|
||||
import { ucApiClient } from "@halo-dev/api-client";
|
||||
import { relativeTimeTo } from "@/utils/date";
|
||||
import {
|
||||
VButton,
|
||||
|
@ -24,12 +24,13 @@ const {
|
|||
} = useQuery({
|
||||
queryKey: ["user-notifications"],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.notification.listUserNotifications({
|
||||
username: currentUser?.metadata.name as string,
|
||||
page: 1,
|
||||
size: 20,
|
||||
fieldSelector: ["spec.unread=true"],
|
||||
});
|
||||
const { data } =
|
||||
await ucApiClient.notification.notification.listUserNotifications({
|
||||
username: currentUser?.metadata.name as string,
|
||||
page: 1,
|
||||
size: 20,
|
||||
fieldSelector: ["spec.unread=true"],
|
||||
});
|
||||
|
||||
return data.items;
|
||||
},
|
||||
|
|
|
@ -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 { defineStore } from "pinia";
|
||||
|
||||
|
@ -14,13 +14,12 @@ export const useSystemConfigMapStore = defineStore({
|
|||
actions: {
|
||||
async fetchSystemConfigMap() {
|
||||
try {
|
||||
const { data } =
|
||||
await apiClient.extension.configMap.getV1alpha1ConfigMap(
|
||||
{
|
||||
name: "system",
|
||||
},
|
||||
{ mute: true }
|
||||
);
|
||||
const { data } = await coreApiClient.configMap.getConfigMap(
|
||||
{
|
||||
name: "system",
|
||||
},
|
||||
{ mute: true }
|
||||
);
|
||||
this.configMap = data;
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch system configMap", error);
|
||||
|
|
|
@ -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 { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
@ -15,7 +15,7 @@ export const useThemeStore = defineStore("theme", () => {
|
|||
}
|
||||
|
||||
try {
|
||||
const { data } = await apiClient.theme.fetchActivatedTheme({
|
||||
const { data } = await consoleApiClient.theme.theme.fetchActivatedTheme({
|
||||
mute: true,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
@ -16,7 +16,7 @@ const loading = ref(false);
|
|||
async function onSubmit(data: ResetPasswordForm) {
|
||||
try {
|
||||
loading.value = true;
|
||||
await apiClient.common.user.sendPasswordResetEmail({
|
||||
await publicApiClient.user.sendPasswordResetEmail({
|
||||
passwordResetEmailRequest: {
|
||||
email: data.email,
|
||||
username: data.username,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
@ -23,7 +23,7 @@ const formState = ref<SystemInitializationRequest>({
|
|||
const handleSubmit = async () => {
|
||||
loading.value = true;
|
||||
|
||||
await apiClient.system.initialize({
|
||||
await consoleApiClient.system.initialize({
|
||||
systemInitializationRequest: formState.value,
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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 { useMutation } from "@tanstack/vue-query";
|
||||
import {
|
||||
|
@ -27,7 +27,7 @@ const globalInfoStore = useGlobalInfoStore();
|
|||
const { mutateAsync: pluginInstallMutate } = useMutation({
|
||||
mutationKey: ["plugin-install"],
|
||||
mutationFn: async (plugin: Plugin) => {
|
||||
const { data } = await apiClient.plugin.installPlugin(
|
||||
const { data } = await consoleApiClient.plugin.plugin.installPlugin(
|
||||
{
|
||||
source: "PRESET",
|
||||
presetName: plugin.metadata.name as string,
|
||||
|
@ -48,7 +48,7 @@ const { mutateAsync: pluginInstallMutate } = useMutation({
|
|||
const { mutateAsync: pluginStartMutate } = useMutation({
|
||||
mutationKey: ["plugin-start"],
|
||||
mutationFn: async (plugin: Plugin) => {
|
||||
return await apiClient.plugin.changePluginRunningState(
|
||||
return await consoleApiClient.plugin.plugin.changePluginRunningState(
|
||||
{
|
||||
name: plugin.metadata.name,
|
||||
pluginRunningStateRequest: {
|
||||
|
@ -69,39 +69,41 @@ async function setupInitialData() {
|
|||
processing.value = true;
|
||||
|
||||
// Create category / tag / post
|
||||
await apiClient.extension.category.createContentHaloRunV1alpha1Category({
|
||||
await coreApiClient.content.category.createCategory({
|
||||
category: category as Category,
|
||||
});
|
||||
await apiClient.extension.tag.createContentHaloRunV1alpha1Tag({
|
||||
await coreApiClient.content.tag.createTag({
|
||||
tag: tag as Tag,
|
||||
});
|
||||
const { data: postData } = await apiClient.post.draftPost({
|
||||
const { data: postData } = await consoleApiClient.content.post.draftPost({
|
||||
postRequest: post as PostRequest,
|
||||
});
|
||||
await apiClient.post.publishPost({ name: postData.metadata.name });
|
||||
await consoleApiClient.content.post.publishPost({
|
||||
name: postData.metadata.name,
|
||||
});
|
||||
|
||||
// Create singlePage
|
||||
const { data: singlePageData } = await apiClient.singlePage.draftSinglePage(
|
||||
{
|
||||
const { data: singlePageData } =
|
||||
await consoleApiClient.content.singlePage.draftSinglePage({
|
||||
singlePageRequest: singlePage as SinglePageRequest,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await apiClient.singlePage.publishSinglePage({
|
||||
await consoleApiClient.content.singlePage.publishSinglePage({
|
||||
name: singlePageData.metadata.name,
|
||||
});
|
||||
|
||||
// Create menu and menu items
|
||||
const menuItemPromises = menuItems.map((item) => {
|
||||
return apiClient.extension.menuItem.createV1alpha1MenuItem({
|
||||
return coreApiClient.menuItem.createMenuItem({
|
||||
menuItem: item,
|
||||
});
|
||||
});
|
||||
await Promise.all(menuItemPromises);
|
||||
await apiClient.extension.menu.createV1alpha1Menu({ menu: menu });
|
||||
await coreApiClient.menu.createMenu({ menu: menu });
|
||||
|
||||
// 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++) {
|
||||
const presetPlugin = presetPlugins[i];
|
||||
|
@ -114,7 +116,7 @@ async function setupInitialData() {
|
|||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
await apiClient.extension.configMap.createV1alpha1ConfigMap({
|
||||
await coreApiClient.configMap.createConfigMap({
|
||||
configMap: {
|
||||
metadata: {
|
||||
name: "system-states",
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
"dev:uc": "vite --host --config ./vite.uc.config.ts",
|
||||
"dev:console": "vite --host --config ./vite.config.ts",
|
||||
"build": "run-s build:console build:uc",
|
||||
"build:uc": "vue-tsc --noEmit && vite build --config ./vite.uc.config.ts",
|
||||
"build:console": "vue-tsc --noEmit && vite build --config ./vite.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 -p tsconfig.app.json --composite false && vite build --config ./vite.config.ts",
|
||||
"build:packages": "pnpm --filter \"./packages/**\" build",
|
||||
"preview": "vite preview --port 5050",
|
||||
"api-client:gen": "pnpm --filter \"./packages/api-client\" gen",
|
||||
|
@ -76,7 +76,7 @@
|
|||
"@vueuse/integrations": "^10.9.0",
|
||||
"@vueuse/router": "^10.9.0",
|
||||
"@vueuse/shared": "^10.9.0",
|
||||
"axios": "^1.6.7",
|
||||
"axios": "^1.7.2",
|
||||
"codemirror": "^6.0.1",
|
||||
"colorjs.io": "^0.4.3",
|
||||
"cropperjs": "^1.5.13",
|
||||
|
|
|
@ -2,23 +2,66 @@
|
|||
|
||||
Halo 2.0 的 JavaScript API 客户端请求库。使用 [OpenAPI Generator](https://openapi-generator.tech/) 生成。
|
||||
|
||||
## 开发环境
|
||||
## 使用
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
```javascript
|
||||
import {
|
||||
coreApiClient,
|
||||
consoleApiClient,
|
||||
ucApiClient,
|
||||
publicApiClient,
|
||||
createCoreApiClient,
|
||||
createConsoleApiClient,
|
||||
createUcApiClient,
|
||||
createPublicApiClient,
|
||||
axiosInstance
|
||||
} from "@halo-dev/api-client"
|
||||
```
|
||||
|
||||
```bash
|
||||
# 根据 OpenAPI 3.0 生成类型和网络请求的代码,此步骤需要启动 Halo 2.0 后端。
|
||||
pnpm gen
|
||||
- coreApiClient: 为 Halo 所有自定义模型的 CRUD 接口封装的 api client。
|
||||
- consoleApiClient: 为 Halo 针对 Console 提供的接口封装的 api client。
|
||||
- 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
|
||||
pnpm build
|
||||
由于已经在 Console 和 UC 项目中引入并设置好了 Axios 拦截器,所以直接使用即可:
|
||||
|
||||
```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
|
||||
})
|
||||
```
|
||||
|
|
|
@ -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
Loading…
Reference in New Issue