fix: s3下载为文本

This commit is contained in:
Lan
2025-02-08 21:30:06 +08:00
parent a8406e2c0c
commit 9970906873
7 changed files with 2704 additions and 2109 deletions
+3 -3
View File
@@ -2,15 +2,15 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/assets/logo_small.png" />
<meta <meta
name="viewport" name="viewport"
content="width=device-width, initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" content="width=device-width, initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"
/> />
<meta name="description" content="{{description}}" /> <meta name="description" content="{{description}}" />
<meta name="keywords" content="{{keywords}}" /> <meta name="keywords" content="{{keywords}}" />
<meta name="generator" content="FileCodeBox2.1" /> <meta name="generator" content="FileCodeBox2.2" />
<title>FileCodeBox</title> <title>{{title}}</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
+2693 -2097
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

+1 -5
View File
@@ -91,12 +91,8 @@ provide('isLoading', isLoading)
<style> <style>
.app-container { .app-container {
position: fixed; min-height: 100vh;
top: 0;
left: 0;
width: 100%; width: 100%;
height: 100%;
overflow: hidden;
transition: background-color 0.5s ease; transition: background-color 0.5s ease;
} }
+2 -2
View File
@@ -2,7 +2,7 @@
<transition-group <transition-group
name="alert-fade" name="alert-fade"
tag="div" tag="div"
class="fixed top-4 right-4 z-50 w-full sm:max-w-sm md:max-w-md space-y-4 px-4 sm:px-0" class="fixed top-4 left-4 z-50 w-full sm:max-w-sm md:max-w-md space-y-4 px-4 sm:px-0"
> >
<div <div
v-for="alert in alerts" v-for="alert in alerts"
@@ -89,6 +89,6 @@ onUnmounted(() => {
.alert-fade-enter-from, .alert-fade-enter-from,
.alert-fade-leave-to { .alert-fade-leave-to {
opacity: 0; opacity: 0;
transform: translateX(50px) scale(0.95); transform: translateX(-50px) scale(0.95);
} }
</style> </style>
+5 -2
View File
@@ -414,9 +414,10 @@ const handleSubmit = async () => {
const res = await api.post('/share/select/', { const res = await api.post('/share/select/', {
code: code.value code: code.value
}) })
if (res.code === 200) { if (res.code === 200) {
if (res.detail) { if (res.detail) {
const isFile = res.detail.text.startsWith('/share/download') const isFile = res.detail.text.startsWith('/share/download') || res.detail.name !=='Text'
const newFileData = { const newFileData = {
id: Date.now(), id: Date.now(),
code: res.detail.code, code: res.detail.code,
@@ -491,9 +492,11 @@ const getQRCodeValue = (record) => {
} }
const downloadRecord = (record) => { const downloadRecord = (record) => {
console.log(record);
if (record.downloadUrl) { if (record.downloadUrl) {
// 如果是文件,直接下载 // 如果是文件,直接下载
window.open(`${baseUrl}${record.downloadUrl}`, '_blank') window.open(`${ record.downloadUrl.startsWith('http') ? '' : baseUrl }${record.downloadUrl}`, '_blank')
} else if (record.content) { } else if (record.content) {
// 如果是文本,转成txt下载 // 如果是文本,转成txt下载
const blob = new Blob([record.content], { type: 'text/plain;charset=utf-8' }) const blob = new Blob([record.content], { type: 'text/plain;charset=utf-8' })