refactor(web): 重构前端界面组件和导航结构
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 40s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m24s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m49s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m15s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m39s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m45s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 2m2s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m13s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m46s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m20s
All checks were successful
Build Multi-Platform Binaries / build-frontend (push) Successful in 40s
Build Multi-Platform Binaries / build-binaries (amd64, linux, client, true) (push) Successful in 1m24s
Build Multi-Platform Binaries / build-binaries (amd64, darwin, server, false) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (amd64, windows, client, true) (push) Successful in 1m27s
Build Multi-Platform Binaries / build-binaries (amd64, linux, server, true) (push) Successful in 1m49s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, client, true) (push) Successful in 1m15s
Build Multi-Platform Binaries / build-binaries (amd64, windows, server, true) (push) Successful in 1m39s
Build Multi-Platform Binaries / build-binaries (arm64, darwin, server, false) (push) Successful in 1m45s
Build Multi-Platform Binaries / build-binaries (arm, 7, linux, server, true) (push) Successful in 2m2s
Build Multi-Platform Binaries / build-binaries (arm64, linux, client, true) (push) Successful in 1m13s
Build Multi-Platform Binaries / build-binaries (arm64, linux, server, true) (push) Successful in 1m46s
Build Multi-Platform Binaries / build-binaries (arm64, windows, server, false) (push) Successful in 1m20s
- 替换 naive-ui 导航组件为自定义玻璃态设计组件 - 引入 GlassModal、GlassSwitch、GlassTag 等自定义组件 - 更新 App.vue 中的布局结构和样式设计 - 重构客户端视图中的表单验证逻辑 - 移除 tabs 组件改用侧边栏导航菜单 - 添加内联日志面板组件 - 优化响应式布局和移动端适配 - 更新图标组件引用方式 - 简化表单验证实现方式 - 添加插件下拉菜单功能 - 优化客户端管理界面UI - 更新依赖注入声明文件 - 重构用户菜单交互逻辑 - 移除路由跳转相关代码优化性能
This commit is contained in:
101
web/src/composables/useToast.ts
Normal file
101
web/src/composables/useToast.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { ref, createApp, h } from 'vue'
|
||||
|
||||
interface ToastOptions {
|
||||
message: string
|
||||
type: 'success' | 'error' | 'warning' | 'info'
|
||||
duration?: number
|
||||
}
|
||||
|
||||
const toasts = ref<Array<ToastOptions & { id: number }>>([])
|
||||
let toastId = 0
|
||||
|
||||
const ToastContainer = {
|
||||
setup() {
|
||||
return () => h('div', { class: 'toast-container' },
|
||||
toasts.value.map(toast =>
|
||||
h('div', {
|
||||
key: toast.id,
|
||||
class: ['toast-item', toast.type]
|
||||
}, toast.message)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
let containerMounted = false
|
||||
|
||||
function ensureContainer() {
|
||||
if (containerMounted) return
|
||||
|
||||
const container = document.createElement('div')
|
||||
container.id = 'toast-root'
|
||||
document.body.appendChild(container)
|
||||
|
||||
const app = createApp(ToastContainer)
|
||||
app.mount(container)
|
||||
containerMounted = true
|
||||
|
||||
// Add styles
|
||||
const style = document.createElement('style')
|
||||
style.textContent = `
|
||||
.toast-container {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 9999;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.toast-item {
|
||||
padding: 12px 20px;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
color: white;
|
||||
backdrop-filter: blur(20px);
|
||||
animation: toast-in 0.3s ease;
|
||||
max-width: 350px;
|
||||
}
|
||||
.toast-item.success {
|
||||
background: rgba(52, 211, 153, 0.9);
|
||||
}
|
||||
.toast-item.error {
|
||||
background: rgba(239, 68, 68, 0.9);
|
||||
}
|
||||
.toast-item.warning {
|
||||
background: rgba(251, 191, 36, 0.9);
|
||||
color: #1e1b4b;
|
||||
}
|
||||
.toast-item.info {
|
||||
background: rgba(96, 165, 250, 0.9);
|
||||
}
|
||||
@keyframes toast-in {
|
||||
from { opacity: 0; transform: translateX(20px); }
|
||||
to { opacity: 1; transform: translateX(0); }
|
||||
}
|
||||
`
|
||||
document.head.appendChild(style)
|
||||
}
|
||||
|
||||
function showToast(options: ToastOptions) {
|
||||
ensureContainer()
|
||||
|
||||
const id = ++toastId
|
||||
toasts.value.push({ ...options, id })
|
||||
|
||||
setTimeout(() => {
|
||||
const index = toasts.value.findIndex(t => t.id === id)
|
||||
if (index > -1) {
|
||||
toasts.value.splice(index, 1)
|
||||
}
|
||||
}, options.duration || 3000)
|
||||
}
|
||||
|
||||
export function useToast() {
|
||||
return {
|
||||
success: (message: string) => showToast({ message, type: 'success' }),
|
||||
error: (message: string) => showToast({ message, type: 'error' }),
|
||||
warning: (message: string) => showToast({ message, type: 'warning' }),
|
||||
info: (message: string) => showToast({ message, type: 'info' })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user