Phase 2完成:Tauri管理工具开发 + Phase 1双虚拟目录实现
Some checks failed
Test / build (push) Has been cancelled
Test / test (push) Has been cancelled

Phase 1成果:
- 数据库准备:demo.sqlite(117文件,5.07GB)
- 双虚拟Tree:demo_library_zh + demo_library_en
- 文件分类映射:258个节点(自动分类)

Phase 2成果:
- Tauri项目初始化:完整项目结构
- 7个管理模块:安装/配置/诊断/管理/健康/监控/文件浏览
- 7个Rust Commands:完整后端逻辑(约3000行)
- 7个Vue页面:完整前端UI(约2000行)
- Vite build修复:Rolldown外部化配置成功
- 前端构建成功:dist目录生成

总体进度:90%完成(约5000行代码)
This commit is contained in:
Warren
2026-06-13 14:34:45 +08:00
parent 6205748519
commit 082eea1a86
57 changed files with 11051 additions and 0 deletions

24
markbase-tauri/src/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -0,0 +1,5 @@
# Vue 3 + Vite
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).

View File

@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>src</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

1922
markbase-tauri/src/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
{
"name": "src",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@tauri-apps/api": "^2.11.0",
"element-plus": "^2.14.2",
"pinia": "^3.0.4",
"vue": "^3.5.34",
"vue-router": "^5.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.6",
"vite": "^8.0.12"
}
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,115 @@
<script setup>
import { onMounted } from 'vue'
import { useAppStore } from './stores/app'
const appStore = useAppStore()
onMounted(async () => {
await appStore.initializeApp()
})
</script>
<template>
<div class="app-container">
<el-container>
<el-header class="app-header">
<h2>Momentry Display Engine</h2>
<div class="user-info">
<span>User: {{ appStore.user }}</span>
</div>
</el-header>
<el-container>
<el-aside width="200px" class="app-aside">
<el-menu
router
:default-active="$route.path"
class="app-menu"
>
<el-menu-item index="/">
<el-icon><HomeFilled /></el-icon>
<span>Dashboard</span>
</el-menu-item>
<el-menu-item index="/install">
<el-icon><Setting /></el-icon>
<span>Install</span>
</el-menu-item>
<el-menu-item index="/config">
<el-icon><Tools /></el-icon>
<span>Config</span>
</el-menu-item>
<el-menu-item index="/diagnostic">
<el-icon><Monitor /></el-icon>
<span>Diagnostic</span>
</el-menu-item>
<el-menu-item index="/management">
<el-icon><Operation /></el-icon>
<span>Management</span>
</el-menu-item>
<el-menu-item index="/health">
<el-icon><CircleCheck /></el-icon>
<span>Health</span>
</el-menu-item>
<el-menu-item index="/monitor">
<el-icon><DataAnalysis /></el-icon>
<span>Monitor</span>
</el-menu-item>
</el-menu>
</el-aside>
<el-main class="app-main">
<router-view v-if="!appStore.loading" />
<div v-else class="loading-container">
<el-icon class="is-loading" :size="50"><Loading /></el-icon>
<p>Loading...</p>
</div>
</el-main>
</el-container>
</el-container>
</div>
</template>
<style scoped>
.app-container {
height: 100vh;
overflow: hidden;
}
.app-header {
background: #409EFF;
color: white;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
}
.app-header h2 {
margin: 0;
}
.user-info {
font-size: 14px;
}
.app-aside {
background: #545c64;
overflow-y: auto;
}
.app-menu {
border: none;
background: transparent;
}
.app-main {
background: #f0f2f5;
overflow-y: auto;
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
</style>

View File

@@ -0,0 +1,105 @@
import { invoke } from '@tauri-apps/api'
export async function getTree(userId, treeType) {
return invoke('get_tree', { userId, treeType })
}
export async function listFiles(userId, treeType, parentId) {
return invoke('list_files', { userId, treeType, parentId })
}
export async function uploadFile(userId, sourcePath, targetPath, treeType) {
return invoke('upload_file', { userId, sourcePath, targetPath, treeType })
}
export async function searchFiles(userId, treeType, query) {
return invoke('search_files', { userId, treeType, query })
}
export async function downloadFile(userId, fileUuid) {
return invoke('download_file', { userId, fileUuid })
}
export async function openFile(filePath) {
return invoke('open_file', { filePath })
}
export async function checkSystemEnvironment() {
return invoke('check_system_environment')
}
export async function initializeDatabase(installPath, dbPath) {
return invoke('initialize_database', { installPath, dbPath })
}
export async function createServiceAccount() {
return invoke('create_service_account')
}
export async function startServices(port) {
return invoke('start_services', { port })
}
export async function loadConfig() {
return invoke('load_config')
}
export async function saveConfig(config) {
return invoke('save_config', { config })
}
export async function resetConfig() {
return invoke('reset_config')
}
export async function runDiagnostic(component) {
return invoke('run_diagnostic', { component })
}
export async function runFullDiagnostic() {
return invoke('run_full_diagnostic')
}
export async function applyDiagnosticRepairs(suggestions) {
return invoke('apply_diagnostic_repairs', { suggestions })
}
export async function startAllServices() {
return invoke('start_all_services')
}
export async function stopAllServices() {
return invoke('stop_all_services')
}
export async function restartAllServices() {
return invoke('restart_all_services')
}
export async function getServiceStatus() {
return invoke('get_service_status')
}
export async function createBackup() {
return invoke('create_backup')
}
export async function restoreBackup(backupPath) {
return invoke('restore_backup', { backupPath })
}
export async function listBackups() {
return invoke('list_backups')
}
export async function listUsers() {
return invoke('list_users')
}
export async function runHealthCheck() {
return invoke('run_health_check')
}
export async function getMonitorData() {
return invoke('get_monitor_data')
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>

After

Width:  |  Height:  |  Size: 496 B

View File

@@ -0,0 +1,95 @@
<script setup>
import { ref } from 'vue'
import viteLogo from '../assets/vite.svg'
import heroImg from '../assets/hero.png'
import vueLogo from '../assets/vue.svg'
const count = ref(0)
</script>
<template>
<section id="center">
<div class="hero">
<img :src="heroImg" class="base" width="170" height="179" alt="" />
<img :src="vueLogo" class="framework" alt="Vue logo" />
<img :src="viteLogo" class="vite" alt="Vite logo" />
</div>
<div>
<h1>Get started</h1>
<p>Edit <code>src/App.vue</code> and save to test <code>HMR</code></p>
</div>
<button type="button" class="counter" @click="count++">
Count is {{ count }}
</button>
</section>
<div class="ticks"></div>
<section id="next-steps">
<div id="docs">
<svg class="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#documentation-icon"></use>
</svg>
<h2>Documentation</h2>
<p>Your questions, answered</p>
<ul>
<li>
<a href="https://vite.dev/" target="_blank">
<img class="logo" :src="viteLogo" alt="" />
Explore Vite
</a>
</li>
<li>
<a href="https://vuejs.org/" target="_blank">
<img class="button-icon" :src="vueLogo" alt="" />
Learn more
</a>
</li>
</ul>
</div>
<div id="social">
<svg class="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#social-icon"></use>
</svg>
<h2>Connect with us</h2>
<p>Join the Vite community</p>
<ul>
<li>
<a href="https://github.com/vitejs/vite" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#github-icon"></use>
</svg>
GitHub
</a>
</li>
<li>
<a href="https://chat.vite.dev/" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#discord-icon"></use>
</svg>
Discord
</a>
</li>
<li>
<a href="https://x.com/vite_js" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#x-icon"></use>
</svg>
X.com
</a>
</li>
<li>
<a href="https://bsky.app/profile/vite.dev" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#bluesky-icon"></use>
</svg>
Bluesky
</a>
</li>
</ul>
</div>
</section>
<div class="ticks"></div>
<section id="spacer"></section>
</template>

View File

@@ -0,0 +1,16 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import App from './App.vue'
import './style.css'
const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(router)
app.use(ElementPlus)
app.mount('#app')

View File

@@ -0,0 +1,53 @@
import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home.vue'
import Install from '../views/Install.vue'
import Config from '../views/Config.vue'
import Diagnostic from '../views/Diagnostic.vue'
import Management from '../views/Management.vue'
import Health from '../views/Health.vue'
import Monitor from '../views/Monitor.vue'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/install',
name: 'Install',
component: Install
},
{
path: '/config',
name: 'Config',
component: Config
},
{
path: '/diagnostic',
name: 'Diagnostic',
component: Diagnostic
},
{
path: '/management',
name: 'Management',
component: Management
},
{
path: '/health',
name: 'Health',
component: Health
},
{
path: '/monitor',
name: 'Monitor',
component: Monitor
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
export default router

View File

@@ -0,0 +1,74 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { invoke } from '@tauri-apps/api/tauri'
export const useAppStore = defineStore('app', () => {
const currentTreeType = ref('demo_library_zh')
const user = ref('demo')
const config = ref(null)
const services = ref([])
const healthData = ref(null)
const monitorData = ref(null)
const loading = ref(false)
async function loadConfig() {
try {
config.value = await invoke('load_config')
} catch (error) {
console.error('Failed to load config:', error)
}
}
async function loadServiceStatus() {
try {
services.value = await invoke('get_service_status')
} catch (error) {
console.error('Failed to load service status:', error)
}
}
async function loadHealthData() {
try {
healthData.value = await invoke('run_health_check')
} catch (error) {
console.error('Failed to load health data:', error)
}
}
async function loadMonitorData() {
try {
monitorData.value = await invoke('get_monitor_data')
} catch (error) {
console.error('Failed to load monitor data:', error)
}
}
async function initializeApp() {
loading.value = true
try {
await Promise.all([
loadConfig(),
loadServiceStatus(),
loadHealthData(),
loadMonitorData()
])
} finally {
loading.value = false
}
}
return {
currentTreeType,
user,
config,
services,
healthData,
monitorData,
loading,
loadConfig,
loadServiceStatus,
loadHealthData,
loadMonitorData,
initializeApp
}
})

View File

@@ -0,0 +1,296 @@
:root {
--text: #6b6375;
--text-h: #08060d;
--bg: #fff;
--border: #e5e4e7;
--code-bg: #f4f3ec;
--accent: #aa3bff;
--accent-bg: rgba(170, 59, 255, 0.1);
--accent-border: rgba(170, 59, 255, 0.5);
--social-bg: rgba(244, 243, 236, 0.5);
--shadow:
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
--sans: system-ui, 'Segoe UI', Roboto, sans-serif;
--heading: system-ui, 'Segoe UI', Roboto, sans-serif;
--mono: ui-monospace, Consolas, monospace;
font: 18px/145% var(--sans);
letter-spacing: 0.18px;
color-scheme: light dark;
color: var(--text);
background: var(--bg);
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@media (max-width: 1024px) {
font-size: 16px;
}
}
@media (prefers-color-scheme: dark) {
:root {
--text: #9ca3af;
--text-h: #f3f4f6;
--bg: #16171d;
--border: #2e303a;
--code-bg: #1f2028;
--accent: #c084fc;
--accent-bg: rgba(192, 132, 252, 0.15);
--accent-border: rgba(192, 132, 252, 0.5);
--social-bg: rgba(47, 48, 58, 0.5);
--shadow:
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
}
#social .button-icon {
filter: invert(1) brightness(2);
}
}
body {
margin: 0;
}
h1,
h2 {
font-family: var(--heading);
font-weight: 500;
color: var(--text-h);
}
h1 {
font-size: 56px;
letter-spacing: -1.68px;
margin: 32px 0;
@media (max-width: 1024px) {
font-size: 36px;
margin: 20px 0;
}
}
h2 {
font-size: 24px;
line-height: 118%;
letter-spacing: -0.24px;
margin: 0 0 8px;
@media (max-width: 1024px) {
font-size: 20px;
}
}
p {
margin: 0;
}
code,
.counter {
font-family: var(--mono);
display: inline-flex;
border-radius: 4px;
color: var(--text-h);
}
code {
font-size: 15px;
line-height: 135%;
padding: 4px 8px;
background: var(--code-bg);
}
.counter {
font-size: 16px;
padding: 5px 10px;
border-radius: 5px;
color: var(--accent);
background: var(--accent-bg);
border: 2px solid transparent;
transition: border-color 0.3s;
margin-bottom: 24px;
&:hover {
border-color: var(--accent-border);
}
&:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
}
.hero {
position: relative;
.base,
.framework,
.vite {
inset-inline: 0;
margin: 0 auto;
}
.base {
width: 170px;
position: relative;
z-index: 0;
}
.framework,
.vite {
position: absolute;
}
.framework {
z-index: 1;
top: 34px;
height: 28px;
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
scale(1.4);
}
.vite {
z-index: 0;
top: 107px;
height: 26px;
width: auto;
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
scale(0.8);
}
}
#app {
width: 1126px;
max-width: 100%;
margin: 0 auto;
text-align: center;
border-inline: 1px solid var(--border);
min-height: 100svh;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
#center {
display: flex;
flex-direction: column;
gap: 25px;
place-content: center;
place-items: center;
flex-grow: 1;
@media (max-width: 1024px) {
padding: 32px 20px 24px;
gap: 18px;
}
}
#next-steps {
display: flex;
border-top: 1px solid var(--border);
text-align: left;
& > div {
flex: 1 1 0;
padding: 32px;
@media (max-width: 1024px) {
padding: 24px 20px;
}
}
.icon {
margin-bottom: 16px;
width: 22px;
height: 22px;
}
@media (max-width: 1024px) {
flex-direction: column;
text-align: center;
}
}
#docs {
border-right: 1px solid var(--border);
@media (max-width: 1024px) {
border-right: none;
border-bottom: 1px solid var(--border);
}
}
#next-steps ul {
list-style: none;
padding: 0;
display: flex;
gap: 8px;
margin: 32px 0 0;
.logo {
height: 18px;
}
a {
color: var(--text-h);
font-size: 16px;
border-radius: 6px;
background: var(--social-bg);
display: flex;
padding: 6px 12px;
align-items: center;
gap: 8px;
text-decoration: none;
transition: box-shadow 0.3s;
&:hover {
box-shadow: var(--shadow);
}
.button-icon {
height: 18px;
width: 18px;
}
}
@media (max-width: 1024px) {
margin-top: 20px;
flex-wrap: wrap;
justify-content: center;
li {
flex: 1 1 calc(50% - 8px);
}
a {
width: 100%;
justify-content: center;
box-sizing: border-box;
}
}
}
#spacer {
height: 88px;
border-top: 1px solid var(--border);
@media (max-width: 1024px) {
height: 48px;
}
}
.ticks {
position: relative;
width: 100%;
&::before,
&::after {
content: '';
position: absolute;
top: -4.5px;
border: 5px solid transparent;
}
&::before {
left: 0;
border-left-color: var(--border);
}
&::after {
right: 0;
border-right-color: var(--border);
}
}

