[add] 動態讀json
This commit is contained in:
parent
84bba89e7e
commit
f8528713e6
@ -20,7 +20,13 @@
|
||||
],
|
||||
"directories": {
|
||||
"output": "release"
|
||||
}
|
||||
},
|
||||
"extraFiles": [
|
||||
{
|
||||
"from": "shared",
|
||||
"to": "resources/shared"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"dayjs": "^1.11.13",
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { app } from 'electron';
|
||||
import path from 'path';
|
||||
|
||||
export function getExternalJsonPath(filename: string): string {
|
||||
@ -7,6 +6,8 @@ export function getExternalJsonPath(filename: string): string {
|
||||
return path.join(__dirname, '../../shared/jsons', filename);
|
||||
} else {
|
||||
// 生产模式下使用外部路径
|
||||
return path.join(app.getPath('userData'), 'jsons', filename);
|
||||
const filepath = path.join(__dirname, `../../../shared/jsons/${filename}`);
|
||||
// console.log('filepath', filepath);
|
||||
return filepath;
|
||||
}
|
||||
}
|
@ -110,7 +110,7 @@ export default abstract class SlotSpinBase {
|
||||
|
||||
protected async GetTemps(): Promise<any> {
|
||||
const filePath = getExternalJsonPath(`slot${this.ID}.json`);
|
||||
console.log('filePath', filePath);
|
||||
// console.log('filePath', filePath);
|
||||
const data = await fs.promises.readFile(filePath, 'utf-8');
|
||||
const jsonData = JSON.parse(data);
|
||||
return jsonData;
|
||||
|
Loading…
Reference in New Issue
Block a user