fix: 兼容V3的目录/

This commit is contained in:
ningmengchongshui 2024-06-14 14:34:17 +08:00
parent 109e7fc907
commit 0bc9112bdb
8 changed files with 75 additions and 30 deletions

2
lib/plugins/handler.ts Normal file
View File

@ -0,0 +1,2 @@
import handler from "../../src/core/plugins/handler.js";
export default handler

2
lib/plugins/loader.ts Normal file
View File

@ -0,0 +1,2 @@
import pluginsLoader from "../../src/core/plugins.loader";
export default pluginsLoader

View File

@ -9,9 +9,9 @@ import Puppeteer from './lib/puppeteer.js'
* @returns renderer.render
*/
export default function (config?: PuppeteerLaunchOptions & {
chromiumPath: string;
puppeteerWS: any;
puppeteerTimeout: any;
chromiumPath?: string;
puppeteerWS?: any;
puppeteerTimeout?: any;
}) {
// TODO Puppeteer待简化重构
return new Puppeteer(config)

View File

@ -1,2 +1,63 @@
export { Common, Data } from '#miao'
export { Character, Weapon } from '#miao.models'
// import lodash from 'lodash'
// import { existsSync, mkdirSync } from 'node:fs'
// import util from 'node:util'
// const rootPath = process.cwd()
// const _path = rootPath
// const getRoot = (root = '') => {
// if (!root) {
// root = `${_path}/`
// } else if (root === 'root' || root === 'yunzai') {
// root = `${_path}/`
// } else if (root === 'miao') {
// root = `${_path}/plugins/miao-plugin/`
// } else {
// root = `${_path}/plugins/${root}/`
// }
// return root
// }
// export const Data = {
// //
// createDir(path = '', root = '', includeFile = false) {
// root = getRoot(root)
// let pathList = path.split('/')
// let nowPath = root
// pathList.forEach((name, idx) => {
// name = name.trim()
// if (!includeFile && idx <= pathList.length - 1) {
// nowPath += name + '/'
// if (name) {
// if (!existsSync(nowPath)) {
// mkdirSync(nowPath)
// }
// }
// }
// })
// },
// isPromise(data) {
// return util.types.isPromise(data)
// },
// async forEach(data, fn) {
// if (lodash.isArray(data)) {
// for (let idx = 0; idx < data.length; idx++) {
// let ret = fn(data[idx], idx)
// ret = Data.isPromise(ret) ? await ret : ret
// if (ret === false) {
// break
// }
// }
// } else if (lodash.isPlainObject(data)) {
// for (const idx in data) {
// let ret = fn(data[idx], idx)
// ret = Data.isPromise(ret) ? await ret : ret
// if (ret === false) {
// break
// }
// }
// }
// }
// }

View File

@ -121,10 +121,7 @@ export class Puppeteer {
* @param timeout
* @returns buffer
*/
async render(
htmlPath: string | Buffer | URL,
Options?: ScreenshotFileOptions
) {
async render(htmlPath: string, Options?: ScreenshotFileOptions) {
if (!(await this.isStart())) return false
try {
const page = await this.#browser?.newPage().catch(err => {

View File

@ -10,9 +10,9 @@ import Puppeteer from './puppeteer.js'
* @returns renderer.render
*/
export default function (config?: PuppeteerLaunchOptions & {
chromiumPath: string;
puppeteerWS: any;
puppeteerTimeout: any;
chromiumPath?: string;
puppeteerWS?: any;
puppeteerTimeout?: any;
}) {
// TODO Puppeteer待简化重构
return new Puppeteer(config)

View File

@ -43,9 +43,9 @@ export default class Puppeteer extends Renderer {
* @param config
*/
constructor(config?: PuppeteerLaunchOptions & {
chromiumPath: string
puppeteerWS: any
puppeteerTimeout: any
chromiumPath?: string
puppeteerWS?: any
puppeteerTimeout?: any
}) {
/**
*

View File

@ -1,6 +1,3 @@
// import { type ScreenshotOptions, type PuppeteerLifeCycleEvent } from 'puppeteer'
// import queryString from 'querystring'
/**
*
*/
@ -12,17 +9,3 @@ export interface ScreenshotFileOptions {
tab?: string
timeout?: number
}
/**
*
*/
// export interface ScreenshotUrlOptions {
// url: string
// time?: number
// rand?: ScreenshotOptions
// params?: queryString.ParsedUrlQueryInput
// tab?: string
// timeout?: number
// cache?: boolean
// waitUntil?: PuppeteerLifeCycleEvent | PuppeteerLifeCycleEvent[]
// }