mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
fix:高版本node报错
This commit is contained in:
parent
b92c557b19
commit
6765ecfc85
4 changed files with 26 additions and 2 deletions
|
|
@ -1,5 +1,8 @@
|
|||
import settings from '../settings.js';
|
||||
import PartnerId2SpriteId from '../../resources/map/PartnerId2Data.json' assert { type: 'json' };
|
||||
// import PartnerId2SpriteId from '../../resources/map/PartnerId2Data.json' assert { type: 'json' };
|
||||
import { getMapData } from '../../utils/file.js';
|
||||
|
||||
const PartnerId2SpriteId = getMapData('PartnerId2Data');
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import WeaponId2Sprite from '../../resources/map/WeaponId2Sprite.json' assert { type: 'json' };
|
||||
// import WeaponId2Sprite from '../../resources/map/WeaponId2Sprite.json' assert { type: 'json' };
|
||||
import { getMapData } from '../../utils/file.js';
|
||||
|
||||
const WeaponId2Sprite = getMapData('WeaponId2Sprite');
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ export const resourcesPath = path.join(pluginPath, 'resources');
|
|||
|
||||
export const imageResourcesPath = path.join(resourcesPath, 'images');
|
||||
|
||||
export const mapResourcesPath = path.join(resourcesPath, 'maps');
|
||||
|
||||
// config 路径
|
||||
export const configPath = path.join(pluginPath, 'config');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,22 @@
|
|||
import fs from 'fs';
|
||||
import { mapResourcesPath } from '../lib/path.js';
|
||||
export function checkFolderExistAndCreate(folderPath) {
|
||||
if (!fs.existsSync(folderPath)) {
|
||||
fs.mkdirSync(folderPath, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} fileName 名称(不包含后缀)
|
||||
* @returns {object | null}
|
||||
*/
|
||||
export function getMapData(fileName) {
|
||||
const mapDataPath = `${mapResourcesPath}/${fileName}.json`;
|
||||
try {
|
||||
const mapData = fs.readFileSync(mapDataPath, 'utf-8');
|
||||
return JSON.parse(mapData);
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue