feat(上传): 修改文件上传路径以包含用户手机号
将图片和文件的上传路径从通用路径改为包含用户手机号的路径,格式为 `mlaj/upload/checkin/{mobile}/{type}/{md5}{suffix}`。这样可以更好地隔离不同用户的文件,便于管理和追踪。
Showing
2 changed files
with
7 additions
and
3 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-06-03 09:41:41 | 2 | * @Date: 2025-06-03 09:41:41 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-06-03 14:28:51 | 4 | + * @LastEditTime: 2025-06-03 17:11:53 |
| 5 | * @FilePath: /mlaj/src/views/checkin/upload/file.vue | 5 | * @FilePath: /mlaj/src/views/checkin/upload/file.vue |
| 6 | * @Description: 音视频文件上传组件 | 6 | * @Description: 音视频文件上传组件 |
| 7 | --> | 7 | --> |
| ... | @@ -73,9 +73,11 @@ import { qiniuTokenAPI, qiniuUploadAPI, saveFileAPI } from '@/api/common' | ... | @@ -73,9 +73,11 @@ import { qiniuTokenAPI, qiniuUploadAPI, saveFileAPI } from '@/api/common' |
| 73 | import BMF from 'browser-md5-file' | 73 | import BMF from 'browser-md5-file' |
| 74 | import _ from 'lodash' | 74 | import _ from 'lodash' |
| 75 | import { useTitle } from '@vueuse/core'; | 75 | import { useTitle } from '@vueuse/core'; |
| 76 | +import { useAuth } from '@/contexts/auth' | ||
| 76 | 77 | ||
| 77 | const route = useRoute() | 78 | const route = useRoute() |
| 78 | const router = useRouter() | 79 | const router = useRouter() |
| 80 | +const { currentUser } = useAuth() | ||
| 79 | useTitle(route.meta.title); | 81 | useTitle(route.meta.title); |
| 80 | 82 | ||
| 81 | const max_count = ref(5); | 83 | const max_count = ref(5); |
| ... | @@ -192,7 +194,7 @@ const handleUpload = async (file) => { | ... | @@ -192,7 +194,7 @@ const handleUpload = async (file) => { |
| 192 | // 新文件上传 | 194 | // 新文件上传 |
| 193 | if (tokenResult.token) { | 195 | if (tokenResult.token) { |
| 194 | const suffix = /.[^.]+$/.exec(file.file.name) || '' | 196 | const suffix = /.[^.]+$/.exec(file.file.name) || '' |
| 195 | - const fileName = `uploadForm/${route.query.code || 'checkin'}/${md5}${suffix}` | 197 | + const fileName = `mlaj/upload/checkin/${currentUser.value.mobile}/file/${md5}${suffix}` |
| 196 | 198 | ||
| 197 | const { filekey } = await uploadToQiniu( | 199 | const { filekey } = await uploadToQiniu( |
| 198 | file.file, | 200 | file.file, | ... | ... |
| ... | @@ -59,9 +59,11 @@ import { qiniuTokenAPI, qiniuUploadAPI, saveFileAPI } from '@/api/common' | ... | @@ -59,9 +59,11 @@ import { qiniuTokenAPI, qiniuUploadAPI, saveFileAPI } from '@/api/common' |
| 59 | import BMF from 'browser-md5-file' | 59 | import BMF from 'browser-md5-file' |
| 60 | import _ from 'lodash' | 60 | import _ from 'lodash' |
| 61 | import { useTitle } from '@vueuse/core'; | 61 | import { useTitle } from '@vueuse/core'; |
| 62 | +import { useAuth } from '@/contexts/auth' | ||
| 62 | 63 | ||
| 63 | const route = useRoute() | 64 | const route = useRoute() |
| 64 | const router = useRouter() | 65 | const router = useRouter() |
| 66 | +const { currentUser } = useAuth() | ||
| 65 | useTitle(route.meta.title); | 67 | useTitle(route.meta.title); |
| 66 | 68 | ||
| 67 | const max_count = ref(5); | 69 | const max_count = ref(5); |
| ... | @@ -180,7 +182,7 @@ const handleUpload = async (file) => { | ... | @@ -180,7 +182,7 @@ const handleUpload = async (file) => { |
| 180 | // 新文件上传 | 182 | // 新文件上传 |
| 181 | if (tokenResult.token) { | 183 | if (tokenResult.token) { |
| 182 | const suffix = /.[^.]+$/.exec(file.file.name) || '' | 184 | const suffix = /.[^.]+$/.exec(file.file.name) || '' |
| 183 | - const fileName = `uploadForm/${route.query.code || 'checkin'}/${md5}${suffix}` | 185 | + const fileName = `mlaj/upload/checkin/${currentUser.value.mobile}/img/${md5}${suffix}` |
| 184 | 186 | ||
| 185 | const { filekey, image_info } = await uploadToQiniu( | 187 | const { filekey, image_info } = await uploadToQiniu( |
| 186 | file.file, | 188 | file.file, | ... | ... |
-
Please register or login to post a comment