fix add-point-card invalid
This commit is contained in:
@@ -25,9 +25,10 @@
|
||||
:add-text="props.addText ?? '选择文件'"
|
||||
:busy="isBusy"
|
||||
:upload-enabled="!!props.upload"
|
||||
@add="emit('add')"
|
||||
@capture-photo="emit('capture-photo')"
|
||||
@capture-video="emit('capture-video')"
|
||||
@add="handleAdd"
|
||||
@action="handleAddAction"
|
||||
@capture-photo="handleCapturePhoto"
|
||||
@capture-video="handleCaptureVideo"
|
||||
@file-change="handleFileChange"
|
||||
/>
|
||||
</div>
|
||||
@@ -90,13 +91,32 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
type Emits = {
|
||||
(event: string): void;
|
||||
(event: "update:modelValue", value: string[]): void;
|
||||
(event: "update:photoItems", value: PhotoItem[]): void;
|
||||
add: [];
|
||||
action: [value: MediaSelectorAddAction];
|
||||
"capture-photo": [];
|
||||
"capture-video": [];
|
||||
"update:modelValue": [value: string[]];
|
||||
"update:photoItems": [value: PhotoItem[]];
|
||||
};
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
function handleAddAction(action: MediaSelectorAddAction): void {
|
||||
emit("action", action);
|
||||
}
|
||||
|
||||
function handleAdd(): void {
|
||||
emit("add");
|
||||
}
|
||||
|
||||
function handleCapturePhoto(): void {
|
||||
emit("capture-photo");
|
||||
}
|
||||
|
||||
function handleCaptureVideo(): void {
|
||||
emit("capture-video");
|
||||
}
|
||||
|
||||
const photoViewerVisible = ref(false);
|
||||
const photoViewerImages = ref<string[]>([]);
|
||||
const photoViewerItems = ref<MediaSelectorViewerItem[]>([]);
|
||||
|
||||
@@ -91,14 +91,12 @@ interface Props {
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<{
|
||||
(event: "add"): void;
|
||||
(event: "capture-photo"): void;
|
||||
(event: "capture-video"): void;
|
||||
(event: "file-change", value: Event): void;
|
||||
add: [];
|
||||
action: [value: MediaSelectorAddAction];
|
||||
"capture-photo": [];
|
||||
"capture-video": [];
|
||||
"file-change": [value: Event];
|
||||
}>();
|
||||
const emitExternal = (event: string): void => {
|
||||
(emit as unknown as (eventName: string) => void)(event);
|
||||
};
|
||||
|
||||
const capturePopoverVisible = ref(false);
|
||||
const fileInput = ref<HTMLInputElement>();
|
||||
@@ -127,15 +125,23 @@ function handleFileAction(): void {
|
||||
|
||||
function handleCaptureAction(action: MediaSelectorAddAction): void {
|
||||
capturePopoverVisible.value = false;
|
||||
if (action.emit === "capture-photo" && props.uploadEnabled) {
|
||||
photoFileInput.value?.click();
|
||||
if (action.emit === "capture-photo") {
|
||||
if (props.uploadEnabled) {
|
||||
photoFileInput.value?.click();
|
||||
return;
|
||||
}
|
||||
emit("capture-photo");
|
||||
return;
|
||||
}
|
||||
if (action.emit === "capture-video" && props.uploadEnabled) {
|
||||
videoFileInput.value?.click();
|
||||
if (action.emit === "capture-video") {
|
||||
if (props.uploadEnabled) {
|
||||
videoFileInput.value?.click();
|
||||
return;
|
||||
}
|
||||
emit("capture-video");
|
||||
return;
|
||||
}
|
||||
emitExternal(action.emit);
|
||||
emit("action", action);
|
||||
}
|
||||
|
||||
function handleFileChange(event: Event): void {
|
||||
|
||||
Reference in New Issue
Block a user