Use env variable for max file size limit
- Frontend: read VITE_MAX_FILE_SIZE_MB from env - Update .env.example files with limits 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
VITE_API_URL=http://localhost:4001
|
||||
VITE_WS_URL=ws://localhost:4001
|
||||
VITE_MAX_FILE_SIZE_MB=10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<form @submit.prevent="handleUpload" class="upload-form">
|
||||
<div class="form-group">
|
||||
<label>MP3 файл (макс. 10MB)</label>
|
||||
<label>MP3 файл (макс. {{ maxFileSizeMb }}MB)</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="audio/mpeg,audio/mp3"
|
||||
@@ -34,6 +34,9 @@ const emit = defineEmits(['uploaded'])
|
||||
|
||||
const tracksStore = useTracksStore()
|
||||
|
||||
const maxFileSizeMb = import.meta.env.VITE_MAX_FILE_SIZE_MB || 10
|
||||
const maxFileSize = maxFileSizeMb * 1024 * 1024
|
||||
|
||||
const title = ref('')
|
||||
const artist = ref('')
|
||||
const file = ref(null)
|
||||
@@ -45,9 +48,9 @@ function handleFileSelect(e) {
|
||||
const selectedFile = e.target.files[0]
|
||||
if (!selectedFile) return
|
||||
|
||||
// Check file size (10MB)
|
||||
if (selectedFile.size > 10 * 1024 * 1024) {
|
||||
error.value = 'Файл слишком большой (макс. 10MB)'
|
||||
// Check file size
|
||||
if (selectedFile.size > maxFileSize) {
|
||||
error.value = `Файл слишком большой (макс. ${maxFileSizeMb}MB)`
|
||||
fileInput.value.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user