4.4 KiB
4.4 KiB
Implementation Plan
Phase 1: UI Consistency & Visual Polish
Goal: Align the Admin UI with the UI2.html artistic direction (Dark Glassmorphism, specific typography).
-
Font & Theme Configuration
- Update
client/index.htmlto includePlayfair Display(Serif) andJetBrains Mono(Monospace) fonts. - Update
client/tailwind.config.js(orstyle.css) to define these font families. - Define global CSS variables for colors if not already present (
--art-bg,--art-accent, etc.) to matchUI2.html.
- Update
-
Admin UI Refinement
- Update
client/src/components/admin/AdminLayout.vue:- Apply
Playfair Displayto the "管理后台" sidebar title. - Refine sidebar transparency and blur effects to match
UI2.html.
- Apply
- Update
client/src/pages/admin/Dashboard.vue:- Apply serif fonts to section headers.
- Ensure cards use the correct glassmorphism background (
rgba(255, 255, 255, 0.05)).
- Responsive Check: Verify sidebar behavior on mobile (already present in code, but needs visual verification of transition/overlay).
- Update
-
Component Standardization
- Ensure
CustomSelect.vueis used in place of native<select>elements in all admin forms (UserForm.vue,PostForm.vue, etc.).
- Ensure
Phase 2: Database & RBAC Implementation
Goal: Implement a robust Role-Based Access Control system.
-
Database Schema Update
- Modify
server/nl_blog.sqlto include:rolestable (id, name, description, created_at...).permissionstable (id, name, resource, action...).role_permissionsjunction table.- Update
userstable to referenceroles.id(foreign key) instead of a string enum, or keep the string but validate against the table. Decision: Use foreign key for strict integrity.
- Add default data: Admin, Editor, Viewer roles and basic permissions.
- Modify
-
Backend Models & Repositories
- Create/Update
server/models/role.goandpermission.go. - Create
server/repositories/permission_repository.go. - Update
server/repositories/user_repository.goto handle role relationships.
- Create/Update
-
Middleware & Logic
- Update
server/middleware/auth.go:- Load user's permissions upon authentication (or cache them).
- Implement
PermissionMiddleware(resource, action)to replace the simpleRoleMiddleware.
- Update
-
API Endpoints
- Add CRUD endpoints for Roles and Permissions in
server/main.go. - Add endpoint to assign permissions to roles.
- Add CRUD endpoints for Roles and Permissions in
Phase 3: Backend Code Execution (Sandbox)
Goal: Securely execute code snippets.
-
Runner Logic (
server/runner)- Create a package
runnerto handle code execution. - Strategy:
- Backend Languages (Go, PHP, Python): Write code to a temporary file, execute via
os/execwith a strictcontext.WithTimeout(e.g., 5s limit). Capturestdoutandstderr. - Frontend Languages (Vue, React, HTML): Do not "execute" on backend. Return the code wrapped in a secure
<iframe>template for the frontend to render.
- Backend Languages (Go, PHP, Python): Write code to a temporary file, execute via
- Security:
- Input validation: Block common dangerous keywords (e.g.,
os.Remove,rm -rf,exec) using regex for a basic layer of protection (Note: not perfect, but adds friction). - Resource limits: Set execution timeouts.
- Input validation: Block common dangerous keywords (e.g.,
- Create a package
-
API Implementation
- Add
POST /api/runendpoint. - Accepts
{ language: string, code: string }. - Returns
{ output: string, error: string, duration: int }.
- Add
-
Logging
- Log every execution attempt (User, IP, Code hash, Result) to a new
execution_logstable or existing logs.
- Log every execution attempt (User, IP, Code hash, Result) to a new
Phase 4: Backend UI Optimization
Goal: Unify the visual style of forms and tables.
-
Global Styles
- Create a standard "Glass Table" CSS class/component for
Users.vue,Posts.vue, etc. - Create a standard "Glass Form" style for inputs and textareas (remove default borders, add bottom border + glow effect).
- Create a standard "Glass Table" CSS class/component for
-
Page Refactoring
- Apply these styles to:
client/src/pages/admin/Users.vue&UserForm.vueclient/src/pages/admin/Posts.vue&PostForm.vueclient/src/pages/admin/Roles.vue(New page)
- Apply these styles to:
-
Validation Feedback
- Ensure form errors use the "Artistic Error Red" (
#ef4444) and shake animation fromUI2.html.
- Ensure form errors use the "Artistic Error Red" (