23 lines
885 B
JavaScript
23 lines
885 B
JavaScript
import fs from 'fs';
|
||
import path from 'path';
|
||
import { fileURLToPath } from 'url';
|
||
import { dirname } from 'path';
|
||
|
||
// 获取当前模块文件的目录
|
||
const __filename = fileURLToPath(import.meta.url);
|
||
const __dirname = dirname(__filename);
|
||
|
||
// 使用相对于当前文件的路径(注意:文件在同一个目录下,不需要 .. )
|
||
const modelPath = path.join(__dirname, 'model.json');
|
||
const modelData = JSON.parse(fs.readFileSync(modelPath, 'utf8'));
|
||
|
||
const platformPath = path.join(__dirname, 'Platform.json');
|
||
const platformData = JSON.parse(fs.readFileSync(platformPath, 'utf8'));
|
||
|
||
const CostPath = path.join(__dirname, 'cost.json');
|
||
const CostData = JSON.parse(fs.readFileSync(CostPath, 'utf8'));
|
||
|
||
// const errorPath = path.join(__dirname, 'error.json');
|
||
// const errorData = JSON.parse(fs.readFileSync(errorPath, 'utf8'));
|
||
|
||
export { modelData, platformData, CostData }; |