mirror of
https://github.com/qitoqito/psyduck.git
synced 2026-01-18 16:50:45 +08:00
修复win环境下运行bug
This commit is contained in:
parent
30b337c711
commit
cabea23a7a
16
main.js
16
main.js
@ -1,9 +1,6 @@
|
||||
// import {Template} from "./template.js"
|
||||
// console.log(process )
|
||||
// let dirname = process.mainModule.path
|
||||
import fs from 'fs'
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import {fileURLToPath, pathToFileURL} from 'url';
|
||||
import ini from 'ini'
|
||||
|
||||
let filename;
|
||||
@ -28,11 +25,16 @@ if (length>2) {
|
||||
if (filename) {
|
||||
let type = filename.match(/(^[A-Za-z0-9]+)\_/)[1]
|
||||
try {
|
||||
let psyDuck = await import( `./parse/${type}/${filename}.js`)
|
||||
let jsPath = pathToFileURL(`./parse/${type}/${filename}.js`).href
|
||||
let psyDuck = await import(jsPath)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
} catch (e) {
|
||||
// console.log(e)
|
||||
if (e == 'End') {
|
||||
console.log("End")
|
||||
}
|
||||
else {
|
||||
let iniText = fs.readFileSync(`config/config.ini`, 'UTF-8')
|
||||
let config = ini.parse(iniText)
|
||||
let iniPath = `config/${type}.ini`
|
||||
@ -49,7 +51,8 @@ if (length>2) {
|
||||
}
|
||||
if (map) {
|
||||
params.mapping = map
|
||||
let psyDuck = await import( `./parse/${type}/${map}.js`)
|
||||
let jsPath = pathToFileURL(`./parse/${type}/${map}.js`).href
|
||||
let psyDuck = await import(jsPath)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
}
|
||||
@ -58,6 +61,7 @@ if (length>2) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})().catch((e) => {
|
||||
console.log(e)
|
||||
}).finally(() => {
|
||||
|
||||
25
qlCreate.js
25
qlCreate.js
@ -181,7 +181,7 @@ class Ql {
|
||||
|
||||
async create() {
|
||||
if (!this.config) {
|
||||
consoel.log("请先初始化config.ini,并设置青龙ClientID和ClientSecret")
|
||||
console.log("请先初始化config.ini,并设置青龙ClientID和ClientSecret")
|
||||
return
|
||||
}
|
||||
await this.getToken()
|
||||
@ -221,9 +221,7 @@ class Ql {
|
||||
let title = obj[filename].title || `${psyDuck.profile.title}分身`
|
||||
let code = `
|
||||
import path from 'path';
|
||||
import {
|
||||
fileURLToPath
|
||||
} from 'url';
|
||||
import {fileURLToPath, pathToFileURL} from 'url';
|
||||
!(async () => {
|
||||
let dirpath = fileURLToPath(import.meta.url).replace('.swap','');
|
||||
let abspath = path.dirname(dirpath)
|
||||
@ -246,11 +244,16 @@ import {
|
||||
}
|
||||
}
|
||||
}
|
||||
let psyDuck = await import (\`\${abspath}/parse/\${type}/${map}.js\`)
|
||||
let jsPath = pathToFileURL(\`\${abspath}/parse/\${type}/${map}.js\`).href
|
||||
let psyDuck = await import (jsPath)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
})().catch((e) => {
|
||||
if (e == 'End') {
|
||||
console.log("End")
|
||||
}else{
|
||||
console.log(e)
|
||||
}
|
||||
})`
|
||||
fs.writeFile(`${abspath}/${filename}.js`, code, function(err, data) {
|
||||
if (err) {
|
||||
@ -281,9 +284,7 @@ import {
|
||||
let crontab = psyDuck.crontab()
|
||||
let code = `
|
||||
import path from 'path';
|
||||
import {
|
||||
fileURLToPath
|
||||
} from 'url';
|
||||
import {fileURLToPath, pathToFileURL} from 'url';
|
||||
!(async () => {
|
||||
let dirpath = fileURLToPath(import.meta.url).replace('.swap','');
|
||||
let abspath = path.dirname(dirpath)
|
||||
@ -304,11 +305,17 @@ import {
|
||||
}
|
||||
}
|
||||
}
|
||||
let psyDuck = await import (\`\${abspath}/parse/\${type}/\${filename}.js\`)
|
||||
let jsPath = pathToFileURL(\`\${abspath}/parse/\${type}/\${filename}.js\`).href
|
||||
let psyDuck = await import (jsPath)
|
||||
let main = new psyDuck.Main()
|
||||
await main.init(params)
|
||||
})().catch((e) => {
|
||||
if (e == 'End') {
|
||||
console.log("End")
|
||||
}else{
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
})`
|
||||
fs.writeFile(`${abspath}/${script}`, code, function(err, data) {
|
||||
if (err) {
|
||||
|
||||
@ -34,7 +34,7 @@ export class Cache {
|
||||
await this._cache.connect();
|
||||
}
|
||||
else {
|
||||
let dirpath = fileURLToPath(import.meta.url).split('/util')[0];
|
||||
let dirpath = fileURLToPath(import.meta.url).split('/util')[0].split("\\util")[0];
|
||||
this._cache = new Tfc({dir: `${dirpath}/temp`})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user