Merge pull request #174 from JeremyYu-cn/generate-html

feat: format server import method: from commonJs to EsModule
This commit is contained in:
Jeremy Yu 2024-12-28 16:35:28 +08:00 committed by GitHub
commit b5b9fe385c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 440 additions and 403 deletions

View File

@ -19,6 +19,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/multiparty": "^4.2.1",
"@types/node": "^16.18.105", "@types/node": "^16.18.105",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"ts-loader": "^6.0.4", "ts-loader": "^6.0.4",
@ -247,6 +248,16 @@
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
"dev": true "dev": true
}, },
"node_modules/@types/multiparty": {
"version": "4.2.1",
"resolved": "https://registry.npmmirror.com/@types/multiparty/-/multiparty-4.2.1.tgz",
"integrity": "sha512-Wi6aK3FgvHLvCDxD7ngG4w8MsCK9h64EB53Gvc8t7FVX81tleiz8vFS3ebBohGxqHRzNGHaNwhfdxTGOGAXm6A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "16.18.105", "version": "16.18.105",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-16.18.105.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-16.18.105.tgz",
@ -4007,6 +4018,15 @@
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
"dev": true "dev": true
}, },
"@types/multiparty": {
"version": "4.2.1",
"resolved": "https://registry.npmmirror.com/@types/multiparty/-/multiparty-4.2.1.tgz",
"integrity": "sha512-Wi6aK3FgvHLvCDxD7ngG4w8MsCK9h64EB53Gvc8t7FVX81tleiz8vFS3ebBohGxqHRzNGHaNwhfdxTGOGAXm6A==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/node": { "@types/node": {
"version": "16.18.105", "version": "16.18.105",
"resolved": "https://registry.npmmirror.com/@types/node/-/node-16.18.105.tgz", "resolved": "https://registry.npmmirror.com/@types/node/-/node-16.18.105.tgz",

View File

@ -27,6 +27,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/multiparty": "^4.2.1",
"@types/node": "^16.18.105", "@types/node": "^16.18.105",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"ts-loader": "^6.0.4", "ts-loader": "^6.0.4",

View File

@ -17,34 +17,34 @@ const serviceComfig = {
/** /**
* *
*/ */
exports.servicePort = serviceComfig.port export const servicePort = serviceComfig.port
/** /**
* *
*/ */
exports.drawLink = isDev ? 'http://127.0.0.1:5173/draw' : serviceComfig.website + '/draw' export const drawLink = isDev ? 'http://127.0.0.1:5173/draw' : serviceComfig.website + '/draw'
/** /**
* *
*/ */
exports.filePath = isDev ? process.cwd() + `/static/` : serviceComfig.filePath export const filePath = isDev ? process.cwd() + `/static/` : serviceComfig.filePath
/** /**
* chrome浏览器位置 * chrome浏览器位置
*/ */
exports.executablePath = isDev ? null : '/opt/google/chrome-unstable/chrome' export const executablePath = isDev ? null : '/opt/google/chrome-unstable/chrome'
/** /**
* *
*/ */
exports.maxNum = 2 export const maxNum = 2
/** /**
* *
*/ */
exports.upperLimit = 20 export const upperLimit = 20
/** /**
* *
*/ */
exports.releaseTime = 300 export const releaseTime = 300

View File

@ -7,7 +7,7 @@
*/ */
let path = '/api' let path = '/api'
module.exports = { export default {
SCREENGHOT: path + '/screenshots', SCREENGHOT: path + '/screenshots',
PRINTSCREEN: path + '/printscreen', PRINTSCREEN: path + '/printscreen',
// 后端示例 // 后端示例

View File

@ -5,12 +5,12 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-12 13:40:13 * @LastEditTime: 2024-08-12 13:40:13
*/ */
const rExpress = require('express') import rExpress from 'express'
const screenshots = require('../service/screenshots.ts') import screenshots from '../service/screenshots'
const fileService = require('../service/files.ts') import fileService from '../service/files'
const userService = require('../service/user.ts') import userService from '../service/user'
const designService = require('../service/design.ts') import designService from '../service/design'
const api = require('./api.ts') import api from './api'
const rRouter = rExpress.Router() const rRouter = rExpress.Router()
rRouter.get(api.SCREENGHOT, screenshots.screenshots) rRouter.get(api.SCREENGHOT, screenshots.screenshots)
@ -23,4 +23,4 @@ rRouter.get(api.GET_MATERIAL, designService.getMaterial)
rRouter.get(api.GET_PHOTOS, designService.getPhotos) rRouter.get(api.GET_PHOTOS, designService.getPhotos)
rRouter.post(api.UPDATE_TEMPLATE, designService.saveTemplate) rRouter.post(api.UPDATE_TEMPLATE, designService.saveTemplate)
module.exports = rRouter export default rRouter

View File

@ -5,13 +5,13 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-11-14 17:36:17 * @LastEditTime: 2024-11-14 17:36:17
*/ */
const express = require('express')
const bodyParser = require('body-parser') import express from 'express'
const fs = require('fs') import bodyParser from 'body-parser'
// const path = require('path') import fs from 'fs'
const router = require('./control/router.ts') import router from './control/router'
const { filePath, servicePort } = require('./configs.ts') import { filePath, servicePort } from './configs'
const handleTimeout = require('./utils/timeout.ts') import handleTimeout from './utils/timeout'
const port = process.env.PORT || servicePort const port = process.env.PORT || servicePort
const app = express() const app = express()

View File

@ -6,18 +6,18 @@
* @LastEditTime: 2024-08-17 11:22:42 * @LastEditTime: 2024-08-17 11:22:42
*/ */
import { Request, Response } from 'express' import { Request, Response } from 'express'
const fs = require('fs') import fs from 'fs'
const path = require('path') import path from 'path'
const axios = require('../utils/http.ts') import axios from '../utils/http'
const multiparty = require('multiparty') import multiparty from 'multiparty'
const { filePath } = require('../configs.ts') import { filePath } from '../configs'
const { checkCreateFolder, randomCode, send } = require('../utils/tools.ts') import { checkCreateFolder, randomCode, send } from '../utils/tools'
const FileUrl = 'http://localhost:7001/static/' const FileUrl = 'http://localhost:7001/static/'
module.exports = {
// design/list 获取模板列表(虚拟) // design/list 获取模板列表(虚拟)
async getTemplates(req: any, res: Response) { export async function getTemplates(req: any, res: Response) {
/** /**
* @api {get} /design/list * @api {get} /design/list
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -29,9 +29,10 @@ module.exports = {
const list = fs.readFileSync(path.resolve(__dirname, tempPath), 'utf8') const list = fs.readFileSync(path.resolve(__dirname, tempPath), 'utf8')
send.success(res, { list: JSON.parse(list) }) send.success(res, { list: JSON.parse(list) })
} catch (error) {} } catch (error) {}
}, }
// design/temp 获取模板(虚拟)
async getDetail(req: any, res: Response) { // design/temp 获取模板(虚拟)
export async function getDetail(req: any, res: Response) {
/** /**
* @api {get} /design/list * @api {get} /design/list
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -43,9 +44,10 @@ module.exports = {
const detail = fs.readFileSync(path.resolve(__dirname, dPath), 'utf8') const detail = fs.readFileSync(path.resolve(__dirname, dPath), 'utf8')
send.success(res, JSON.parse(detail)) send.success(res, JSON.parse(detail))
} catch (error) {} } catch (error) {}
}, }
// design/material 获取素材(虚拟)
async getMaterial(req: any, res: any) { // design/material 获取素材(虚拟)
export async function getMaterial(req: any, res: any) {
/** /**
* @api {get} /design/material * @api {get} /design/material
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -58,9 +60,10 @@ module.exports = {
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
}, }
// design/imgs 获取照片素材(虚拟)
async getPhotos(req: any, res: any) { // design/imgs 获取照片素材(虚拟)
export async function getPhotos(req: any, res: any) {
/** /**
* @api {get} /design/imgs * @api {get} /design/imgs
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -71,9 +74,10 @@ module.exports = {
const detail = fs.readFileSync(path.resolve(__dirname, `../mock/materials/photos/${cate}.json`), 'utf8') const detail = fs.readFileSync(path.resolve(__dirname, `../mock/materials/photos/${cate}.json`), 'utf8')
send.success(res, { list: JSON.parse(detail) }) send.success(res, { list: JSON.parse(detail) })
} catch (error) {} } catch (error) {}
}, }
// design/edit 保存模板(虚拟)
async saveTemplate(req: any, res: any) { // design/edit 保存模板(虚拟)
export async function saveTemplate(req: any, res: any) {
/** /**
* @api {post} /design/edit * @api {post} /design/edit
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -110,7 +114,12 @@ module.exports = {
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
},
} }
export {} export default {
getTemplates,
getDetail,
getMaterial,
getPhotos,
saveTemplate
}

View File

@ -12,9 +12,9 @@ const { checkCreateFolder, randomCode, copyFile, send } = require('../utils/tool
const FileUrl = 'http://localhost:7001/static/' const FileUrl = 'http://localhost:7001/static/'
module.exports = {
// api/file/upload 上传接口 // api/file/upload 上传接口
async upload(req: Request, res: Response) { export async function upload(req: Request, res: Response) {
/** /**
* @api {post} /api/file/upload * @api {post} /api/file/upload
* @apiVersion 1.0.0 * @apiVersion 1.0.0
@ -54,7 +54,6 @@ module.exports = {
}) })
} }
}) })
},
} }
export {} export default { upload }

View File

@ -5,16 +5,13 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-17 11:23:58 * @LastEditTime: 2024-08-17 11:23:58
*/ */
const { saveScreenshot } = require('../utils/download-single.ts') import { saveScreenshot } from '../utils/download-single'
const uuid = require('../utils/uuid.ts') import uuid from '../utils/uuid'
const { filePath, upperLimit, drawLink } = require('../configs.ts') import { filePath, upperLimit, drawLink } from '../configs'
const { queueRun, queueList } = require('../utils/node-queue.ts') import { queueRun, queueList } from '../utils/node-queue'
// const path = require('path') // const path = require('path')
const fs = require('fs')
module.exports = { /**
async screenshots(req: any, res: any) {
/**
* @api {get} api/screenshots * @api {get} api/screenshots
* @apiVersion 1.0.0 * @apiVersion 1.0.0
* @apiGroup screenShot * @apiGroup screenShot
@ -30,6 +27,7 @@ module.exports = {
* @apiParam {String} quality , * @apiParam {String} quality ,
* @apiParam {String|Number} index , * @apiParam {String|Number} index ,
*/ */
export async function screenshots(req: any, res: any) {
let { id, tempid, tempType, width, height, screenshot_url, type = 'file', size, quality, index = 0 } = req.query let { id, tempid, tempType, width, height, screenshot_url, type = 'file', size, quality, index = 0 } = req.query
id == 'undefined' && (id = null) id == 'undefined' && (id = null)
const url = (screenshot_url || drawLink) + `${id ? '?id=' : '?tempid='}` const url = (screenshot_url || drawLink) + `${id ? '?id=' : '?tempid='}`
@ -56,9 +54,9 @@ module.exports = {
} else { } else {
res.json({ code: 500, msg: '缺少参数,请检查' }) res.json({ code: 500, msg: '缺少参数,请检查' })
} }
}, }
async printscreen(req: any, res: any) {
/** /**
* @api {get} api/printscreen * @api {get} api/printscreen
* @apiVersion 1.0.0 * @apiVersion 1.0.0
* @apiGroup screenShot * @apiGroup screenShot
@ -75,12 +73,14 @@ module.exports = {
* @apiParam {String} devices () uawidthheight均会失效eg: iPhone 6 /src/utils/widget/Device.js * @apiParam {String} devices () uawidthheight均会失效eg: iPhone 6 /src/utils/widget/Device.js
* @apiParam {Number} scale () (DPR) 1~41 * @apiParam {Number} scale () (DPR) 1~41
*/ */
export async function printscreen(req: any, res: any) {
let { width = 375, height = 0, url, type = 'file', size, quality, prevent = false, ua, devices, scale, wait } = req.query let { width = 375, height = 0, url, type = 'file', size, quality, prevent = false, ua, devices, scale, wait } = req.query
const path = filePath + `screenshot_${new Date().getTime()}_${uuid()}.png` const path = filePath + `screenshot_${new Date().getTime()}_${uuid()}.png`
const thumbPath = type === 'cover' ? path.replace('.png', '.jpg') : null const thumbPath = type === 'cover' ? path.replace('.png', '.jpg') : null
if (url) { if (url) {
const sign = `${new Date().getTime()}_${uuid(8)}` const sign = `${new Date().getTime()}_${uuid()}`
req._queueSign = sign req._queueSign = sign
// console.log(url + id, path, thumbPath); // console.log(url + id, path, thumbPath);
if (queueList.length > upperLimit) { if (queueList.length > upperLimit) {
@ -104,7 +104,6 @@ module.exports = {
} else { } else {
res.json({ code: 500, msg: '缺少参数,请检查' }) res.json({ code: 500, msg: '缺少参数,请检查' })
} }
},
} }
export {} export default { printscreen, screenshots }

View File

@ -12,7 +12,7 @@ const { checkCreateFolder, filesReader, send } = require('../utils/tools.ts')
const FileUrl = 'http://localhost:7001/static/' const FileUrl = 'http://localhost:7001/static/'
module.exports = { export default {
// design/user/image 获取用户上传列表(虚拟) // design/user/image 获取用户上传列表(虚拟)
async getUserImages(req: Request, res: Response) { async getUserImages(req: Request, res: Response) {
/** /**
@ -24,5 +24,3 @@ module.exports = {
send.success(res, { list }) send.success(res, { list })
}, },
} }
export {}

View File

@ -15,7 +15,7 @@ const forceTimeOut = 60 // 强制超时时间,单位:秒
const maxPXs = 4211840 // 超出此规格会触发限制器降低dpr节省服务器资源 const maxPXs = 4211840 // 超出此规格会触发限制器降低dpr节省服务器资源
const maximum = 5000 // 最大宽高限制,超过截断以防止服务崩溃 const maximum = 5000 // 最大宽高限制,超过截断以防止服务崩溃
const saveScreenshot = async (url: string, { path, width, height, thumbPath, size = 0, quality = 0, prevent, ua, devices, scale, wait }: any) => { export const saveScreenshot = async (url: string, { path, width, height, thumbPath, size = 0, quality = 0, prevent, ua, devices, scale, wait }: any) => {
return new Promise(async (resolve: Function, reject: Function) => { return new Promise(async (resolve: Function, reject: Function) => {
let isPageLoad = false let isPageLoad = false
let browser: any = null let browser: any = null
@ -154,6 +154,5 @@ const saveScreenshot = async (url: string, { path, width, height, thumbPath, siz
}) })
} }
module.exports = { saveScreenshot } export default { saveScreenshot }
export {}

View File

@ -13,7 +13,7 @@ const forceTimeOut = 60 // 强制超时时间,单位:秒
let browser: typeof puppeteer = null let browser: typeof puppeteer = null
let release: any = null let release: any = null
const saveScreenshot = async (url: string, { path, width, height, thumbPath, size = 0, quality = 0, prevent, ua, devices, scale, wait }: any) => { export const saveScreenshot = async (url: string, { path, width, height, thumbPath, size = 0, quality = 0, prevent, ua, devices, scale, wait }: any) => {
return new Promise(async (resolve: Function) => { return new Promise(async (resolve: Function) => {
// 启动浏览器 // 启动浏览器
if (!browser) { if (!browser) {
@ -123,6 +123,4 @@ async function autoScroll(page: any) {
}) })
} }
module.exports = { saveScreenshot } export default { saveScreenshot }
export {}

View File

@ -6,13 +6,12 @@
* @LastEditTime: 2024-08-12 06:29:58 * @LastEditTime: 2024-08-12 06:29:58
*/ */
import fs from 'fs' import fs from 'fs'
const path = require('path') import path from 'path'
const imageSize = require('image-size') import imageSize from 'image-size'
const { filePath: StaticPath } = require('../configs.ts') import { filePath as StaticPath } from '../configs'
const FileUrl = 'http://localhost:7001/static/' const FileUrl = 'http://localhost:7001/static/'
module.exports = { export function copyFile(sourceFile: string, destinationFile: string): Promise<void> {
copyFile(sourceFile: string, destinationFile: string): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const readStream = fs.createReadStream(sourceFile) const readStream = fs.createReadStream(sourceFile)
const writeStream = fs.createWriteStream(destinationFile) const writeStream = fs.createWriteStream(destinationFile)
@ -31,9 +30,10 @@ module.exports = {
readStream.pipe(writeStream) readStream.pipe(writeStream)
}) })
}, }
// 读取目录
filesReader(directoryPath: string) { // 读取目录
export function filesReader(directoryPath: string) {
return new Promise((resolve) => { return new Promise((resolve) => {
try { try {
const files = fs.readdirSync(StaticPath + directoryPath) const files = fs.readdirSync(StaticPath + directoryPath)
@ -62,9 +62,10 @@ module.exports = {
console.error('Error reading directory:', err) console.error('Error reading directory:', err)
} }
}) })
}, }
// 读取文件
readFile(directoryPath: string) { // 读取文件
export function readFile(directoryPath: string) {
return new Promise((resolve) => { return new Promise((resolve) => {
try { try {
resolve(fs.readFileSync(StaticPath + directoryPath, 'utf8')) resolve(fs.readFileSync(StaticPath + directoryPath, 'utf8'))
@ -72,7 +73,10 @@ module.exports = {
console.error('Error reading file:', err) console.error('Error reading file:', err)
} }
}) })
},
} }
export {} export default {
copyFile,
filesReader,
readFile,
}

View File

@ -5,7 +5,7 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-12 13:59:34 * @LastEditTime: 2024-08-12 13:59:34
*/ */
const axios = require('axios') import axios from 'axios'
const httpRequest = axios.create({ const httpRequest = axios.create({
maxContentLength: Infinity, maxContentLength: Infinity,
@ -16,4 +16,4 @@ httpRequest.interceptors.response.use((config: any) => {
return config.data return config.data
}) })
module.exports = httpRequest export default httpRequest

View File

@ -10,7 +10,7 @@ interface Queue {
sign?: string | number sign?: string | number
} }
const { maxNum } = require('../configs.ts') import { maxNum } from '../configs'
const queueList: any = [] // 任务队列 const queueList: any = [] // 任务队列
let curNum = 0 // 当前执行的任务数 let curNum = 0 // 当前执行的任务数
@ -38,4 +38,4 @@ function run(Fn: Function) {
}) })
} }
module.exports = { queueRun, queueList } export { queueRun, queueList }

View File

@ -6,7 +6,7 @@
* @LastEditTime: 2023-07-05 20:17:00 * @LastEditTime: 2023-07-05 20:17:00
*/ */
module.exports = async (req: any, res: any, next: any) => { export default async (req: any, res: any, next: any) => {
const { queueList } = require('../utils/node-queue.ts') const { queueList } = require('../utils/node-queue.ts')
const time = 30000 // 设置所有HTTP请求的服务器响应超时时间 const time = 30000 // 设置所有HTTP请求的服务器响应超时时间
res.setTimeout(time, () => { res.setTimeout(time, () => {

View File

@ -5,12 +5,11 @@
* @LastEditors: ShawnPhang <https://m.palxp.cn> * @LastEditors: ShawnPhang <https://m.palxp.cn>
* @LastEditTime: 2024-08-12 13:48:40 * @LastEditTime: 2024-08-12 13:48:40
*/ */
const fs = require('fs') import fs from 'fs'
const path = require('path') import path from 'path'
const fsFunc = require('./fs.ts') import { filesReader, copyFile, readFile } from './fs'
module.exports = { export const send = {
send: {
success: (res: any, result: any, msg: string = 'ok') => { success: (res: any, result: any, msg: string = 'ok') => {
res.json({ res.json({
code: 200, code: 200,
@ -24,14 +23,17 @@ module.exports = {
msg, msg,
}) })
}, },
}, }
isNumber: (value: any) => { export const isNumber = (value: any) => {
return typeof value === 'number' && !isNaN(value) return typeof value === 'number' && !isNaN(value)
}, }
buildTree: (data: any[]) => {},
groupBy: (array: any[], property: any) => {}, export const buildTree = (data: any[]) => {}
// 检测目录并创建目录(支持深层级)
checkCreateFolder: (folder: string) => { export const groupBy = (array: any[], property: any) => {}
// 检测目录并创建目录(支持深层级)
export const checkCreateFolder = (folder: string) => {
try { try {
const pathArr = splitPath(folder) const pathArr = splitPath(folder)
let _path = '' let _path = ''
@ -42,9 +44,10 @@ module.exports = {
} }
} }
} catch (e) {} } catch (e) {}
}, }
// 检测文件
checkCreateFile: (filePath: string) => { // 检测文件
export const checkCreateFile = (filePath: string) => {
try { try {
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
fs.writeFileSync(filePath, '') fs.writeFileSync(filePath, '')
@ -52,9 +55,10 @@ module.exports = {
} catch (e) { } catch (e) {
fs.writeFileSync(filePath, '') fs.writeFileSync(filePath, '')
} }
}, }
// 生成随机码
randomCode: (length = 5) => { // 生成随机码
export const randomCode = (length = 5) => {
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
let result = '' let result = ''
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
@ -62,14 +66,15 @@ module.exports = {
result += chars[randomIndex] result += chars[randomIndex]
} }
return result return result
},
// 取数组差集
findDifference: (a: any, b: any) => {
return a.concat(b).filter((v: any) => !a.includes(v) || !b.includes(v))
},
...fsFunc,
} }
// 取数组差集
export const findDifference = (a: any, b: any) => {
return a.concat(b).filter((v: any) => !a.includes(v) || !b.includes(v))
}
export { copyFile, readFile, filesReader }
/** /**
* *
* @param dirPath * @param dirPath
@ -81,4 +86,3 @@ function splitPath(dirPath: string) {
return normalizedPath.split(separator) return normalizedPath.split(separator)
} }
export {}

View File

@ -7,9 +7,9 @@
* @Description: ,`customMade`, koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: ,`customMade`, koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
const nodeCrypto = require('crypto'); import nodeCrypto from 'crypto';
module.exports = () => export default () =>
// @ts-ignore // @ts-ignore
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c: number) => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c: number) =>
(c ^ (nodeCrypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) (c ^ (nodeCrypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)

View File

@ -3,7 +3,7 @@
/* Basic Options */ /* Basic Options */
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "ESNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": ["dom", "es2015"], /* Specify library files to be included in the compilation. */ // "lib": ["dom", "es2015"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */

View File

@ -39,6 +39,12 @@ module.exports = {
}, },
], ],
}, },
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'], // 解析的文件类型
alias: {
'@': path.resolve(__dirname, 'src') // 配置路径别名,指向 src 目录
}
},
// plugins: [new BundleAnalyzerPlugin()], // plugins: [new BundleAnalyzerPlugin()],
plugins: [ new buildPlugin() ] plugins: [ new buildPlugin() ]
} }