feat(fileserver): 新增内网文件服务器服务与管理页面
新增 FastAPI 文件服务器核心模块(配置、鉴权、存储、心跳上报),新增 HTTP 路由接口(健康检查、文件上传/下载/删除、管理登录/密码修改/统计),新增 Vue3 管理页面源码;新增 MySQL 元数据存储支持,新增 PyMySQL 依赖;新增 .gitignore 忽略 IDE 与备份文件;新增文件服务器工具脚本;删除旧的 build/ 脚本与 exe 构建产物,优化 Electron 平台登录逻辑为纯接口模式,新增平台账号环境变量注入,优化试用期异常检查逻辑,拆分服务岗转正流程为独立脚本。
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# fileserver 管理页面(Vue 3)
|
||||
|
||||
文件服务器(8802)的 Web 管理界面:查看文件列表、上传时间、大小、SHA256,支持上传/下载/删除。
|
||||
|
||||
## 文件说明
|
||||
|
||||
| 文件 | 说明 |
|
||||
|------|------|
|
||||
| `index.html` | 页面骨架 + 样式 |
|
||||
| `app.js` | Vue 3 应用逻辑(列表/上传/删除/搜索) |
|
||||
| `vue.global.prod.js` | Vue 运行时(本地托管,离线可用,部署在服务器 `/opt/37du/fileserver-admin/`) |
|
||||
|
||||
## 架构
|
||||
|
||||
```
|
||||
浏览器 → Nginx(:80)
|
||||
├── 页面静态文件(/opt/37du/fileserver-admin/)
|
||||
└── /fs-api/* → 反代到 127.0.0.1:8802
|
||||
```
|
||||
- 管理接口(列表/上传/删除)需**页面内登录**:`POST /api/admin/login`(账号密码在 fileserver/.env 的 `FILESERVER_ADMIN_USER/PASSWORD`),签发 HMAC 会话 Token(默认 12h),前端存 localStorage、以 `Authorization: Bearer` 携带
|
||||
- 前端**不接触** X-API-Token(中心机/自动化直连 8802 时用)
|
||||
- 下载 `/files/{fid}` 保持开放(执行机内网直连)
|
||||
- Nginx `client_max_body_size 0` 支持大文件上传
|
||||
|
||||
## 部署位置(服务器 172.30.30.243)
|
||||
|
||||
- 站点配置:`/etc/nginx/sites-available/37du-fileserver-admin`
|
||||
- 页面文件:`/opt/37du/fileserver-admin/`
|
||||
- 认证文件:`/etc/nginx/.htpasswd`
|
||||
|
||||
## 修改管理密码
|
||||
|
||||
```bash
|
||||
# 修改 /opt/37du/fileserver/.env 中的 FILESERVER_ADMIN_PASSWORD,然后重启服务:
|
||||
systemctl restart 37du-fileserver
|
||||
```
|
||||
|
||||
## 更新页面
|
||||
|
||||
1. 本地修改 `desktop/fileserver/frontend/` 下文件
|
||||
2. 上传覆盖 `/opt/37du/fileserver-admin/` 同名文件
|
||||
3. `systemctl reload nginx`
|
||||
|
||||
## 防火墙(ufw)
|
||||
|
||||
已启用:默认拒绝入站,放行 `22/tcp`(limit)、`80/tcp`、`3306/tcp`、`8802/tcp`。
|
||||
管理:`ufw status verbose` / `ufw allow <port>/tcp` / `ufw delete allow <port>/tcp`
|
||||
@@ -0,0 +1,316 @@
|
||||
// 37du 文件服务器管理页面 v2.0 - Vue 3 应用逻辑
|
||||
// API 走同源 /fs-api 反代;管理接口用登录后的会话 Bearer Token 鉴权。
|
||||
"use strict";
|
||||
|
||||
const API_BASE = "/fs-api";
|
||||
const TOKEN_KEY = "fs_admin_token";
|
||||
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
files: [],
|
||||
loading: false,
|
||||
keyword: "",
|
||||
sortKey: "created",
|
||||
sortDir: -1, // -1 降序 1 升序
|
||||
uploading: false,
|
||||
uploadIdx: 0,
|
||||
uploadTotal: 0,
|
||||
uploadPercent: 0,
|
||||
statusMsg: "",
|
||||
statusClass: "",
|
||||
baseUrl: location.origin,
|
||||
// 登录态
|
||||
token: localStorage.getItem(TOKEN_KEY) || "",
|
||||
username: "",
|
||||
password: "",
|
||||
showPwd: false,
|
||||
loginMsg: "",
|
||||
loggingIn: false,
|
||||
// 改密码
|
||||
showPwdModal: false,
|
||||
oldPwd: "",
|
||||
newPwd: "",
|
||||
newPwd2: "",
|
||||
pwdMsg: "",
|
||||
savingPwd: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
loggedIn() {
|
||||
return !!this.token;
|
||||
},
|
||||
tokenUser() {
|
||||
try {
|
||||
const raw = atob(this.token.split(".")[0]);
|
||||
return raw.split("|")[0] || "?";
|
||||
} catch (e) {
|
||||
return "?";
|
||||
}
|
||||
},
|
||||
sortedFiles() {
|
||||
const k = this.keyword.trim().toLowerCase();
|
||||
let list = this.files;
|
||||
if (k) list = list.filter((f) => (f.filename || "").toLowerCase().includes(k));
|
||||
const dir = this.sortDir;
|
||||
const key = this.sortKey;
|
||||
return list.slice().sort((a, b) => {
|
||||
let r = 0;
|
||||
if (key === "filename") r = (a.filename || "").localeCompare(b.filename || "", "zh");
|
||||
else if (key === "size") r = (Number(a.size) || 0) - (Number(b.size) || 0);
|
||||
else if (key === "created") r = (a.created || 0) - (b.created || 0);
|
||||
else if (key === "downloads") r = (Number(a.downloads) || 0) - (Number(b.downloads) || 0);
|
||||
return r * dir;
|
||||
});
|
||||
},
|
||||
totalCount() {
|
||||
return this.files.length;
|
||||
},
|
||||
totalSizeText() {
|
||||
return this.fmtSize(this.files.reduce((s, f) => s + (Number(f.size) || 0), 0));
|
||||
},
|
||||
totalDownloads() {
|
||||
return this.files.reduce((s, f) => s + (Number(f.downloads) || 0), 0);
|
||||
},
|
||||
lastUploadText() {
|
||||
if (!this.files.length) return "-";
|
||||
const t = Math.max(...this.files.map((f) => Number(f.created) || 0));
|
||||
return this.fmtTime(t);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
authHeaders() {
|
||||
return { Authorization: "Bearer " + this.token };
|
||||
},
|
||||
flash(msg, ok) {
|
||||
this.statusMsg = msg;
|
||||
this.statusClass = ok ? "ok" : "err";
|
||||
clearTimeout(this._t);
|
||||
this._t = setTimeout(() => {
|
||||
this.statusMsg = "";
|
||||
this.statusClass = "";
|
||||
}, 3000);
|
||||
},
|
||||
sortBy(key) {
|
||||
if (this.sortKey === key) {
|
||||
this.sortDir = -this.sortDir;
|
||||
} else {
|
||||
this.sortKey = key;
|
||||
this.sortDir = key === "filename" ? 1 : -1;
|
||||
}
|
||||
},
|
||||
// ===== 登录 =====
|
||||
async login() {
|
||||
this.loggingIn = true;
|
||||
this.loginMsg = "";
|
||||
try {
|
||||
const r = await fetch(`${API_BASE}/api/admin/login`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ username: this.username, password: this.password }),
|
||||
});
|
||||
const j = await r.json().catch(() => ({}));
|
||||
if (!r.ok) {
|
||||
this.loginMsg = j.detail || ("登录失败 HTTP " + r.status);
|
||||
return;
|
||||
}
|
||||
this.token = j.token;
|
||||
localStorage.setItem(TOKEN_KEY, j.token);
|
||||
this.password = "";
|
||||
this.load();
|
||||
} catch (e) {
|
||||
this.loginMsg = "网络错误:" + e.message;
|
||||
} finally {
|
||||
this.loggingIn = false;
|
||||
}
|
||||
},
|
||||
logout() {
|
||||
this.token = "";
|
||||
localStorage.removeItem(TOKEN_KEY);
|
||||
this.files = [];
|
||||
this.loginMsg = "";
|
||||
this.keyword = "";
|
||||
},
|
||||
// ===== 数据 =====
|
||||
async load() {
|
||||
this.loading = true;
|
||||
try {
|
||||
const r = await fetch(`${API_BASE}/api/files`, { headers: this.authHeaders() });
|
||||
if (r.status === 401) {
|
||||
this.logout();
|
||||
this.loginMsg = "登录已过期,请重新登录";
|
||||
return;
|
||||
}
|
||||
if (!r.ok) throw new Error("HTTP " + r.status);
|
||||
const j = await r.json();
|
||||
this.files = j.files || [];
|
||||
this.flash("已刷新,共 " + this.files.length + " 个文件", true);
|
||||
} catch (e) {
|
||||
this.flash("加载文件列表失败:" + e.message, false);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
// ===== 上传(支持多文件)=====
|
||||
async onFilesPicked(ev) {
|
||||
const files = Array.from(ev.target.files || []);
|
||||
ev.target.value = "";
|
||||
if (!files.length) return;
|
||||
this.uploading = true;
|
||||
this.uploadTotal = files.length;
|
||||
let okCount = 0;
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
this.uploadIdx = i + 1;
|
||||
this.uploadPercent = 0;
|
||||
if (await this.uploadOne(files[i])) okCount++;
|
||||
}
|
||||
this.uploading = false;
|
||||
this.flash(`上传完成:成功 ${okCount}/${files.length} 个`, okCount > 0);
|
||||
this.load();
|
||||
},
|
||||
uploadOne(file) {
|
||||
return new Promise((resolve) => {
|
||||
const fd = new FormData();
|
||||
fd.append("upload", file);
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", `${API_BASE}/api/upload`);
|
||||
xhr.setRequestHeader("Authorization", "Bearer " + this.token);
|
||||
xhr.upload.onprogress = (e) => {
|
||||
if (e.lengthComputable) this.uploadPercent = Math.round((e.loaded / e.total) * 100);
|
||||
};
|
||||
xhr.onload = () => {
|
||||
if (xhr.status === 401) {
|
||||
this.logout();
|
||||
this.loginMsg = "登录已过期,请重新登录";
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
if (xhr.status < 300) resolve(true);
|
||||
else {
|
||||
this.flash(`上传 ${file.name} 失败:HTTP ${xhr.status}`, false);
|
||||
resolve(false);
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => {
|
||||
this.flash(`上传 ${file.name} 失败:网络错误`, false);
|
||||
resolve(false);
|
||||
};
|
||||
xhr.send(fd);
|
||||
});
|
||||
},
|
||||
// ===== 删除 =====
|
||||
async remove(f) {
|
||||
if (!confirm(`确定删除文件「${f.filename}」?此操作不可恢复。`)) return;
|
||||
try {
|
||||
const r = await fetch(`${API_BASE}/api/files/${f.fid}`, {
|
||||
method: "DELETE",
|
||||
headers: this.authHeaders(),
|
||||
});
|
||||
if (r.status === 401) {
|
||||
this.logout();
|
||||
this.loginMsg = "登录已过期,请重新登录";
|
||||
return;
|
||||
}
|
||||
if (!r.ok) throw new Error("HTTP " + r.status);
|
||||
const j = await r.json();
|
||||
if (j.ok) {
|
||||
this.files = this.files.filter((x) => x.fid !== f.fid);
|
||||
this.flash("已删除:" + f.filename, true);
|
||||
} else {
|
||||
this.flash("删除失败", false);
|
||||
}
|
||||
} catch (e) {
|
||||
this.flash("删除失败:" + e.message, false);
|
||||
}
|
||||
},
|
||||
// ===== 链接复制 =====
|
||||
async copyLink(f) {
|
||||
const url = this.downloadUrl(f);
|
||||
try {
|
||||
await navigator.clipboard.writeText(url);
|
||||
this.flash("下载链接已复制", true);
|
||||
} catch (e) {
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = url;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand("copy");
|
||||
ta.remove();
|
||||
this.flash("下载链接已复制", true);
|
||||
}
|
||||
},
|
||||
// ===== 修改密码 =====
|
||||
openPwdModal() {
|
||||
this.oldPwd = this.newPwd = this.newPwd2 = "";
|
||||
this.pwdMsg = "";
|
||||
this.showPwdModal = true;
|
||||
},
|
||||
closePwdModal() {
|
||||
this.showPwdModal = false;
|
||||
},
|
||||
async changePwd() {
|
||||
this.pwdMsg = "";
|
||||
if (this.newPwd !== this.newPwd2) {
|
||||
this.pwdMsg = "两次输入的新密码不一致";
|
||||
return;
|
||||
}
|
||||
if (this.newPwd.length < 6) {
|
||||
this.pwdMsg = "新密码至少 6 位";
|
||||
return;
|
||||
}
|
||||
this.savingPwd = true;
|
||||
try {
|
||||
const r = await fetch(`${API_BASE}/api/admin/change-password`, {
|
||||
method: "POST",
|
||||
headers: Object.assign({ "Content-Type": "application/json" }, this.authHeaders()),
|
||||
body: JSON.stringify({ old_password: this.oldPwd, new_password: this.newPwd }),
|
||||
});
|
||||
const j = await r.json().catch(() => ({}));
|
||||
if (!r.ok) {
|
||||
this.pwdMsg = j.detail || ("修改失败 HTTP " + r.status);
|
||||
return;
|
||||
}
|
||||
this.showPwdModal = false;
|
||||
this.logout();
|
||||
this.loginMsg = "密码已修改,请用新密码重新登录";
|
||||
} catch (e) {
|
||||
this.pwdMsg = "网络错误:" + e.message;
|
||||
} finally {
|
||||
this.savingPwd = false;
|
||||
}
|
||||
},
|
||||
// ===== 工具 =====
|
||||
downloadUrl(f) {
|
||||
return `${API_BASE}/files/${f.fid}?dl=${encodeURIComponent(f.filename || f.fid)}`;
|
||||
},
|
||||
extOf(name) {
|
||||
const m = /\.([A-Za-z0-9]+)$/.exec(name || "");
|
||||
return m ? m[1].toUpperCase().slice(0, 6) : "FILE";
|
||||
},
|
||||
whoLabel(who) {
|
||||
if (!who) return "-";
|
||||
return who === "center" ? "中心机" : who;
|
||||
},
|
||||
fmtSize(bytes) {
|
||||
const b = Number(bytes) || 0;
|
||||
if (b < 1024) return b + " B";
|
||||
if (b < 1024 * 1024) return (b / 1024).toFixed(1) + " KB";
|
||||
if (b < 1024 * 1024 * 1024) return (b / 1024 / 1024).toFixed(1) + " MB";
|
||||
return (b / 1024 / 1024 / 1024).toFixed(2) + " GB";
|
||||
},
|
||||
fmtTime(ts) {
|
||||
if (!ts) return "-";
|
||||
const d = new Date(Number(ts) * 1000);
|
||||
const p = (n) => String(n).padStart(2, "0");
|
||||
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
|
||||
},
|
||||
shortSha(s) {
|
||||
return (s || "").slice(0, 12) + "…";
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
if (this.token) this.load();
|
||||
},
|
||||
}).mount("#app");
|
||||
@@ -0,0 +1,424 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>37du 文件服务器管理</title>
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body {
|
||||
font-family: "Comic Sans MS", "Comic Neue", "Segoe Print", "Marker Felt", "Bradley Hand", cursive;
|
||||
background-color: #fffdf3;
|
||||
background-image:
|
||||
repeating-linear-gradient(transparent 0 31px, rgba(120, 150, 210, .15) 31px 32px),
|
||||
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.035'/></svg>");
|
||||
color: #2b2b2b; font-size: 15px; min-height: 100vh;
|
||||
}
|
||||
::selection { background: #ffe066; color: #2b2b2b; }
|
||||
|
||||
/* ===== 手绘通用 ===== */
|
||||
.hand { border: 2.5px solid #2b2b2b; border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px; }
|
||||
.squiggle {
|
||||
display: inline-block; height: 7px; margin-top: 3px;
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='7'><path d='M0 3 Q 10 0, 20 3 T 40 3 T 60 3 T 80 3 T 100 3 T 120 3 T 140 3' stroke='%23e8590c' stroke-width='2.6' fill='none' stroke-linecap='round'/></svg>");
|
||||
background-repeat: no-repeat; background-size: 100% 100%;
|
||||
}
|
||||
.pin { position: absolute; font-size: 20px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
|
||||
.tape {
|
||||
position: absolute; width: 92px; height: 26px; z-index: 2;
|
||||
background: rgba(255, 224, 130, .62);
|
||||
border-left: 2px dashed rgba(0,0,0,.18);
|
||||
border-right: 2px dashed rgba(0,0,0,.18);
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,.12);
|
||||
}
|
||||
|
||||
/* ===== 登录页 ===== */
|
||||
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
|
||||
.login-card {
|
||||
position: relative; width: 410px; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
box-shadow: 5px 7px 0 rgba(0,0,0,.12);
|
||||
padding: 44px 38px 36px; transform: rotate(-.6deg);
|
||||
}
|
||||
.login-card .tape { top: -14px; left: 50%; margin-left: -46px; transform: rotate(-3deg); }
|
||||
.login-card .pin { top: -12px; right: 22px; transform: rotate(12deg); }
|
||||
.login-card .emblem {
|
||||
width: 58px; height: 58px; border-radius: 50%;
|
||||
background: #fff; border: 3px solid #2b2b2b;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-weight: 800; font-size: 24px; color: #e8590c;
|
||||
transform: rotate(-7deg); box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.login-card h2 { font-size: 27px; font-weight: 800; letter-spacing: .5px; }
|
||||
.login-card .login-sub { font-size: 13px; color: #868e96; font-weight: 700; margin: 4px 0 20px; }
|
||||
.login-field { position: relative; margin-bottom: 13px; }
|
||||
.login-field input {
|
||||
width: 100%; padding: 11px 44px 11px 14px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 15px; font-weight: 600; outline: none;
|
||||
background: #fff;
|
||||
}
|
||||
.login-field input:focus { background: #fff9db; }
|
||||
.eye { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 17px; user-select: none; }
|
||||
.login-card .btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }
|
||||
.login-hint { margin-top: 14px; font-size: 12.5px; color: #868e96; font-weight: 700; }
|
||||
.login-msg {
|
||||
margin-top: 12px; background: #ffe3e3; color: #c92a2a;
|
||||
padding: 10px 12px; font-weight: 700; font-size: 13px;
|
||||
border: 2.5px dashed #c92a2a; border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
}
|
||||
|
||||
/* ===== 顶栏(便签条)===== */
|
||||
.header {
|
||||
position: relative; background: #ffe066;
|
||||
border-bottom: 3px solid #2b2b2b;
|
||||
padding: 16px 30px;
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 16px;
|
||||
transform: rotate(-.35deg); margin: 0 -4px;
|
||||
}
|
||||
.header .pin.l { top: 6px; left: 14px; transform: rotate(-14deg); }
|
||||
.header .pin.r { top: 6px; right: 200px; transform: rotate(10deg); }
|
||||
.header .brand { display: flex; align-items: center; gap: 14px; }
|
||||
.header .emblem {
|
||||
width: 48px; height: 48px; border-radius: 50%;
|
||||
background: #fff; border: 3px solid #2b2b2b;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-weight: 800; font-size: 21px; color: #e8590c;
|
||||
transform: rotate(-6deg); box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
}
|
||||
.header h1 { font-size: 23px; font-weight: 800; line-height: 1.1; }
|
||||
.header h1 .squiggle { width: 150px; }
|
||||
.header .sub { font-size: 12.5px; color: #5c5c5c; font-weight: 700; margin-top: 2px; }
|
||||
.header .actions { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||
|
||||
/* ===== 统计条 ===== */
|
||||
.stats {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
|
||||
padding: 22px 30px 18px;
|
||||
}
|
||||
.stat {
|
||||
position: relative; background: #fffef8; padding: 12px 16px 13px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
box-shadow: 3px 5px 0 rgba(0,0,0,.1);
|
||||
transition: transform .18s ease, box-shadow .18s ease;
|
||||
}
|
||||
.stat:nth-child(odd) { transform: rotate(-1.2deg); }
|
||||
.stat:nth-child(even) { transform: rotate(1deg); }
|
||||
.stat:hover { transform: rotate(0) translateY(-3px); box-shadow: 5px 8px 0 rgba(0,0,0,.14); }
|
||||
.stat .tape { top: -11px; left: 50%; margin-left: -46px; transform: rotate(-2deg); width: 74px; height: 22px; }
|
||||
.stat .k { font-size: 12.5px; font-weight: 700; color: #868e96; letter-spacing: .5px; }
|
||||
.stat .v { font-size: 23px; font-weight: 800; margin-top: 3px; color: #2b2b2b; }
|
||||
.stat:nth-child(1) .v { color: #e8590c; }
|
||||
.stat:nth-child(2) .v { color: #1971c2; }
|
||||
.stat:nth-child(3) .v { color: #2f9e44; }
|
||||
.stat:nth-child(4) .v { color: #9c36b5; }
|
||||
|
||||
/* ===== 工具栏 ===== */
|
||||
.toolbar {
|
||||
display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
|
||||
padding: 8px 30px 18px;
|
||||
}
|
||||
.toolbar input[type="text"] {
|
||||
padding: 9px 14px; border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 14px; font-weight: 600; outline: none;
|
||||
width: 280px; background: #fff;
|
||||
}
|
||||
.toolbar input[type="text"]:focus { background: #fff9db; }
|
||||
.toolbar .hint { color: #868e96; font-size: 12.5px; font-weight: 700; }
|
||||
|
||||
/* ===== 按钮(标记笔)===== */
|
||||
.btn {
|
||||
font-family: inherit; font-weight: 700; font-size: 14.5px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
background: #fff; color: #2b2b2b;
|
||||
padding: 9px 18px; cursor: pointer;
|
||||
box-shadow: 2px 3px 0 rgba(0,0,0,.14);
|
||||
transition: transform .12s ease, background .12s ease;
|
||||
user-select: none;
|
||||
}
|
||||
.btn:hover { transform: rotate(-1.6deg) scale(1.04); }
|
||||
.btn:active { transform: rotate(0) translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.14); }
|
||||
.btn-primary { background: #ffe066; }
|
||||
.btn-primary:hover { background: #ffd43b; }
|
||||
.btn-success { background: #b2f2bb; }
|
||||
.btn-success:hover { background: #8ce99a; }
|
||||
.btn:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.upload-btn input[type="file"] { display: none; }
|
||||
.tag {
|
||||
display: inline-block; padding: 6px 12px;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-size: 13px; font-weight: 700; background: #ffd8a8; color: #2b2b2b;
|
||||
transform: rotate(-1deg); box-shadow: 2px 3px 0 rgba(0,0,0,.1);
|
||||
}
|
||||
|
||||
/* ===== 状态条(标记笔高亮)===== */
|
||||
.status-bar { display: none; padding: 11px 30px; font-weight: 700; font-size: 14px; }
|
||||
.status-bar.ok { display: block; background: #fff3bf; color: #2b2b2b; border-bottom: 2.5px dashed #f59f00; }
|
||||
.status-bar.err { display: block; background: #ffe3e3; color: #c92a2a; border-bottom: 2.5px dashed #e03131; }
|
||||
|
||||
.main { padding: 8px 30px 30px; }
|
||||
|
||||
/* ===== 主卡片(纸页 + 折角)===== */
|
||||
.card {
|
||||
position: relative; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
box-shadow: 5px 7px 0 rgba(0,0,0,.1);
|
||||
transform: rotate(.2deg);
|
||||
}
|
||||
.card > .tape { top: -13px; left: 50%; margin-left: -46px; transform: rotate(-3deg); }
|
||||
.card::after {
|
||||
content: ""; position: absolute; top: 0; right: 0;
|
||||
width: 0; height: 0;
|
||||
border-style: solid;
|
||||
border-width: 0 0 30px 30px;
|
||||
border-color: transparent transparent #ffe066 transparent;
|
||||
filter: drop-shadow(-2px 2px 1px rgba(0,0,0,.08));
|
||||
}
|
||||
|
||||
/* ===== 加载中(翻本子)===== */
|
||||
.loading {
|
||||
padding: 70px; text-align: center; font-weight: 800; font-size: 18px; color: #495057;
|
||||
}
|
||||
.loading .pen { display: inline-block; animation: pen 1.1s ease-in-out infinite; }
|
||||
@keyframes pen {
|
||||
0%, 100% { transform: rotate(-8deg) translateY(0); }
|
||||
50% { transform: rotate(10deg) translateY(-6px); }
|
||||
}
|
||||
|
||||
/* ===== 表格 ===== */
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th {
|
||||
background: #fff3bf; color: #2b2b2b; text-align: left; cursor: pointer; user-select: none;
|
||||
padding: 11px 14px; font-weight: 800; letter-spacing: .3px;
|
||||
border-bottom: 3px solid #2b2b2b; font-size: 14px; white-space: nowrap;
|
||||
}
|
||||
th .arrow { color: #e8590c; margin-left: 3px; }
|
||||
td { padding: 11px 14px; border-bottom: 2px dashed #ced4da; font-weight: 600; vertical-align: middle; }
|
||||
tr:last-child td { border-bottom: none; }
|
||||
tbody tr:hover td { background: #ffecb3; }
|
||||
.fname-cell { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
|
||||
.filename { font-weight: 800; word-break: break-all; }
|
||||
.fname-meta { display: flex; gap: 8px; align-items: center; }
|
||||
.ext {
|
||||
display: inline-block; padding: 1px 8px;
|
||||
border: 2px solid #2b2b2b; border-radius: 50%;
|
||||
background: #d0ebff; font-size: 10px; font-weight: 800; color: #1971c2;
|
||||
transform: rotate(-4deg);
|
||||
}
|
||||
.sha { font-family: "Courier New", Consolas, monospace; color: #868e96; font-size: 11.5px; cursor: help; font-weight: 700; }
|
||||
tbody tr:hover .sha { color: #2b2b2b; }
|
||||
.empty { padding: 46px 20px; text-align: center; font-weight: 700; font-size: 15px; color: #2b2b2b; }
|
||||
.empty svg { margin-bottom: 14px; }
|
||||
.empty .et { display: inline-block; border: 2.5px dashed #adb5bd;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
padding: 10px 26px; background: #fffdf3; }
|
||||
a.dl, a.cp, a.rm { text-decoration: none; font-weight: 800; font-size: 13.5px; padding: 0 3px; margin-right: 6px; }
|
||||
a.dl { color: #1971c2; background: linear-gradient(transparent 62%, #a5d8ff 62%); }
|
||||
a.dl:hover { background: #a5d8ff; }
|
||||
a.cp { color: #2f9e44; background: linear-gradient(transparent 62%, #b2f2bb 62%); }
|
||||
a.cp:hover { background: #b2f2bb; }
|
||||
a.rm { color: #e03131; background: linear-gradient(transparent 62%, #ffc9c9 62%); }
|
||||
a.rm:hover { background: #ffc9c9; }
|
||||
.who { font-weight: 800; }
|
||||
.who.center { color: #1971c2; }
|
||||
|
||||
.footer {
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
padding: 12px 18px; border-top: 2.5px dashed #adb5bd;
|
||||
font-weight: 700; font-size: 12.5px; color: #495057;
|
||||
}
|
||||
.footer .dot { color: #e8590c; }
|
||||
|
||||
/* ===== 修改密码弹窗(便签)===== */
|
||||
.mask {
|
||||
position: fixed; inset: 0; background: rgba(43,43,43,.45);
|
||||
display: flex; align-items: center; justify-content: center; z-index: 99; padding: 24px;
|
||||
}
|
||||
.modal {
|
||||
position: relative; width: 410px; background: #fffef8;
|
||||
border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
box-shadow: 6px 8px 0 rgba(0,0,0,.16); padding: 36px 34px 30px;
|
||||
transform: rotate(.5deg);
|
||||
}
|
||||
.modal .tape { top: -13px; left: 50%; margin-left: -46px; transform: rotate(2deg); }
|
||||
.modal h3 { font-size: 21px; font-weight: 800; }
|
||||
.modal .msub { font-size: 12.5px; color: #868e96; font-weight: 700; margin: 3px 0 16px; }
|
||||
.modal input {
|
||||
width: 100%; padding: 10px 14px; border: 2.5px solid #2b2b2b;
|
||||
border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
|
||||
font-family: inherit; font-size: 14px; font-weight: 600; outline: none;
|
||||
margin-bottom: 12px; background: #fff;
|
||||
}
|
||||
.modal input:focus { background: #fff9db; }
|
||||
.modal .mrow { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
|
||||
.modal .pwd-msg {
|
||||
margin-bottom: 12px; background: #ffe3e3; color: #c92a2a;
|
||||
padding: 9px 12px; font-weight: 700; font-size: 12.5px;
|
||||
border: 2.5px dashed #c92a2a;
|
||||
border-radius: 15px 255px 15px 255px / 255px 15px 255px 15px;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.stats { grid-template-columns: repeat(2, 1fr); }
|
||||
th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5) { display: none; }
|
||||
.header .pin.r { display: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<!-- 登录界面 -->
|
||||
<div class="login-wrap" v-if="!loggedIn">
|
||||
<div class="login-card">
|
||||
<span class="tape"></span>
|
||||
<span class="pin">📌</span>
|
||||
<div class="emblem">37</div>
|
||||
<h2>文件服务器管理</h2>
|
||||
<div class="login-sub">37DU 内网文件服务器 · 管理台</div>
|
||||
<div class="login-field">
|
||||
<input type="text" v-model="username" placeholder="账号" @keyup.enter="login">
|
||||
</div>
|
||||
<div class="login-field">
|
||||
<input :type="showPwd ? 'text' : 'password'" v-model="password" placeholder="密码" @keyup.enter="login">
|
||||
<span class="eye" @click="showPwd = !showPwd">{{ showPwd ? '🙈' : '👁' }}</span>
|
||||
</div>
|
||||
<button class="btn btn-primary" @click="login" :disabled="loggingIn">{{ loggingIn ? "登录中…" : "登 录" }}</button>
|
||||
<div class="login-hint">初始账号 puddy / 123456,登录后请尽快修改密码</div>
|
||||
<div class="login-msg" v-if="loginMsg">{{ loginMsg }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主界面 -->
|
||||
<template v-else>
|
||||
<div class="header">
|
||||
<span class="pin l">📌</span>
|
||||
<span class="pin r">📌</span>
|
||||
<div class="brand">
|
||||
<div class="emblem">37</div>
|
||||
<div>
|
||||
<h1>文件服务器管理 <span class="squiggle"></span></h1>
|
||||
<div class="sub">{{ baseUrl }} · 登录用户:{{ tokenUser }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn" @click="openPwdModal">改密码</button>
|
||||
<button class="btn" @click="logout">退出</button>
|
||||
<button class="btn btn-primary" @click="load">↻ 刷新</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats">
|
||||
<div class="stat"><span class="tape"></span><div class="k">文件数</div><div class="v">{{ totalCount }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">总大小</div><div class="v">{{ totalSizeText }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">总下载</div><div class="v">{{ totalDownloads }}</div></div>
|
||||
<div class="stat"><span class="tape"></span><div class="k">最近上传</div><div class="v" style="font-size:15px;line-height:1.4">{{ lastUploadText }}</div></div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<input type="text" v-model="keyword" placeholder="搜索文件名…">
|
||||
<label class="btn btn-success upload-btn">
|
||||
⬆ 上传文件
|
||||
<input type="file" multiple @change="onFilesPicked">
|
||||
</label>
|
||||
<span v-if="uploading" class="tag">上传 {{ uploadIdx }}/{{ uploadTotal }} {{ uploadPercent }}%</span>
|
||||
<span class="hint" style="flex:1"></span>
|
||||
<span class="hint">点击表头排序 · 元数据存 MySQL</span>
|
||||
</div>
|
||||
|
||||
<div class="status-bar" :class="statusClass">{{ statusMsg }}</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="loading" v-if="loading"><span class="pen">✏️</span> 翻本子中…</div>
|
||||
<div class="card" v-else>
|
||||
<span class="tape"></span>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:42px">#</th>
|
||||
<th @click="sortBy('filename')">文件名<span class="arrow" v-if="sortKey==='filename'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:90px" @click="sortBy('size')">大小<span class="arrow" v-if="sortKey==='size'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:160px" @click="sortBy('created')">上传时间<span class="arrow" v-if="sortKey==='created'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:90px">上传人</th>
|
||||
<th style="width:70px" @click="sortBy('downloads')">下载<span class="arrow" v-if="sortKey==='downloads'">{{ sortDir===1?'▲':'▼' }}</span></th>
|
||||
<th style="width:190px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody v-if="sortedFiles.length">
|
||||
<tr v-for="(f, i) in sortedFiles" :key="f.fid">
|
||||
<td style="color:#adb5bd;font-weight:800">{{ i + 1 }}</td>
|
||||
<td>
|
||||
<div class="fname-cell">
|
||||
<span class="filename">{{ f.filename }}</span>
|
||||
<span class="fname-meta">
|
||||
<span class="ext">{{ extOf(f.filename) }}</span>
|
||||
<span class="sha" :title="f.sha256">{{ shortSha(f.sha256) }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ fmtSize(f.size) }}</td>
|
||||
<td>{{ fmtTime(f.created) }}</td>
|
||||
<td><span class="who" :class="f.uploader==='center'?'center':''">{{ whoLabel(f.uploader) }}</span></td>
|
||||
<td>{{ f.downloads || 0 }}</td>
|
||||
<td>
|
||||
<a class="dl" :href="downloadUrl(f)" target="_blank" rel="noopener">下载</a>
|
||||
<a class="cp" href="javascript:;" @click="copyLink(f)">复制</a>
|
||||
<a class="rm" href="javascript:;" @click="remove(f)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody v-else>
|
||||
<tr><td colspan="7">
|
||||
<div class="empty">
|
||||
<svg width="150" height="120" viewBox="0 0 150 120" fill="none" stroke="#2b2b2b" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M20 36 Q22 31 27 31 L56 31 L67 41 L129 41"/>
|
||||
<path d="M15 41 L135 41 Q139 42 139 46 L139 96 Q139 101 134 101 L16 101 Q11 101 11 96 L11 46 Q11 42 15 41 Z"/>
|
||||
<path d="M18 51 L132 51" stroke="#ffd43b" stroke-width="5" opacity=".65"/>
|
||||
<path d="M96 22 L110 13"/>
|
||||
<path d="M112 28 L128 20"/>
|
||||
<path d="M86 14 L92 4"/>
|
||||
<path d="M102 8 l13 8 -6 10 -13 -8 z" transform="rotate(-12 108 17)"/>
|
||||
<path d="M82 4 l10 6 -5 8 -10 -6 z" transform="rotate(-30 87 11)"/>
|
||||
</svg>
|
||||
<div class="et">📭 暂无文件{{ keyword ? '(与搜索条件匹配)' : '' }}</div>
|
||||
</div>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="footer">
|
||||
<span>37DU <span class="dot">✏️</span> 内网文件服务器</span>
|
||||
<span>DOODLE ADMIN v2.2</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 修改密码弹窗 -->
|
||||
<div class="mask" v-if="showPwdModal">
|
||||
<div class="modal">
|
||||
<span class="tape"></span>
|
||||
<h3>修改密码</h3>
|
||||
<div class="msub">修改后需重新登录</div>
|
||||
<div class="pwd-msg" v-if="pwdMsg">{{ pwdMsg }}</div>
|
||||
<input type="password" v-model="oldPwd" placeholder="旧密码">
|
||||
<input type="password" v-model="newPwd" placeholder="新密码(至少 6 位)">
|
||||
<input type="password" v-model="newPwd2" placeholder="确认新密码">
|
||||
<div class="mrow">
|
||||
<button class="btn" @click="closePwdModal">取消</button>
|
||||
<button class="btn btn-primary" @click="changePwd" :disabled="savingPwd">{{ savingPwd ? "保存中…" : "保存" }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<script src="/vue.global.prod.js"></script>
|
||||
<script src="/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user