fix:qrcode

This commit is contained in:
Lan
2024-12-02 00:16:26 +08:00
parent 007291a2d9
commit a8406e2c0c
5 changed files with 59 additions and 22 deletions
+8
View File
@@ -100,6 +100,14 @@ provide('isLoading', isLoading)
transition: background-color 0.5s ease;
}
.light {
@apply bg-gradient-to-br from-blue-50 via-indigo-50 to-white;
}
.dark {
@apply bg-gradient-to-br from-gray-900 via-indigo-900 to-black;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s ease;
+1 -1
View File
@@ -109,7 +109,7 @@ const props = defineProps({
defineEmits(['close', 'show-preview'])
const copyShareLink = async () => {
copyToClipboard(`${props.baseUrl}/retrieve/${props.record.code}`)
copyToClipboard(`${props.baseUrl}/#/?code=${props.record.code}`)
}
</script>
+7 -6
View File
@@ -269,7 +269,7 @@
<p :class="[isDarkMode ? 'text-gray-300' : 'text-gray-800']">
<span class="font-medium">文件内容</span>
</p>
<div v-if="selectedRecord.content" class="ml-2">
<div v-if="selectedRecord.filename == 'Text'" class="ml-2">
<button
@click="showContentPreview"
class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300"
@@ -369,10 +369,7 @@ import { marked } from 'marked'
import { useAlertStore } from '@/stores/alertStore'
const alertStore = useAlertStore()
const baseUrl =
import.meta.env.MODE === 'production'
? import.meta.env.VITE_API_BASE_URL_PROD
: import.meta.env.VITE_API_BASE_URL_DEV
const baseUrl = window.location.origin
const router = useRouter()
const isDarkMode = inject('isDarkMode')
@@ -486,7 +483,11 @@ const toSend = () => {
}
const getQRCodeValue = (record) => {
return `${baseUrl}${record.downloadUrl}`
if (record.downloadUrl) {
return `${baseUrl}${record.downloadUrl}`
} else {
return `${baseUrl}?code=${record.code}`
}
}
const downloadRecord = (record) => {
+13 -14
View File
@@ -240,7 +240,7 @@
class="font-medium text-lg truncate"
:class="[isDarkMode ? 'text-white' : 'text-gray-800']"
>
{{ record.filename }}
{{ record.filename ? record.filename : 'Text' }}
</p>
<p
class="text-sm truncate"
@@ -603,12 +603,13 @@ const handleSubmit = async () => {
try {
let response: any
const formData = new FormData()
if (sendType.value === 'file') {
const isFile = sendType.value === 'file'
if (isFile) {
formData.append('file', selectedFile.value!)
} else {
const textBlob = new Blob([textContent.value], { type: 'text/plain' })
formData.append('file', textBlob, 'text_content.txt')
formData.append('text', textContent.value)
// const textBlob = new Blob([textContent.value], { type: 'text/plain' })
// formData.append('file', textBlob, 'text_content.txt')
}
if (expirationMethod.value !== 'forever') {
@@ -626,8 +627,11 @@ const handleSubmit = async () => {
uploadProgress.value = percentCompleted
}
}
response = await api.post('/share/file/', formData, config)
if (isFile) {
response = await api.post('/share/file/', formData, config)
} else {
response = await api.post('/share/text/', formData, config)
}
if (response && response.code === 200) {
const retrieveCode = response.detail.code
@@ -696,14 +700,9 @@ const deleteRecord = (id: number) => {
fileDataStore.deleteShareData(index)
}
}
const baseUrl =
import.meta.env.MODE === 'production'
? import.meta.env.VITE_API_BASE_URL_PROD
: import.meta.env.VITE_API_BASE_URL_DEV
const baseUrl = window.location.origin + '/#/'
const getQRCodeValue = (record: any) => {
// 这里返回你想要在二维码中编码的信息
// 例如,可以是一个包含文件ID和取件码的URL
return `${baseUrl}/?code=${record.retrieveCode}`
return `${baseUrl}?code=${record.retrieveCode}`
}
// 使用 onMounted 钩子延迟加载一些非关键资源或初始化
+30 -1
View File
@@ -8,6 +8,7 @@ interface ConfigState {
name: string
description: string
file_storage: string
themesChoices: any[]
expireStyle: string[]
admin_token: string
robotsText: string
@@ -34,12 +35,14 @@ interface ConfigState {
errorMinute: number
errorCount: number
s3_proxy: number
themesSelect: string
}
const config = ref<ConfigState>({
name: '',
description: '',
file_storage: '',
themesChoices: [],
expireStyle: [],
admin_token: '',
robotsText: '',
@@ -65,7 +68,8 @@ const config = ref<ConfigState>({
uploadCount: 1,
errorMinute: 1,
errorCount: 1,
s3_proxy: 0
s3_proxy: 0,
themesSelect: ''
})
const fileSize = ref(1)
@@ -268,6 +272,31 @@ refreshData()
/>
</div>
<!-- 主题选择 -->
<div class="space-y-2">
<label
class="block text-sm font-medium"
:class="[isDarkMode ? 'text-gray-300' : 'text-gray-700']"
>
主题选择
</label>
<select
v-model="config.themesSelect"
class="w-full rounded-md shadow-sm px-4 py-2.5 transition-all duration-200 ease-in-out border appearance-none bg-no-repeat bg-right focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 outline-none cursor-pointer"
:class="[
isDarkMode
? 'bg-gray-700 border-gray-600 text-white hover:border-gray-500'
: 'border-gray-300 hover:border-gray-400'
]"
style="
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M7%208l3%203%203-3%22%20stroke%3D%22%236B7280%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E');
"
>
<option v-for="item in config.themesChoices" :value="item.key" :key="item.key">
{{ item.name }} (by {{ item.author }} V{{ item.version }})
</option>
</select>
</div>
<div class="space-y-2">
<label
class="block text-sm font-medium"