const path = require('path')const fs = require('fs')const BASE_PATH = path.resolve(__dirname, '../example')const OUTPUT_BASE_PATH = BASE_PATH + '/packages'if(!fs.existsSync(OUTPUT_BASE_PATH)) {process.env.OUTPUT_BASE_PATH = OUTPUT_BASE_PATHrequire('./utils').buildCode()}const files = fs.readdirSync(BASE_PATH).filter(name => name.endsWith('.html'))const links = files.map(f => `<a href="/example/${f}" target="main">${f}</a>`).join('')const html = `<html><head><link rel="stylesheet" href="/example/index.css"/></head><body><aside>${links}</aside><iframe name="main"></iframe></body></html`const chalk = require('chalk')const express = require('express')const app = express()const port = 8802app.use('/example', express.static('example'))app.use('/libs', express.static('docs/libs'))app.get('/', (req, res) => res.send(html))app.listen(port, () => {const link = chalk.green.bold(`http://localhost:${port}`)const arrow = chalk.green.bold('➜')console.log(arrow + ' example running at ' + link)})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。