From 4e576ad7e2ac3981eb69c88e27100200ef9c410d Mon Sep 17 00:00:00 2001
From: liukl <1138493417@qq.com>
Date: Thu, 17 Oct 2024 14:45:59 +0800
Subject: [PATCH 01/26] =?UTF-8?q?feat:=E4=BD=BF=E7=94=A8sqlite=E8=AE=B0?=
=?UTF-8?q?=E5=BD=95=E6=96=87=E4=BB=B6=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/templates/files.tmpl | 2 +-
assets/templates/footer.tmpl | 24 ++++++++++++--
build.bat | 11 +++++++
conf/conf.go | 9 ++++--
control/control.go | 53 +++++++++++++++++++++++-------
control/db.go | 63 ++++++++++++++++++++++++++++++++++++
go.mod | 7 +++-
go.sum | 4 +++
main.go | 14 ++++++++
9 files changed, 168 insertions(+), 19 deletions(-)
create mode 100644 build.bat
create mode 100644 control/db.go
diff --git a/assets/templates/files.tmpl b/assets/templates/files.tmpl
index 8659c8a..e48fb8b 100644
--- a/assets/templates/files.tmpl
+++ b/assets/templates/files.tmpl
@@ -1,6 +1,6 @@
{{template "public/header" .}}
上传中...
上传中...
+
+
📁 File Upload to Telegram
+
Secure, Fast, Permanent Storage
+
+
+
+
📤
+
Drag files here or click to select
+
+
+
+
+
+
+
+ 📊 Multiple Files
+ 🔒 Secure
+ ⚡ Fast
+
+
+
+
Uploading...
+
+
+
+
+
+
{{template "public/footer" .}}
diff --git a/assets/templates/footer.tmpl b/assets/templates/footer.tmpl
index ab0af6c..04cb22f 100644
--- a/assets/templates/footer.tmpl
+++ b/assets/templates/footer.tmpl
@@ -3,7 +3,7 @@
function uploadFile(file) {
var limit = 10 * 1024 * 1024;
if (file.size <= limit) {
- uploadImg(file, 1).then((url) => {
+ uploadImg(file, 1, file.name).then((url) => {
// 处理上传成功的情况
console.log(url);
}).catch((error) => {
@@ -18,7 +18,7 @@
function uploadNextChunk() {
if (start < file.size) {
var chunk = file.slice(start, end);
- return uploadImg(chunk, 0)
+ return uploadImg(chunk, 0, file.name)
.then((url) => {
// 处理上传成功的情况
temp = temp + '\n' + url.replace(/^\/d\//, ''); // 每次改变值都换行
@@ -47,7 +47,7 @@
// 将字符串转换为 Blob 对象
var blob = new Blob([temp], { type: 'text/plain' });
var fileAll = new File([blob], 'fileAll.txt', { type: 'text/plain' });
- return uploadImg(fileAll, 1);
+ return uploadImg(fileAll, 1, file.name);
})
.catch((error) => {
// 处理上传失败的情况
@@ -55,13 +55,14 @@
});
}
}
- function uploadImg(e, ms) {
+ function uploadImg(e, ms, fileName) {
return new Promise((resolve, reject) => {
var o = new FormData();
o.append("file", e);
var isImage = e.type.startsWith('image/');
+ var displayFileName = fileName || e.name || 'Unknown file';
$("#uploadButton").prop("disabled", !0);
- $("#uploadButton").text("上传中");
+ $("#uploadButton").text("Uploading");
$("#loading").show();
var a = window.location.protocol + "//" + window.location.hostname;
"80" !== window.location.port &&
@@ -75,101 +76,118 @@
processData: !1,
success: function (e) {
- var link = window.location.href + e.message;
+ var link = window.location.href.replace(/\/$/, "") + e.message;
var proxyUrl = e.proxyUrl
var t;
if (e.code == 1) {
if (ms) {
+ var shortLink = e.shortFileUrl ? window.location.href.replace(/\/$/, "") + e.shortUrl : '';
+ var fileNameToShow = displayFileName;
+
if (isImage) {
- t = $(
- '