mirror of https://github.com/halo-dev/halo
fix: not remembering the selected attachment policy in upload modal (#6115)
#### What type of PR is this? /area ui /kind bug /milestone 2.17.x #### What this PR does / why we need it: 修复首次上传附件时,没有默认选择第一个存储策略的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/6094 #### Does this PR introduce a user-facing change? ```release-note 修复首次上传附件时,没有默认选择第一个存储策略的问题。 ```pull/6128/head
parent
373229e9de
commit
ae7dcbb317
|
@ -8,7 +8,7 @@ import {
|
||||||
VModal,
|
VModal,
|
||||||
} from "@halo-dev/components";
|
} from "@halo-dev/components";
|
||||||
import { useLocalStorage } from "@vueuse/core";
|
import { useLocalStorage } from "@vueuse/core";
|
||||||
import { ref, watch } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
|
import { useFetchAttachmentGroup } from "../composables/use-attachment-group";
|
||||||
import {
|
import {
|
||||||
useFetchAttachmentPolicy,
|
useFetchAttachmentPolicy,
|
||||||
|
@ -32,35 +32,11 @@ const selectedPolicyName = useLocalStorage("attachment-upload-policy", "");
|
||||||
const policyEditingModal = ref(false);
|
const policyEditingModal = ref(false);
|
||||||
const policyTemplateNameToCreate = ref();
|
const policyTemplateNameToCreate = ref();
|
||||||
|
|
||||||
watch(
|
onMounted(() => {
|
||||||
() => groups.value,
|
if (!selectedPolicyName.value) {
|
||||||
() => {
|
selectedPolicyName.value = policies.value?.[0].metadata.name;
|
||||||
if (selectedGroupName.value === "") return;
|
|
||||||
|
|
||||||
const group = groups.value?.find(
|
|
||||||
(group) => group.metadata.name === selectedGroupName.value
|
|
||||||
);
|
|
||||||
if (!group) {
|
|
||||||
selectedGroupName.value = groups.value?.length
|
|
||||||
? groups.value[0].metadata.name
|
|
||||||
: "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
watch(
|
|
||||||
() => policies.value,
|
|
||||||
() => {
|
|
||||||
const policy = policies.value?.find(
|
|
||||||
(policy) => policy.metadata.name === selectedPolicyName.value
|
|
||||||
);
|
|
||||||
if (!policy) {
|
|
||||||
selectedPolicyName.value = policies.value?.length
|
|
||||||
? policies.value[0].metadata.name
|
|
||||||
: "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
|
const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
|
||||||
policyTemplateNameToCreate.value = policyTemplate.metadata.name;
|
policyTemplateNameToCreate.value = policyTemplate.metadata.name;
|
||||||
|
|
Loading…
Reference in New Issue