Skip to content

Commit

Permalink
[coc-card] fix upload avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
masquevil committed Feb 25, 2024
1 parent 8e50fa6 commit 0eeb2a0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/components/coc-card/ActionButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
interface Props {
fullWidth?: boolean;
disabled?: boolean;
tag?: string;
}
withDefaults(defineProps<Props>(), { fullWidth: false, disabled: false });
withDefaults(defineProps<Props>(), {
fullWidth: false,
disabled: false,
tag: 'button',
});
interface Emits {
(event: 'click', evt?: MouseEvent): void;
Expand All @@ -12,7 +17,8 @@ defineEmits<Emits>();
</script>

<template>
<button
<component
:is="tag"
class="action-button"
:class="{
'action-button-full-width': fullWidth,
Expand All @@ -21,7 +27,7 @@ defineEmits<Emits>();
:disabled="disabled"
>
<slot></slot>
</button>
</component>
</template>

<style scoped lang="scss">
Expand Down
7 changes: 6 additions & 1 deletion src/components/coc-card/AvatarModalContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ function refreshSDImages() {
<div class="avatar-modal-content">
<div class="action-buttons">
<UploadAvatarButtonWrapper @uploaded="onUploaded">
<ActionButton fullWidth>上传形象</ActionButton>
<ActionButton
tag="div"
fullWidth
>
上传形象
</ActionButton>
</UploadAvatarButtonWrapper>
<ActionButton
fullWidth
Expand Down
8 changes: 7 additions & 1 deletion src/components/coc-card/UploadAvatarButtonWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ import {
import { getImageSize } from '@/utils/image';
import { usePC } from '@/hooks/useCOCCardProviders';
interface Props {
id?: string;
}
interface Emits {
(event: 'uploaded', url: string): void;
}
defineProps<Props>();
const emit = defineEmits<Emits>();
const WIDTH = 132 * 2;
Expand Down Expand Up @@ -47,8 +52,9 @@ async function handleUpload(event: Event) {
</script>

<template>
<label>
<label :for="id">
<input
:id="id"
class="input-file"
type="file"
accept="image/*"
Expand Down

0 comments on commit 0eeb2a0

Please sign in to comment.