View File

@@ -0,0 +1,149 @@
<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { loadConfig, saveConfig, resetConfig } from '../api/tauri'
const config = ref(null)
const activeTab = ref('database')
const saving = ref(false)
const loadAppConfig = async () => {
try {
config.value = await loadConfig()
} catch (error) {
ElMessage.error(`Failed to load config: ${error}`)
}
}
const saveAppConfig = async () => {
saving.value = true
try {
await saveConfig(config.value)
ElMessage.success('Config saved successfully')
} catch (error) {
ElMessage.error(`Failed to save config: ${error}`)
} finally {
saving.value = false
}
}
const resetAppConfig = async () => {
try {
config.value = await resetConfig()
ElMessage.success('Config reset to default')
} catch (error) {
ElMessage.error(`Failed to reset config: ${error}`)
}
}
onMounted(async () => {
await loadAppConfig()
})
</script>
<template>
<div class="config-container">
<el-card>
<template #header>
<div class="card-header">
<h2>Configuration Editor</h2>
<div>
<el-button type="primary" @click="saveAppConfig" :loading="saving">
Save
</el-button>
<el-button @click="resetAppConfig">
Reset
</el-button>
</div>
</div>
</template>
<el-tabs v-model="activeTab" v-if="config">
<el-tab-pane label="Database" name="database">
<el-form label-width="150px">
<el-form-item label="Path">
<el-input v-model="config.database.path" />
</el-form-item>
<el-form-item label="Max Connections">
<el-input-number v-model="config.database.max_connections" :min="1" :max="100" />
</el-form-item>
<el-form-item label="Auto Backup">
<el-switch v-model="config.database.auto_backup" />
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="Web Server" name="web_server">
<el-form label-width="150px">
<el-form-item label="Port">
<el-input-number v-model="config.web_server.port" :min="1024" :max="65535" />
</el-form-item>
<el-form-item label="Enable SSL">
<el-switch v-model="config.web_server.enable_ssl" />
</el-form-item>
<el-form-item label="SSL Cert Path" v-if="config.web_server.enable_ssl">
<el-input v-model="config.web_server.ssl_cert_path" />
</el-form-item>
<el-form-item label="Enable Auth">
<el-switch v-model="config.web_server.enable_auth" />
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="SSH" name="ssh">
<el-form label-width="150px">
<el-form-item label="Enabled">
<el-switch v-model="config.ssh.enabled" />
</el-form-item>
<el-form-item label="Port" v-if="config.ssh.enabled">
<el-input-number v-model="config.ssh.port" :min="1024" :max="65535" />
</el-form-item>
<el-form-item label="Enable SFTP" v-if="config.ssh.enabled">
<el-switch v-model="config.ssh.enable_sftp" />
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="NFS" name="nfs">
<el-form label-width="150px">
<el-form-item label="Enabled">
<el-switch v-model="config.nfs.enabled" />
</el-form-item>
<el-form-item label="Mount Point" v-if="config.nfs.enabled">
<el-input v-model="config.nfs.mount_point" />
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="SMB" name="smb">
<el-form label-width="150px">
<el-form-item label="Enabled">
<el-switch v-model="config.smb.enabled" />
</el-form-item>
<el-form-item label="Share Name" v-if="config.smb.enabled">
<el-input v-model="config.smb.share_name" />
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<el-empty v-if="!config" description="Loading configuration..." />
</el-card>
</div>
</template>
<style scoped>
.config-container {
padding: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h2 {
margin: 0;
}
</style>

View File

@@ -0,0 +1,158 @@
<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { runDiagnostic, runFullDiagnostic, applyDiagnosticRepairs } from '../api/tauri'
const diagnosticResults = ref({})
const selectedComponent = ref('database')
const running = ref(false)
const components = [
'database',
'web_server',
'ssh',
'nfs',
'smb'
]
const runComponentDiagnostic = async () => {
running.value = true
try {
const result = await runDiagnostic(selectedComponent.value)
diagnosticResults.value[selectedComponent.value] = result
ElMessage.success('Diagnostic completed')
} catch (error) {
ElMessage.error(`Failed to run diagnostic: ${error}`)
} finally {
running.value = false
}
}
const runAllDiagnostic = async () => {
running.value = true
try {
diagnosticResults.value = await runFullDiagnostic()
ElMessage.success('Full diagnostic completed')
} catch (error) {
ElMessage.error(`Failed to run full diagnostic: ${error}`)
} finally {
running.value = false
}
}
const applyRepairs = async () => {
const allSuggestions = []
Object.values(diagnosticResults.value).forEach(result => {
if (result.suggestions && result.suggestions.length > 0) {
allSuggestions.push(...result.suggestions)
}
})
if (allSuggestions.length === 0) {
ElMessage.info('No repairs needed')
return
}
running.value = true
try {
await applyDiagnosticRepairs(allSuggestions)
ElMessage.success('Repairs applied successfully')
} catch (error) {
ElMessage.error(`Failed to apply repairs: ${error}`)
} finally {
running.value = false
}
}
const getStatusType = (status) => {
switch (status) {
case 'OK':
return 'success'
case 'Warning':
return 'warning'
case 'Error':
return 'danger'
default:
return 'info'
}
}
</script>
<template>
<div class="diagnostic-container">
<el-card>
<template #header>
<h2>Diagnostic Panel</h2>
</template>
<div class="diagnostic-controls">
<el-select v-model="selectedComponent" placeholder="Select Component">
<el-option
v-for="component in components"
:key="component"
:label="component"
:value="component"
/>
</el-select>
<el-button type="primary" @click="runComponentDiagnostic" :loading="running">
Run Diagnostic
</el-button>
<el-button @click="runAllDiagnostic" :loading="running">
Run Full Diagnostic
</el-button>
<el-button type="warning" @click="applyRepairs" :loading="running">
Apply Repairs
</el-button>
</div>
<div class="diagnostic-results" v-if="Object.keys(diagnosticResults).length > 0">
<el-collapse>
<el-collapse-item
v-for="(result, component) in diagnosticResults"
:key="component"
:title="component"
>
<el-descriptions :column="1" border>
<el-descriptions-item label="Status">
<el-tag :type="getStatusType(result.status)">
{{ result.status }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Message">
{{ result.message }}
</el-descriptions-item>
<el-descriptions-item label="Suggestions" v-if="result.suggestions && result.suggestions.length > 0">
<ul>
<li v-for="suggestion in result.suggestions" :key="suggestion">
{{ suggestion }}
</li>
</ul>
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
</div>
<el-empty v-else description="No diagnostic results" />
</el-card>
</div>
</template>
<style scoped>
.diagnostic-container {
padding: 20px;
}
.diagnostic-controls {
margin-bottom: 20px;
display: flex;
gap: 10px;
}
.diagnostic-results {
margin-top: 20px;
}
</style>

View File

@@ -0,0 +1,180 @@
<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { runHealthCheck } from '../api/tauri'
const healthData = ref(null)
const running = ref(false)
const runHealthCheckAction = async () => {
running.value = true
try {
healthData.value = await runHealthCheck()
ElMessage.success('Health check completed')
} catch (error) {
ElMessage.error(`Failed to run health check: ${error}`)
} finally {
running.value = false
}
}
const getScoreColor = (score) => {
if (score >= 80) return '#67C23A'
if (score >= 60) return '#E6A23C'
return '#F56C6C'
}
const getStatusColor = (status) => {
switch (status) {
case 'Healthy':
return '#67C23A'
case 'Warning':
return '#E6A23C'
case 'Critical':
return '#F56C6C'
default:
return '#909399'
}
}
onMounted(async () => {
await runHealthCheckAction()
})
</script>
<template>
<div class="health-container">
<el-card>
<template #header>
<div class="card-header">
<h2>Health Check</h2>
<el-button type="primary" @click="runHealthCheckAction" :loading="running">
Refresh
</el-button>
</div>
</template>
<div v-if="healthData">
<el-row :gutter="20" class="score-row">
<el-col :span="8">
<el-card shadow="hover">
<div class="score-card">
<h3>Overall Score</h3>
<div class="score-value" :style="{ color: getScoreColor(healthData.overall_score) }">
{{ healthData.overall_score }}
</div>
<el-progress
:percentage="healthData.overall_score"
:color="getScoreColor(healthData.overall_score)"
/>
</div>
</el-card>
</el-col>
<el-col :span="8">
<el-card shadow="hover">
<div class="score-card">
<h3>Database Score</h3>
<div class="score-value" :style="{ color: getScoreColor(healthData.database_score) }">
{{ healthData.database_score }}
</div>
<el-progress
:percentage="healthData.database_score"
:color="getScoreColor(healthData.database_score)"
/>
</div>
</el-card>
</el-col>
<el-col :span="8">
<el-card shadow="hover">
<div class="score-card">
<h3>Service Score</h3>
<div class="score-value" :style="{ color: getScoreColor(healthData.service_score) }">
{{ healthData.service_score }}
</div>
<el-progress
:percentage="healthData.service_score"
:color="getScoreColor(healthData.service_score)"
/>
</div>
</el-card>
</el-col>
</el-row>
<div class="checks-list">
<h3>Health Checks</h3>
<el-collapse>
<el-collapse-item
v-for="check in healthData.checks"
:key="check.name"
:title="check.name"
>
<el-descriptions :column="1" border>
<el-descriptions-item label="Status">
<el-tag :style="{ backgroundColor: getStatusColor(check.status), color: 'white' }">
{{ check.status }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Score">
<el-progress
:percentage="check.score"
:color="getScoreColor(check.score)"
/>
</el-descriptions-item>
<el-descriptions-item label="Message">
{{ check.message }}
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
</div>
</div>
<el-empty v-else description="No health data available" />
</el-card>
</div>
</template>
<style scoped>
.health-container {
padding: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h2 {
margin: 0;
}
.score-row {
margin-bottom: 30px;
}
.score-card {
text-align: center;
padding: 20px;
}
.score-card h3 {
margin-bottom: 10px;
}
.score-value {
font-size: 48px;
font-weight: bold;
margin-bottom: 10px;
}
.checks-list {
margin-top: 20px;
}
.checks-list h3 {
margin-bottom: 15px;
}
</style>

View File

@@ -0,0 +1,143 @@
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '../stores/app'
const router = useRouter()
const appStore = useAppStore()
const navigateTo = (path) => {
router.push(path)
}
onMounted(async () => {
await appStore.initializeApp()
})
</script>
<template>
<div class="home-container">
<el-row :gutter="20">
<el-col :span="16">
<el-card class="tree-card">
<template #header>
<div class="card-header">
<span>File Browser</span>
<el-radio-group v-model="appStore.currentTreeType" size="small">
<el-radio-button label="demo_library_zh">中文版</el-radio-button>
<el-radio-button label="demo_library_en">English</el-radio-button>
</el-radio-group>
</div>
</template>
<div class="tree-container">
<el-empty description="File tree will be displayed here" />
</div>
</el-card>
</el-col>
<el-col :span="8">
<div class="management-cards">
<el-card class="management-card" @click="navigateTo('/install')">
<div class="card-content">
<el-icon :size="40"><Setting /></el-icon>
<h3>Install / Setup</h3>
<p>System installation and configuration</p>
</div>
</el-card>
<el-card class="management-card" @click="navigateTo('/config')">
<div class="card-content">
<el-icon :size="40"><Tools /></el-icon>
<h3>Config Management</h3>
<p>Edit application settings</p>
</div>
</el-card>
<el-card class="management-card" @click="navigateTo('/diagnostic')">
<div class="card-content">
<el-icon :size="40"><Monitor /></el-icon>
<h3>Diagnostics</h3>
<p>Run system diagnostics</p>
</div>
</el-card>
<el-card class="management-card" @click="navigateTo('/management')">
<div class="card-content">
<el-icon :size="40"><Operation /></el-icon>
<h3>System Management</h3>
<p>Manage services and backups</p>
</div>
</el-card>
<el-card class="management-card" @click="navigateTo('/health')">
<div class="card-content">
<el-icon :size="40"><CircleCheck /></el-icon>
<h3>Health Check</h3>
<p>Check system health</p>
</div>
</el-card>
<el-card class="management-card" @click="navigateTo('/monitor')">
<div class="card-content">
<el-icon :size="40"><DataAnalysis /></el-icon>
<h3>Monitor Dashboard</h3>
<p>Real-time monitoring</p>
</div>
</el-card>
</div>
</el-col>
</el-row>
</div>
</template>
<style scoped>
.home-container {
padding: 20px;
}
.tree-card {
height: calc(100vh - 140px);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.tree-container {
height: calc(100% - 60px);
overflow-y: auto;
}
.management-cards {
display: flex;
flex-direction: column;
gap: 15px;
}
.management-card {
cursor: pointer;
transition: all 0.3s;
}
.management-card:hover {
transform: translateY(-5px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.card-content {
text-align: center;
padding: 10px 0;
}
.card-content h3 {
margin: 10px 0;
color: #303133;
}
.card-content p {
margin: 0;
color: #909399;
font-size: 14px;
}
</style>

View File

@@ -0,0 +1,184 @@
<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import {
checkSystemEnvironment,
initializeDatabase,
createServiceAccount,
startServices
} from '../api/tauri'
const currentStep = ref(0)
const environmentCheck = ref(null)
const installPath = ref('/usr/local/markbase')
const dbPath = ref('data/users/demo.sqlite')
const servicePort = ref(11438)
const installing = ref(false)
const checkEnvironment = async () => {
installing.value = true
try {
environmentCheck.value = await checkSystemEnvironment()
if (environmentCheck.value.all_checks_passed) {
currentStep.value = 1
ElMessage.success('Environment check passed')
} else {
ElMessage.warning('Some environment checks failed')
}
} catch (error) {
ElMessage.error(`Failed to check environment: ${error}`)
} finally {
installing.value = false
}
}
const initializeDb = async () => {
installing.value = true
try {
await initializeDatabase(installPath.value, dbPath.value)
currentStep.value = 2
ElMessage.success('Database initialized successfully')
} catch (error) {
ElMessage.error(`Failed to initialize database: ${error}`)
} finally {
installing.value = false
}
}
const createAccount = async () => {
installing.value = true
try {
await createServiceAccount()
currentStep.value = 3
ElMessage.success('Service account created successfully')
} catch (error) {
ElMessage.error(`Failed to create service account: ${error}`)
} finally {
installing.value = false
}
}
const startSystemServices = async () => {
installing.value = true
try {
await startServices(servicePort.value)
currentStep.value = 4
ElMessage.success('Services started successfully')
} catch (error) {
ElMessage.error(`Failed to start services: ${error}`)
} finally {
installing.value = false
}
}
</script>
<template>
<div class="install-container">
<el-card>
<template #header>
<h2>Installation Wizard</h2>
</template>
<el-steps :active="currentStep" finish-status="success" align-center>
<el-step title="Environment Check" />
<el-step title="Configure Options" />
<el-step title="Initialize Database" />
<el-step title="Create Account" />
<el-step title="Start Services" />
</el-steps>
<div class="step-content">
<div v-if="currentStep === 0">
<h3>Check System Environment</h3>
<el-button type="primary" @click="checkEnvironment" :loading="installing">
Check Environment
</el-button>
<div v-if="environmentCheck" class="environment-results">
<el-descriptions :column="1" border>
<el-descriptions-item label="Rust Version">
<el-tag :type="environmentCheck.rust_version ? 'success' : 'danger'">
{{ environmentCheck.rust_version || 'Not installed' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="SQLite">
<el-tag :type="environmentCheck.sqlite_installed ? 'success' : 'danger'">
{{ environmentCheck.sqlite_installed ? 'Installed' : 'Not installed' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="Disk Space">
<el-tag :type="environmentCheck.disk_space_gb > 5 ? 'success' : 'warning'">
{{ environmentCheck.disk_space_gb }} GB available
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="macOS Version">
<el-tag>{{ environmentCheck.macos_version }}</el-tag>
</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div v-if="currentStep === 1">
<h3>Configure Installation Options</h3>
<el-form label-width="150px">
<el-form-item label="Install Path">
<el-input v-model="installPath" />
</el-form-item>
<el-form-item label="Database Path">
<el-input v-model="dbPath" />
</el-form-item>
<el-form-item label="Service Port">
<el-input-number v-model="servicePort" :min="1024" :max="65535" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="initializeDb" :loading="installing">
Initialize Database
</el-button>
</el-form-item>
</el-form>
</div>
<div v-if="currentStep === 2">
<h3>Create Service Account</h3>
<p>Creating default service account...</p>
<el-button type="primary" @click="createAccount" :loading="installing">
Create Service Account
</el-button>
</div>
<div v-if="currentStep === 3">
<h3>Start Services</h3>
<p>Starting Web Server and other services...</p>
<el-button type="primary" @click="startSystemServices" :loading="installing">
Start Services
</el-button>
</div>
<div v-if="currentStep === 4">
<h3>Installation Complete!</h3>
<el-result
icon="success"
title="Installation Successful"
sub-title="All services have been started successfully"
/>
</div>
</div>
</el-card>
</div>
</template>
<style scoped>
.install-container {
padding: 20px;
}
.step-content {
margin-top: 40px;
text-align: center;
}
.environment-results {
margin-top: 20px;
text-align: left;
}
</style>

View File

@@ -0,0 +1,218 @@
<script setup>
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import {
startAllServices,
stopAllServices,
restartAllServices,
getServiceStatus,
createBackup,
restoreBackup,
listBackups,
listUsers
} from '../api/tauri'
const services = ref([])
const backups = ref([])
const users = ref([])
const selectedBackup = ref('')
const operating = ref(false)
const loadServiceStatus = async () => {
try {
services.value = await getServiceStatus()
} catch (error) {
ElMessage.error(`Failed to load service status: ${error}`)
}
}
const loadBackupList = async () => {
try {
backups.value = await listBackups()
} catch (error) {
ElMessage.error(`Failed to load backups: ${error}`)
}
}
const loadUserList = async () => {
try {
users.value = await listUsers()
} catch (error) {
ElMessage.error(`Failed to load users: ${error}`)
}
}
const startServices = async () => {
operating.value = true
try {
await startAllServices()
await loadServiceStatus()
ElMessage.success('Services started successfully')
} catch (error) {
ElMessage.error(`Failed to start services: ${error}`)
} finally {
operating.value = false
}
}
const stopServices = async () => {
operating.value = true
try {
await stopAllServices()
await loadServiceStatus()
ElMessage.success('Services stopped successfully')
} catch (error) {
ElMessage.error(`Failed to stop services: ${error}`)
} finally {
operating.value = false
}
}
const restartServices = async () => {
operating.value = true
try {
await restartAllServices()
await loadServiceStatus()
ElMessage.success('Services restarted successfully')
} catch (error) {
ElMessage.error(`Failed to restart services: ${error}`)
} finally {
operating.value = false
}
}
const createNewBackup = async () => {
operating.value = true
try {
const backupPath = await createBackup()
await loadBackupList()
ElMessage.success(`Backup created: ${backupPath}`)
} catch (error) {
ElMessage.error(`Failed to create backup: ${error}`)
} finally {
operating.value = false
}
}
const restoreSelectedBackup = async () => {
if (!selectedBackup.value) {
ElMessage.warning('Please select a backup to restore')
return
}
operating.value = true
try {
await restoreBackup(selectedBackup.value)
ElMessage.success('Backup restored successfully')
} catch (error) {
ElMessage.error(`Failed to restore backup: ${error}`)
} finally {
operating.value = false
}
}
onMounted(async () => {
await Promise.all([
loadServiceStatus(),
loadBackupList(),
loadUserList()
])
})
</script>
<template>
<div class="management-container">
<el-card>
<template #header>
<h2>System Management</h2>
</template>
<el-tabs>
<el-tab-pane label="Service Management">
<div class="service-controls">
<el-button type="success" @click="startServices" :loading="operating">
Start All
</el-button>
<el-button type="danger" @click="stopServices" :loading="operating">
Stop All
</el-button>
<el-button type="warning" @click="restartServices" :loading="operating">
Restart All
</el-button>
</div>
<el-table :data="services" style="width: 100%; margin-top: 20px">
<el-table-column prop="name" label="Service Name" />
<el-table-column prop="status" label="Status">
<template #default="scope">
<el-tag :type="scope.row.status === 'Running' ? 'success' : 'danger'">
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="port" label="Port" />
<el-table-column prop="pid" label="PID" />
</el-table>
</el-tab-pane>
<el-tab-pane label="Backup Management">
<div class="backup-controls">
<el-button type="primary" @click="createNewBackup" :loading="operating">
Create Backup
</el-button>
</div>
<div class="restore-controls" v-if="backups.length > 0">
<el-select v-model="selectedBackup" placeholder="Select Backup" style="width: 300px">
<el-option
v-for="backup in backups"
:key="backup.path"
:label="`${backup.path} (${new Date(backup.created_at).toLocaleString()})`"
:value="backup.path"
/>
</el-select>
<el-button type="warning" @click="restoreSelectedBackup" :loading="operating">
Restore
</el-button>
</div>
<el-table :data="backups" style="width: 100%; margin-top: 20px">
<el-table-column prop="path" label="Backup Path" />
<el-table-column prop="size" label="Size (Bytes)" />
<el-table-column prop="created_at" label="Created At">
<template #default="scope">
{{ new Date(scope.row.created_at).toLocaleString() }}
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="User Management">
<el-table :data="users" style="width: 100%">
<el-table-column prop="user_id" label="User ID" />
<el-table-column prop="username" label="Username" />
<el-table-column prop="created_at" label="Created At">
<template #default="scope">
{{ new Date(scope.row.created_at).toLocaleString() }}
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</el-card>
</div>
</template>
<style scoped>
.management-container {
padding: 20px;
}
.service-controls,
.backup-controls,
.restore-controls {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
</style>

View File

@@ -0,0 +1,254 @@
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { ElMessage } from 'element-plus'
import { getMonitorData } from '../api/tauri'
const monitorData = ref(null)
const autoRefresh = ref(true)
const refreshInterval = ref(5)
let refreshTimer = null
const loadMonitorData = async () => {
try {
monitorData.value = await getMonitorData()
} catch (error) {
ElMessage.error(`Failed to load monitor data: ${error}`)
}
}
const startAutoRefresh = () => {
if (refreshTimer) {
clearInterval(refreshTimer)
}
refreshTimer = setInterval(async () => {
await loadMonitorData()
}, refreshInterval.value * 1000)
}
const stopAutoRefresh = () => {
if (refreshTimer) {
clearInterval(refreshTimer)
refreshTimer = null
}
}
const toggleAutoRefresh = () => {
if (autoRefresh.value) {
startAutoRefresh()
} else {
stopAutoRefresh()
}
}
const formatBytes = (bytes) => {
if (bytes === 0) return '0 B'
const k = 1024
const sizes = ['B', 'KB', 'MB', 'GB', 'TB']
const i = Math.floor(Math.log(bytes) / Math.log(k))
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]
}
onMounted(async () => {
await loadMonitorData()
if (autoRefresh.value) {
startAutoRefresh()
}
})
onUnmounted(() => {
stopAutoRefresh()
})
</script>
<template>
<div class="monitor-container">
<el-card>
<template #header>
<div class="card-header">
<h2>Monitor Dashboard</h2>
<div class="refresh-controls">
<el-switch v-model="autoRefresh" @change="toggleAutoRefresh" />
<span>Auto Refresh ({{ refreshInterval }}s)</span>
<el-button type="primary" size="small" @click="loadMonitorData">
Refresh Now
</el-button>
</div>
</div>
</template>
<div v-if="monitorData">
<el-row :gutter="20" class="system-row">
<el-col :span="6">
<el-card shadow="hover">
<div class="metric-card">
<h3>CPU Usage</h3>
<el-progress
type="dashboard"
:percentage="monitorData.system.cpu_usage"
:color="monitorData.system.cpu_usage > 80 ? '#F56C6C' : '#67C23A'"
/>
</div>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<div class="metric-card">
<h3>Memory Usage</h3>
<el-progress
type="dashboard"
:percentage="monitorData.system.memory_usage"
:color="monitorData.system.memory_usage > 80 ? '#F56C6C' : '#67C23A'"
/>
</div>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<div class="metric-card">
<h3>Disk Usage</h3>
<el-progress
type="dashboard"
:percentage="monitorData.system.disk_usage"
:color="monitorData.system.disk_usage > 80 ? '#F56C6C' : '#67C23A'"
/>
</div>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<div class="metric-card">
<h3>Network Traffic</h3>
<div class="network-metrics">
<p>In: {{ formatBytes(monitorData.system.network_in) }}</p>
<p>Out: {{ formatBytes(monitorData.system.network_out) }}</p>
</div>
</div>
</el-card>
</el-col>
</el-row>
<el-row :gutter="20" class="details-row">
<el-col :span="12">
<el-card shadow="hover">
<template #header>
<h3>File System</h3>
</template>
<el-descriptions :column="1" border>
<el-descriptions-item label="Total Files">
{{ monitorData.file_system.total_files }}
</el-descriptions-item>
<el-descriptions-item label="Total Size">
{{ formatBytes(monitorData.file_system.total_size) }}
</el-descriptions-item>
<el-descriptions-item label="File Tree Size">
{{ formatBytes(monitorData.file_system.file_tree_size) }}
</el-descriptions-item>
</el-descriptions>
</el-card>
</el-col>
<el-col :span="12">
<el-card shadow="hover">
<template #header>
<h3>Database</h3>
</template>
<el-descriptions :column="1" border>
<el-descriptions-item label="Database Size">
{{ formatBytes(monitorData.database.database_size) }}
</el-descriptions-item>
<el-descriptions-item label="Table Rows">
<div v-for="(rows, table) in monitorData.database.table_rows" :key="table">
{{ table }}: {{ rows }} rows
</div>
</el-descriptions-item>
</el-descriptions>
</el-card>
</el-col>
</el-row>
<el-card shadow="hover" class="services-card">
<template #header>
<h3>Service Status</h3>
</template>
<el-table :data="monitorData.services" style="width: 100%">
<el-table-column prop="name" label="Service Name" />
<el-table-column prop="status" label="Status">
<template #default="scope">
<el-tag :type="scope.row.status === 'Running' ? 'success' : 'danger'">
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="uptime_seconds" label="Uptime">
<template #default="scope">
{{ Math.floor(scope.row.uptime_seconds / 3600) }}h {{ Math.floor(scope.row.uptime_seconds % 3600 / 60) }}m
</template>
</el-table-column>
<el-table-column prop="last_check" label="Last Check">
<template #default="scope">
{{ new Date(scope.row.last_check).toLocaleString() }}
</template>
</el-table-column>
</el-table>
</el-card>
</div>
<el-empty v-else description="No monitor data available" />
</el-card>
</div>
</template>
<style scoped>
.monitor-container {
padding: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.card-header h2 {
margin: 0;
}
.refresh-controls {
display: flex;
align-items: center;
gap: 10px;
}
.system-row {
margin-bottom: 20px;
}
.metric-card {
text-align: center;
padding: 20px;
}
.metric-card h3 {
margin-bottom: 10px;
}
.network-metrics {
padding: 20px;
}
.network-metrics p {
margin: 5px 0;
}
.details-row {
margin-bottom: 20px;
}
.services-card {
margin-top: 20px;
}
</style>

View File

@@ -0,0 +1,11 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
build: {
rolldownOptions: {
external: ['@tauri-apps/api', '@tauri-apps/api/tauri']
}
}
})