diff --git a/console/package.json b/console/package.json index af0225f..2015e40 100644 --- a/console/package.json +++ b/console/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@halo-dev/api-client": "^2.17.0", - "@halo-dev/components": "^2.17.0", + "@halo-dev/components": "https://pkg.pr.new/@halo-dev/components@7383", "@halo-dev/console-shared": "^2.17.0", "@tanstack/vue-query": "4.29.1", "axios": "^1.7.2", diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml index f18d761..6dd8340 100644 --- a/console/pnpm-lock.yaml +++ b/console/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^2.17.0 version: 2.17.0(axios@1.7.2) '@halo-dev/components': - specifier: ^2.17.0 - version: 2.17.0(vue-router@4.4.0(vue@3.4.31(typescript@5.3.3)))(vue@3.4.31(typescript@5.3.3)) + specifier: https://pkg.pr.new/@halo-dev/components@7383 + version: https://pkg.pr.new/@halo-dev/components@7383(vue-router@4.4.0(vue@3.4.31(typescript@5.3.3)))(vue@3.4.31(typescript@5.3.3)) '@halo-dev/console-shared': specifier: ^2.17.0 version: 2.17.0(axios@1.7.2)(vue-router@4.4.0(vue@3.4.31(typescript@5.3.3)))(vue@3.4.31(typescript@5.3.3)) @@ -449,10 +449,11 @@ packages: peerDependencies: axios: ^1.7.x - '@halo-dev/components@2.17.0': - resolution: {integrity: sha512-yujCVNfpZA1HjpilxD1Dzkh5Ge54u9hcIyuGj7Mr8hNHAY1xgiVo0uvuYwm8ik5/njI9HED4GXR2JIreSu/PeA==} + '@halo-dev/components@https://pkg.pr.new/@halo-dev/components@7383': + resolution: {tarball: https://pkg.pr.new/@halo-dev/components@7383} + version: 2.21.0 peerDependencies: - vue: ^3.4.27 + vue: ^3.5.13 vue-router: ^4.3.2 '@halo-dev/console-shared@2.17.0': @@ -573,55 +574,46 @@ packages: resolution: {integrity: sha512-C/zbRYRXFjWvz9Z4haRxcTdnkPt1BtCkz+7RtBSuNmKzMzp3ZxdM28Mpccn6pt28/UWUCTXa+b0Mx1k3g6NOMA==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.18.0': resolution: {integrity: sha512-l3m9ewPgjQSXrUMHg93vt0hYCGnrMOcUpTz6FLtbwljo2HluS4zTXFy2571YQbisTnfTKPZ01u/ukJdQTLGh9A==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.18.0': resolution: {integrity: sha512-rJ5D47d8WD7J+7STKdCUAgmQk49xuFrRi9pZkWoRD1UeSMakbcepWXPF8ycChBoAqs1pb2wzvbY6Q33WmN2ftw==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.18.0': resolution: {integrity: sha512-be6Yx37b24ZwxQ+wOQXXLZqpq4jTckJhtGlWGZs68TgdKXJgw54lUUoFYrg6Zs/kjzAQwEwYbp8JxZVzZLRepQ==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-powerpc64le-gnu@4.18.0': resolution: {integrity: sha512-hNVMQK+qrA9Todu9+wqrXOHxFiD5YmdEi3paj6vP02Kx1hjd2LLYR2eaN7DsEshg09+9uzWi2W18MJDlG0cxJA==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.18.0': resolution: {integrity: sha512-ROCM7i+m1NfdrsmvwSzoxp9HFtmKGHEqu5NNDiZWQtXLA8S5HBCkVvKAxJ8U+CVctHwV2Gb5VUaK7UAkzhDjlg==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-s390x-gnu@4.18.0': resolution: {integrity: sha512-0UyyRHyDN42QL+NbqevXIIUnKA47A+45WyasO+y2bGJ1mhQrfrtXUpTxCOrfxCR4esV3/RLYyucGVPiUsO8xjg==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.18.0': resolution: {integrity: sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.18.0': resolution: {integrity: sha512-LKaqQL9osY/ir2geuLVvRRs+utWUNilzdE90TpyoX0eNqPzWjRm14oMEE+YLve4k/NAqCdPkGYDaDF5Sw+xBfg==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.18.0': resolution: {integrity: sha512-7J6TkZQFGo9qBKH0pk2cEVSRhJbL6MtfWxth7Y5YmZs57Pi+4x6c2dStAUvaQkHQLnEQv1jzBUW43GvZW8OFqA==} @@ -2817,7 +2809,7 @@ snapshots: dependencies: axios: 1.7.2 - '@halo-dev/components@2.17.0(vue-router@4.4.0(vue@3.4.31(typescript@5.3.3)))(vue@3.4.31(typescript@5.3.3))': + '@halo-dev/components@https://pkg.pr.new/@halo-dev/components@7383(vue-router@4.4.0(vue@3.4.31(typescript@5.3.3)))(vue@3.4.31(typescript@5.3.3))': dependencies: floating-vue: 5.2.2(vue@3.4.31(typescript@5.3.3)) vue: 3.4.31(typescript@5.3.3) diff --git a/console/src/views/S3Link.vue b/console/src/views/S3Link.vue index e0c6027..b312954 100644 --- a/console/src/views/S3Link.vue +++ b/console/src/views/S3Link.vue @@ -8,6 +8,7 @@ import { VCard, VEmpty, VEntity, + VEntityContainer, VEntityField, VLoading, VModal, @@ -22,12 +23,16 @@ import { axiosInstance, coreApiClient, type Group } from "@halo-dev/api-client"; import { S3LinkControllerApi } from "@/api"; import type { S3ListResult, LinkResultItem, Policy, ObjectVo } from "@/api"; -const s3LinkControllerApi = new S3LinkControllerApi(undefined, axiosInstance.defaults.baseURL, axiosInstance); +const s3LinkControllerApi = new S3LinkControllerApi( + undefined, + axiosInstance.defaults.baseURL, + axiosInstance +); const componentInstance = getCurrentInstance(); const t = (key: string) => { // @ts-ignore - if (typeof componentInstance?.proxy?.$t === 'function') { + if (typeof componentInstance?.proxy?.$t === "function") { // @ts-ignore return componentInstance.proxy.$t(key); } @@ -38,12 +43,14 @@ const selectedFiles = ref([]); const policyName = ref(""); const page = ref(1); const size = ref(50); -const selectedGroup = ref("") -const policyOptions = ref<{ label: string; value: string; attrs: any }[]>([{ - label: "请选择存储策略", - value: "", - attrs: {disabled: true} -}]); +const selectedGroup = ref(""); +const policyOptions = ref<{ label: string; value: string; attrs: any }[]>([ + { + label: "请选择存储策略", + value: "", + attrs: { disabled: true }, + }, +]); const defaultGroup = ref({ apiVersion: "", kind: "", @@ -76,13 +83,15 @@ const isFetchingPolicies = ref(true); const linkTips = ref(""); const linkFailedTable = ref([]); const linkedStatusItems: { label: string; value?: boolean }[] = [ - {label: "全部"}, - {label: "未关联", value: true}, + { label: "全部" }, + { label: "未关联", value: true }, ]; // action state const checkedAll = ref(false); -const selectedLinkedStatusItem = ref(linkedStatusItems[0].value); +const selectedLinkedStatusItem = ref( + linkedStatusItems[0].value +); const emptyTips = computed(() => { if (isFetchingPolicies.value) { @@ -98,34 +107,37 @@ const emptyTips = computed(() => { }); const handleCheckAllChange = (e: Event) => { - const {checked} = e.target as HTMLInputElement; + const { checked } = e.target as HTMLInputElement; if (checked) { selectedFiles.value = - s3Objects.value.objects?.filter(file => !file.isLinked).map((file) => { - return file.key || ""; - }) || []; + s3Objects.value.objects + ?.filter((file) => !file.isLinked) + .map((file) => { + return file.key || ""; + }) || []; } else { selectedFiles.value.length = 0; checkedAll.value = false; } }; - const fetchPolicies = async () => { try { - const {status, data} = await s3LinkControllerApi.listS3Policies(); + const { status, data } = await s3LinkControllerApi.listS3Policies(); if (status === 200) { - policyOptions.value = [{ - label: "请选择存储策略", - value: "", - attrs: {disabled: true} - }]; + policyOptions.value = [ + { + label: "请选择存储策略", + value: "", + attrs: { disabled: true }, + }, + ]; data.forEach((policy: Policy) => { policyOptions.value.push({ label: policy.spec.displayName, value: policy.metadata.name, - attrs: {} + attrs: {}, }); }); } @@ -137,7 +149,8 @@ const fetchPolicies = async () => { const changeNextTokenAndObject = () => { s3Objects.value.currentToken = s3Objects.value.nextToken; - s3Objects.value.currentContinuationObject = s3Objects.value.nextContinuationObject; + s3Objects.value.currentContinuationObject = + s3Objects.value.nextContinuationObject; s3Objects.value.nextToken = ""; s3Objects.value.nextContinuationObject = ""; }; @@ -158,20 +171,28 @@ const fetchObjects = async () => { isFetching.value = true; s3Objects.value.objects = []; try { - const {status, data} = await s3LinkControllerApi.listObjects({ + const { status, data } = await s3LinkControllerApi.listObjects({ policyName: policyName.value, pageSize: size.value, continuationToken: s3Objects.value.currentToken, continuationObject: s3Objects.value.currentContinuationObject, unlinked: selectedLinkedStatusItem.value, - filePrefix: filePrefix.value + filePrefix: filePrefix.value, }); if (status === 200) { s3Objects.value = data; - if (s3Objects.value.objects?.length === 0 && s3Objects.value.hasMore && s3Objects.value.nextToken) { + if ( + s3Objects.value.objects?.length === 0 && + s3Objects.value.hasMore && + s3Objects.value.nextToken + ) { changeNextTokenAndObject(); await fetchObjects(); - } else if (s3Objects.value.objects?.length === 0 && !s3Objects.value.hasMore && page.value > 1) { + } else if ( + s3Objects.value.objects?.length === 0 && + !s3Objects.value.hasMore && + page.value > 1 + ) { page.value = 1; clearTokenAndObject(); await fetchObjects(); @@ -200,15 +221,15 @@ const handleLink = async () => { policyName: policyName.value, objectKeys: selectedFiles.value, groupName: selectedGroup.value, - } + }, }); const items = linkResult.data.items || []; - const successCount = items.filter(item => item.success).length; - const failedCount = items.filter(item => !item.success).length; + const successCount = items.filter((item) => item.success).length; + const failedCount = items.filter((item) => !item.success).length; linkTips.value = `关联成功${successCount}个文件,关联失败${failedCount}个文件`; if (failedCount > 0) { - linkFailedTable.value = items.filter(item => !item.success); + linkFailedTable.value = items.filter((item) => !item.success); } isLinking.value = false; }; @@ -245,7 +266,7 @@ const handleModalClose = () => { }; const fetchCustomGroups = async () => { - const {status, data} = await coreApiClient.storage.group.listGroup({ + const { status, data } = await coreApiClient.storage.group.listGroup({ labelSelector: ["!halo.run/hidden"], sort: ["metadata.creationTimestamp,asc"], }); @@ -260,19 +281,20 @@ onMounted(() => { }); watch(selectedFiles, (newValue) => { - checkedAll.value = s3Objects.value.objects?.filter(file => !file.isLinked) - .filter(file => !newValue.includes(file.key || "")).length === 0 - && s3Objects.value.objects?.length !== 0; + checkedAll.value = + s3Objects.value.objects + ?.filter((file) => !file.isLinked) + .filter((file) => !newValue.includes(file.key || "")).length === 0 && + s3Objects.value.objects?.length !== 0; }); watch(selectedLinkedStatusItem, handleFirstPage); - - + - - + -
    -
  • - 关联后所加入的分组 -
    +
    +
    + + 关联后所加入的分组 + +
    -
  • -
  • - -