前端构建告警清理:happy-dom 替代 jsdom、批准 esbuild 安装脚本、CodeMirror 与重路由懒加载分包
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { Bold, Italic, Link2, Code, Table, Eye, EyeOff } from 'lucide-react'
|
||||
import { api, ApiError } from '../lib/api'
|
||||
import type { NoteItem } from '../lib/api'
|
||||
import Editor from '../components/Editor'
|
||||
import MarkdownViewer from '../components/MarkdownViewer'
|
||||
import { slugPreview } from '../lib/utils'
|
||||
|
||||
// CodeMirror 体积大,单独拆 chunk,编辑器在首帧后异步加载
|
||||
const Editor = lazy(() => import('../components/Editor'))
|
||||
|
||||
interface NoteFull extends NoteItem {
|
||||
content: string
|
||||
prev?: unknown
|
||||
@@ -202,12 +204,14 @@ export default function AdminEdit() {
|
||||
<div className="flex min-h-0 flex-1 gap-3">
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-3">
|
||||
<div className="min-h-0 flex-1">
|
||||
<Editor
|
||||
value={form.content}
|
||||
onChange={(v) => set('content', v)}
|
||||
onUploadStart={(name) => setUploadMsg(`上传中:${name}…`)}
|
||||
onUploadEnd={(err) => setUploadMsg(err ?? null)}
|
||||
/>
|
||||
<Suspense fallback={<div className="flex h-full items-center justify-center text-sm text-zinc-500">编辑器加载中…</div>}>
|
||||
<Editor
|
||||
value={form.content}
|
||||
onChange={(v) => set('content', v)}
|
||||
onUploadStart={(name) => setUploadMsg(`上传中:${name}…`)}
|
||||
onUploadEnd={(err) => setUploadMsg(err ?? null)}
|
||||
/>
|
||||
</Suspense>
|
||||
</div>
|
||||
{uploadMsg && <p className="text-xs text-zinc-400">{uploadMsg}</p>}
|
||||
{showPreview && (
|
||||
|
||||
Reference in New Issue
Block a user