fix: address plan review issues

- Add history saving to generate_image endpoint
- Remove DALL-E from spec (Gemini only for now)
- Add mkdir commands for frontend directories
- Add fetchCurrentUser to auth store

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-24 14:43:04 +08:00
parent ce6a775ffd
commit eb47af57c4
2 changed files with 36 additions and 3 deletions
@@ -1214,6 +1214,20 @@ async def generate_image(
# Save image
image_url = service.save_image(result["image_b64"], str(current_user.id))
# Save to history
from app.models.history import GenerationHistory
history_item = GenerationHistory(
user_id=current_user.id,
original_prompt=data.prompt,
optimized_prompt=data.optimized_prompt,
mode=data.mode,
model=result["model"],
image_url=image_url,
input_image_url=f"/uploads/{input_image_b64.split('/')[0]}.png" if data.mode == "image2image" and data.input_image_b64 else None
)
db.add(history_item)
db.commit()
return ImageGenerateResponse(
image_url=image_url,
model=result["model"],
@@ -1512,9 +1526,14 @@ git add -A && git commit -m "feat: add backend Dockerfile and docker-compose"
- Create: `/opt/imagecreator/imagecreator/frontend/tailwind.config.js`
- Create: `/opt/imagecreator/imagecreator/frontend/src/main.ts`
- Create: `/opt/imagecreator/imagecreator/frontend/src/App.vue`
- Create: `/opt/imagecreator/imagecreator/frontend/src/style.css`
- Create: `/opt/imagecreator/imagecreator/frontend/src/router/index.ts`
- Create: `/opt/imagecreator/imagecreator/frontend/src/api/index.ts`
- [ ] **Step 0: Create frontend directory structure**
Run: `mkdir -p /opt/imagecreator/imagecreator/frontend/src/{api,components,views,stores,router}`
- [ ] **Step 1: Create package.json**
```json
@@ -1690,7 +1709,7 @@ router.beforeEach((to, from, next) => {
export default router
```
- [ ] **Step 8: Create style.css**
- [ ] **Step 9: Create style.css**
```css
/* src/style.css */
@@ -1759,6 +1778,7 @@ export const authApi = {
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { authApi } from '../api/auth'
import api from '../api/index'
export const useAuthStore = defineStore('auth', () => {
const token = ref<string | null>(localStorage.getItem('access_token'))
@@ -1768,6 +1788,18 @@ export const useAuthStore = defineStore('auth', () => {
const response = await authApi.login({ username, password })
token.value = response.data.access_token
localStorage.setItem('access_token', response.data.access_token)
await fetchCurrentUser()
}
const fetchCurrentUser = async () => {
if (!token.value) return
try {
const response = await api.get('/users/me')
user.value = response.data
} catch {
// Token might be expired
logout()
}
}
const register = async (username: string, email: string, password: string) => {
@@ -1780,7 +1812,7 @@ export const useAuthStore = defineStore('auth', () => {
localStorage.removeItem('access_token')
}
return { token, user, login, register, logout }
return { token, user, login, register, logout, fetchCurrentUser }
})
```