Files
it-tools-pro/src/pages/Admin.page.vue
T

1650 lines
49 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useHead } from '@vueuse/head';
import { useUserAuth } from '@/composable/user-auth';
import { useToolStore } from '@/tools/tools.store';
useHead({ title: '管理后台 - IT-TOOLS-PRO' });
const { username: adminName, login: authLogin, logout: authLogout, isAdmin } = useUserAuth();
const TOKEN_KEY = 'it-tools-admin-token';
const token = ref(localStorage.getItem(TOKEN_KEY) ?? '');
const authed = ref(false);
const error = ref('');
const busy = ref(false);
const loginUser = ref('');
const loginPass = ref('');
function authHeaders(): Record<string, string> {
const h: Record<string, string> = {};
if (token.value) {
// Bearer = logged-in admin session (channel 2); X-Admin-Token = bootstrap
// ADMIN_TOKEN paste flow (channel 1). Send both so either kind works.
h['Authorization'] = `Bearer ${token.value}`;
h['X-Admin-Token'] = token.value;
}
return h;
}
async function api(path: string, init: RequestInit = {}) {
const res = await fetch(`/relay${path}`, {
...init,
headers: {
'Content-Type': 'application/json',
...authHeaders(),
...(init.headers ?? {}),
},
});
if (res.status === 403) {
authed.value = false;
throw new Error('无权限或登录已失效');
}
return res.json();
}
async function login() {
busy.value = true;
error.value = '';
try {
// channel A: admin account login (normal flow)
if (loginUser.value && loginPass.value) {
await authLogin(loginUser.value.trim(), loginPass.value);
if (!isAdmin.value) {
authLogout();
throw new Error('该账号不是管理员');
}
const auth = JSON.parse(localStorage.getItem('it-tools-auth') ?? '{}');
token.value = auth.token ?? '';
localStorage.setItem(TOKEN_KEY, token.value);
}
// verify access (also supports the bootstrap ADMIN_TOKEN pasted below)
const b = await api('/admin/overview');
if (b.code === 200) {
authed.value = true;
localStorage.setItem(TOKEN_KEY, token.value);
loadOverview();
loadFeedback();
}
}
catch (e: any) {
error.value = String(e?.message || e);
}
finally {
busy.value = false;
}
}
// ============ 总览 ============
const overview = ref<any>(null);
const users = computed(() => overview.value?.users ?? []);
const totals = computed(() => overview.value?.totals ?? { users: 0, files: 0, size: 0 });
function fmtSize(n: number) {
if (n > 1024 * 1024 * 1024) {
return (n / 1024 / 1024 / 1024).toFixed(2) + ' GB';
}
if (n > 1024 * 1024) {
return (n / 1024 / 1024).toFixed(1) + ' MB';
}
if (n > 1024) {
return (n / 1024).toFixed(1) + ' KB';
}
return n + ' B';
}
function fmtDate(t: number) {
if (!t) {
return '-';
}
const d = new Date(t * 1000);
const pad = (n: number) => String(n).padStart(2, '0');
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
}
async function loadOverview() {
const b = await api('/admin/overview');
overview.value = b.data;
}
// ============ 文件管理(默认全量聚合,50 条/页自动分页)============
const fileUser = ref(''); // ''=全部, '__gen__'=AI生成, 其他=指定用户
const fileKind = ref(''); // 按功能筛选:''=全部功能, '__none__'=未分类, 其他=kind 原值
const fileKinds = ref<{ k: string; n: number }[]>([]); // 后端返回的 kind 分布(带计数)
const KIND_LABELS: Record<string, string> = {
gen: 'AI 生图', edit: 'AI 图片编辑', 'face-swap': 'AI 换脸', retouch: 'AI 修图',
'text-edit': 'AI 文字编辑', poster: 'AI 海报', 'text-to-image': '文字生图',
'image-lab': 'AI 图片实验室', 'image-tools': '图片工具', 'label-designer': '标签设计',
'pdf-tools': 'PDF 工具', ocr: 'OCR 识别', mcp: 'MCP 产出', __none__: '未分类',
};
function kindLabel(k: string) {
return KIND_LABELS[k] || k || '未分类';
}
const fileList = ref<any[]>([]);
const fileTotal = ref(0); // 合计字节数
const fileCount = ref(0); // 总记录数
const filePage = ref(1);
const filePages = ref(1);
const FILE_PAGE_SIZE = 50;
const cleanupDays = ref(7);
const cleanupUser = ref('');
const cleanupResult = ref('');
async function loadFiles() {
const q = new URLSearchParams();
if (fileUser.value === '__gen__') q.set('scope', 'gen');
else if (fileUser.value) q.set('username', fileUser.value);
if (fileKind.value) q.set('kind', fileKind.value);
q.set('page', String(filePage.value));
q.set('page_size', String(FILE_PAGE_SIZE));
const b = await api(`/admin/files?${q}`);
fileList.value = b.data?.files ?? [];
fileKinds.value = b.data?.kinds ?? [];
fileTotal.value = b.data?.total_size ?? 0;
fileCount.value = b.data?.total ?? 0;
filePages.value = b.data?.pages ?? 1;
filePage.value = b.data?.page ?? 1;
}
function gotoFilePage(p: number) {
filePage.value = Math.min(Math.max(1, p), filePages.value);
loadFiles();
}
// 文件直链:缩略图 <img> 与下载 <a> 无法携带 header,鉴权走 ?token=
function fileUrl(f: any, dl = false) {
const q = new URLSearchParams();
q.set('path', f.path || '');
if (f.name) q.set('name', f.name);
if (dl) q.set('dl', '1');
if (token.value) q.set('token', token.value);
return `/relay/admin/file?${q}`;
}
function windowOpen(url: string) {
window.open(url, '_blank', 'noopener');
}
function fileOwner(f: any) {
if (f.source === 'gen') return f.machine || 'AI';
if (f.source === 'mcp') return 'MCP';
return f.username || f.source || '-';
}
async function delFile(f: any) {
const body: any = { id: f.id };
if (f.source === 'gen') {
body.username = '__gen__';
body.machine = f.machine;
} else if (f.source === 'mcp') {
body.username = '__mcp__';
} else {
body.username = f.username || fileUser.value;
}
const b = await api('/admin/delete-file', { method: 'POST', body: JSON.stringify(body) });
if (b.code === 200) {
await loadFiles();
loadOverview();
}
}
async function cleanup() {
if (!window.confirm(`确认删除 ${cleanupUser.value || '全部用户'} 在 ${cleanupDays.value} 天前的所有云端文件?不可恢复!`)) {
return;
}
const before = Math.floor(Date.now() / 1000) - cleanupDays.value * 86400;
const b = await api('/admin/cleanup', {
method: 'POST',
body: JSON.stringify({ before, username: cleanupUser.value }),
});
if (b.code === 200) {
cleanupResult.value = `已删除 ${b.data.removed} 个文件,释放 ${fmtSize(b.data.freed)}`;
loadOverview();
filePage.value = 1;
loadFiles();
}
}
function pickUser(u: string) {
fileUser.value = u;
cleanupUser.value = u;
tab.value = 'files';
filePage.value = 1;
loadFiles();
}
// ============ 用户管理 ============
const showAdd = ref(false);
const addName = ref('');
const addPass = ref('');
const addRole = ref('user');
const adminMsg = ref('');
function setMsg(m: string) {
adminMsg.value = m;
setTimeout(() => (adminMsg.value = ''), 3500);
}
async function addUser() {
const b = await api('/admin/user-create', {
method: 'POST',
body: JSON.stringify({ username: addName.value.trim(), password: addPass.value, role: addRole.value }),
});
if (b.code === 200) {
setMsg(`用户 ${addName.value} 已创建`);
addName.value = '';
addPass.value = '';
showAdd.value = false;
loadOverview();
}
else {
setMsg(b.message || '创建失败');
}
}
async function toggleDisabled(u: any) {
const b = await api('/admin/user-update', {
method: 'POST',
body: JSON.stringify({ username: u.username, disabled: !u.disabled }),
});
if (b.code === 200) {
setMsg(u.disabled ? `已启用 ${u.username}` : `已禁用 ${u.username}`);
loadOverview();
}
else {
setMsg(b.message || '操作失败');
}
}
async function resetPassword(u: any) {
const np = window.prompt(`为 ${u.username} 设置新密码(至少 6 位):`);
if (!np) {
return;
}
const b = await api('/admin/user-update', {
method: 'POST',
body: JSON.stringify({ username: u.username, password: np }),
});
setMsg(b.code === 200 ? `已重置 ${u.username} 的密码` : (b.message || '失败'));
}
async function toggleRole(u: any) {
if (u.username === 'jinghui') {
setMsg('默认管理员不可降级');
return;
}
const b = await api('/admin/user-update', {
method: 'POST',
body: JSON.stringify({ username: u.username, role: u.role === 'admin' ? 'user' : 'admin' }),
});
if (b.code === 200) {
setMsg('角色已更新');
loadOverview();
}
else {
setMsg(b.message || '失败');
}
}
async function deleteUser(u: any) {
if (!window.confirm(`确认删除用户 ${u.username}?其云端文件与数据将一并删除,不可恢复!`)) {
return;
}
const b = await api('/admin/user-delete', {
method: 'POST',
body: JSON.stringify({ username: u.username }),
});
if (b.code === 200) {
setMsg(`已删除 ${u.username}`);
loadOverview();
}
else {
setMsg(b.message || '失败');
}
}
// ============ 存储设置 ============
const storage = ref<any>(null);
const newRoot = ref('');
async function loadStorage() {
const b = await api('/admin/storage');
storage.value = b.data;
if (b.data?.root) {
newRoot.value = b.data.root;
}
}
async function saveStorage() {
if (!window.confirm(`确认将文件存储路径修改为 ${newRoot.value}?现有数据将自动迁移,服务随即重启(约几秒恢复)。`)) {
return;
}
const b = await api('/admin/storage', { method: 'POST', body: JSON.stringify({ root: newRoot.value }) });
if (b.code === 200) {
setMsg(`已切换到 ${b.data.root}(${(b.data.moved ?? []).length} 项已迁移),服务重启中…`);
setTimeout(() => loadStorage(), 6000);
}
else {
setMsg(b.message || '修改失败');
}
}
// ============ 使用统计 ============
const usageDays = ref(7);
const usage = ref<any>(null);
// 用户活跃排行 = 登录用户 + 未登录访客(访客功能使用也统计展示)
const userRows = computed(() => {
const rows: { username: string; count: number; last: number }[] = [...(usage.value?.by_user ?? [])];
const g = usage.value?.guest;
if (g && g.count > 0) {
rows.push({ username: '__guest__', count: g.count, last: g.last });
}
return rows.sort((a, b) => b.count - a.count);
});
async function loadUsage() {
const b = await api(`/admin/usage?days=${usageDays.value}`);
usage.value = b.data;
}
// ============ MCP 调用记录 ============
const mcpDays = ref(7);
const mcpData = ref<any>(null);
async function loadMcpUsage() {
const b = await api(`/admin/mcp-usage?days=${mcpDays.value}`);
mcpData.value = b.data;
}
const TOOL_LABELS: Record<string, string> = {
'translator': '在线翻译',
'image-ocr': '图片OCR',
'pdf-ocr': 'PDF文字识别',
'ai-retouch': 'AI修图',
'label-designer': '面单设计',
'doc-convert': '文档格式转换',
'image-tools': '图片工具',
'pdf-tools': 'PDF工具',
'video-tools': '视频工具',
'audio-tools': '音频工具',
'audio-tools-tts': '音频工具·文字转语音',
'audio-tools-asr': '音频工具·语音识别',
};
function toolLabel(t: string) {
if (TOOL_LABELS[t]) {
return TOOL_LABELS[t];
}
// 前端上报的是工具路径(如 json-to-xml),回退查工具目录显示名称
const hit = toolStore.tools.find((x: any) => x.path === `/${t}` || x.path === t);
return hit?.name || t;
}
function fmtTime(t: number) {
if (!t) {
return '-';
}
const d = new Date(t * 1000);
const pad = (n: number) => String(n).padStart(2, '0');
return `${d.getMonth() + 1}/${d.getDate()} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
}
// ============ tabs ============
// ============ 首页推荐 ============
const reco = ref<any[]>([]);
const recoBusy = ref(false);
// 工具下拉数据:全部工具按分类分组(选择已有功能,无需手填 path/名称)
const toolStore = useToolStore();
const toolGroups = computed(() => {
const byCat = new Map<string, { path: string; name: string; description: string }[]>();
for (const t of toolStore.tools) {
const c = t.category || '其他';
if (!byCat.has(c)) {
byCat.set(c, []);
}
byCat.get(c)!.push({ path: t.path, name: t.name, description: t.description });
}
return [...byCat.entries()]
.map(([cat, list]) => ({ cat, list: [...list].sort((a, b) => a.name.localeCompare(b.name, 'zh')) }))
.sort((a, b) => a.cat.localeCompare(b.cat, 'zh'));
});
const toolMap = computed(() => new Map(toolStore.tools.map(t => [t.path, t])));
// 常见工具 emoji:选中工具时自动填图标
const RECO_EMOJI: Record<string, string> = {
'/ai-chat': '🤖', '/ai-image-lab': '🪄', '/ai-retouch': '🎨', '/copywriting': '✍️',
'/video-tools': '🎥', '/audio-tools': '🎙️', '/seal-maker': '🔴', '/signature-pad': '✍️',
'/zh-convert': '🈶', '/pinyin-converter': '🀄', '/user-center': '👤', '/pricing': '🔑',
'/image-ocr': '🔍', '/pdf-ocr': '📄', '/image-tools': '🖼️', '/pdf-tools': '📑',
'/doc-convert': '🔄', '/text-to-image': '🖼️', '/qrcode-generator': '📱', '/encryption': '🔒',
'/hash-text': '#️⃣', '/jwt-parser': '🎫', '/regex-tester': ' .*', '/json-prettify': '{ }',
'/lorem-ipsum-generator': '📝', '/password-strength-analyser': '🔐', '/color-converter': '🎨',
'/markdown-to-html': 'MD', '/base64-string-converter': '64', '/random-port-generator': '🔌',
'/crontab-generator': '⏰', '/uuid-generator': '🆔', '/token-generator': '🎟️',
'/site-bookmarks': '🔖', '/label-designer': '🏷️', '/emoji-picker': '😀', '/git-memo': '🐙',
'/camera-recorder': '📷', '/chronometer': '⏱️', '/device-information': '💻', '/math-evaluator': '🧮',
};
function emojiFor(path: string) {
return RECO_EMOJI[path] || '🧰';
}
// 选中工具:自动填 名称 / 描述 / 图标(无需手动输入)
function onToolPick(it: any) {
const t = toolMap.value.get(it.path);
if (t) {
it.name = t.name;
it.desc = t.description;
it.icon = emojiFor(t.path);
}
}
async function loadReco() {
const b = await api('/admin/reco');
reco.value = (b.data ?? []).map((x: any) => ({ ...x }));
}
async function saveReco() {
recoBusy.value = true;
try {
const b = await api('/admin/reco', { method: 'POST', body: JSON.stringify({ items: reco.value }) });
setMsg(b.code === 200 ? '首页推荐已保存,首页立即生效' : (b.message || '保存失败'));
}
finally {
recoBusy.value = false;
}
}
// ============ 留言反馈(网站访客提交,与授权系统无关) ============
const feedback = ref<any[]>([]);
async function loadFeedback() {
try {
const b = await api('/admin/feedback');
feedback.value = b.data ?? [];
} catch (e: any) {
setMsg(`留言加载失败:${e.message}`);
}
}
async function fbSetStatus(f: any, status: string) {
try {
const b = await api('/admin/feedback', { method: 'POST', body: JSON.stringify({ id: f.id, status }) });
setMsg(b.code === 200 ? '已更新留言状态' : (b.message || '状态更新失败'));
if (b.code === 200) f.status = status;
} catch (e: any) {
setMsg(`状态更新失败:${e.message}`);
}
}
function fbOnStatus(f: any, e: Event) {
fbSetStatus(f, (e.target as HTMLSelectElement).value);
}
async function fbDelete(f: any) {
if (!window.confirm('确定删除这条留言?删除后无法恢复。')) return;
try {
const b = await api('/admin/feedback', { method: 'POST', body: JSON.stringify({ id: f.id, action: 'delete' }) });
setMsg(b.code === 200 ? '已删除' : (b.message || '删除失败'));
if (b.code === 200) feedback.value = feedback.value.filter(x => x.id !== f.id);
} catch (e: any) {
setMsg(`删除失败:${e.message}`);
}
}
function fbTime(ts: any) {
try {
const d = new Date(Number(ts) * 1000);
const p = (n: number) => String(n).padStart(2, '0');
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`;
} catch {
return String(ts ?? '');
}
}
const fbNewCount = computed(() => feedback.value.filter(f => f.status === 'new').length);
function recoAdd() {
reco.value.unshift({ path: '', icon: '🧰', name: '', desc: '', enabled: true });
}
function recoDel(i: number) {
reco.value.splice(i, 1);
}
function recoMove(i: number, d: -1 | 1) {
const j = i + d;
if (j < 0 || j >= reco.value.length) {
return;
}
const [it] = reco.value.splice(i, 1);
reco.value.splice(j, 0, it);
}
const tab = ref<'overview' | 'files' | 'usage' | 'mcp' | 'storage' | 'reco' | 'feedback'>('overview');
// 在线人数 30s 自动刷新(切走用量页签即停)
let usageTimer: ReturnType<typeof setInterval> | null = null;
function switchTab(id: 'overview' | 'files' | 'usage' | 'mcp' | 'storage' | 'reco' | 'feedback') {
if (usageTimer) {
clearInterval(usageTimer);
usageTimer = null;
}
tab.value = id;
if (id === 'overview') {
loadOverview();
}
if (id === 'reco') {
loadReco();
}
if (id === 'usage') {
loadUsage();
usageTimer = setInterval(loadUsage, 30000);
}
if (id === 'mcp') {
loadMcpUsage();
}
if (id === 'storage') {
loadStorage();
}
if (id === 'feedback') {
loadFeedback();
}
if (id === 'files') {
loadFiles();
}
}
</script>
<template>
<div class="adm-root">
<!-- login -->
<div v-if="!authed" class="adm-login">
<div class="adm-login-box">
<div class="adm-login-title">🛠️ 管理后台</div>
<input v-model="loginUser" class="adm-input" placeholder="管理员账号" autocomplete="username" @keyup.enter="login">
<input v-model="loginPass" class="adm-input" type="password" placeholder="密码" autocomplete="current-password" @keyup.enter="login">
<div v-if="error" class="adm-error">{{ error }}</div>
<button class="adm-btn" :disabled="busy || !loginUser || !loginPass" @click="login">
{{ busy ? '验证中…' : '登录后台' }}
</button>
<div class="adm-login-alt">
或粘贴应急令牌:<input v-model="token" class="adm-token-input" type="password" placeholder="ADMIN_TOKEN" @keyup.enter="login">
</div>
</div>
</div>
<!-- panel -->
<div v-else>
<div class="adm-topbar">
<div class="adm-nav-title">🛠️ 管理后台</div>
<div class="adm-nav">
<div class="adm-nav-item" :class="{ active: tab === 'overview' }" @click="switchTab('overview')">📊 总览与用户</div>
<div class="adm-nav-item" :class="{ active: tab === 'files' }" @click="switchTab('files')">📁 文件管理</div>
<div class="adm-nav-item" :class="{ active: tab === 'usage' }" @click="switchTab('usage')">📈 使用统计</div>
<div class="adm-nav-item" :class="{ active: tab === 'mcp' }" @click="switchTab('mcp')">🤖 MCP 调用</div>
<div class="adm-nav-item" :class="{ active: tab === 'storage' }" @click="switchTab('storage')">💾 存储设置</div>
<div class="adm-nav-item" :class="{ active: tab === 'reco' }" @click="switchTab('reco')">🏠 首页推荐</div>
<div class="adm-nav-item" :class="{ active: tab === 'feedback' }" @click="switchTab('feedback')">
💬 留言反馈
<span v-if="fbNewCount > 0" class="adm-badge bad" style="margin-left: 6px">{{ fbNewCount }}</span>
</div>
</div>
<a href="javascript:;" class="adm-logout" @click="authed = false; localStorage.removeItem(TOKEN_KEY)">退出</a>
</div>
<div class="adm-main">
<!-- overview -->
<template v-if="tab === 'overview'">
<div class="adm-cards">
<div class="adm-card"><div class="adm-card-num">{{ totals.users }}</div><div class="adm-card-label">注册用户</div></div>
<div class="adm-card"><div class="adm-card-num">{{ totals.files }}</div><div class="adm-card-label">云端文件</div></div>
<div class="adm-card"><div class="adm-card-num">{{ fmtSize(totals.size) }}</div><div class="adm-card-label">总占用</div></div>
</div>
<div class="adm-userbar">
<h3 class="adm-h3" style="margin: 0">用户列表 <span class="adm-sub">按占用排序,点击用户名查看文件</span></h3>
<div class="adm-userbar-right">
<span v-if="adminMsg" class="adm-ok">{{ adminMsg }}</span>
<button class="adm-btn adm-btn-sm" @click="showAdd = !showAdd">+ 添加用户</button>
</div>
</div>
<div v-if="showAdd" class="adm-addbox">
<input v-model="addName" class="adm-mini-input" placeholder="用户名(3-32位)">
<input v-model="addPass" class="adm-mini-input" type="password" placeholder="密码(至少6位)">
<select v-model="addRole" class="adm-select">
<option value="user">普通用户</option>
<option value="admin">管理员</option>
</select>
<button class="adm-btn adm-btn-sm" :disabled="!addName || addPass.length < 6" @click="addUser">创建</button>
</div>
<table class="adm-table">
<thead>
<tr><th>用户名</th><th>角色</th><th>状态</th><th>文件数</th><th>文件占用</th><th>设备</th><th>授权</th><th>注册</th><th>最后登录</th><th>操作</th></tr>
</thead>
<tbody>
<tr v-for="u in users" :key="u.username">
<td class="adm-user" @click="pickUser(u.username)">{{ u.username }}</td>
<td><span class="adm-badge" :class="u.role === 'admin' ? 'admin' : ''">{{ u.role === 'admin' ? '管理员' : '用户' }}</span></td>
<td><span class="adm-badge" :class="u.disabled ? 'bad' : 'ok'">{{ u.disabled ? '已禁用' : '正常' }}</span></td>
<td>{{ u.files }}</td>
<td>{{ fmtSize(u.file_size) }}</td>
<td>{{ u.devices }}</td>
<td><span class="adm-badge" :class="u.licensed ? 'ok' : ''">{{ u.licensed ? '已授权' : '-' }}</span></td>
<td>{{ fmtDate(u.created) }}</td>
<td>{{ u.last_login ? fmtDate(u.last_login) : '未登录' }}</td>
<td class="adm-ops">
<a href="javascript:;" class="adm-link" @click="pickUser(u.username)">文件</a>
<a href="javascript:;" class="adm-link" @click="resetPassword(u)">改密</a>
<a href="javascript:;" class="adm-link" @click="toggleRole(u)">{{ u.role === 'admin' ? '降为用户' : '升管理员' }}</a>
<a href="javascript:;" :class="u.disabled ? 'adm-link' : 'adm-del'" @click="toggleDisabled(u)">{{ u.disabled ? '启用' : '禁用' }}</a>
<a v-if="u.username !== 'jinghui'" href="javascript:;" class="adm-del" @click="deleteUser(u)">删除</a>
</td>
</tr>
<tr v-if="!users.length"><td colspan="10" class="adm-none">暂无注册用户</td></tr>
</tbody>
</table>
</template>
<!-- files -->
<template v-if="tab === 'files'">
<div class="adm-toolbar">
<select v-model="fileUser" class="adm-select" @change="filePage = 1; loadFiles()">
<option value="">全部(所有用户 + AI 生成 + MCP)</option>
<option value="__gen__">仅 AI 生成图片(换脸/生图/海报)</option>
<option v-for="u in users" :key="u.username" :value="u.username">仅 {{ u.username }}</option>
</select>
<select v-model="fileKind" class="adm-select" title="按功能查询文件" @change="filePage = 1; loadFiles()">
<option value="">全部功能</option>
<option v-for="k in fileKinds" :key="k.k" :value="k.k">{{ kindLabel(k.k) }}({{ k.n }})</option>
</select>
<span class="adm-sub">共 {{ fileCount }} 条记录 · 合计 {{ fmtSize(fileTotal) }}</span>
<span v-if="filePages > 1" class="adm-pager">
<button class="adm-btn adm-btn-sm" :disabled="filePage <= 1" @click="gotoFilePage(filePage - 1)">‹ 上一页</button>
<span class="adm-pageinfo">第 {{ filePage }} / {{ filePages }} 页</span>
<button class="adm-btn adm-btn-sm" :disabled="filePage >= filePages" @click="gotoFilePage(filePage + 1)">下一页 ›</button>
</span>
</div>
<div class="adm-cleanup">
<b>🗑️ 按日期清理</b>
<select v-model="cleanupUser" class="adm-select">
<option value="">全部用户</option>
<option v-for="u in users" :key="u.username" :value="u.username">{{ u.username }}</option>
</select>
<select v-model.number="cleanupDays" class="adm-select">
<option :value="1">1 天前</option>
<option :value="3">3 天前</option>
<option :value="7">7 天前</option>
<option :value="14">14 天前</option>
<option :value="30">30 天前</option>
<option :value="90">90 天前</option>
</select>
<button class="adm-btn adm-btn-sm" @click="cleanup">执行清理</button>
<span v-if="cleanupResult" class="adm-ok">{{ cleanupResult }}</span>
</div>
<div class="adm-fscroll">
<table class="adm-table">
<thead>
<tr><th class="adm-thumbcol">预览</th><th>文件</th><th>来源</th><th>类型</th><th>大小</th><th>时间</th><th></th></tr>
</thead>
<tbody>
<tr v-for="f in fileList" :key="(f.source || '') + ':' + (f.machine || '') + ':' + f.id">
<td class="adm-thumbcell">
<img v-if="f.is_image" class="adm-thumb" :src="fileUrl(f)" alt="" @click="windowOpen(fileUrl(f))">
<span v-else class="adm-ftype">{{ f.file_type || '文件' }}</span>
</td>
<td class="adm-fname" :title="f.prompt || f.name">{{ f.name }}</td>
<td>{{ fileOwner(f) }}</td>
<td>{{ kindLabel(f.kind || '__none__') }}</td>
<td>{{ fmtSize(f.size) }}</td>
<td>{{ fmtTime(f.mtime) }}</td>
<td class="adm-ops">
<a :href="fileUrl(f, true)" class="adm-dl" download>下载</a>
<a href="javascript:;" class="adm-del" @click="delFile(f)">删除</a>
</td>
</tr>
<tr v-if="!fileList.length"><td colspan="7" class="adm-none">暂无文件</td></tr>
</tbody>
</table>
</div>
<div v-if="filePages > 1" class="adm-pager adm-pager-b">
<button class="adm-btn adm-btn-sm" :disabled="filePage <= 1" @click="gotoFilePage(filePage - 1)">‹ 上一页</button>
<span class="adm-pageinfo">第 {{ filePage }} / {{ filePages }} 页 · 共 {{ fileCount }} 条</span>
<button class="adm-btn adm-btn-sm" :disabled="filePage >= filePages" @click="gotoFilePage(filePage + 1)">下一页 ›</button>
</div>
</template>
<!-- storage -->
<template v-if="tab === 'storage'">
<h3 class="adm-h3">💾 文件存储设置 <span class="adm-sub">用户上传文件与云端数据的实际存放位置</span></h3>
<div class="adm-storage-info" v-if="storage">
<div class="adm-storage-row">
<span class="adm-storage-label">当前存储目录</span>
<code class="adm-storage-path">{{ storage.root }}</code>
</div>
<div class="adm-storage-row">
<span class="adm-storage-label">用户文件结构</span>
<code class="adm-storage-path">{{ storage.root }}/users/&lt;用户名&gt;/files/&lt;工具名&gt;/</code>
</div>
<div class="adm-storage-row">
<span class="adm-storage-label">当前总占用</span>
<b>{{ fmtSize(storage.size) }}</b>
</div>
<div class="adm-storage-tip">
💡 这里显示的是<strong>宿主机真实路径</strong>,在宿主机上可直接访问(如 <code>ls {{ storage.root }}/users</code>)。
常用场景:系统盘(/vol1)空间不足时,把存储切到数据盘(/vol2)。
</div>
</div>
<div class="adm-storage-edit">
<b>修改宿主机存储目录</b>
<input v-model="newRoot" class="adm-storage-input" placeholder="宿主机绝对路径,如 /vol2/1000/HD2/it-tools-data">
<button class="adm-btn adm-btn-sm" @click="saveStorage">保存并重启</button>
<span v-if="adminMsg" class="adm-ok">{{ adminMsg }}</span>
</div>
<div class="adm-storage-note">
修改后:现有用户文件与数据库<strong>自动迁移</strong>到新目录(宿主机上直接移动),服务自动重启生效(约几秒)。
系统目录(/etc、/usr、/root 等)禁止使用;请确保目标磁盘已挂载(如 /vol1、/vol2)。
</div>
</template>
<!-- reco -->
<template v-if="tab === 'reco'">
<div class="adm-toolbar">
<h3 class="adm-h3" style="margin:0">🏠 首页推荐管理 <span class="adm-sub">配置首页「⭐ 精选推荐」展示的工具,下拉选择已有功能,按顺序排列,可启停</span></h3>
<button class="adm-btn adm-btn-sm" @click="recoAdd">+ 添加推荐</button>
<button class="adm-btn adm-btn-sm adm-btn-primary" :disabled="recoBusy" @click="saveReco">{{ recoBusy ? '保存中…' : '💾 保存并发布' }}</button>
<span v-if="adminMsg" class="adm-ok">{{ adminMsg }}</span>
</div>
<div class="adm-reco-list">
<div v-for="(it, i) in reco" :key="i" class="adm-reco-row">
<span class="adm-reco-ord">{{ i + 1 }}</span>
<input v-model="it.icon" class="adm-reco-icon" maxlength="4" title="图标(emoji),选中工具自动填">
<select v-model="it.path" class="adm-reco-sel" :title="it.path || '选择工具'" @change="onToolPick(it)">
<option value="" disabled>▼ 选择工具</option>
<optgroup v-for="g in toolGroups" :key="g.cat" :label="g.cat">
<option v-for="t in g.list" :key="t.path" :value="t.path">{{ t.name }}</option>
</optgroup>
</select>
<input v-model="it.desc" class="adm-reco-desc" placeholder="描述(选中工具自动填)">
<label class="adm-reco-on"><input v-model="it.enabled" type="checkbox"> 显示</label>
<span class="adm-reco-ops">
<button class="adm-mini" :disabled="i === 0" @click="recoMove(i, -1)" title="上移">↑</button>
<button class="adm-mini" :disabled="i === reco.length - 1" @click="recoMove(i, 1)" title="下移">↓</button>
<button class="adm-mini adm-mini-del" @click="recoDel(i)" title="删除">✕</button>
</span>
</div>
<div v-if="!reco.length" class="adm-empty">暂无推荐项,点右上「添加推荐」新增</div>
</div>
<div class="adm-storage-note" style="margin-top:10px">
💡 点「保存并发布」后首页「⭐ 精选推荐」立即生效,所有访客可见。下拉框直接选择已有工具(自动填名称/描述/图标),未启用的项不显示。
</div>
</template>
<!-- usage -->
<template v-if="tab === 'usage'">
<div class="adm-toolbar">
<select v-model.number="usageDays" class="adm-select" @change="loadUsage">
<option :value="7">近 7 天</option>
<option :value="30">近 30 天</option>
<option :value="90">近 90 天</option>
</select>
<span v-if="usage" class="adm-sub" style="color:#16a34a;font-weight:600">● 当前在线(未登录,停留&gt;1分钟):{{ usage.online ?? 0 }} 人</span>
<span v-if="usage" class="adm-sub">总使用次数:{{ usage.total }}<template v-if="usage.guest?.count">(其中未登录 {{ usage.guest.count }} 次)</template></span>
</div>
<div class="adm-usage-grid">
<div>
<h3 class="adm-h3">功能使用排行</h3>
<div v-for="t in usage?.by_tool ?? []" :key="t.tool" class="adm-bar-row">
<span class="adm-bar-label">{{ toolLabel(t.tool) }}</span>
<div class="adm-bar-track"><div class="adm-bar" :style="{ width: Math.min(100, t.count * 100 / Math.max(1, usage.by_tool[0].count)) + '%' }" /></div>
<span class="adm-bar-count">{{ t.count }}</span>
</div>
<div v-if="!usage?.by_tool?.length" class="adm-none">暂无使用记录</div>
</div>
<div>
<h3 class="adm-h3">用户活跃排行</h3>
<table class="adm-table">
<thead><tr><th>用户</th><th>次数</th><th>最近活跃</th></tr></thead>
<tbody>
<tr v-for="u in userRows" :key="u.username">
<td :class="u.username === '__guest__' ? 'adm-user adm-guest' : 'adm-user'">{{ u.username === '__guest__' ? '未登录访客' : u.username }}</td>
<td>{{ u.count }}</td>
<td>{{ fmtTime(u.last) }}</td>
</tr>
<tr v-if="!userRows.length"><td colspan="3" class="adm-none">暂无登录用户使用记录</td></tr>
</tbody>
</table>
</div>
</div>
</template>
<!-- MCP 调用记录:AI 客户端经 /mcp 调用本站工具的流水 -->
<template v-if="tab === 'mcp'">
<div class="adm-toolbar">
<select v-model.number="mcpDays" class="adm-select" @change="loadMcpUsage">
<option :value="7">近 7 天</option>
<option :value="30">近 30 天</option>
<option :value="90">近 90 天</option>
</select>
<span v-if="mcpData" class="adm-sub">总调用:{{ mcpData.total }}(成功 {{ mcpData.ok_total }})</span>
<span v-else class="adm-sub">加载中…</span>
</div>
<div class="adm-usage-grid">
<div>
<h3 class="adm-h3">工具调用排行</h3>
<div v-for="t in mcpData?.by_tool ?? []" :key="t.tool" class="adm-bar-row">
<span class="adm-bar-label">{{ t.tool }}</span>
<div class="adm-bar-track"><div class="adm-bar" :style="{ width: Math.min(100, t.count * 100 / Math.max(1, mcpData.by_tool[0].count)) + '%' }" /></div>
<span class="adm-bar-count">{{ t.count }}</span>
</div>
<div v-if="!mcpData?.by_tool?.length" class="adm-none">暂无 MCP 调用记录</div>
</div>
<div>
<h3 class="adm-h3">调用流水(最近 {{ mcpData?.rows?.length ?? 0 }} 条)</h3>
<div class="adm-mcp-scroll">
<table class="adm-table">
<thead><tr><th>时间</th><th>令牌</th><th>机器码</th><th>工具</th><th>结果</th><th>耗时</th><th>错误</th></tr></thead>
<tbody>
<tr v-for="(r, i) in mcpData?.rows ?? []" :key="i">
<td>{{ fmtTime(r.at) }}</td>
<td>…{{ r.token_tail }}</td>
<td>{{ r.machine }}</td>
<td>{{ r.tool }}</td>
<td :style="{ color: r.ok ? '#16a34a' : '#dc2626', fontWeight: 600 }">{{ r.ok ? '✓ 成功' : '✗ 失败' }}</td>
<td>{{ r.dur_ms }} ms</td>
<td class="adm-mcp-err">{{ r.err || '—' }}</td>
</tr>
<tr v-if="!mcpData?.rows?.length"><td colspan="7" class="adm-none">暂无 MCP 调用记录</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<!-- 留言反馈:网站访客提交的留言,按时间倒序 -->
<template v-if="tab === 'feedback'">
<div class="adm-toolbar">
<span class="adm-sub">
共 {{ feedback.length }} 条 · 未处理 {{ fbNewCount }} 条(同一 IP 一小时内限提交 1 次 + 图形验证码)
</span>
<button class="adm-btn adm-btn-sm" @click="loadFeedback">🔄 刷新</button>
</div>
<div class="adm-fb-scroll">
<table class="adm-table">
<thead>
<tr>
<th>时间</th>
<th>类型</th>
<th>内容</th>
<th>联系方式</th>
<th>IP</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for="f in feedback" :key="f.id">
<td class="adm-fb-time">{{ fbTime(f.ts) }}</td>
<td>
<span class="adm-badge" :class="f.type === '功能建议' ? 'ok' : 'admin'">{{ f.type }}</span>
</td>
<td class="adm-fb-content">{{ f.content }}</td>
<td class="adm-fb-contact">{{ f.contact || '—' }}</td>
<td class="adm-fb-ip">{{ f.ip }}</td>
<td>
<select class="adm-select" :value="f.status" @change="fbOnStatus(f, $event)">
<option value="new">未处理</option>
<option value="replied">已回复</option>
<option value="done">已处理</option>
</select>
</td>
<td class="adm-fb-ops">
<a href="javascript:;" class="adm-link" @click="fbDelete(f)">删除</a>
</td>
</tr>
<tr v-if="!feedback.length">
<td colspan="7" class="adm-none">暂无留言,访客提交后会显示在这里</td>
</tr>
</tbody>
</table>
</div>
</template>
</div>
</div>
</div>
</template>
<style lang="less" scoped>
.adm-root {
min-height: 80vh;
padding-bottom: 60px;
}
.adm-login {
display: flex;
justify-content: center;
padding-top: 90px;
.adm-login-box {
width: 320px;
border: 1px solid rgba(128, 128, 128, 0.25);
border-radius: 14px;
padding: 26px;
text-align: center;
.adm-login-title {
font-size: 19px;
font-weight: 800;
margin-bottom: 16px;
}
}
}
.adm-input {
width: 100%;
box-sizing: border-box;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 8px;
padding: 9px 12px;
font-size: 14px;
outline: none;
margin-bottom: 12px;
&:focus {
border-color: #18a058;
}
}
.adm-btn {
background: #18a058;
color: #fff;
border: none;
border-radius: 8px;
padding: 8px 24px;
font-size: 14px;
font-weight: 700;
cursor: pointer;
&:disabled {
opacity: 0.45;
cursor: not-allowed;
}
&.adm-btn-sm {
padding: 5px 14px;
font-size: 12.5px;
}
}
.adm-btn-primary {
background: #2563eb;
}
.adm-mini {
border: 1px solid rgba(128, 128, 128, 0.3);
background: #fff;
border-radius: 6px;
padding: 2px 9px;
font-size: 12.5px;
cursor: pointer;
line-height: 1.5;
&:disabled {
opacity: 0.35;
cursor: not-allowed;
}
&:hover:not(:disabled) {
border-color: #18a058;
color: #18a058;
}
&.adm-mini-del:hover:not(:disabled) {
border-color: #d03050;
color: #d03050;
}
}
.adm-empty {
text-align: center;
opacity: 0.45;
font-size: 13px;
padding: 26px 0;
}
.adm-reco-list {
display: flex;
flex-direction: column;
gap: 7px;
}
// ---- 留言反馈列表 ----
.adm-fb-time {
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.adm-fb-content {
max-width: 460px;
white-space: pre-wrap;
word-break: break-word;
line-height: 1.6;
}
.adm-fb-contact,
.adm-fb-ip {
white-space: nowrap;
}
.adm-fb-ip {
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 12px;
}
.adm-fb-ops {
white-space: nowrap;
}
.adm-reco-row {
display: flex;
align-items: center;
gap: 7px;
border: 1px solid rgba(128, 128, 128, 0.2);
border-radius: 9px;
padding: 7px 10px;
background: rgba(128, 128, 128, 0.03);
.adm-reco-ord {
width: 22px;
height: 22px;
border-radius: 50%;
background: rgba(24, 160, 88, 0.15);
color: #18a058;
font-size: 12px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
input,
select {
border: 1px solid rgba(128, 128, 128, 0.32);
border-radius: 7px;
padding: 5px 8px;
font-size: 12.5px;
outline: none;
background: #fff;
&:focus {
border-color: #18a058;
}
}
.adm-reco-icon {
width: 46px;
text-align: center;
flex-shrink: 0;
}
.adm-reco-sel {
width: 190px;
flex-shrink: 0;
cursor: pointer;
}
.adm-reco-desc {
flex: 1;
min-width: 120px;
}
.adm-reco-on {
display: flex;
align-items: center;
gap: 4px;
font-size: 12px;
flex-shrink: 0;
cursor: pointer;
}
.adm-reco-ops {
display: flex;
gap: 4px;
flex-shrink: 0;
}
}
.adm-error {
color: #d03050;
font-size: 12.5px;
margin-bottom: 10px;
}
.adm-topbar {
display: flex;
align-items: center;
gap: 18px;
border: 1px solid rgba(128, 128, 128, 0.2);
border-radius: 12px;
padding: 8px 16px;
margin-bottom: 14px;
position: sticky;
top: 62px;
z-index: 20;
background: #fff;
flex-wrap: wrap;
.adm-nav-title {
font-size: 15px;
font-weight: 800;
flex-shrink: 0;
}
.adm-nav {
display: flex;
gap: 4px;
align-items: center;
flex-wrap: wrap;
.adm-nav-item {
padding: 7px 14px;
border-radius: 999px;
font-size: 13px;
cursor: pointer;
transition: background 0.15s;
&:hover {
background: rgba(128, 128, 128, 0.07);
}
&.active {
background: rgba(24, 160, 88, 0.12);
color: #18a058;
font-weight: 700;
}
}
}
.adm-logout {
margin-left: auto;
font-size: 12.5px;
color: #d03050;
text-decoration: none;
flex-shrink: 0;
&:hover {
text-decoration: underline;
}
}
}
.adm-main {
width: 100%;
box-sizing: border-box;
border: 1px solid rgba(128, 128, 128, 0.2);
border-radius: 12px;
padding: 18px 20px;
}
.adm-cards {
display: flex;
gap: 12px;
margin-bottom: 18px;
.adm-card {
flex: 1;
border: 1px solid rgba(128, 128, 128, 0.2);
border-radius: 10px;
padding: 14px;
text-align: center;
.adm-card-num {
font-size: 22px;
font-weight: 800;
color: #18a058;
}
.adm-card-label {
font-size: 12px;
opacity: 0.55;
margin-top: 2px;
}
}
}
.adm-h3 {
font-size: 14.5px;
font-weight: 700;
margin: 14px 0 10px;
.adm-sub {
font-size: 11.5px;
font-weight: 400;
opacity: 0.5;
margin-left: 6px;
}
}
.adm-table {
width: 100%;
border-collapse: collapse;
font-size: 12.5px;
th, td {
text-align: left;
padding: 7px 10px;
border-bottom: 1px solid rgba(128, 128, 128, 0.13);
}
th {
opacity: 0.55;
font-weight: 600;
}
tbody tr:hover {
background: rgba(128, 128, 128, 0.05);
}
.adm-user {
font-weight: 700;
cursor: pointer;
color: #18a058;
}
.adm-fname {
max-width: 260px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.adm-none {
text-align: center;
opacity: 0.45;
padding: 24px 0;
}
}
/* 留言反馈表:窄视口容器内横向滚动,表头保持横排不被挤成竖列 */
.adm-fb-scroll {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
.adm-table {
min-width: 820px;
th {
white-space: nowrap;
}
td {
word-break: break-word;
max-width: 360px;
}
}
}
.adm-badge {
font-size: 11px;
padding: 1px 8px;
border-radius: 999px;
background: rgba(128, 128, 128, 0.12);
&.ok {
background: rgba(24, 160, 88, 0.14);
color: #18a058;
}
&.bad {
background: rgba(208, 48, 80, 0.14);
color: #d03050;
}
&.admin {
background: rgba(240, 146, 38, 0.16);
color: #d97706;
}
}
.adm-link {
color: #18a058;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.adm-del {
color: #d03050;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
/* ===== 文件管理:缩略图/类型徽标/分页 ===== */
.adm-fscroll {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
.adm-table {
min-width: 860px;
th {
white-space: nowrap;
}
}
}
.adm-thumbcol,
.adm-thumbcell {
width: 116px;
padding-top: 8px !important;
padding-bottom: 8px !important;
}
.adm-thumb {
width: 100px;
height: 100px;
object-fit: cover;
border-radius: 8px;
border: 1px solid rgba(128, 128, 128, 0.22);
background: rgba(128, 128, 128, 0.06);
display: block;
cursor: zoom-in;
}
.adm-ftype {
display: flex;
align-items: center;
justify-content: center;
width: 100px;
height: 64px;
border-radius: 8px;
background: rgba(128, 128, 128, 0.1);
font-weight: 700;
font-size: 13px;
letter-spacing: 0.5px;
color: rgba(128, 128, 128, 0.95);
text-transform: uppercase;
}
.adm-ops {
white-space: nowrap;
a + a {
margin-left: 10px;
}
}
.adm-dl {
color: #18a058;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
.adm-pager {
display: inline-flex;
align-items: center;
gap: 8px;
}
.adm-pager-b {
display: flex;
justify-content: center;
margin-top: 14px;
}
.adm-pageinfo {
font-size: 12.5px;
opacity: 0.75;
white-space: nowrap;
}
.adm-userbar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
flex-wrap: wrap;
gap: 8px;
.adm-userbar-right {
display: flex;
align-items: center;
gap: 10px;
}
}
.adm-addbox {
display: flex;
gap: 8px;
align-items: center;
background: rgba(24, 160, 88, 0.05);
border: 1px solid rgba(24, 160, 88, 0.3);
border-radius: 10px;
padding: 10px 14px;
margin-bottom: 12px;
flex-wrap: wrap;
.adm-mini-input {
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 10px;
font-size: 12.5px;
outline: none;
width: 160px;
&:focus {
border-color: #18a058;
}
}
}
.adm-ops {
white-space: nowrap;
a {
margin-right: 8px;
}
}
.adm-token-input {
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 6px;
padding: 3px 8px;
font-size: 12px;
outline: none;
width: 150px;
margin-left: 6px;
}
.adm-login-alt {
margin-top: 12px;
font-size: 11.5px;
opacity: 0.6;
}
.adm-toolbar {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
flex-wrap: wrap;
}
.adm-select {
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 5px 10px;
font-size: 12.5px;
background: #fff;
outline: none;
}
.adm-sub {
font-size: 12px;
opacity: 0.55;
}
.adm-cleanup {
display: flex;
align-items: center;
gap: 10px;
background: rgba(208, 48, 80, 0.05);
border: 1px solid rgba(208, 48, 80, 0.25);
border-radius: 10px;
padding: 10px 14px;
margin-bottom: 14px;
font-size: 12.5px;
flex-wrap: wrap;
}
.adm-ok {
color: #18a058;
font-weight: 600;
}
.adm-storage-info {
border: 1px solid rgba(128, 128, 128, 0.2);
border-radius: 10px;
padding: 14px 16px;
margin-bottom: 14px;
background: rgba(24, 160, 88, 0.03);
.adm-storage-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 8px;
font-size: 13px;
.adm-storage-label {
width: 110px;
opacity: 0.6;
flex-shrink: 0;
}
.adm-storage-path {
background: rgba(128, 128, 128, 0.1);
padding: 2px 10px;
border-radius: 5px;
font-size: 12.5px;
word-break: break-all;
}
}
.adm-storage-tip {
font-size: 12px;
opacity: 0.6;
line-height: 1.8;
margin-top: 10px;
code {
background: rgba(128, 128, 128, 0.12);
padding: 1px 6px;
border-radius: 4px;
font-size: 11.5px;
}
}
}
.adm-storage-edit {
display: flex;
align-items: center;
gap: 10px;
background: rgba(240, 146, 38, 0.06);
border: 1px solid rgba(240, 146, 38, 0.3);
border-radius: 10px;
padding: 10px 14px;
margin-bottom: 10px;
font-size: 12.5px;
flex-wrap: wrap;
.adm-storage-input {
flex: 1;
min-width: 220px;
border: 1px solid rgba(128, 128, 128, 0.35);
border-radius: 7px;
padding: 6px 10px;
font-size: 12.5px;
font-family: monospace;
outline: none;
&:focus {
border-color: #18a058;
}
}
}
.adm-storage-note {
font-size: 11.5px;
opacity: 0.5;
line-height: 1.7;
}
.adm-mcp-scroll {
max-height: 420px;
overflow: auto;
}
.adm-mcp-err {
max-width: 260px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #dc2626;
font-size: 12px;
}
.adm-usage-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.adm-bar-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 7px;
.adm-bar-label {
width: 140px;
font-size: 12px;
text-align: right;
flex-shrink: 0;
}
.adm-bar-track {
flex: 1;
height: 14px;
background: rgba(128, 128, 128, 0.1);
border-radius: 7px;
overflow: hidden;
.adm-bar {
height: 100%;
background: linear-gradient(90deg, #3b956f, #18a058);
border-radius: 7px;
min-width: 4px;
}
}
.adm-bar-count {
width: 40px;
font-size: 12px;
font-weight: 700;
}
}
</style>