@@ -8,7 +8,22 @@ import logger from './logger';
8
8
import { setting } from './db/service' ;
9
9
import puppeteerInElectron from '../utils/pie' ;
10
10
11
- export const ipcListen = ( ) => {
11
+
12
+ const tmpDir = async ( path : string ) => {
13
+ try {
14
+ const pathExists = await fs . pathExistsSync ( path ) ;
15
+ logger . info ( `[ipcMain] tmpDir: ${ path } -exists-${ pathExists } ` ) ;
16
+ if ( pathExists ) {
17
+ await fs . removeSync ( path ) ; // 删除文件, 不存在不会报错
18
+ }
19
+ await fs . emptyDirSync ( path ) ; // 清空目录, 不存在自动创建
20
+ logger . info ( `[ipcMain] tmpDir: ${ path } -created-sucess` ) ;
21
+ } catch ( err ) {
22
+ logger . error ( err )
23
+ }
24
+ } ;
25
+
26
+ const ipcListen = ( ) => {
12
27
ipcMain . on ( 'uninstallShortcut' , ( ) => {
13
28
logger . info ( `[ipcMain] globalShortcut unregisterAll` ) ;
14
29
globalShortcut . unregisterAll ( ) ;
@@ -53,20 +68,6 @@ export const ipcListen = () => {
53
68
return totalSize ;
54
69
} ;
55
70
56
- const tmpDir = async ( path : string ) => {
57
- try {
58
- const pathExists = await fs . pathExistsSync ( path ) ;
59
- logger . info ( `[ipcMain] tmpDir: ${ path } -exists-${ pathExists } ` ) ;
60
- if ( pathExists ) {
61
- await fs . removeSync ( path ) ; // 删除文件, 不存在不会报错
62
- }
63
- await fs . emptyDirSync ( path ) ; // 清空目录, 不存在自动创建
64
- logger . info ( `[ipcMain] tmpDir: ${ path } -created-sucess` ) ;
65
- } catch ( err ) {
66
- logger . error ( err )
67
- }
68
- } ;
69
-
70
71
ipcMain . on ( 'tmpdir-manage' , ( event , action , trails ) => {
71
72
let formatPath ;
72
73
if ( is . dev ) {
@@ -139,4 +140,6 @@ export const ipcListen = () => {
139
140
ipcMain . on ( 'quit-app' , ( ) => {
140
141
app . quit ( ) ;
141
142
} ) ;
142
- }
143
+ }
144
+
145
+ export { ipcListen , tmpDir }
0 commit comments