Modify backend database structure:
photostable: removealbum_idfield, addfilenamefield, addphoto_timefieldfilenamedefaults to the file name when the photo is uploaded, allowing users to modify the file name after uploadingphoto_timeextraction: extract the shooting time of the photo from the photo's metadata and store it in thephoto_timefield. If there is no shooting time in the metadata, the time when the photo was uploaded is used by default.
- Add
album_photostable to store the many-to-many relationship between photos and albums. One photo may correspond to multiple albums, and one album contains multiple photos. album_photostable structure:- id: primary key
- album_id: album ID, foreign key referencing
albumstable - photo_id: photo ID, foreign key referencing
photostable - created_at: creation time
photo_metadatatable: modifycamera_infotoexif_infofield, used to store the camera information of the photo. Location information includes two types: one is latitude and longitude, and the other is human-readable address information (such as city, street, etc., which needs to be obtained from third-party APIs, temporarily reserving the interface for future extension), and returning the address information to the frontend for display.- Modify the corresponding CRUD code and API interfaces for both frontend and backend to correspond completely.
Specific implementation plan for modifying backend database structure:
photostable structure adjustment:- Remove
album_idfield - Add
filenamefield: VARCHAR(255), storing photo file name - Add
photo_timefield: TIMESTAMP, storing photo shooting time - Implementation logic:
- Filename processing: automatically fill in the original file name when uploading, providing API interface for users to modify
- Photo time processing: prioritize extracting
DateTimeOriginalfield from EXIF metadata. If not available, extract time from file name (formats such as 20230815_123456, 20230815, etc.). If the file name also has no time information, use the current system time.
- Remove
Add
album_photosassociation table:- Table structure:
- id: INT PRIMARY KEY AUTO_INCREMENT
- album_id: INT NOT NULL, foreign key constraint REFERENCES albums(id)
- photo_id: INT NOT NULL, foreign key constraint REFERENCES photos(id)
- created_at: TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- Create composite unique index (album_id, photo_id) to prevent duplicate associations
- Table structure:
photo_metadatatable modification:- Rename
camera_infotoexif_info: TEXT, storing complete EXIF metadata - Add
locationfield: JSON, storing structured location information- Includes: latitude (float), longitude (float), formatted_address (string)
- Keep
location_apifield: VARCHAR(255), reserved for subsequent address parsing API
- Rename
API interface adjustment:
- Photo related interfaces:
- Upload interface: return complete photo information including filename
- Update interface: support modifying filename
- Query interface: return list of all album IDs associated with the photo
- Album related interfaces:
- Add/Remove photos: operate on
album_photostable - Query album photos: joint query of
photosandalbum_photostables
- Add/Remove photos: operate on
- Photo related interfaces:
Frontend and backend coordination:
- Update API documentation and TypeScript type definitions
- Frontend needs adaptation:
- Photo upload process adjustment
- Album management interface supports many-to-many relationships
- Photo detail page displays EXIF information and location data
Refactor photo display functions in PhotosPage.vue and AlbumDetail.vue into a common component module, implementing the following specific optimization plans:
Component extraction requirements:
- Create a common component named
PhotoGallery.vue - Extract the photo display layout, style, and interaction logic shared by the two pages
- Retain the special business logic differences of each page
- Create a common component named
Performance optimization plan
- Implement Virtual Scrolling technology
- Add Image Lazy Loading function
- Adopt Responsive Images scheme
- Implement Image Preloading strategy
- Add loading state Placeholder
Interface design
- Define unified props interface:
- photos:
Array<Photo> (required) - loading: Boolean
- layoutType: 'grid' | 'masonry' (default 'grid')
- Other customized parameters
Implementation steps
- Analyze the functional differences between the two pages
- Abstract common logic to
PhotoGallerycomponent - Replace original implementation in both pages
- Add performance optimization functions
- Write unit tests
Quality requirements
- Maintain 100% compatibility with original functions
- Improve first screen loading performance by more than 30%
- Scroll smoothness reaches 60FPS
- Reduce memory usage by 20%
- Support accessibility
Refactor PhotosPage.vue and PhotoGallery.vue components to achieve the following functional improvements
Add "Save to Local" option in batch selection function
- Add a save button or menu item, clicking it can batch download selected images to the user's device
- Implement file download function, ensuring support for simultaneous multi-file download
- Add download progress prompt and completion notification
Migrate batch selection function to common component
PhotoGallery.vue:- Extract batch selection related code from
PhotosPage.vue - Implement general batch selection logic in
PhotoGallery.vue - Receive configuration parameters through props and trigger parent component operations through events
- Ensure style and interaction behavior are consistent with original functions
- Extract batch selection related code from