Skip to content

Commit 69d7e82

Browse files
committed
feat(ui): modernize CharacterModals with glassmorphism design and add save API
UI Improvements: - Redesign modal wrapper with gradient background and decorative glow effects - Apply glassmorphism styling (backdrop-blur, white/10 borders, rounded-2xl/3xl) - Update form inputs with modern styling (rounded-xl, focus rings, transitions) - Enhance range slider with gradient thumb and dynamic fill - Improve tag badges with border accents - Add glow drop-shadow utilities in tailwind config API Additions: - Add db-save-character-details IPC handler in database-handlers.js - Syncs profile fields (name, nickname, relationship_label, etc.) to characters table - Expose saveCharacterDetails in preload.js - Add graceful fallback with user-friendly error message if API not loaded
1 parent 1d4d666 commit 69d7e82

4 files changed

Lines changed: 143 additions & 70 deletions

File tree

desktop/src/core/modules/ipc-handlers/database-handlers.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,46 @@ export function registerDatabaseHandlers({ db }) {
177177
}
178178
});
179179

180+
ipcMain.handle('db-save-character-details', (event, characterId, details) => {
181+
try {
182+
const normalizedDetails = {
183+
...(details || {}),
184+
character_id: characterId,
185+
updated_at: Date.now()
186+
};
187+
188+
// 1) 先保存详情表
189+
const ok = db.saveCharacterDetails(characterId, normalizedDetails);
190+
191+
// 2) 如果详情里包含 profile,则同步更新 characters 主表,避免 UI 列表与详情不一致
192+
const profile = normalizedDetails?.profile;
193+
if (profile && typeof profile === 'object') {
194+
const updates = {};
195+
const allowed = [
196+
'name',
197+
'nickname',
198+
'relationship_label',
199+
'avatar_color',
200+
'affinity',
201+
'notes'
202+
];
203+
for (const key of allowed) {
204+
if (Object.prototype.hasOwnProperty.call(profile, key)) {
205+
updates[key] = profile[key];
206+
}
207+
}
208+
if (Object.keys(updates).length > 0) {
209+
db.updateCharacter(characterId, updates);
210+
}
211+
}
212+
213+
return !!ok;
214+
} catch (error) {
215+
console.error('Error saving character details:', error);
216+
return false;
217+
}
218+
});
219+
180220
ipcMain.handle(
181221
'db-update-character-details-custom-fields',
182222
(event, characterId, customFields) => {

desktop/src/preload.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
144144
getConversationAIData: (conversationId) => ipcRenderer.invoke('db-get-conversation-ai-data', conversationId),
145145
selectActionSuggestion: (payload) => ipcRenderer.invoke('db-select-action-suggestion', payload),
146146
getCharacterDetails: (characterId) => ipcRenderer.invoke('db-get-character-details', characterId),
147+
saveCharacterDetails: (characterId, details) =>
148+
ipcRenderer.invoke('db-save-character-details', characterId, details),
147149
updateCharacterDetailsCustomFields: (characterId, customFields) => ipcRenderer.invoke('db-update-character-details-custom-fields', characterId, customFields),
148150
regenerateCharacterDetails: (characterId) => ipcRenderer.invoke('db-regenerate-character-details', characterId),
149151
deleteConversation: (conversationId) => ipcRenderer.invoke('db-delete-conversation', conversationId),

0 commit comments

Comments
 (0)