Spaces:
Sleeping
Sleeping
Đỗ Hải Nam
commited on
Commit
·
f84178d
1
Parent(s):
5a43934
fix: resolve broken image assets on production by using asset imports
Browse files- frontend/src/App.jsx +12 -3
frontend/src/App.jsx
CHANGED
|
@@ -7,7 +7,10 @@ import { SearchModal, ImageViewer, SettingsModal } from './components/Modals'
|
|
| 7 |
import { Menu, MoreHorizontal } from 'lucide-react'
|
| 8 |
import './App.css'
|
| 9 |
import GuideTour from './components/GuideTour'
|
| 10 |
-
import
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
const API_BASE = '/api'
|
| 13 |
|
|
@@ -38,9 +41,15 @@ function App() {
|
|
| 38 |
try {
|
| 39 |
const profile = JSON.parse(saved)
|
| 40 |
// Migrate old static paths to new hashed assets
|
| 41 |
-
if (profile.avatar === '/
|
| 42 |
-
profile.avatar =
|
| 43 |
localStorage.setItem('user_profile', JSON.stringify(profile))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
return profile
|
| 46 |
} catch (e) {
|
|
|
|
| 7 |
import { Menu, MoreHorizontal } from 'lucide-react'
|
| 8 |
import './App.css'
|
| 9 |
import GuideTour from './components/GuideTour'
|
| 10 |
+
import pochiAsset from './assets/pochi.jpeg'
|
| 11 |
+
import hnamAsset from './assets/hnam.jpeg'
|
| 12 |
+
|
| 13 |
+
const defaultAvatar = pochiAsset
|
| 14 |
|
| 15 |
const API_BASE = '/api'
|
| 16 |
|
|
|
|
| 41 |
try {
|
| 42 |
const profile = JSON.parse(saved)
|
| 43 |
// Migrate old static paths to new hashed assets
|
| 44 |
+
if (profile.avatar === '/pochi.jpeg') {
|
| 45 |
+
profile.avatar = pochiAsset
|
| 46 |
localStorage.setItem('user_profile', JSON.stringify(profile))
|
| 47 |
+
} else if (profile.avatar === '/hnam.jpeg' || (profile.avatar && profile.avatar.includes('hnam'))) {
|
| 48 |
+
// Only update if it's the old string path or contains 'hnam' but isn't already the hashed asset path
|
| 49 |
+
if (typeof profile.avatar === 'string' && !profile.avatar.startsWith('data:') && !profile.avatar.includes('assets/hnam-')) {
|
| 50 |
+
profile.avatar = hnamAsset
|
| 51 |
+
localStorage.setItem('user_profile', JSON.stringify(profile))
|
| 52 |
+
}
|
| 53 |
}
|
| 54 |
return profile
|
| 55 |
} catch (e) {
|