feat: 优化加载
This commit is contained in:
parent
46f3b3bd38
commit
1dc768ec08
|
@ -5,11 +5,10 @@ import './tailwindcss.js'
|
||||||
import Koa from 'koa'
|
import Koa from 'koa'
|
||||||
import KoaStatic from 'koa-static'
|
import KoaStatic from 'koa-static'
|
||||||
import Router from 'koa-router'
|
import Router from 'koa-router'
|
||||||
import { Component, createRequire } from 'yunzai/utils'
|
import { Component } from 'yunzai/utils'
|
||||||
import { readdirSync } from 'fs'
|
import { readdirSync } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import mount from 'koa-mount'
|
import mount from 'koa-mount'
|
||||||
const require = createRequire(import.meta.url)
|
|
||||||
|
|
||||||
const Com = new Component()
|
const Com = new Component()
|
||||||
const app = new Koa()
|
const app = new Koa()
|
||||||
|
@ -43,10 +42,9 @@ for (const flie of flies) {
|
||||||
console.log(`http://127.0.0.1:${Port}${url}`)
|
console.log(`http://127.0.0.1:${Port}${url}`)
|
||||||
const options = item?.options ?? {}
|
const options = item?.options ?? {}
|
||||||
router.get(url, ctx => {
|
router.get(url, ctx => {
|
||||||
const href = require('../public/output.css')
|
|
||||||
const HTML = Com.create(item.element, {
|
const HTML = Com.create(item.element, {
|
||||||
...options,
|
...options,
|
||||||
html_head: `${options?.html_head ?? ''}<link rel="stylesheet" href="${href}">`,
|
html_head: options?.html_head ?? '',
|
||||||
file_create: false
|
file_create: false
|
||||||
})
|
})
|
||||||
// 转义路径中的所有反斜杠
|
// 转义路径中的所有反斜杠
|
||||||
|
|
|
@ -45,7 +45,7 @@ export class Component {
|
||||||
const href = require('../../public/output.css')
|
const href = require('../../public/output.css')
|
||||||
const DOCTYPE = '<!DOCTYPE html>'
|
const DOCTYPE = '<!DOCTYPE html>'
|
||||||
const Link = `<link rel="stylesheet" href="${href}"></link>`
|
const Link = `<link rel="stylesheet" href="${href}"></link>`
|
||||||
const head = `<head>${options?.html_head ?? Link}</head>`
|
const head = `<head>${Link}${options?.html_head}</head>`
|
||||||
const body = `<body> ${str} ${options?.html_body ?? ''}</body>`
|
const body = `<body> ${str} ${options?.html_body ?? ''}</body>`
|
||||||
const html = `${DOCTYPE}<html>${head}${body}</html>`
|
const html = `${DOCTYPE}<html>${head}${body}</html>`
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue