Skip to content

Commit

Permalink
feat: create asar on export game
Browse files Browse the repository at this point in the history
  • Loading branch information
nini22P committed Jul 13, 2024
1 parent 7e5da2e commit b1f3d88
Show file tree
Hide file tree
Showing 3 changed files with 1,205 additions and 1,140 deletions.
1 change: 1 addition & 0 deletions packages/terre2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"dependencies": {
"@babel/traverse": "7.23.2",
"@electron/asar": "^3.2.10",
"@fastify/static": "^7.0.1",
"@nestjs/common": "^9.0.5",
"@nestjs/core": "^9.0.5",
Expand Down
25 changes: 25 additions & 0 deletions packages/terre2/src/Modules/manage-game/manage-game.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ConsoleLogger, Injectable } from '@nestjs/common';
import { _open } from '../../util/open';
import { IFileInfo, WebgalFsService } from '../webgal-fs/webgal-fs.service';
import * as process from 'process';
import * as asar from '@electron/asar';

@Injectable()
export class ManageGameService {
Expand Down Expand Up @@ -218,6 +219,14 @@ export class ManageGameService {
gameDir,
`${electronExportDir}/resources/app/public/game/`,
);
// 创建 app.asar
await asar.createPackage(
`${electronExportDir}/resources/app/`,
`${electronExportDir}/resources/app.asar`,
);
await this.webgalFs.deleteFileOrDirectory(
`${electronExportDir}/resources/app/`,
)
await _open(electronExportDir);
}
if (process.platform === 'linux') {
Expand Down Expand Up @@ -259,6 +268,14 @@ export class ManageGameService {
gameDir,
`${electronExportDir}/resources/app/public/game/`,
);
// 创建 app.asar
await asar.createPackage(
`${electronExportDir}/resources/app/`,
`${electronExportDir}/resources/app.asar`,
);
await this.webgalFs.deleteFileOrDirectory(
`${electronExportDir}/resources/app/`,
)
await _open(electronExportDir);
}
if (process.platform === 'darwin') {
Expand Down Expand Up @@ -300,6 +317,14 @@ export class ManageGameService {
gameDir,
`${electronExportDir}/Contents/Resources/app/public/game/`,
);
// 创建 app.asar
await asar.createPackage(
`${electronExportDir}/Contents/Resources/app/`,
`${electronExportDir}/Contents/Resources/app.asar`,
);
await this.webgalFs.deleteFileOrDirectory(
`${electronExportDir}/Contents/Resources/app/`,
)
await _open(exportDir);
}
}
Expand Down
Loading

0 comments on commit b1f3d88

Please sign in to comment.