feat: 首页添加后台管理入口 + 修复登录token解析 + 重置密码qq755141

This commit is contained in:
Agent
2026-07-14 20:31:37 +08:00
parent 9cafd5ca78
commit 6598ce103e
3 changed files with 26 additions and 4 deletions
+2 -2
View File
@@ -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), '管理员']);
}
// 分类
+23 -1
View File
@@ -6,6 +6,10 @@
<span class="logo">{{ data.settings.site_name || '导航' }}</span>
<p class="desc">{{ data.settings.site_description }}</p>
</div>
<a href="#/admin" class="admin-link">
<el-icon><Setting /></el-icon>
后台管理
</a>
<el-input
v-model="search"
placeholder="搜索网址..."
@@ -63,7 +67,7 @@
<script setup lang="ts">
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 {
+1 -1
View File
@@ -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('登录成功')