Unify attachment pickers and download lists
This commit is contained in:
1 parent
2f312eb5d7
commit
14ed0ad15c
6 files changed
+98
-9
No files matched your search
Vendored
+1
@@ -16,6 +16,7 @@ declare module 'vue' {
|
||||
ApprovalAttachmentPicker: typeof import('./components/ApprovalAttachmentPicker.vue')['default']
|
||||
AppUpdateManagementPanel: typeof import('./components/AppUpdateManagementPanel.vue')['default']
|
||||
ArchiveDialog: typeof import('./components/ArchiveDialog.vue')['default']
|
||||
AttachmentFileList: typeof import('./components/AttachmentFileList.vue')['default']
|
||||
ChinesePostalCodeInput: typeof import('./components/ChinesePostalCodeInput.vue')['default']
|
||||
CourseDiscussionPanel: typeof import('./components/CourseDiscussionPanel.vue')['default']
|
||||
CustomExportDialog: typeof import('./components/CustomExportDialog.vue')['default']
|
||||
|
||||
@@ -3,6 +3,8 @@ import { onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
import AttachmentFileList from './AttachmentFileList.vue'
|
||||
|
||||
const props = defineProps<{ type: string; id: string }>()
|
||||
const { locale } = useI18n()
|
||||
const files = ref<{ id: string; fileName: string; length: number }[]>([])
|
||||
@@ -15,5 +17,9 @@ async function download(file: { id: string; fileName: string }) {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<section><strong>{{ locale.startsWith('zh') ? '附件' : 'Attachments' }}</strong><p v-if="!files.length">{{ locale.startsWith('zh') ? '暂无附件' : 'No attachments' }}</p><div v-for="file in files" :key="file.id"><el-button link type="primary" @click="download(file)">{{ file.fileName }}</el-button> ({{ (file.length / 1024).toFixed(1) }} KiB)</div></section>
|
||||
<section>
|
||||
<strong>{{ locale.startsWith('zh') ? '附件' : 'Attachments' }}</strong>
|
||||
<p v-if="!files.length" class="attachment-hint">{{ locale.startsWith('zh') ? '暂无附件' : 'No attachments' }}</p>
|
||||
<AttachmentFileList v-else :files="files" @download="download" />
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { onMounted, ref, useId } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
|
||||
const policyHintId = useId()
|
||||
const props = defineProps<{ type: string }>()
|
||||
const emit = defineEmits<{ change: [files: File[]] }>()
|
||||
const { locale } = useI18n()
|
||||
@@ -25,8 +26,8 @@ function change(event: Event) {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div>
|
||||
<input type="file" multiple :disabled="!ready" :accept="policy.allowedExtensions" @change="change" />
|
||||
<p v-if="ready">{{ policy.allowedExtensions }} · {{ (policy.maxFileBytes / 1048576).toFixed(1) }} MiB / {{ locale.startsWith('zh') ? '文件' : 'file' }} · {{ locale.startsWith('zh') ? '最多' : 'up to' }} {{ policy.maxFileCount }} · {{ locale.startsWith('zh') ? '总计不超过 100 MiB' : '100 MiB total' }}</p>
|
||||
<div class="attachment-picker">
|
||||
<input type="file" :aria-label="locale.startsWith('zh') ? '附件' : 'Attachments'" :aria-describedby="ready ? policyHintId : undefined" multiple :disabled="!ready" :accept="policy.allowedExtensions" @change="change" />
|
||||
<p v-if="ready" :id="policyHintId" class="attachment-hint">{{ policy.allowedExtensions }} · {{ (policy.maxFileBytes / 1048576).toFixed(1) }} MiB / {{ locale.startsWith('zh') ? '文件' : 'file' }} · {{ locale.startsWith('zh') ? '最多' : 'up to' }} {{ policy.maxFileCount }} · {{ locale.startsWith('zh') ? '总计不超过 100 MiB' : '100 MiB total' }}</p>
|
||||
</div>
|
||||
</template>
|
||||
Loaded 3 of 6 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user