feat(app): scaffold Vue3 frontend (stage 1)

This commit is contained in:
2025-12-13 22:42:31 +08:00
parent 39153cc946
commit 34f44eed3e
35 changed files with 2910 additions and 0 deletions

5
app-frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
dist
node_modules
.DS_Store
.vite

4
app-frontend/README.md Normal file
View File

@@ -0,0 +1,4 @@
# app-frontend
前台用户端Vue3 + Vite 工程,构建产物输出到 `static/app/`

14
app-frontend/index.html Normal file
View File

@@ -0,0 +1,14 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title>知识管理平台</title>
</head>
<body>
<noscript>该页面需要启用 JavaScript 才能使用。</noscript>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

2079
app-frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

25
app-frontend/package.json Normal file
View File

@@ -0,0 +1,25 @@
{
"name": "app-frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.2",
"axios": "^1.12.2",
"element-plus": "^2.11.3",
"pinia": "^3.0.3",
"socket.io-client": "^4.8.1",
"vue": "^3.5.24",
"vue-router": "^4.6.3"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.1",
"vite": "^7.2.4"
}
}

6
app-frontend/src/App.vue Normal file
View File

@@ -0,0 +1,6 @@
<script setup></script>
<template>
<RouterView />
</template>

View File

@@ -0,0 +1,195 @@
<script setup>
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { Calendar, Camera, User } from '@element-plus/icons-vue'
const route = useRoute()
const router = useRouter()
const isMobile = ref(false)
const drawerOpen = ref(false)
let mediaQuery
function syncIsMobile() {
isMobile.value = Boolean(mediaQuery?.matches)
if (!isMobile.value) drawerOpen.value = false
}
onMounted(() => {
mediaQuery = window.matchMedia('(max-width: 768px)')
mediaQuery.addEventListener?.('change', syncIsMobile)
syncIsMobile()
})
onBeforeUnmount(() => {
mediaQuery?.removeEventListener?.('change', syncIsMobile)
})
const menuItems = [
{ path: '/app/accounts', label: '账号管理', icon: User },
{ path: '/app/schedules', label: '定时任务', icon: Calendar },
{ path: '/app/screenshots', label: '截图管理', icon: Camera },
]
const activeMenu = computed(() => route.path)
async function go(path) {
await router.push(path)
drawerOpen.value = false
}
async function logout() {
try {
await ElMessageBox.confirm('确定退出登录吗?', '退出登录', {
confirmButtonText: '退出',
cancelButtonText: '取消',
type: 'warning',
})
} catch {
return
}
window.location.href = '/login'
}
</script>
<template>
<el-container class="layout-root">
<el-aside v-if="!isMobile" width="220px" class="layout-aside">
<div class="brand">
<div class="brand-title">知识管理平台</div>
<div class="brand-sub app-muted">用户中心</div>
</div>
<el-menu :default-active="activeMenu" class="aside-menu" router @select="go">
<el-menu-item v-for="item in menuItems" :key="item.path" :index="item.path">
<el-icon><component :is="item.icon" /></el-icon>
<span>{{ item.label }}</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-container>
<el-header class="layout-header">
<div class="header-left">
<el-button v-if="isMobile" text class="header-menu-btn" @click="drawerOpen = true">
菜单
</el-button>
<div class="header-title">用户控制台</div>
</div>
<div class="header-right">
<el-button type="primary" plain @click="logout">退出</el-button>
</div>
</el-header>
<el-main class="layout-main">
<RouterView />
</el-main>
</el-container>
<el-drawer v-model="drawerOpen" size="240px" :with-header="false">
<div class="drawer-brand">
<div class="brand-title">知识管理平台</div>
<div class="brand-sub app-muted">用户中心</div>
</div>
<el-menu :default-active="activeMenu" class="aside-menu" router @select="go">
<el-menu-item v-for="item in menuItems" :key="item.path" :index="item.path">
<el-icon><component :is="item.icon" /></el-icon>
<span>{{ item.label }}</span>
</el-menu-item>
</el-menu>
</el-drawer>
</el-container>
</template>
<style scoped>
.layout-root {
height: 100%;
}
.layout-aside {
background: #ffffff;
border-right: 1px solid var(--app-border);
}
.brand,
.drawer-brand {
padding: 18px 16px 10px;
}
.brand-title {
font-size: 15px;
font-weight: 800;
letter-spacing: 0.2px;
}
.brand-sub {
margin-top: 2px;
font-size: 12px;
}
.aside-menu {
border-right: none;
}
.layout-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
background: rgba(246, 247, 251, 0.6);
backdrop-filter: saturate(180%) blur(10px);
border-bottom: 1px solid var(--app-border);
}
.header-left {
display: flex;
align-items: center;
gap: 10px;
min-width: 0;
}
.header-title {
font-size: 14px;
font-weight: 800;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-menu-btn {
padding-left: 0;
padding-right: 0;
}
.header-right {
display: flex;
align-items: center;
gap: 12px;
}
.layout-main {
padding: 16px;
}
@media (max-width: 768px) {
.layout-header {
flex-wrap: wrap;
height: auto;
padding-top: 10px;
padding-bottom: 10px;
}
.header-right {
width: 100%;
justify-content: flex-end;
}
.layout-main {
padding: 12px;
}
}
</style>

15
app-frontend/src/main.js Normal file
View File

@@ -0,0 +1,15 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import './style.css'
createApp(App).use(createPinia()).use(router).use(ElementPlus, { locale: zhCn }).mount('#app')

View File

@@ -0,0 +1,20 @@
<template>
<el-card shadow="never" :body-style="{ padding: '16px' }" class="card">
<h2 class="title">账号管理</h2>
<div class="app-muted">阶段1页面壳子已就绪功能将在后续阶段迁移</div>
</el-card>
</template>
<style scoped>
.card {
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
}
.title {
margin: 0 0 6px;
font-size: 16px;
font-weight: 800;
}
</style>

View File

@@ -0,0 +1,68 @@
<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
function goRegister() {
router.push('/register')
}
</script>
<template>
<div class="auth-wrap">
<el-card shadow="never" class="auth-card" :body-style="{ padding: '22px' }">
<div class="brand">
<div class="brand-title">知识管理平台</div>
<div class="brand-sub app-muted">用户登录</div>
</div>
<el-alert
type="info"
:closable="false"
title="阶段1仅完成前台工程与布局搭建。登录/验证码/找回密码等功能将在后续阶段迁移。"
show-icon
/>
<div class="actions">
<el-button type="primary" @click="goRegister">前往注册</el-button>
</div>
</el-card>
</div>
</template>
<style scoped>
.auth-wrap {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.auth-card {
width: 100%;
max-width: 420px;
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
box-shadow: var(--app-shadow);
}
.brand {
margin-bottom: 14px;
}
.brand-title {
font-size: 18px;
font-weight: 900;
}
.brand-sub {
margin-top: 4px;
font-size: 12px;
}
.actions {
margin-top: 16px;
}
</style>

View File

@@ -0,0 +1,68 @@
<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
function goLogin() {
router.push('/login')
}
</script>
<template>
<div class="auth-wrap">
<el-card shadow="never" class="auth-card" :body-style="{ padding: '22px' }">
<div class="brand">
<div class="brand-title">知识管理平台</div>
<div class="brand-sub app-muted">用户注册</div>
</div>
<el-alert
type="info"
:closable="false"
title="阶段1仅完成前台工程与布局搭建。注册/邮箱验证等功能将在后续阶段迁移。"
show-icon
/>
<div class="actions">
<el-button @click="goLogin">返回登录</el-button>
</div>
</el-card>
</div>
</template>
<style scoped>
.auth-wrap {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.auth-card {
width: 100%;
max-width: 420px;
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
box-shadow: var(--app-shadow);
}
.brand {
margin-bottom: 14px;
}
.brand-title {
font-size: 18px;
font-weight: 900;
}
.brand-sub {
margin-top: 4px;
font-size: 12px;
}
.actions {
margin-top: 16px;
}
</style>

View File

@@ -0,0 +1,68 @@
<script setup>
import { useRouter } from 'vue-router'
const router = useRouter()
function goLogin() {
router.push('/login')
}
</script>
<template>
<div class="auth-wrap">
<el-card shadow="never" class="auth-card" :body-style="{ padding: '22px' }">
<div class="brand">
<div class="brand-title">知识管理平台</div>
<div class="brand-sub app-muted">重置密码</div>
</div>
<el-alert
type="info"
:closable="false"
title="阶段1仅完成前台工程与布局搭建。重置密码功能将在后续阶段迁移。"
show-icon
/>
<div class="actions">
<el-button @click="goLogin">返回登录</el-button>
</div>
</el-card>
</div>
</template>
<style scoped>
.auth-wrap {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.auth-card {
width: 100%;
max-width: 420px;
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
box-shadow: var(--app-shadow);
}
.brand {
margin-bottom: 14px;
}
.brand-title {
font-size: 18px;
font-weight: 900;
}
.brand-sub {
margin-top: 4px;
font-size: 12px;
}
.actions {
margin-top: 16px;
}
</style>

View File

@@ -0,0 +1,20 @@
<template>
<el-card shadow="never" :body-style="{ padding: '16px' }" class="card">
<h2 class="title">定时任务</h2>
<div class="app-muted">阶段1页面壳子已就绪功能将在后续阶段迁移</div>
</el-card>
</template>
<style scoped>
.card {
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
}
.title {
margin: 0 0 6px;
font-size: 16px;
font-weight: 800;
}
</style>

View File

@@ -0,0 +1,20 @@
<template>
<el-card shadow="never" :body-style="{ padding: '16px' }" class="card">
<h2 class="title">截图管理</h2>
<div class="app-muted">阶段1页面壳子已就绪功能将在后续阶段迁移</div>
</el-card>
</template>
<style scoped>
.card {
border-radius: var(--app-radius);
border: 1px solid var(--app-border);
}
.title {
margin: 0 0 6px;
font-size: 16px;
font-weight: 800;
}
</style>

View File

@@ -0,0 +1,37 @@
import { createRouter, createWebHistory } from 'vue-router'
import AppLayout from '../layouts/AppLayout.vue'
const LoginPage = () => import('../pages/LoginPage.vue')
const RegisterPage = () => import('../pages/RegisterPage.vue')
const ResetPasswordPage = () => import('../pages/ResetPasswordPage.vue')
const AccountsPage = () => import('../pages/AccountsPage.vue')
const SchedulesPage = () => import('../pages/SchedulesPage.vue')
const ScreenshotsPage = () => import('../pages/ScreenshotsPage.vue')
const routes = [
{ path: '/', redirect: '/login' },
{ path: '/login', name: 'login', component: LoginPage },
{ path: '/register', name: 'register', component: RegisterPage },
{ path: '/reset_password', name: 'reset_password', component: ResetPasswordPage },
{
path: '/app',
component: AppLayout,
children: [
{ path: '', redirect: '/app/accounts' },
{ path: 'accounts', name: 'accounts', component: AccountsPage },
{ path: 'schedules', name: 'schedules', component: SchedulesPage },
{ path: 'screenshots', name: 'screenshots', component: ScreenshotsPage },
],
},
{ path: '/:pathMatch(.*)*', redirect: '/login' },
]
const router = createRouter({
history: createWebHistory(),
routes,
})
export default router

View File

@@ -0,0 +1,61 @@
:root {
--app-bg: #f6f7fb;
--app-text: #111827;
--app-muted: #6b7280;
--app-border: rgba(17, 24, 39, 0.08);
--app-radius: 12px;
--app-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html,
body,
#app {
height: 100%;
}
body {
margin: 0;
background: var(--app-bg);
color: var(--app-text);
}
a {
color: inherit;
text-decoration: none;
}
.app-muted {
color: var(--app-muted);
}
@media (max-width: 768px) {
.el-dialog {
max-width: 92vw;
}
.el-form-item {
flex-direction: column;
align-items: stretch;
}
.el-form-item__label {
width: auto !important;
justify-content: flex-start !important;
padding: 0 0 6px !important;
line-height: 1.4;
text-align: left !important;
}
.el-form-item__content {
margin-left: 0 !important;
width: 100%;
}
}

View File

@@ -0,0 +1,13 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
base: './',
build: {
outDir: '../static/app',
emptyOutDir: true,
manifest: true,
},
})