@@ -35,6 +35,14 @@ protocol.registerSchemesAsPrivileged([
3535 stream : true ,
3636 bypassCSP : true
3737 }
38+ } ,
39+ {
40+ scheme : 'local-image' ,
41+ privileges : {
42+ secure : true ,
43+ supportFetchAPI : true ,
44+ bypassCSP : true
45+ }
3846 }
3947] )
4048
@@ -116,7 +124,8 @@ function createWindow() {
116124 webPreferences : {
117125 preload : join ( __dirname , 'preload.js' ) ,
118126 contextIsolation : true ,
119- nodeIntegration : false
127+ nodeIntegration : false ,
128+ webSecurity : false // 允许加载本地文件
120129 } ,
121130 titleBarStyle : 'hidden' ,
122131 titleBarOverlay : {
@@ -198,7 +207,8 @@ function createChatWindow() {
198207 webPreferences : {
199208 preload : join ( __dirname , 'preload.js' ) ,
200209 contextIsolation : true ,
201- nodeIntegration : false
210+ nodeIntegration : false ,
211+ webSecurity : false // 允许加载本地文件
202212 } ,
203213 titleBarStyle : 'hidden' ,
204214 titleBarOverlay : {
@@ -274,7 +284,8 @@ function createGroupAnalyticsWindow() {
274284 webPreferences : {
275285 preload : join ( __dirname , 'preload.js' ) ,
276286 contextIsolation : true ,
277- nodeIntegration : false
287+ nodeIntegration : false ,
288+ webSecurity : false // 允许加载本地文件
278289 } ,
279290 titleBarStyle : 'hidden' ,
280291 titleBarOverlay : {
@@ -361,7 +372,8 @@ function createChatHistoryWindow(sessionId: string, messageId: number) {
361372 webPreferences : {
362373 preload : join ( __dirname , 'preload.js' ) ,
363374 contextIsolation : true ,
364- nodeIntegration : false
375+ nodeIntegration : false ,
376+ webSecurity : false // 允许加载本地文件
365377 } ,
366378 titleBarStyle : 'hidden' ,
367379 titleBarOverlay : {
@@ -428,7 +440,8 @@ function createAnnualReportWindow(year: number) {
428440 webPreferences : {
429441 preload : join ( __dirname , 'preload.js' ) ,
430442 contextIsolation : true ,
431- nodeIntegration : false
443+ nodeIntegration : false ,
444+ webSecurity : false // 允许加载本地文件
432445 } ,
433446 titleBarStyle : 'hidden' ,
434447 titleBarOverlay : {
@@ -501,7 +514,8 @@ function createAgreementWindow() {
501514 webPreferences : {
502515 preload : join ( __dirname , 'preload.js' ) ,
503516 contextIsolation : true ,
504- nodeIntegration : false
517+ nodeIntegration : false ,
518+ webSecurity : false // 允许加载本地文件
505519 } ,
506520 titleBarStyle : 'hidden' ,
507521 titleBarOverlay : {
@@ -564,7 +578,8 @@ function createWelcomeWindow() {
564578 webPreferences : {
565579 preload : join ( __dirname , 'preload.js' ) ,
566580 contextIsolation : true ,
567- nodeIntegration : false
581+ nodeIntegration : false ,
582+ webSecurity : false // 允许加载本地文件
568583 } ,
569584 show : false
570585 } )
@@ -609,7 +624,8 @@ function createPurchaseWindow() {
609624 icon : iconPath ,
610625 webPreferences : {
611626 contextIsolation : true ,
612- nodeIntegration : false
627+ nodeIntegration : false ,
628+ webSecurity : false // 允许加载本地文件
613629 } ,
614630 title : '获取激活码 - 密语' ,
615631 show : false ,
@@ -893,7 +909,8 @@ function createAISummaryWindow(sessionId: string, sessionName: string) {
893909 webPreferences : {
894910 preload : join ( __dirname , 'preload.js' ) ,
895911 contextIsolation : true ,
896- nodeIntegration : false
912+ nodeIntegration : false ,
913+ webSecurity : false // 允许加载本地文件
897914 } ,
898915 // 使用自定义标题栏但保留原生窗口控件
899916 frame : false ,
@@ -1724,6 +1741,10 @@ function registerIpcHandlers() {
17241741 return chatService . getContactAvatar ( username )
17251742 } )
17261743
1744+ ipcMain . handle ( 'chat:resolveTransferDisplayNames' , async ( _ , chatroomId : string , payerUsername : string , receiverUsername : string ) => {
1745+ return chatService . resolveTransferDisplayNames ( chatroomId , payerUsername , receiverUsername )
1746+ } )
1747+
17271748 ipcMain . handle ( 'chat:getMyAvatarUrl' , async ( ) => {
17281749 const result = chatService . getMyAvatarUrl ( )
17291750 // 首页会调用这个接口,失败是正常的,不记录错误日志
@@ -1968,6 +1989,40 @@ function registerIpcHandlers() {
19681989 }
19691990 } )
19701991
1992+ ipcMain . handle ( 'cache:clearEmojis' , async ( ) => {
1993+ logService ?. info ( 'Cache' , '开始清除表情包缓存' )
1994+ try {
1995+ const cacheService = new ( await import ( './services/cacheService' ) ) . CacheService ( configService ! )
1996+ const result = await cacheService . clearEmojis ( )
1997+ if ( result . success ) {
1998+ logService ?. info ( 'Cache' , '表情包缓存清除成功' )
1999+ } else {
2000+ logService ?. error ( 'Cache' , '表情包缓存清除失败' , { error : result . error } )
2001+ }
2002+ return result
2003+ } catch ( e ) {
2004+ logService ?. error ( 'Cache' , '表情包缓存清除异常' , { error : String ( e ) } )
2005+ return { success : false , error : String ( e ) }
2006+ }
2007+ } )
2008+
2009+ ipcMain . handle ( 'cache:clearDatabases' , async ( ) => {
2010+ logService ?. info ( 'Cache' , '开始清除数据库缓存' )
2011+ try {
2012+ const cacheService = new ( await import ( './services/cacheService' ) ) . CacheService ( configService ! )
2013+ const result = await cacheService . clearDatabases ( )
2014+ if ( result . success ) {
2015+ logService ?. info ( 'Cache' , '数据库缓存清除成功' )
2016+ } else {
2017+ logService ?. error ( 'Cache' , '数据库缓存清除失败' , { error : result . error } )
2018+ }
2019+ return result
2020+ } catch ( e ) {
2021+ logService ?. error ( 'Cache' , '数据库缓存清除异常' , { error : String ( e ) } )
2022+ return { success : false , error : String ( e ) }
2023+ }
2024+ } )
2025+
19712026 ipcMain . handle ( 'cache:clearAll' , async ( ) => {
19722027 logService ?. info ( 'Cache' , '开始清除所有缓存' )
19732028 try {
@@ -2835,7 +2890,8 @@ function createSplashWindow(): BrowserWindow {
28352890 webPreferences : {
28362891 preload : join ( __dirname , 'preload.js' ) ,
28372892 contextIsolation : true ,
2838- nodeIntegration : false
2893+ nodeIntegration : false ,
2894+ webSecurity : false // 允许加载本地文件
28392895 } ,
28402896 backgroundColor : '#00000000' // 完全透明的背景色
28412897 } )
0 commit comments