Strategic Cooperation Description Update
Summary
Updated the Strategic Cooperation section to allow configurable descriptions from the admin panel, with content displayed in 2 lines on the official website.
Changes Made
1. Backend Changes
Database Model (backend/app/models.py)
- Added
description field (TEXT type) to StrategicCooperation model
API Routes (backend/app/routes.py)
- Updated GET endpoint to return
description field
- Updated POST endpoint to accept
description field
- Updated PUT endpoint to update
description field
2. Admin Panel Changes (admin-web/src/views/StrategicCooperation.vue)
- Added "描述" column to the table view
- Added textarea input for description in the create/edit dialog
- Updated form data structure to include
description field
- Description input supports multi-line text with 3 rows
3. Official Website Changes (official-web/src/views/Home.vue)
- Updated to display
description from API response
- Falls back to default text if description is empty
- CSS already configured to limit display to 2 lines using
-webkit-line-clamp: 2
4. Database Migration
Created migration files:
backend/add_description_to_strategic_cooperation.sql - SQL script
backend/migrate_strategic_cooperation.py - Python migration script
backend/MIGRATION_INSTRUCTIONS.md - Detailed instructions
How to Apply Changes
Step 1: Run Database Migration
cd backend
python migrate_strategic_cooperation.py
Step 2: Restart Backend Server
cd backend
python run.py
Step 3: Update Admin Panel
The admin panel will automatically pick up the new field. No rebuild needed if using dev server.
Step 4: Update Official Website
The official website will automatically display descriptions from the API.
Testing
- Log into admin panel at
http://localhost:5173
- Navigate to "战略合作" (Strategic Cooperation)
- Edit an existing item or create a new one
- Add a description in the textarea field
- Save the changes
- Visit the official website homepage
- Verify the description displays in the Strategic Cooperation section (limited to 2 lines)
Features
- ✅ Configurable descriptions from admin panel
- ✅ Multi-line textarea input (3 rows)
- ✅ Display limited to 2 lines on official website
- ✅ Automatic text overflow with ellipsis
- ✅ Fallback to default text if description is empty
- ✅ Backward compatible with existing data