Skip to content

Commit

Permalink
feat: add download file
Browse files Browse the repository at this point in the history
  • Loading branch information
alongw committed Nov 7, 2024
1 parent 10ad74d commit 5333fde
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web/src/pages/File/File.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { useFileListStore } from '@/stores/fileList'
import { getIconUrl } from '@/utils/file'
import { getIconUrl, getDownloadUrl } from '@/utils/file'
import type { PaginationProps } from 'tdesign-vue-next'
Expand Down Expand Up @@ -71,7 +71,14 @@ const onChange: PaginationProps['onChange'] = pageInfo => {
</t-list-item-meta>

<template #action>
<t-link theme="primary" hover="color" style="margin-left: 16px">
<t-link
theme="primary"
hover="color"
style="margin-left: 16px"
:href="getDownloadUrl(item.fullName)"
target="_blank"
name="download"
>
下载
</t-link>
</template>
Expand Down
6 changes: 6 additions & 0 deletions web/src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ export const getIconUrl = (ext: string): string => {
}
return '/icons/file.png'
}

const URL = import.meta.env.VITE_BASE_URL || window.location.host

export const getDownloadUrl = (fullName: string) => {
return `${URL}/share/${fullName}`
}

0 comments on commit 5333fde

Please sign in to comment.