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:
@@ -1214,6 +1214,20 @@ async def generate_image(
|
|||||||
# Save image
|
# Save image
|
||||||
image_url = service.save_image(result["image_b64"], str(current_user.id))
|
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(
|
return ImageGenerateResponse(
|
||||||
image_url=image_url,
|
image_url=image_url,
|
||||||
model=result["model"],
|
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/tailwind.config.js`
|
||||||
- Create: `/opt/imagecreator/imagecreator/frontend/src/main.ts`
|
- Create: `/opt/imagecreator/imagecreator/frontend/src/main.ts`
|
||||||
- Create: `/opt/imagecreator/imagecreator/frontend/src/App.vue`
|
- 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/router/index.ts`
|
||||||
- Create: `/opt/imagecreator/imagecreator/frontend/src/api/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**
|
- [ ] **Step 1: Create package.json**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@@ -1690,7 +1709,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
export default router
|
export default router
|
||||||
```
|
```
|
||||||
|
|
||||||
- [ ] **Step 8: Create style.css**
|
- [ ] **Step 9: Create style.css**
|
||||||
|
|
||||||
```css
|
```css
|
||||||
/* src/style.css */
|
/* src/style.css */
|
||||||
@@ -1759,6 +1778,7 @@ export const authApi = {
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { authApi } from '../api/auth'
|
import { authApi } from '../api/auth'
|
||||||
|
import api from '../api/index'
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', () => {
|
export const useAuthStore = defineStore('auth', () => {
|
||||||
const token = ref<string | null>(localStorage.getItem('access_token'))
|
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 })
|
const response = await authApi.login({ username, password })
|
||||||
token.value = response.data.access_token
|
token.value = response.data.access_token
|
||||||
localStorage.setItem('access_token', 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) => {
|
const register = async (username: string, email: string, password: string) => {
|
||||||
@@ -1780,7 +1812,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
localStorage.removeItem('access_token')
|
localStorage.removeItem('access_token')
|
||||||
}
|
}
|
||||||
|
|
||||||
return { token, user, login, register, logout }
|
return { token, user, login, register, logout, fetchCurrentUser }
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,8 @@
|
|||||||
| 模型 | Provider | T2I | I2I | 风格迁移 | 变体 |
|
| 模型 | Provider | T2I | I2I | 风格迁移 | 变体 |
|
||||||
|------|----------|-----|-----|----------|------|
|
|------|----------|-----|-----|----------|------|
|
||||||
| Gemini 2.5 Flash | Google | ✓ | ✓ | ✓ | ✓ |
|
| Gemini 2.5 Flash | Google | ✓ | ✓ | ✓ | ✓ |
|
||||||
| DALL-E 3 | OpenAI | ✓ | - | - | - |
|
|
||||||
|
> **注意**: 当前版本仅支持 Gemini 模型。OpenAI DALL-E 等其他模型可在后续版本中添加。
|
||||||
|
|
||||||
### 4. 历史记录
|
### 4. 历史记录
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user