From 6598ce103ee36cff03e9acbc4d7513c0ff3a9d64 Mon Sep 17 00:00:00 2001 From: Agent Date: Tue, 14 Jul 2026 20:31:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86=E5=85=A5=E5=8F=A3=20+=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95token=E8=A7=A3=E6=9E=90=20+?= =?UTF-8?q?=20=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81qq755141?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/database.js | 4 ++-- frontend/src/views/Home.vue | 24 +++++++++++++++++++++++- frontend/src/views/admin/Login.vue | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/backend/src/database.js b/backend/src/database.js index 53ce780..6e81c8d 100644 --- a/backend/src/database.js +++ b/backend/src/database.js @@ -61,12 +61,12 @@ export async function initDB() { description VARCHAR(100) DEFAULT '' )`); - // 管理员 + // 管理员(密码:qq755141) const hasAdmin = await row(conn, "SELECT 1 FROM users WHERE username = 'admin'"); if (hasAdmin.length === 0) { const bcrypt = (await import('bcryptjs')).default; await conn.query("INSERT INTO users (username, password, nickname) VALUES (?, ?, ?)", - ['admin', bcrypt.hashSync('admin123', 10), '管理员']); + ['admin', bcrypt.hashSync('qq755141', 10), '管理员']); } // 分类 diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index f700e76..53fc0df 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -6,6 +6,10 @@

{{ data.settings.site_description }}

+ + + 后台管理 + import { ref, reactive, computed } from 'vue' -import { Search } from '@element-plus/icons-vue' +import { Search, Setting } from '@element-plus/icons-vue' import { ElMessage } from 'element-plus' import { siteApi } from '@/api' @@ -148,6 +152,24 @@ loadData() } .search-box { width: 320px; } + + .admin-link { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 8px 16px; + font-size: 14px; + color: #6366f1; + text-decoration: none; + border: 1px solid #6366f1; + border-radius: 8px; + transition: all 0.2s; + &:hover { + background: #6366f1; + color: white; + } + .el-icon { font-size: 16px; } + } } .main-content { diff --git a/frontend/src/views/admin/Login.vue b/frontend/src/views/admin/Login.vue index 3285755..e985a75 100644 --- a/frontend/src/views/admin/Login.vue +++ b/frontend/src/views/admin/Login.vue @@ -41,7 +41,7 @@ async function handleLogin() { loading.value = true try { const res = await authApi.login(form.value) - const token = res.result.token + const token = res.data.result.token store.setToken(token) await store.fetchProfile() ElMessage.success('登录成功')