From 45ec38a0238449982900887f218a0f48bc07497b Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 28 Apr 2026 22:49:55 +0800 Subject: [PATCH] fix: fix JavaScript syntax errors in HTTP file browser, use ES5 syntax and HTML entities for icons --- httpfile/server.go | 156 ++++++++++++++++++++++++--------------------- 1 file changed, 83 insertions(+), 73 deletions(-) diff --git a/httpfile/server.go b/httpfile/server.go index 9ba341b..44c4908 100644 --- a/httpfile/server.go +++ b/httpfile/server.go @@ -54,6 +54,9 @@ func (s *Server) handleFileBrowser(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") + w.Header().Set("Pragma", "no-cache") + w.Header().Set("Expires", "0") w.Write([]byte(fileBrowserHTML)) } @@ -158,8 +161,6 @@ const fileBrowserHTML = ` .btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(102,126,234,0.4); } .btn-success { background: #28a745; color: white; } .btn-success:hover { background: #218838; } - .btn-danger { background: #dc3545; color: white; } - .btn-danger:hover { background: #c82333; } .btn-sm { padding: 6px 12px; font-size: 12px; } .file-list { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); } table { width: 100%; border-collapse: collapse; } @@ -177,24 +178,6 @@ const fileBrowserHTML = ` .file-link { color: #667eea; text-decoration: none; font-weight: 500; } .file-link:hover { text-decoration: underline; } .actions-cell { display: flex; gap: 8px; } - .toast { position: fixed; top: 80px; right: 30px; padding: 14px 24px; border-radius: 8px; color: white; font-size: 14px; font-weight: 500; z-index: 2000; animation: slideIn 0.3s ease; } - .toast-success { background: #28a745; } - .toast-error { background: #dc3545; } - @keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } } - .modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; } - .modal-overlay.show { display: flex; } - .modal { background: white; border-radius: 12px; padding: 30px; width: 480px; max-width: 90%; } - .modal h2 { margin-bottom: 24px; font-size: 20px; } - .modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; } - .form-group { margin-bottom: 16px; } - .form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: #555; font-size: 14px; } - .form-group input { width: 100%; padding: 10px 14px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; } - .form-group input:focus { outline: none; border-color: #667eea; } - .drop-zone { border: 2px dashed #667eea; border-radius: 8px; padding: 40px 20px; text-align: center; background: #f8f9ff; transition: all 0.3s; cursor: pointer; margin-bottom: 16px; } - .drop-zone:hover, .drop-zone.dragover { background: #e8ebff; border-color: #764ba2; } - .progress-bar { width: 100%; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; margin-top: 12px; display: none; } - .progress-bar.show { display: block; } - .progress-fill { height: 100%; background: linear-gradient(135deg, #667eea, #764ba2); transition: width 0.3s; width: 0%; } .empty-state { text-align: center; padding: 60px 20px; color: #999; } .empty-state .icon { font-size: 64px; margin-bottom: 16px; } @@ -202,17 +185,14 @@ const fileBrowserHTML = `
-

📁 HTTP 文件服务器

+

HTTP 文件服务器

在线浏览、下载文件

- +
- +
@@ -220,8 +200,7 @@ const fileBrowserHTML = ` 名称大小修改时间操作 - - +