@@ -4,6 +4,7 @@ const configs = require('../configs')
44const { ipcRenderer, remote : electronRemote , shell } = require ( 'electron' )
55const dialog = electronRemote . dialog
66const AdmZip = require ( 'adm-zip' )
7+ const Util = require ( '../Util' )
78const os = require ( 'os' )
89
910const app = electronRemote . app
@@ -23,28 +24,6 @@ const toolsRootDir = path.join(__dirname, '../', configs.TOOLS_DIR)
2324
2425const userConfig = require ( configs . USER_CONFIG_PATH )
2526
26- /**
27- * 同步删除文件夹
28- * @param {string } dir 要删除的目录
29- * @author romin
30- * @description 同步删除文件夹,https://juejin.im/post/5ab32b20518825557f00d36c
31- */
32- function removeDir ( dir ) {
33- let files = fs . readdirSync ( dir )
34- for ( var i = 0 ; i < files . length ; i ++ ) {
35- let newPath = path . join ( dir , files [ i ] )
36- let stat = fs . statSync ( newPath )
37- if ( stat . isDirectory ( ) ) {
38- //如果是文件夹就递归下去
39- removeDir ( newPath )
40- } else {
41- //删除文件
42- fs . unlinkSync ( newPath )
43- }
44- }
45- fs . rmdirSync ( dir ) //如果文件夹是空的,就将自己删除掉
46- }
47-
4827/**
4928 * 刷新所有模组和插件并重新加载DOM
5029 * @type {function }
@@ -386,7 +365,7 @@ const reloadDOM = (executes, mods, tools) => {
386365 }
387366 const onremoveFunction = ( ) => {
388367 infoCard . DOM . remove ( )
389- removeDir ( infoCard . infos . filesDir )
368+ Util . removeDir ( infoCard . infos . filesDir )
390369 refreshFunction ( )
391370 }
392371 infoCard . addEventListener ( 'change' , onchangeFunction )
@@ -467,7 +446,7 @@ const reloadDOM = (executes, mods, tools) => {
467446 }
468447 const onremoveFunction = ( ) => {
469448 infoCard . DOM . remove ( )
470- removeDir ( infoCard . infos . filesDir )
449+ Util . removeDir ( infoCard . infos . filesDir )
471450 refreshFunction ( )
472451 }
473452 infoCard . addEventListener ( 'change' , onchangeFunction )
@@ -520,7 +499,7 @@ const reloadDOM = (executes, mods, tools) => {
520499 }
521500 const onremoveFunction = ( ) => {
522501 infoCard . DOM . remove ( )
523- removeDir ( infoCard . infos . filesDir )
502+ Util . removeDir ( infoCard . infos . filesDir )
524503 refreshFunction ( )
525504 }
526505 infoCard . addEventListener ( 'click' , onClickFunction )
0 commit comments