diff --git a/components/Cfg.js b/components/Cfg.js index eabce460..d71d7f1a 100644 --- a/components/Cfg.js +++ b/components/Cfg.js @@ -3,7 +3,8 @@ import lodash from 'lodash' import cfgData from './cfg/CfgData.js' import { Version } from '#miao' -const _path = process.cwd() +//const _path = process.cwd() +const _path = import.meta.dirname + '/../../../' const _cfgPath = `${_path}/plugins/miao-plugin/components/` let cfg = {} let miaoCfg = {} diff --git a/components/Data.js b/components/Data.js index 849e4ae7..44e4d576 100644 --- a/components/Data.js +++ b/components/Data.js @@ -2,7 +2,8 @@ import lodash from 'lodash' import fs from 'node:fs' import util from 'node:util' -const _path = process.cwd() +//const _path = process.cwd() +const _path = import.meta.dirname + '/../../../' const getRoot = (root = '') => { if (!root) { root = `${_path}/` diff --git a/models/ProfileDmg.js b/models/ProfileDmg.js index 70002197..f06bde91 100644 --- a/models/ProfileDmg.js +++ b/models/ProfileDmg.js @@ -20,14 +20,15 @@ export default class ProfileDmg extends Base { } static dmgRulePath (name, game = 'gs') { - const _path = process.cwd() + //const _path = process.cwd() + const _path = import.meta.dirname + '/../' let dmgFile = [ { file: 'calc_user', name: '自定义伤害' }, { file: 'calc_auto', name: '组团伤害', test: () => Common.cfg('teamCalc') }, { file: 'calc', name: '喵喵' } ] for (let ds of dmgFile) { - let path = `${_path}/plugins/miao-plugin/resources/meta-${game}/character/${name}/${ds.file}.js` + let path = `${_path}/resources/meta-${game}/character/${name}/${ds.file}.js` if (ds.test && !ds.test()) { continue } diff --git a/models/character/CharCfg.js b/models/character/CharCfg.js index 95a56f9b..aaa75723 100644 --- a/models/character/CharCfg.js +++ b/models/character/CharCfg.js @@ -2,7 +2,7 @@ import { Data } from '#miao' import lodash from 'lodash' import fs from 'node:fs' -const charPath = process.cwd() + '/plugins/miao-plugin/resources/meta-gs/character' +const charPath = import.meta.dirname + '../../../resources/meta-gs/character' let cfgMap = { char: {}, async init () { diff --git a/models/index.js b/models/index.js index e86305ea..7b9c3221 100644 --- a/models/index.js +++ b/models/index.js @@ -17,10 +17,10 @@ import Button from './Button.js' for (let game of ['gs', 'sr']) { for (let type of ['artifact', 'character', 'material', 'weapon']) { - let file = `./plugins/miao-plugin/resources/meta-${game}/${type}/index.js` + let file = `${import.meta.dirname}/../resources/meta-${game}/${type}/index.js` if (fs.existsSync(file)) { try { - await import(`file://${process.cwd()}/${file}`) + await import(`file://${file}`) } catch (e) { console.log(e) }