@web-mods/articles 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # @web-module/articles
1
+ # @web-mods/articles
2
2
 
3
3
  文章管理组件库,提供完整的文章 CRUD 管理界面(列表、编辑、详情)以及服务端 HTML 渲染能力。
4
4
 
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- pnpm add @web-module/articles
8
+ pnpm add @web-mods/articles
9
9
  ```
10
10
 
11
11
  > **Peer dependencies**:`react >=18`、`react-dom >=18`
@@ -18,13 +18,13 @@ pnpm add @web-module/articles
18
18
 
19
19
  ### 1. 配置 ArticleService(可选)
20
20
 
21
- 组件库内置了指向 `https://api-blog.aisee.live` 的默认 service,**`service` prop 不传即使用默认值,无需任何配置**。
21
+ **`service` prop 不传即使用内置默认值,无需任何配置**。
22
22
 
23
23
  只有以下情况才需要手动配置:
24
24
 
25
25
  **自定义 API 地址:**
26
26
  ```ts
27
- import { createArticleService } from '@web-module/articles'
27
+ import { createArticleService } from '@web-mods/articles'
28
28
  const articleService = createArticleService('https://your-api.example.com')
29
29
  // 然后传给 Provider:<ArticlesProvider service={articleService} ...>
30
30
  ```
@@ -32,7 +32,7 @@ const articleService = createArticleService('https://your-api.example.com')
32
32
  **完全自定义请求逻辑**(如附带鉴权 Header、适配不同数据格式等):
33
33
 
34
34
  ```ts
35
- import type { ArticleService } from '@web-module/articles'
35
+ import type { ArticleService } from '@web-mods/articles'
36
36
 
37
37
  const articleService: ArticleService = {
38
38
  getList: (params) => api.get('/news', { params }), // 返回 { items, total }
@@ -79,8 +79,8 @@ export default [
79
79
  ```tsx
80
80
  // pages/articles/layout.tsx
81
81
  import { Outlet } from 'react-router'
82
- import { ArticlesProvider, ReactRouterAdapter } from '@web-module/articles'
83
- import '@web-module/articles/style.css'
82
+ import { ArticlesProvider, ReactRouterAdapter } from '@web-mods/articles'
83
+ import '@web-mods/articles/style.css'
84
84
 
85
85
  export default function ArticlesLayout() {
86
86
  return (
@@ -101,8 +101,8 @@ export default function ArticlesLayout() {
101
101
  // app/articles/layout.tsx
102
102
  'use client'
103
103
  import { useRouter } from 'next/navigation'
104
- import { ArticlesProvider } from '@web-module/articles'
105
- import '@web-module/articles/style.css'
104
+ import { ArticlesProvider } from '@web-mods/articles'
105
+ import '@web-mods/articles/style.css'
106
106
 
107
107
  export default function ArticlesLayout({ children }: { children: React.ReactNode }) {
108
108
  const router = useRouter()
@@ -118,7 +118,7 @@ export default function ArticlesLayout({ children }: { children: React.ReactNode
118
118
  // app/articles/[id]/edit/page.tsx
119
119
  'use client'
120
120
  import { useParams } from 'next/navigation'
121
- import { ArticleEdit } from '@web-module/articles'
121
+ import { ArticleEdit } from '@web-mods/articles'
122
122
 
123
123
  export default function EditPage() {
124
124
  const { id } = useParams<{ id: string }>()
@@ -130,7 +130,7 @@ export default function EditPage() {
130
130
 
131
131
  ```tsx
132
132
  // React Router:无需传 props,路由参数由 ReactRouterAdapter 自动注入
133
- import { ArticleList, ArticleEdit, ArticleDetail } from '@web-module/articles'
133
+ import { ArticleList, ArticleEdit, ArticleDetail } from '@web-mods/articles'
134
134
  export default function ListPage() { return <ArticleList /> }
135
135
  export default function EditPage() { return <ArticleEdit /> }
136
136
  export default function DetailPage() { return <ArticleDetail /> }
@@ -147,7 +147,7 @@ export default function DetailPage() { return <ArticleDetail id={id} /> }
147
147
  | 属性 | 类型 | 必填 | 说明 |
148
148
  |------|------|------|------|
149
149
  | `basePath` | `string` | ✅ | 文章路由根路径,如 `/articles` |
150
- | `service` | `ArticleService` | — | 数据服务,不传默认使用内置 `https://api-blog.aisee.live` |
150
+ | `service` | `ArticleService` | — | 数据服务,不传使用内置默认值 |
151
151
  | `navigate` | `(path: string) => void` | — | 非 react-router 环境必传,由框架路由实现跳转 |
152
152
  | `previewBaseUrl` | `string` | — | 预览 iframe 注入 `<base href="..."`,用于正确加载相对路径资源 |
153
153
  | `previewTailwind` | `boolean` | — | 预览时自动注入 Tailwind CDN,适合内容使用了 Tailwind 类名的场景 |
@@ -186,14 +186,14 @@ interface Article {
186
186
  从独立的 `server` 入口引入,**不包含任何 React 依赖**,可安全在服务端使用:
187
187
 
188
188
  ```ts
189
- import { renderArticleByPathname } from '@web-module/articles/server'
189
+ import { renderArticleByPathname } from '@web-mods/articles/server'
190
190
  ```
191
191
 
192
192
  ### Next.js 示例
193
193
 
194
194
  ```ts
195
195
  // app/[slug]/route.ts
196
- import { renderArticleByPathname, defaultArticleService } from '@web-module/articles/server'
196
+ import { renderArticleByPathname, defaultArticleService } from '@web-mods/articles/server'
197
197
 
198
198
  export async function GET(_req: Request, { params }: { params: Promise<{ slug: string }> }) {
199
199
  const { slug } = await params
@@ -206,7 +206,7 @@ export async function GET(_req: Request, { params }: { params: Promise<{ slug: s
206
206
  如需自定义 API 地址:
207
207
 
208
208
  ```ts
209
- import { renderArticleByPathname, createArticleService } from '@web-module/articles/server'
209
+ import { renderArticleByPathname, createArticleService } from '@web-mods/articles/server'
210
210
 
211
211
  const service = createArticleService('https://your-api.example.com')
212
212
 
@@ -234,17 +234,5 @@ export async function GET(_req: Request, { params }: { params: Promise<{ slug: s
234
234
  组件库使用 Tailwind CSS 构建,样式已编译打包至 `dist/style.css`。在 Layout 中引入一次即可,框架会在构建时将其内联进 `<head>`,**不会有样式闪烁(FOUC)**:
235
235
 
236
236
  ```ts
237
- import '@web-module/articles/style.css'
237
+ import '@web-mods/articles/style.css'
238
238
  ```
239
-
240
- ---
241
-
242
- ## 发布新版本(维护者)
243
-
244
- ```bash
245
- pnpm release # patch 升版本 1.0.x → 1.0.x+1
246
- pnpm release:minor # minor 升版本 1.0.x → 1.1.0
247
- pnpm release:major # major 升版本 1.x.x → 2.0.0
248
- ```
249
-
250
- 流程:构建 → 升版本号 → git commit → publish → git push。
package/dist/index.cjs CHANGED
@@ -128,7 +128,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
128
128
  monaco.config({ paths: { vs: '...' } })
129
129
 
130
130
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
131
- `},Ie=vr(kr)(Je),$r={config:jr},Mr=function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return function(o){return n.reduceRight(function(u,g){return g(u)},o)}};function Ke(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],Ke(e[n],r[n]))}),ze(ze({},e),r)}var Sr={type:"cancelation",msg:"operation is manually canceled"};function be(e){var r=!1,n=new Promise(function(s,o){e.then(function(u){return r?o(Sr):s(u)}),e.catch(o)});return n.cancel=function(){return r=!0},n}var Cr=["monaco"],Or=yr.create({config:br,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ge=er(Or,2),ie=Ge[0],me=Ge[1];function Pr(e){var r=$r.config(e),n=r.monaco,s=Qt(r,Cr);me(function(o){return{config:Ke(o.config,s),monaco:n}})}function Dr(){var e=ie(function(r){var n=r.monaco,s=r.isInitialized,o=r.resolve;return{monaco:n,isInitialized:s,resolve:o}});if(!e.isInitialized){if(me({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),be(ve);if(window.monaco&&window.monaco.editor)return Qe(window.monaco),e.resolve(window.monaco),be(ve);Mr(Er,Ar)(Tr)}return be(ve)}function Er(e){return document.body.appendChild(e)}function Lr(e){var r=document.createElement("script");return e&&(r.src=e),r}function Ar(e){var r=ie(function(s){var o=s.config,u=s.reject;return{config:o,reject:u}}),n=Lr("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function Tr(){var e=ie(function(n){var s=n.config,o=n.resolve,u=n.reject;return{config:s,resolve:o,reject:u}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var s=n.m||n;Qe(s),e.resolve(s)},function(n){e.reject(n)})}function Qe(e){ie().monaco||me({monaco:e})}function _r(){return ie(function(e){var r=e.monaco;return r})}var ve=new Promise(function(e,r){return me({resolve:e,reject:r})}),Xe={config:Pr,init:Dr,__getMonacoInstance:_r},zr={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},we=zr,Rr={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Hr=Rr;function Ir({children:e}){return c.createElement("div",{style:Hr.container},e)}var Wr=Ir,Vr=Wr;function Yr({width:e,height:r,isEditorReady:n,loading:s,_ref:o,className:u,wrapperProps:g}){return c.createElement("section",{style:{...we.wrapper,width:e,height:r},...g},!n&&c.createElement(Vr,null,s),c.createElement("div",{ref:o,style:{...we.fullWidth,...!n&&we.hide},className:u}))}var qr=Yr,et=c.memo(qr);function Ur(e){c.useEffect(e,[])}var tt=Ur;function Fr(e,r,n=!0){let s=c.useRef(!0);c.useEffect(s.current||!n?()=>{s.current=!1}:e,r)}var B=Fr;function se(){}function te(e,r,n,s){return Br(e,s)||Zr(e,r,n,s)}function Br(e,r){return e.editor.getModel(rt(e,r))}function Zr(e,r,n,s){return e.editor.createModel(r,n,s?rt(e,s):void 0)}function rt(e,r){return e.Uri.parse(r)}function Jr({original:e,modified:r,language:n,originalLanguage:s,modifiedLanguage:o,originalModelPath:u,modifiedModelPath:g,keepCurrentOriginalModel:k=!1,keepCurrentModifiedModel:$=!1,theme:C="light",loading:m="Loading...",options:S={},height:H="100%",width:P="100%",className:T,wrapperProps:R={},beforeMount:z=se,onMount:q=se}){let[_,p]=c.useState(!1),[A,O]=c.useState(!0),y=c.useRef(null),w=c.useRef(null),I=c.useRef(null),E=c.useRef(q),x=c.useRef(z),M=c.useRef(!1);tt(()=>{let a=Xe.init();return a.then(i=>(w.current=i)&&O(!1)).catch(i=>(i==null?void 0:i.type)!=="cancelation"&&console.error("Monaco initialization: error:",i)),()=>y.current?b():a.cancel()}),B(()=>{if(y.current&&w.current){let a=y.current.getOriginalEditor(),i=te(w.current,e||"",s||n||"text",u||"");i!==a.getModel()&&a.setModel(i)}},[u],_),B(()=>{if(y.current&&w.current){let a=y.current.getModifiedEditor(),i=te(w.current,r||"",o||n||"text",g||"");i!==a.getModel()&&a.setModel(i)}},[g],_),B(()=>{let a=y.current.getModifiedEditor();a.getOption(w.current.editor.EditorOption.readOnly)?a.setValue(r||""):r!==a.getValue()&&(a.executeEdits("",[{range:a.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),a.pushUndoStop())},[r],_),B(()=>{var a,i;(i=(a=y.current)==null?void 0:a.getModel())==null||i.original.setValue(e||"")},[e],_),B(()=>{let{original:a,modified:i}=y.current.getModel();w.current.editor.setModelLanguage(a,s||n||"text"),w.current.editor.setModelLanguage(i,o||n||"text")},[n,s,o],_),B(()=>{var a;(a=w.current)==null||a.editor.setTheme(C)},[C],_),B(()=>{var a;(a=y.current)==null||a.updateOptions(S)},[S],_);let Y=c.useCallback(()=>{var d;if(!w.current)return;x.current(w.current);let a=te(w.current,e||"",s||n||"text",u||""),i=te(w.current,r||"",o||n||"text",g||"");(d=y.current)==null||d.setModel({original:a,modified:i})},[n,r,o,e,s,u,g]),Z=c.useCallback(()=>{var a;!M.current&&I.current&&(y.current=w.current.editor.createDiffEditor(I.current,{automaticLayout:!0,...S}),Y(),(a=w.current)==null||a.editor.setTheme(C),p(!0),M.current=!0)},[S,C,Y]);c.useEffect(()=>{_&&E.current(y.current,w.current)},[_]),c.useEffect(()=>{!A&&!_&&Z()},[A,_,Z]);function b(){var i,d,l,v;let a=(i=y.current)==null?void 0:i.getModel();k||((d=a==null?void 0:a.original)==null||d.dispose()),$||((l=a==null?void 0:a.modified)==null||l.dispose()),(v=y.current)==null||v.dispose()}return c.createElement(et,{width:P,height:H,isEditorReady:_,loading:m,_ref:I,className:T,wrapperProps:R})}var Kr=Jr;c.memo(Kr);function Gr(e){let r=c.useRef();return c.useEffect(()=>{r.current=e},[e]),r.current}var Qr=Gr,le=new Map;function Xr({defaultValue:e,defaultLanguage:r,defaultPath:n,value:s,language:o,path:u,theme:g="light",line:k,loading:$="Loading...",options:C={},overrideServices:m={},saveViewState:S=!0,keepCurrentModel:H=!1,width:P="100%",height:T="100%",className:R,wrapperProps:z={},beforeMount:q=se,onMount:_=se,onChange:p,onValidate:A=se}){let[O,y]=c.useState(!1),[w,I]=c.useState(!0),E=c.useRef(null),x=c.useRef(null),M=c.useRef(null),Y=c.useRef(_),Z=c.useRef(q),b=c.useRef(),a=c.useRef(s),i=Qr(u),d=c.useRef(!1),l=c.useRef(!1);tt(()=>{let f=Xe.init();return f.then(j=>(E.current=j)&&I(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>x.current?N():f.cancel()}),B(()=>{var j,D,h,L;let f=te(E.current,e||s||"",r||o||"",u||n||"");f!==((j=x.current)==null?void 0:j.getModel())&&(S&&le.set(i,(D=x.current)==null?void 0:D.saveViewState()),(h=x.current)==null||h.setModel(f),S&&((L=x.current)==null||L.restoreViewState(le.get(u))))},[u],O),B(()=>{var f;(f=x.current)==null||f.updateOptions(C)},[C],O),B(()=>{!x.current||s===void 0||(x.current.getOption(E.current.editor.EditorOption.readOnly)?x.current.setValue(s):s!==x.current.getValue()&&(l.current=!0,x.current.executeEdits("",[{range:x.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),x.current.pushUndoStop(),l.current=!1))},[s],O),B(()=>{var j,D;let f=(j=x.current)==null?void 0:j.getModel();f&&o&&((D=E.current)==null||D.editor.setModelLanguage(f,o))},[o],O),B(()=>{var f;k!==void 0&&((f=x.current)==null||f.revealLine(k))},[k],O),B(()=>{var f;(f=E.current)==null||f.editor.setTheme(g)},[g],O);let v=c.useCallback(()=>{var f;if(!(!M.current||!E.current)&&!d.current){Z.current(E.current);let j=u||n,D=te(E.current,s||e||"",r||o||"",j||"");x.current=(f=E.current)==null?void 0:f.editor.create(M.current,{model:D,automaticLayout:!0,...C},m),S&&x.current.restoreViewState(le.get(j)),E.current.editor.setTheme(g),k!==void 0&&x.current.revealLine(k),y(!0),d.current=!0}},[e,r,n,s,o,u,C,m,S,g,k]);c.useEffect(()=>{O&&Y.current(x.current,E.current)},[O]),c.useEffect(()=>{!w&&!O&&v()},[w,O,v]),a.current=s,c.useEffect(()=>{var f,j;O&&p&&((f=b.current)==null||f.dispose(),b.current=(j=x.current)==null?void 0:j.onDidChangeModelContent(D=>{l.current||p(x.current.getValue(),D)}))},[O,p]),c.useEffect(()=>{if(O){let f=E.current.editor.onDidChangeMarkers(j=>{var h;let D=(h=x.current.getModel())==null?void 0:h.uri;if(D&&j.find(L=>L.path===D.path)){let L=E.current.editor.getModelMarkers({resource:D});A==null||A(L)}});return()=>{f==null||f.dispose()}}return()=>{}},[O,A]);function N(){var f,j;(f=b.current)==null||f.dispose(),H?S&&le.set(u,x.current.saveViewState()):(j=x.current.getModel())==null||j.dispose(),x.current.dispose()}return c.createElement(et,{width:P,height:T,isEditorReady:O,loading:$,_ref:M,className:R,wrapperProps:z})}var en=Xr,tn=c.memo(en),rn=tn;function he({title:e,children:r,placement:n="top"}){const[s,o]=c.useState(!1);return e?t.jsxs("div",{className:"relative inline-flex",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[r,s&&t.jsx("div",{className:`absolute left-1/2 -translate-x-1/2 z-50 px-2 py-1 bg-gray-800/90 text-white text-xs rounded-md whitespace-nowrap pointer-events-none ${n==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:e})]}):t.jsx(t.Fragment,{children:r})}const je=[{key:"desktop",icon:t.jsx(Ue,{size:13}),label:"Desktop",width:null},{key:"tablet",icon:t.jsx(Be,{size:13}),label:"Tablet",width:768},{key:"mobile",icon:t.jsx(Fe,{size:13}),label:"Mobile",width:390}],nn=({id:e,record:r})=>{const{navigate:n,params:s,locationState:o}=Ce(),u=e??s.id,{basePath:g,service:k,previewBaseUrl:$,previewTailwind:C}=Oe(),m=!!u,[S,H]=Ze(),[P,T]=c.useState(!1),[R,z]=c.useState(r??(o==null?void 0:o.record)??null),[q,_]=c.useState(""),[p,A]=c.useState(""),[O,y]=c.useState(""),[w,I]=c.useState(""),[E,x]=c.useState("code"),[M,Y]=c.useState(!1),[Z,b]=c.useState("desktop"),[a,i]=c.useState(!1),[d,l]=c.useState(null),v=(h,L)=>{const J=$?`<base href="${$}">`:"",U=L?`<meta name="viewport" content="width=${L}, initial-scale=1">`:"",K=L?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",G=C&&!h.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",W=J+U+K+G;return W?h.includes("</head>")?h.replace("</head>",`${W}
131
+ `},Ie=vr(kr)(Je),$r={config:jr},Mr=function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return function(o){return n.reduceRight(function(u,g){return g(u)},o)}};function Ke(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],Ke(e[n],r[n]))}),ze(ze({},e),r)}var Sr={type:"cancelation",msg:"operation is manually canceled"};function be(e){var r=!1,n=new Promise(function(s,o){e.then(function(u){return r?o(Sr):s(u)}),e.catch(o)});return n.cancel=function(){return r=!0},n}var Cr=["monaco"],Or=yr.create({config:br,isInitialized:!1,resolve:null,reject:null,monaco:null}),Ge=er(Or,2),ie=Ge[0],me=Ge[1];function Pr(e){var r=$r.config(e),n=r.monaco,s=Qt(r,Cr);me(function(o){return{config:Ke(o.config,s),monaco:n}})}function Dr(){var e=ie(function(r){var n=r.monaco,s=r.isInitialized,o=r.resolve;return{monaco:n,isInitialized:s,resolve:o}});if(!e.isInitialized){if(me({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),be(ve);if(window.monaco&&window.monaco.editor)return Qe(window.monaco),e.resolve(window.monaco),be(ve);Mr(Er,Ar)(Tr)}return be(ve)}function Er(e){return document.body.appendChild(e)}function Lr(e){var r=document.createElement("script");return e&&(r.src=e),r}function Ar(e){var r=ie(function(s){var o=s.config,u=s.reject;return{config:o,reject:u}}),n=Lr("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function Tr(){var e=ie(function(n){var s=n.config,o=n.resolve,u=n.reject;return{config:s,resolve:o,reject:u}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var s=n.m||n;Qe(s),e.resolve(s)},function(n){e.reject(n)})}function Qe(e){ie().monaco||me({monaco:e})}function _r(){return ie(function(e){var r=e.monaco;return r})}var ve=new Promise(function(e,r){return me({resolve:e,reject:r})}),Xe={config:Pr,init:Dr,__getMonacoInstance:_r},zr={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},we=zr,Rr={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Hr=Rr;function Ir({children:e}){return c.createElement("div",{style:Hr.container},e)}var Wr=Ir,Vr=Wr;function Yr({width:e,height:r,isEditorReady:n,loading:s,_ref:o,className:u,wrapperProps:g}){return c.createElement("section",{style:{...we.wrapper,width:e,height:r},...g},!n&&c.createElement(Vr,null,s),c.createElement("div",{ref:o,style:{...we.fullWidth,...!n&&we.hide},className:u}))}var qr=Yr,et=c.memo(qr);function Ur(e){c.useEffect(e,[])}var tt=Ur;function Fr(e,r,n=!0){let s=c.useRef(!0);c.useEffect(s.current||!n?()=>{s.current=!1}:e,r)}var B=Fr;function se(){}function te(e,r,n,s){return Br(e,s)||Zr(e,r,n,s)}function Br(e,r){return e.editor.getModel(rt(e,r))}function Zr(e,r,n,s){return e.editor.createModel(r,n,s?rt(e,s):void 0)}function rt(e,r){return e.Uri.parse(r)}function Jr({original:e,modified:r,language:n,originalLanguage:s,modifiedLanguage:o,originalModelPath:u,modifiedModelPath:g,keepCurrentOriginalModel:k=!1,keepCurrentModifiedModel:$=!1,theme:C="light",loading:m="Loading...",options:S={},height:H="100%",width:P="100%",className:T,wrapperProps:R={},beforeMount:z=se,onMount:q=se}){let[_,p]=c.useState(!1),[A,O]=c.useState(!0),y=c.useRef(null),w=c.useRef(null),I=c.useRef(null),E=c.useRef(q),x=c.useRef(z),M=c.useRef(!1);tt(()=>{let a=Xe.init();return a.then(i=>(w.current=i)&&O(!1)).catch(i=>(i==null?void 0:i.type)!=="cancelation"&&console.error("Monaco initialization: error:",i)),()=>y.current?b():a.cancel()}),B(()=>{if(y.current&&w.current){let a=y.current.getOriginalEditor(),i=te(w.current,e||"",s||n||"text",u||"");i!==a.getModel()&&a.setModel(i)}},[u],_),B(()=>{if(y.current&&w.current){let a=y.current.getModifiedEditor(),i=te(w.current,r||"",o||n||"text",g||"");i!==a.getModel()&&a.setModel(i)}},[g],_),B(()=>{let a=y.current.getModifiedEditor();a.getOption(w.current.editor.EditorOption.readOnly)?a.setValue(r||""):r!==a.getValue()&&(a.executeEdits("",[{range:a.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),a.pushUndoStop())},[r],_),B(()=>{var a,i;(i=(a=y.current)==null?void 0:a.getModel())==null||i.original.setValue(e||"")},[e],_),B(()=>{let{original:a,modified:i}=y.current.getModel();w.current.editor.setModelLanguage(a,s||n||"text"),w.current.editor.setModelLanguage(i,o||n||"text")},[n,s,o],_),B(()=>{var a;(a=w.current)==null||a.editor.setTheme(C)},[C],_),B(()=>{var a;(a=y.current)==null||a.updateOptions(S)},[S],_);let Y=c.useCallback(()=>{var d;if(!w.current)return;x.current(w.current);let a=te(w.current,e||"",s||n||"text",u||""),i=te(w.current,r||"",o||n||"text",g||"");(d=y.current)==null||d.setModel({original:a,modified:i})},[n,r,o,e,s,u,g]),Z=c.useCallback(()=>{var a;!M.current&&I.current&&(y.current=w.current.editor.createDiffEditor(I.current,{automaticLayout:!0,...S}),Y(),(a=w.current)==null||a.editor.setTheme(C),p(!0),M.current=!0)},[S,C,Y]);c.useEffect(()=>{_&&E.current(y.current,w.current)},[_]),c.useEffect(()=>{!A&&!_&&Z()},[A,_,Z]);function b(){var i,d,l,v;let a=(i=y.current)==null?void 0:i.getModel();k||((d=a==null?void 0:a.original)==null||d.dispose()),$||((l=a==null?void 0:a.modified)==null||l.dispose()),(v=y.current)==null||v.dispose()}return c.createElement(et,{width:P,height:H,isEditorReady:_,loading:m,_ref:I,className:T,wrapperProps:R})}var Kr=Jr;c.memo(Kr);function Gr(e){let r=c.useRef();return c.useEffect(()=>{r.current=e},[e]),r.current}var Qr=Gr,le=new Map;function Xr({defaultValue:e,defaultLanguage:r,defaultPath:n,value:s,language:o,path:u,theme:g="light",line:k,loading:$="Loading...",options:C={},overrideServices:m={},saveViewState:S=!0,keepCurrentModel:H=!1,width:P="100%",height:T="100%",className:R,wrapperProps:z={},beforeMount:q=se,onMount:_=se,onChange:p,onValidate:A=se}){let[O,y]=c.useState(!1),[w,I]=c.useState(!0),E=c.useRef(null),x=c.useRef(null),M=c.useRef(null),Y=c.useRef(_),Z=c.useRef(q),b=c.useRef(),a=c.useRef(s),i=Qr(u),d=c.useRef(!1),l=c.useRef(!1);tt(()=>{let f=Xe.init();return f.then(j=>(E.current=j)&&I(!1)).catch(j=>(j==null?void 0:j.type)!=="cancelation"&&console.error("Monaco initialization: error:",j)),()=>x.current?N():f.cancel()}),B(()=>{var j,D,h,L;let f=te(E.current,e||s||"",r||o||"",u||n||"");f!==((j=x.current)==null?void 0:j.getModel())&&(S&&le.set(i,(D=x.current)==null?void 0:D.saveViewState()),(h=x.current)==null||h.setModel(f),S&&((L=x.current)==null||L.restoreViewState(le.get(u))))},[u],O),B(()=>{var f;(f=x.current)==null||f.updateOptions(C)},[C],O),B(()=>{!x.current||s===void 0||(x.current.getOption(E.current.editor.EditorOption.readOnly)?x.current.setValue(s):s!==x.current.getValue()&&(l.current=!0,x.current.executeEdits("",[{range:x.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),x.current.pushUndoStop(),l.current=!1))},[s],O),B(()=>{var j,D;let f=(j=x.current)==null?void 0:j.getModel();f&&o&&((D=E.current)==null||D.editor.setModelLanguage(f,o))},[o],O),B(()=>{var f;k!==void 0&&((f=x.current)==null||f.revealLine(k))},[k],O),B(()=>{var f;(f=E.current)==null||f.editor.setTheme(g)},[g],O);let v=c.useCallback(()=>{var f;if(!(!M.current||!E.current)&&!d.current){Z.current(E.current);let j=u||n,D=te(E.current,s||e||"",r||o||"",j||"");x.current=(f=E.current)==null?void 0:f.editor.create(M.current,{model:D,automaticLayout:!0,...C},m),S&&x.current.restoreViewState(le.get(j)),E.current.editor.setTheme(g),k!==void 0&&x.current.revealLine(k),y(!0),d.current=!0}},[e,r,n,s,o,u,C,m,S,g,k]);c.useEffect(()=>{O&&Y.current(x.current,E.current)},[O]),c.useEffect(()=>{!w&&!O&&v()},[w,O,v]),a.current=s,c.useEffect(()=>{var f,j;O&&p&&((f=b.current)==null||f.dispose(),b.current=(j=x.current)==null?void 0:j.onDidChangeModelContent(D=>{l.current||p(x.current.getValue(),D)}))},[O,p]),c.useEffect(()=>{if(O){let f=E.current.editor.onDidChangeMarkers(j=>{var h;let D=(h=x.current.getModel())==null?void 0:h.uri;if(D&&j.find(L=>L.path===D.path)){let L=E.current.editor.getModelMarkers({resource:D});A==null||A(L)}});return()=>{f==null||f.dispose()}}return()=>{}},[O,A]);function N(){var f,j;(f=b.current)==null||f.dispose(),H?S&&le.set(u,x.current.saveViewState()):(j=x.current.getModel())==null||j.dispose(),x.current.dispose()}return c.createElement(et,{width:P,height:T,isEditorReady:O,loading:$,_ref:M,className:R,wrapperProps:z})}var en=Xr,tn=c.memo(en),rn=tn;function he({title:e,children:r,placement:n="top"}){const[s,o]=c.useState(!1);return e?t.jsxs("div",{className:"relative inline-flex",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[r,s&&t.jsx("div",{className:`absolute left-1/2 -translate-x-1/2 z-50 px-2 py-1 bg-gray-800/90 text-white text-xs rounded-md whitespace-nowrap pointer-events-none ${n==="top"?"bottom-full mb-1.5":"top-full mt-1.5"}`,children:e})]}):t.jsx(t.Fragment,{children:r})}const je=[{key:"desktop",icon:t.jsx(Ue,{size:13}),label:"Desktop",width:null},{key:"tablet",icon:t.jsx(Be,{size:13}),label:"Tablet",width:768},{key:"mobile",icon:t.jsx(Fe,{size:13}),label:"Mobile",width:390}],nn=({id:e,record:r})=>{const{navigate:n,params:s,locationState:o}=Ce(),u=e??s.id,{basePath:g,service:k,previewBaseUrl:$,previewTailwind:C}=Oe(),m=!!u,[S,H]=Ze(),[P,T]=c.useState(!1),[R,z]=c.useState(r??(o==null?void 0:o.record)??null),[q,_]=c.useState(""),[p,A]=c.useState(m?"":"https://aisee.live"),[O,y]=c.useState(""),[w,I]=c.useState(""),[E,x]=c.useState("code"),[M,Y]=c.useState(!1),[Z,b]=c.useState("desktop"),[a,i]=c.useState(!1),[d,l]=c.useState(null),v=(h,L)=>{const J=$?`<base href="${$}">`:"",U=L?`<meta name="viewport" content="width=${L}, initial-scale=1">`:"",K=L?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",G=C&&!h.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",W=J+U+K+G;return W?h.includes("</head>")?h.replace("</head>",`${W}
132
132
  </head>`):W+h:h},N=async()=>{if(!w.trim()){F.warning("请先输入 HTML 代码");return}i(!0),l(null);try{const h=await Ae(w);l(h),h.networkError?F.warning("W3C 校验服务不可用"):h.isValid&&F.success("W3C 校验通过")}finally{i(!1)}};c.useEffect(()=>{m&&(R?(_(R.pathname||""),A(R.host||""),I(R.content||"")):k.getById(u).then(h=>{z(h),_(h.pathname||""),A(h.host||""),I(h.content||"")}).catch(h=>{F.error(h.message||"获取数据失败"),n(g)}))},[u]);const f=()=>n(g),j=!q.trim(),D=async()=>{if(!q.trim()){y("请输入 pathname");return}if(!w.trim()){Y(!0),F.error("请输入 HTML 代码");return}T(!0);const h=await Ae(w);if(T(!1),h.networkError)F.warning("W3C 校验服务不可用,已跳过校验");else if(!h.isValid&&!await new Promise(J=>{S.confirm({title:"W3C 校验发现问题",content:t.jsxs("div",{className:"mt-1",children:[t.jsx("p",{className:"text-gray-600 mb-2",children:"检测到以下 W3C 标准问题,仍要保存吗?"}),t.jsxs("ul",{className:"space-y-1",children:[h.errors.slice(0,5).map((U,K)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-red-500 text-sm",children:[t.jsx("span",{className:"shrink-0",children:"✕"}),t.jsxs("span",{children:[U.lastLine?`第 ${U.lastLine} 行:`:"",U.message]})]},K)),h.errors.length>5&&t.jsxs("li",{className:"text-gray-400 text-xs mt-1",children:["还有 ",h.errors.length-5," 个问题…"]})]})]}),okText:"仍然保存",cancelText:"返回修改",onOk:()=>J(!0),onCancel:()=>J(!1)})}))return;T(!0);try{const L={pathname:q.trim(),content:w,host:(p==null?void 0:p.trim())||void 0};m&&R?(await k.update(R.id,L),F.success("编辑成功")):(await k.create(L),F.success("添加成功")),n(g)}catch(L){F.error(L.message||"保存失败")}finally{T(!1)}};return t.jsxs(t.Fragment,{children:[H,t.jsxs("div",{className:"w-full bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden flex flex-col",style:{height:"calc(100vh - 90px)"},children:[t.jsxs("div",{className:"shrink-0 flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/60",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-200 transition -ml-1 cursor-pointer",onClick:f,children:t.jsx(Ye,{size:15})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-base font-semibold text-gray-800 leading-tight",children:m?"编辑 Article":"新增 Article"}),m&&R&&t.jsxs("div",{className:"text-xs text-gray-400 mt-0.5 font-mono",children:["/",R.pathname]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{className:"px-4 py-1.5 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-gray-50 transition cursor-pointer",onClick:f,children:"取消"}),t.jsx("button",{disabled:j||P,className:"px-4 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",onClick:D,children:P?"保存中…":"保存"})]})]}),t.jsx("div",{className:"shrink-0 px-6 pt-5 pb-4 border-b border-gray-100",children:t.jsxs("div",{className:"flex gap-4",children:[t.jsxs("div",{className:"flex-1",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["Pathname",t.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"前台网站路径"})]}),t.jsxs("div",{className:`flex items-center border rounded-lg transition focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-400 ${O?"border-red-400 ring-2 ring-red-500/20":"border-gray-200"}`,children:[t.jsx("span",{className:"pl-3 text-gray-400 select-none text-sm shrink-0",children:"/"}),t.jsx("input",{className:"flex-1 pr-3 py-1.5 text-sm bg-transparent focus:outline-none",placeholder:"例如 about-us",value:q,onChange:h=>{_(h.target.value),O&&y("")}})]}),O&&t.jsx("p",{className:"text-red-500 text-xs mt-1",children:O})]}),t.jsxs("div",{className:"flex-1",children:[t.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["Website URL",t.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"可跳转的网站地址"})]}),t.jsx("input",{className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition",placeholder:"例如 https://aisee.live",value:p,onChange:h=>A(h.target.value)})]})]})}),t.jsx("div",{className:"shrink-0 border-b border-gray-100 bg-gray-50/40",children:t.jsxs("div",{className:"flex items-center justify-between px-6 py-2",children:[t.jsx("div",{className:"flex items-center gap-3",children:t.jsxs("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:[t.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none cursor-pointer ${E==="code"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>x("code"),children:[t.jsx(qe,{size:11})," Code"]}),t.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none ${E==="preview"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50 cursor-pointer":w?"text-gray-400 hover:text-gray-600 hover:bg-white/50 cursor-pointer":"text-gray-300 cursor-not-allowed"}`,onClick:()=>x("preview"),disabled:!w,children:[t.jsx($e,{size:11})," 预览"]})]})}),E==="preview"&&w&&t.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:je.map(h=>t.jsx(he,{title:h.label,children:t.jsx("button",{className:`flex items-center justify-center w-7 h-6 rounded-md text-xs transition-all duration-150 select-none cursor-pointer ${Z===h.key?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>b(h.key),children:h.icon})},h.key))}),E==="code"&&t.jsxs("div",{className:"flex items-center gap-2",children:[w&&t.jsxs("span",{className:"text-xs text-gray-400",children:[w.split(`
133
133
  `).length," 行 ·"," ",w.length," 字符"]}),d&&!d.networkError&&(d.isValid?t.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-50 border border-green-200 text-green-600 text-xs",children:[t.jsx(Ee,{size:11})," 校验通过"]}):t.jsx(he,{title:t.jsxs("ul",{className:"m-0 pl-0 list-none space-y-1 max-w-xs",children:[d.errors.slice(0,5).map((h,L)=>t.jsxs("li",{className:"text-xs",children:[h.lastLine?`第 ${h.lastLine} 行:`:"",h.message]},L)),d.errors.length>5&&t.jsxs("li",{className:"text-gray-400 text-xs",children:["还有"," ",d.errors.length-5," ","个问题…"]})]}),children:t.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-50 border border-red-200 text-red-500 text-xs cursor-default",children:["✕"," ",d.errors.length," ","个问题"]})})),t.jsxs("button",{disabled:!w||a,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs border border-gray-200 rounded-lg hover:bg-gray-50 text-gray-600 transition disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",onClick:N,children:[t.jsx(Ee,{size:12}),a?"校验中…":"W3C 校验"]})]})]})}),t.jsxs("div",{className:"flex-1 min-h-0 relative",children:[t.jsx("div",{className:"absolute inset-0",style:{display:E==="code"?"block":"none",outline:M?"2px solid #ff4d4f":"none"},children:t.jsx(rn,{height:"100%",language:"html",theme:"vs-dark",value:w,onChange:h=>{I(h??""),M&&Y(!1),d&&l(null)},options:{fontSize:13,minimap:{enabled:!1},wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,formatOnPaste:!0,lineNumbers:"on",renderWhitespace:"none",smoothScrolling:!0,cursorBlinking:"smooth",padding:{top:12,bottom:12}}})}),E==="preview"&&(w?t.jsx("div",{className:"absolute inset-0 overflow-auto bg-gray-100/60 flex justify-center",children:Z!=="desktop"?t.jsx("div",{className:"flex flex-col items-center py-6 h-full",children:t.jsx("iframe",{srcDoc:v(w,je.find(h=>h.key===Z).width),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:`${je.find(h=>h.key===Z).width}px`,height:"100%",minHeight:0,border:"1px solid #e5e7eb",borderRadius:10,background:"#fff",boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",flexShrink:0}})}):t.jsx("iframe",{srcDoc:v(w),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:"100%",height:"100%",border:"none",background:"#fff",display:"block"}})}):t.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-300 gap-3 select-none",children:[t.jsx($e,{size:36}),t.jsx("span",{className:"text-sm",children:"请先输入 HTML 代码"})]}))]})]})]})},Ne=[{key:"desktop",icon:t.jsx(Ue,{size:13}),label:"Desktop",width:null},{key:"tablet",icon:t.jsx(Be,{size:13}),label:"Tablet",width:768},{key:"mobile",icon:t.jsx(Fe,{size:13}),label:"Mobile",width:390}],sn=({id:e,record:r})=>{const{navigate:n,params:s,locationState:o}=Ce(),u=e??s.id,{basePath:g,service:k,previewBaseUrl:$,previewTailwind:C}=Oe(),[m,S]=c.useState(r??(o==null?void 0:o.record)??null),[H,P]=c.useState(!1),[T,R]=c.useState("preview"),[z,q]=c.useState("desktop");c.useEffect(()=>{!m&&u&&(P(!0),k.getById(u).then(S).catch(y=>{F.error(y.message||"获取数据失败"),n(g)}).finally(()=>P(!1)))},[u]);const _=()=>n(g),p=()=>n(`${g}/${u}/edit`,{state:{record:m}}),A=()=>{m!=null&&m.content&&(navigator.clipboard.writeText(m.content),F.success("已复制到剪贴板"))},O=(y,w)=>{const I=$?`<base href="${$}">`:"",E=w?`<meta name="viewport" content="width=${w}, initial-scale=1">`:"",x=w?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",M=C&&!y.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",Y=I+E+x+M;return Y?y.includes("</head>")?y.replace("</head>",`${Y}
134
134
  </head>`):Y+y:y};return H?t.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400 text-sm",children:"加载中…"}):t.jsxs("div",{className:"w-full bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden flex flex-col",style:{height:"calc(100vh - 90px)"},children:[t.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-gray-100 bg-white shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[t.jsx("button",{className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100 transition -ml-1 shrink-0 cursor-pointer",onClick:_,children:t.jsx(Ye,{size:15})}),t.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg shrink-0",style:{background:"linear-gradient(135deg, #60a5fa, #818cf8)"},children:t.jsx($t,{size:13,className:"text-white"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-semibold text-gray-800 text-sm leading-tight",children:"Article 详情"}),t.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0 rounded bg-blue-50 border border-blue-100 text-blue-600 font-mono text-xs leading-5 truncate max-w-[300px]",children:[t.jsx(Ot,{size:9}),"/",m==null?void 0:m.pathname]})})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[T==="preview"&&t.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:Ne.map(y=>t.jsx(he,{title:y.label,children:t.jsx("button",{className:`flex items-center justify-center w-7 h-6 rounded-md text-xs transition-all duration-150 select-none cursor-pointer ${z===y.key?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>q(y.key),children:y.icon})},y.key))}),t.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:["preview","code"].map(y=>t.jsx("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none cursor-pointer ${T===y?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>R(y),children:y==="preview"?t.jsxs(t.Fragment,{children:[t.jsx($e,{size:11})," 预览"]}):t.jsxs(t.Fragment,{children:[t.jsx(qe,{size:11})," Code"]})},y))}),T==="code"&&t.jsx(he,{title:"复制代码",children:t.jsx("button",{className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 transition cursor-pointer",onClick:A,children:t.jsx(vt,{size:14})})})]})]}),t.jsx("div",{className:`flex-1 min-h-0 ${T==="preview"?"bg-gray-100/70":""}`,children:T==="preview"?t.jsx("div",{className:"w-full h-full flex justify-center overflow-auto py-0",children:z!=="desktop"?t.jsx("div",{className:"flex flex-col items-center py-6 h-full",children:t.jsx("iframe",{srcDoc:O((m==null?void 0:m.content)||"",Ne.find(y=>y.key===z).width),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:`${Ne.find(y=>y.key===z).width}px`,height:"100%",minHeight:0,border:"1px solid #e5e7eb",borderRadius:10,background:"#fff",boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",flexShrink:0}})}):t.jsx("iframe",{srcDoc:O((m==null?void 0:m.content)||""),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:"100%",height:"100%",border:"none",background:"#fff",display:"block"}})}):t.jsxs("div",{className:"h-full flex flex-col",style:{background:"#1e1e2e"},children:[t.jsxs("div",{className:"shrink-0 flex items-center justify-between px-4 py-2 border-b",style:{borderColor:"#2d2d3e",background:"#252536"},children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("span",{className:"w-3 h-3 rounded-full bg-red-400/80 inline-block"}),t.jsx("span",{className:"w-3 h-3 rounded-full bg-yellow-400/80 inline-block"}),t.jsx("span",{className:"w-3 h-3 rounded-full bg-green-400/80 inline-block"})]}),t.jsx("span",{className:"text-xs font-mono ml-2",style:{color:"#6c7086"},children:"index.html"})]}),t.jsx("span",{className:"text-xs font-mono",style:{color:"#6c7086"},children:m!=null&&m.content?`${m.content.split(`
package/dist/index.js CHANGED
@@ -1633,7 +1633,7 @@ const Me = [
1633
1633
  { key: "tablet", icon: /* @__PURE__ */ a(rt, { size: 13 }), label: "Tablet", width: 768 },
1634
1634
  { key: "mobile", icon: /* @__PURE__ */ a(tt, { size: 13 }), label: "Mobile", width: 390 }
1635
1635
  ], Nn = ({ id: e, record: t }) => {
1636
- const { navigate: r, params: n, locationState: s } = Ee(), u = e ?? n.id, { basePath: y, service: $, previewBaseUrl: M, previewTailwind: j } = ze(), m = !!u, [S, W] = nt(), [P, E] = A(!1), [I, H] = A(t ?? (s == null ? void 0 : s.record) ?? null), [B, z] = A(""), [p, T] = A(""), [O, b] = A(""), [w, R] = A(""), [L, g] = A("code"), [C, q] = A(!1), [G, x] = A("desktop"), [i, o] = A(!1), [d, c] = A(null), v = (h, _) => {
1636
+ const { navigate: r, params: n, locationState: s } = Ee(), u = e ?? n.id, { basePath: y, service: $, previewBaseUrl: M, previewTailwind: j } = ze(), m = !!u, [S, W] = nt(), [P, E] = A(!1), [I, H] = A(t ?? (s == null ? void 0 : s.record) ?? null), [B, z] = A(""), [p, T] = A(m ? "" : "https://aisee.live"), [O, b] = A(""), [w, R] = A(""), [L, g] = A("code"), [C, q] = A(!1), [G, x] = A("desktop"), [i, o] = A(!1), [d, c] = A(null), v = (h, _) => {
1637
1637
  const Q = M ? `<base href="${M}">` : "", F = _ ? `<meta name="viewport" content="width=${_}, initial-scale=1">` : "", X = _ ? "<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>" : "", ee = j && !h.includes("cdn.tailwindcss.com") ? '<script src="https://cdn.tailwindcss.com"><\/script>' : "", V = Q + F + X + ee;
1638
1638
  return V ? h.includes("</head>") ? h.replace("</head>", `${V}
1639
1639
  </head>`) : V + h : h;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/web-module/aisee-articles.git"
6
6
  },
7
- "version": "1.1.0",
7
+ "version": "1.1.2",
8
8
  "description": "Reusable articles management module",
9
9
  "type": "module",
10
10
  "main": "./dist/index.cjs",
@@ -26,14 +26,6 @@
26
26
  "files": [
27
27
  "dist"
28
28
  ],
29
- "scripts": {
30
- "build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
31
- "dev": "vite build --watch",
32
- "playground": "vite --config playground/vite.config.ts",
33
- "release": "bash scripts/release.sh",
34
- "release:minor": "bash scripts/release.sh minor",
35
- "release:major": "bash scripts/release.sh major"
36
- },
37
29
  "peerDependencies": {
38
30
  "react": ">=18",
39
31
  "react-dom": ">=18",
@@ -59,5 +51,13 @@
59
51
  "publishConfig": {
60
52
  "registry": "https://registry.npmjs.org",
61
53
  "access": "public"
54
+ },
55
+ "scripts": {
56
+ "build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
57
+ "dev": "vite build --watch",
58
+ "playground": "vite --config playground/vite.config.ts",
59
+ "release": "bash scripts/release.sh",
60
+ "release:minor": "bash scripts/release.sh minor",
61
+ "release:major": "bash scripts/release.sh major"
62
62
  }
63
- }
63
+ }