@qingwu-ui/ai-editor 0.9.0-beta.25 → 0.9.0-beta.26
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/dist/components/release-notes-dialog.d.ts +1 -1
- package/dist/components/release-notes-dialog.d.ts.map +1 -1
- package/dist/editor/ai-editor.d.ts.map +1 -1
- package/dist/{export-dialog-BSEeEEHv.cjs → export-dialog-BJReD1PN.cjs} +1 -1
- package/dist/{export-dialog-CL7ie13Z.js → export-dialog-CJhm3uqR.js} +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.js +6 -7
- package/dist/{md-import-dialog-CnstzrIK.cjs → md-import-dialog-CVvu-Adt.cjs} +1 -1
- package/dist/{md-import-dialog-Cf3ZOwA_.js → md-import-dialog-DbC-NCH_.js} +1 -1
- package/dist/{sanitize-CrbFQE46.cjs → sanitize-Bcj55kwd.cjs} +1 -1
- package/dist/{sanitize-z8gMk0lV.js → sanitize-wGLeVLFO.js} +1 -1
- package/dist/{signed-fetch-DiWXujJ1.cjs → signed-fetch-BiI-JlzZ.cjs} +1 -1
- package/dist/{storage-settings-dialog-DZqqDAiO.js → storage-settings-dialog-DnWNQWjN.js} +3 -3
- package/dist/storage-settings-dialog-zPgJahMO.cjs +1 -0
- package/dist/styles.css +1 -1
- package/dist/{video-embed-dialog-AeGcMb4X.js → video-embed-dialog-B0_pc5xe.js} +1 -1
- package/dist/video-embed-dialog-f5HKKPzg.cjs +1 -0
- package/package.json +1 -1
- package/scripts/cli.mjs +1 -1
- package/scripts/copy-assets.mjs +1 -1
- package/dist/storage-settings-dialog-ZtMUoApJ.cjs +0 -1
- package/dist/video-embed-dialog-BbVHq51W.cjs +0 -1
|
@@ -79,7 +79,7 @@ var c = ({ open: c, onClose: l, onInsert: u }) => {
|
|
|
79
79
|
onClick: S
|
|
80
80
|
}), /* @__PURE__ */ a("div", {
|
|
81
81
|
ref: g,
|
|
82
|
-
className: "relative w-[calc(100vw-
|
|
82
|
+
className: "relative w-[calc(100vw-2rem)] max-w-[520px] max-h-[90dvh] bg-background rounded-2xl shadow-2xl border border-default-200 overflow-hidden animate-in",
|
|
83
83
|
children: [
|
|
84
84
|
/* @__PURE__ */ a("div", {
|
|
85
85
|
className: "flex items-center justify-between px-5 py-4 border-b border-default-100",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require("react"),t=require("react/jsx-runtime");function n(e){return e.trim()?/bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e)?`bilibili`:/xiaohongshu\.com|xhslink\.com/i.test(e)?`xiaohongshu`:/\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e)||/\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e)?`direct`:`unknown`:`unknown`}function r(e){let t=e.match(/BV[a-zA-Z0-9]{10}/);if(t)return t[0];let n=e.match(/av(\d+)/i);return n?n[0]:e.trim()}var i=({open:i,onClose:a,onInsert:o})=>{let[s,c]=(0,e.useState)(``),[l,u]=(0,e.useState)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=`video-preview-player`,m=n(s.trim()),h=m!==`unknown`,g=m===`bilibili`||m===`xiaohongshu`;(0,e.useEffect)(()=>{if(m!==`direct`||!i)return;let e=!1,t=setTimeout(async()=>{if(!e&&!(!document.getElementById(p)||d.current))try{let{default:t}=await import(`xgplayer`);if(e||!document.getElementById(p))return;d.current=new t({id:p,url:s.trim(),width:`100%`,fluid:!0,fitVideoSize:`fixWidth`,autoplay:!1,controls:!0,ignores:[`fullscreen`],lang:`zh-cn`})}catch{}},200);return()=>{e=!0,clearTimeout(t),d.current&&=(d.current.destroy(),null)}},[m,s,i]);let _=(0,e.useCallback)(()=>{if(!h){u(`请输入有效的视频链接`);return}o(s.trim()),c(``),u(null),d.current&&=(d.current.destroy(),null),a()},[s,h,o,a]),v=(0,e.useCallback)(()=>{c(``),u(null),d.current&&=(d.current.destroy(),null),a()},[a]);return(0,e.useEffect)(()=>{if(!i)return;let e=f.current;if(!e)return;let t=e=>{let t=e.clipboardData?.getData(`text`)?.trim();t&&n(t)!==`unknown`&&(e.preventDefault(),c(t))};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[i]),(0,e.useEffect)(()=>{if(!i||m!==`direct`)return;let e=e=>{if(e.key!==` `)return;let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`))return;let n=d.current;n&&(e.preventDefault(),n.paused?n.play():n.pause())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,m]),i?(0,t.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center`,children:[(0,t.jsx)(`div`,{className:`absolute inset-0 bg-black/40 backdrop-blur-sm`,onClick:v}),(0,t.jsxs)(`div`,{ref:f,className:`relative w-[calc(100vw-2rem)] max-w-[520px] max-h-[90dvh] bg-background rounded-2xl shadow-2xl border border-default-200 overflow-hidden animate-in`,children:[(0,t.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-default-100`,children:[(0,t.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,t.jsx)(`svg`,{className:`w-5 h-5 text-primary`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:`2`,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z`})}),(0,t.jsx)(`h2`,{className:`text-base font-semibold`,children:`导入视频`})]}),(0,t.jsx)(`button`,{type:`button`,className:`w-7 h-7 flex items-center justify-center rounded-lg text-default-400 hover:text-default-600 hover:bg-default-100 transition-colors`,onClick:v,children:`✕`})]}),(0,t.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,t.jsxs)(`div`,{children:[(0,t.jsx)(`label`,{className:`block text-xs font-medium text-default-600 mb-1.5`,children:`粘贴视频链接`}),(0,t.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2.5 rounded-xl border border-default-200 bg-background text-sm focus:outline-none focus:border-primary transition-colors`,placeholder:`粘贴视频直链、B站链接 或 小红书链接...`,value:s,onChange:e=>{c(e.target.value),u(null)},onKeyDown:e=>{e.key===`Enter`&&_()}}),(0,t.jsx)(`p`,{className:`mt-1.5 text-[11px] text-default-400`,children:`支持直链 (mp4/m3u8/webm…) · B站链接 · 小红书链接 — 粘贴后自动识别`})]}),s.trim()&&(0,t.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,t.jsx)(`span`,{className:`text-xs text-default-400`,children:`识别为:`}),(0,t.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${m===`bilibili`?`bg-[#fb7299]/10 text-[#fb7299]`:m===`direct`?`bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400`:m===`xiaohongshu`?`bg-[#ff2442]/10 text-[#ff2442]`:`bg-default-100 text-default-500`}`,children:m===`bilibili`?`B站视频`:m===`xiaohongshu`?`小红书`:m===`direct`?`直链视频`:`未知类型`})]}),g&&s.trim()&&(0,t.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 text-xs`,children:[(0,t.jsx)(`svg`,{className:`w-4 h-4 shrink-0 mt-px text-amber-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:`2`,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})}),(0,t.jsxs)(`div`,{children:[(0,t.jsxs)(`p`,{className:`font-medium text-amber-700 dark:text-amber-400`,children:[`版权提示:`,m===`bilibili`?`B站`:`小红书`,`视频将以官方播放器嵌入,版权归原作者所有。`]}),(0,t.jsx)(`p`,{className:`mt-0.5 text-amber-600 dark:text-amber-500`,children:`请确保您有权限分享该内容。支持通过官方分享链接导入。`})]})]}),m===`direct`&&h?(0,t.jsx)(`div`,{id:p,style:{width:`100%`,aspectRatio:`16/9`,borderRadius:12,overflow:`hidden`,background:`#000`}}):m===`bilibili`&&h?(0,t.jsx)(`div`,{className:`relative rounded-xl overflow-hidden bg-black aspect-video`,children:(0,t.jsx)(`iframe`,{src:`https://player.bilibili.com/player.html?bvid=${r(s.trim())}&page=1&high_quality=1&autoplay=0`,className:`w-full h-full`,allowFullScreen:!0,style:{border:`none`},sandbox:`allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox`,referrerPolicy:`no-referrer-when-downgrade`})}):m===`xiaohongshu`&&h?(0,t.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-6 rounded-xl border border-dashed border-default-200 bg-default-50 dark:bg-default-100/10`,children:[(0,t.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-[#ff2442]/10 flex items-center justify-center text-lg`,children:`📌`}),(0,t.jsxs)(`div`,{children:[(0,t.jsx)(`p`,{className:`text-sm font-medium`,children:`小红书笔记`}),(0,t.jsx)(`p`,{className:`text-xs text-default-400`,children:`导入后将显示为卡片样式,点击跳转至小红书查看`})]})]}):s.trim()&&!h?(0,t.jsx)(`div`,{className:`flex items-center justify-center py-10 rounded-xl border border-dashed border-default-200 text-sm text-default-400`,children:`无法识别该链接类型,请检查后重试`}):(0,t.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-10 rounded-xl border-2 border-dashed border-default-200 bg-default-50 dark:bg-default-100/10 text-default-400`,children:[(0,t.jsx)(`svg`,{className:`w-10 h-10`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z`})}),(0,t.jsxs)(`div`,{className:`text-center`,children:[(0,t.jsx)(`p`,{className:`text-sm`,children:`粘贴链接后自动识别并预览`}),(0,t.jsx)(`p`,{className:`text-xs mt-1`,children:`支持直链 mp4/m3u8 · B站 · 小红书`})]})]}),l&&(0,t.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg bg-danger-50 dark:bg-danger-900/20 text-sm text-danger`,children:[(0,t.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z`})}),l]}),(0,t.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,t.jsx)(`button`,{type:`button`,className:`flex-1 py-2.5 rounded-xl bg-primary text-white text-sm font-medium hover:opacity-90 disabled:opacity-40 transition-opacity`,disabled:!h,onClick:_,children:`导入视频`}),(0,t.jsx)(`button`,{type:`button`,className:`px-4 py-2.5 rounded-xl border border-default-200 text-sm hover:bg-default-50 dark:hover:bg-default-100/10 transition-colors`,onClick:v,children:`取消`})]})]}),(0,t.jsx)(`div`,{className:`px-5 py-2.5 border-t border-default-100 text-[11px] text-default-300 text-center`,children:`直链使用 xgplayer 播放 · B站/小红书使用官方播放器`})]})]}):null};exports.VideoEmbedDialog=i;
|
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
2
3
|
/**
|
|
3
4
|
* @qingwu-ui/ai-editor 命令行入口
|
|
4
5
|
*
|
|
@@ -7,7 +8,6 @@
|
|
|
7
8
|
* 拷贝附件预览(PDF/Word/Excel/PPT/压缩包)所需的 worker/wasm/字体资源。
|
|
8
9
|
*/
|
|
9
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
|
-
import { dirname, join } from "node:path";
|
|
11
11
|
|
|
12
12
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
const [command, ...rest] = process.argv.slice(2);
|
package/scripts/copy-assets.mjs
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* 注意:请在「项目根目录」执行,默认输出到 public/。
|
|
15
15
|
*/
|
|
16
16
|
import { cpSync, existsSync, mkdirSync } from "node:fs";
|
|
17
|
-
import { basename, dirname, join, resolve } from "node:path";
|
|
18
17
|
import { createRequire } from "node:module";
|
|
18
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
19
19
|
import { pathToFileURL } from "node:url";
|
|
20
20
|
|
|
21
21
|
const args = process.argv.slice(2);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./signed-fetch-DiWXujJ1.cjs"),t=require("./storage-VaeLS7eM.cjs"),n=require("./local-D4481lUa.cjs");let r=require("react"),i=require("react/jsx-runtime");var a=[{key:`local`,label:`本地`,icon:`💻`},{key:`s3`,label:`S3 对象存储`,icon:`☁️`}],o=({open:o,onClose:s})=>{let c=t.t(),[l,u]=(0,r.useState)(c?.type===`local`?`local`:`s3`),[d,f]=(0,r.useState)(!1),[p,m]=(0,r.useState)(!1),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)(``),[y,b]=(0,r.useState)(``),[x,S]=(0,r.useState)(`auto`),[C,w]=(0,r.useState)(``),[T,E]=(0,r.useState)(``),[D,O]=(0,r.useState)(``),[k,A]=(0,r.useState)(`qingwu`),[j,M]=(0,r.useState)(`{ts}{tz}_{src}_{name}_{rand}{ext}`);(0,r.useEffect)(()=>{let e=t.r();e?.type===`s3`?(v(e.endpoint||``),b(e.bucket||``),S(e.region||`auto`),w(e.accessKeyId||``),E(e.secretAccessKey||``),O(e.customDomain||``),A(e.uploadPrefix||`qingwu`),M(e.nameTemplate||`{ts}{tz}_{src}_{name}_{rand}{ext}`),u(`s3`)):e?.type===`oss`?(v(`https://${e.bucket}.${e.region}.aliyuncs.com`),b(e.bucket||``),S(e.region||`oss-cn-hangzhou`),w(e.accessKeyId||``),E(e.accessKeySecret||``),O(e.customDomain||``),A(e.uploadPrefix||`qingwu`),M(e.nameTemplate||`{ts}{tz}_{src}_{name}_{rand}{ext}`),u(`s3`)):e?.type===`cos`&&(v(`https://${e.bucket}.cos.${e.region}.myqcloud.com`),b(e.bucket||``),S(e.region||`ap-guangzhou`),w(e.secretId||``),E(e.secretKey||``),O(e.customDomain||``),A(e.uploadPrefix||`qingwu`),M(e.nameTemplate||`{ts}{tz}_{src}_{name}_{rand}{ext}`),u(`s3`))},[]),(0,r.useEffect)(()=>{if(!h)return;let e=window.setTimeout(()=>g(null),4e3);return()=>window.clearTimeout(e)},[h]);let N=(0,r.useCallback)(()=>{g(null),t.a(n.t(),{type:`local`,location:`浏览器内存 (Base64 编码)`}),f(!0),setTimeout(()=>{f(!1),s()},600)},[s]),P=(0,r.useCallback)(async()=>{if(!p){m(!0),g(null);try{let e=n.t(),t=new File([`qingwu storage test`],`qingwu-storage-test.txt`,{type:`text/plain`}),r=await e.upload(t,`editor`);await e.remove(r).catch(()=>{}),g({type:`success`,message:`本地存储可用`})}catch(e){g({type:`error`,message:e instanceof Error?e.message:`本地存储测试失败`})}finally{m(!1)}}},[p]),F=(0,r.useCallback)(()=>{if(!_||!y||!C)return;g(null);let r={endpoint:_,bucket:y,region:x,accessKeyId:C,secretAccessKey:T,customDomain:D||void 0,uploadPrefix:k||`qingwu`,nameTemplate:j||`{ts}{tz}_{src}_{name}_{rand}{ext}`};t.a(n.n(r),{type:`s3`,endpoint:_,bucket:y,region:x,accessKeyId:C,secretAccessKey:T,customDomain:D||void 0,uploadPrefix:k||`qingwu`,nameTemplate:j||`{ts}{tz}_{src}_{name}_{rand}{ext}`}),e.t(r),f(!0),setTimeout(()=>{f(!1),s()},600)},[_,y,x,C,T,D,k,j,s]),I=(0,r.useCallback)(async()=>{if(!_||!y||!C||p)return;m(!0),g(null);let e=``;try{let t=n.n({endpoint:_,bucket:y,region:x,accessKeyId:C,secretAccessKey:T,customDomain:D||void 0}),r=new File([`qingwu storage test`],`qingwu-storage-test.txt`,{type:`text/plain`});e=await t.upload(r,`editor`);let i=!1,a=!1;try{i=(await fetch(e,{method:`GET`})).ok}catch{i=!1}if(!i)try{let{signPreviewUrlHeaders:t}=await Promise.resolve().then(()=>require("./signed-fetch-DiWXujJ1.cjs")).then(e=>e.i),{registerS3PreviewConfig:n}=await Promise.resolve().then(()=>require("./signed-fetch-DiWXujJ1.cjs")).then(e=>e.i);n({endpoint:_,bucket:y,region:x,accessKeyId:C,secretAccessKey:T,customDomain:D||void 0});let r=await t(e);r&&(await fetch(e,{headers:r})).ok&&(i=!0,a=!0)}catch{}if(!i)throw Error(`上传成功,但访问失败。请确认 Bucket 读写权限配置正确。`);g({type:`success`,message:a?`存储连接成功(私有桶,通过签名访问)`:`存储连接和公开访问均成功`})}catch(e){g({type:`error`,message:e instanceof Error?e.message:`存储连接失败`})}finally{e&&await n.n({endpoint:_,bucket:y,region:x,accessKeyId:C,secretAccessKey:T,customDomain:D||void 0}).remove(e).catch(()=>{}),m(!1)}},[_,y,x,C,T,D,p]);return o?(0,i.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center`,children:[h&&(0,i.jsx)(`div`,{className:`fixed right-4 top-4 z-[10001] w-[calc(100vw-32px)] max-w-sm rounded-xl border px-4 py-3 text-sm shadow-2xl backdrop-blur-sm ${h.type===`success`?`border-green-200 bg-green-50/95 text-green-700`:`border-danger-200 bg-danger-50/95 text-danger`}`,children:(0,i.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,i.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:h.type===`success`?`✓`:`!`}),(0,i.jsx)(`span`,{className:`min-w-0 break-words`,children:h.message})]})}),(0,i.jsx)(`div`,{className:`absolute inset-0 bg-black/40 backdrop-blur-sm`,onClick:s}),(0,i.jsxs)(`div`,{className:`relative w-[calc(100vw-32px)] max-w-[460px] max-h-[85vh] bg-background rounded-2xl shadow-2xl border border-default-200 overflow-hidden animate-in`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-default-100`,children:[(0,i.jsx)(`h2`,{className:`text-base font-semibold`,children:`存储设置`}),(0,i.jsx)(`button`,{type:`button`,className:`w-7 h-7 flex items-center justify-center rounded-lg text-default-400 hover:text-default-600 hover:bg-default-100 transition-colors`,onClick:s,children:`✕`})]}),c&&(0,i.jsxs)(`div`,{className:`mx-5 mt-4 p-3 rounded-xl bg-default-50 border border-default-100`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-default-500 mb-1`,children:[(0,i.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500`}),`当前存储服务`]}),(0,i.jsx)(`div`,{className:`text-sm font-medium`,children:c.name}),(0,i.jsx)(`div`,{className:`text-[11px] text-default-400 mt-0.5`,children:c.type===`local`?`位置:浏览器内存 · Base64 编码 · 关闭页面后丢失`:c.type===`s3`&&c.config?.type===`s3`?`${c.config.endpoint} · ${c.config.bucket}${c.config.customDomain?` → ${c.config.customDomain}`:``}`:``})]}),(0,i.jsx)(`div`,{className:`flex border-b border-default-100 px-5 mt-4`,children:a.map(({key:e,label:t,icon:n})=>(0,i.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-3 py-2.5 text-sm font-medium transition-colors border-b-2 -mb-[1px] ${l===e?`border-primary text-primary`:`border-transparent text-default-400 hover:text-default-600`}`,onClick:()=>{u(e),f(!1)},children:[(0,i.jsx)(`span`,{children:n}),t]},e))}),(0,i.jsxs)(`div`,{className:`p-5 max-h-[50vh] overflow-y-auto`,children:[l===`local`&&(0,i.jsxs)(`div`,{className:`space-y-4`,children:[(0,i.jsxs)(`div`,{className:`p-4 rounded-xl bg-blue-50 border border-blue-100`,children:[(0,i.jsx)(`p`,{className:`text-sm font-medium text-blue-800 mb-1`,children:`💻 浏览器内存存储`}),(0,i.jsx)(`p`,{className:`text-xs text-blue-600 leading-relaxed`,children:`文件以 Base64 编码存储在浏览器内存中,页面关闭后清除。 适合演示和临时使用,不建议用于生产环境。`})]}),(0,i.jsx)(`button`,{type:`button`,className:`w-full py-2.5 rounded-xl text-sm font-medium transition-all ${d?`bg-green-500 text-white`:`bg-primary text-white hover:opacity-90`}`,onClick:N,children:d?`✓ 已保存`:`使用本地存储`}),(0,i.jsx)(`button`,{type:`button`,className:`w-full py-2.5 rounded-xl text-sm font-medium border border-default-200 hover:bg-default-100 transition-all disabled:opacity-40`,disabled:p,onClick:P,children:p?`测试中...`:`测试连接`})]}),l===`s3`&&(0,i.jsxs)(`div`,{className:`space-y-3`,children:[(0,i.jsx)(`div`,{className:`p-3 rounded-lg bg-default-50 text-xs text-default-500 leading-relaxed mb-1`,children:`兼容 AWS S3、Cloudflare R2、MinIO、阿里云 OSS、腾讯云 COS 等所有 S3 协议对象存储服务。`}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`Endpoint *`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`https://<account>.r2.cloudflarestorage.com`,value:_,onChange:e=>v(e.target.value)})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`Bucket 名称 *`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`my-bucket`,value:y,onChange:e=>b(e.target.value)})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`Region`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`auto / us-east-1 / ap-northeast-1`,value:x,onChange:e=>S(e.target.value)}),(0,i.jsxs)(`p`,{className:`text-[11px] text-default-400 mt-0.5`,children:[`R2 / MinIO 填 `,(0,i.jsx)(`code`,{children:`auto`}),`,AWS 按实际区域填写`]})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`Access Key ID *`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`AKIAIOSFODNN7EXAMPLE`,value:C,onChange:e=>w(e.target.value)})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`Secret Access Key`}),(0,i.jsx)(`input`,{type:`password`,className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`••••••••`,value:T,onChange:e=>E(e.target.value)})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`自定义访问域名(CDN,可选)`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`cdn.example.com`,value:D,onChange:e=>O(e.target.value)}),(0,i.jsx)(`p`,{className:`text-[11px] text-default-400 mt-0.5`,children:`设置后,上传返回的资源 URL 将使用此域名`})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`资源目录`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`qingwu`,value:k,onChange:e=>A(e.target.value)}),(0,i.jsx)(`p`,{className:`text-[11px] text-default-400 mt-0.5`,children:`上传文件的存储目录,默认 qingwu(MinIO/S3 路径风格需填 bucket 名)`})]}),(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`label`,{className:`block text-xs text-default-500 mb-1`,children:`文件名模板`}),(0,i.jsx)(`input`,{className:`w-full px-3 py-2 rounded-lg border border-default-200 bg-background text-sm focus:outline-none focus:border-primary`,placeholder:`{ts}{tz}_{src}_{name}_{rand}{ext}`,value:j,onChange:e=>M(e.target.value)}),(0,i.jsx)(`p`,{className:`text-[11px] text-default-400 mt-0.5`,children:`占位符: {ts}=时间戳, {tz}=时区, {src}=出处(editor/cover), {name}=原名, {ext}=扩展名, {rand}=随机串`})]}),(0,i.jsxs)(`div`,{className:`p-3 rounded-lg bg-default-50 text-[11px] text-default-500 leading-relaxed`,children:[`上传路径:`,_&&y?`${_}/${y}/qingwu/...`:`请填写 Endpoint 和 Bucket`,D?`\n访问域名:https://${D}/qingwu/...`:``]}),(0,i.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,i.jsx)(`button`,{type:`button`,className:`py-2.5 rounded-xl text-sm font-medium border border-default-200 hover:bg-default-100 transition-all disabled:opacity-40`,disabled:!_||!y||!C||p,onClick:I,children:p?`测试中...`:`测试连接`}),(0,i.jsx)(`button`,{type:`button`,className:`py-2.5 rounded-xl text-sm font-medium transition-all disabled:opacity-40 ${d?`bg-green-500 text-white`:`bg-primary text-white hover:opacity-90`}`,disabled:!_||!y||!C||p,onClick:F,children:d?`✓ 已保存`:`保存并应用`})]})]})]})]})]}):null};exports.StorageSettingsDialog=o;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=require("react"),t=require("react/jsx-runtime");function n(e){return e.trim()?/bilibili\.com|BV[a-zA-Z0-9]{10}|av\d+/i.test(e)?`bilibili`:/xiaohongshu\.com|xhslink\.com/i.test(e)?`xiaohongshu`:/\.(mp4|m3u8|webm|ogg|flv|mkv|mov|avi|wmv|ts|m4v|3gp|f4v|rmvb)(\?|$)/i.test(e)||/\/.*\.(mp4|m3u8|mov|webm|flv|mkv)/i.test(e)?`direct`:`unknown`:`unknown`}function r(e){let t=e.match(/BV[a-zA-Z0-9]{10}/);if(t)return t[0];let n=e.match(/av(\d+)/i);return n?n[0]:e.trim()}var i=({open:i,onClose:a,onInsert:o})=>{let[s,c]=(0,e.useState)(``),[l,u]=(0,e.useState)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=`video-preview-player`,m=n(s.trim()),h=m!==`unknown`,g=m===`bilibili`||m===`xiaohongshu`;(0,e.useEffect)(()=>{if(m!==`direct`||!i)return;let e=!1,t=setTimeout(async()=>{if(!e&&!(!document.getElementById(p)||d.current))try{let{default:t}=await import(`xgplayer`);if(e||!document.getElementById(p))return;d.current=new t({id:p,url:s.trim(),width:`100%`,fluid:!0,fitVideoSize:`fixWidth`,autoplay:!1,controls:!0,ignores:[`fullscreen`],lang:`zh-cn`})}catch{}},200);return()=>{e=!0,clearTimeout(t),d.current&&=(d.current.destroy(),null)}},[m,s,i]);let _=(0,e.useCallback)(()=>{if(!h){u(`请输入有效的视频链接`);return}o(s.trim()),c(``),u(null),d.current&&=(d.current.destroy(),null),a()},[s,h,o,a]),v=(0,e.useCallback)(()=>{c(``),u(null),d.current&&=(d.current.destroy(),null),a()},[a]);return(0,e.useEffect)(()=>{if(!i)return;let e=f.current;if(!e)return;let t=e=>{let t=e.clipboardData?.getData(`text`)?.trim();t&&n(t)!==`unknown`&&(e.preventDefault(),c(t))};return e.addEventListener(`paste`,t),()=>e.removeEventListener(`paste`,t)},[i]),(0,e.useEffect)(()=>{if(!i||m!==`direct`)return;let e=e=>{if(e.key!==` `)return;let t=e.target;if(t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`))return;let n=d.current;n&&(e.preventDefault(),n.paused?n.play():n.pause())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,m]),i?(0,t.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center`,children:[(0,t.jsx)(`div`,{className:`absolute inset-0 bg-black/40 backdrop-blur-sm`,onClick:v}),(0,t.jsxs)(`div`,{ref:f,className:`relative w-[calc(100vw-32px)] max-w-[520px] max-h-[90vh] bg-background rounded-2xl shadow-2xl border border-default-200 overflow-hidden animate-in`,children:[(0,t.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-default-100`,children:[(0,t.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,t.jsx)(`svg`,{className:`w-5 h-5 text-primary`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:`2`,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z`})}),(0,t.jsx)(`h2`,{className:`text-base font-semibold`,children:`导入视频`})]}),(0,t.jsx)(`button`,{type:`button`,className:`w-7 h-7 flex items-center justify-center rounded-lg text-default-400 hover:text-default-600 hover:bg-default-100 transition-colors`,onClick:v,children:`✕`})]}),(0,t.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,t.jsxs)(`div`,{children:[(0,t.jsx)(`label`,{className:`block text-xs font-medium text-default-600 mb-1.5`,children:`粘贴视频链接`}),(0,t.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2.5 rounded-xl border border-default-200 bg-background text-sm focus:outline-none focus:border-primary transition-colors`,placeholder:`粘贴视频直链、B站链接 或 小红书链接...`,value:s,onChange:e=>{c(e.target.value),u(null)},onKeyDown:e=>{e.key===`Enter`&&_()}}),(0,t.jsx)(`p`,{className:`mt-1.5 text-[11px] text-default-400`,children:`支持直链 (mp4/m3u8/webm…) · B站链接 · 小红书链接 — 粘贴后自动识别`})]}),s.trim()&&(0,t.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,t.jsx)(`span`,{className:`text-xs text-default-400`,children:`识别为:`}),(0,t.jsx)(`span`,{className:`px-2 py-0.5 text-xs rounded-full font-medium ${m===`bilibili`?`bg-[#fb7299]/10 text-[#fb7299]`:m===`direct`?`bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400`:m===`xiaohongshu`?`bg-[#ff2442]/10 text-[#ff2442]`:`bg-default-100 text-default-500`}`,children:m===`bilibili`?`B站视频`:m===`xiaohongshu`?`小红书`:m===`direct`?`直链视频`:`未知类型`})]}),g&&s.trim()&&(0,t.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 text-xs`,children:[(0,t.jsx)(`svg`,{className:`w-4 h-4 shrink-0 mt-px text-amber-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:`2`,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z`})}),(0,t.jsxs)(`div`,{children:[(0,t.jsxs)(`p`,{className:`font-medium text-amber-700 dark:text-amber-400`,children:[`版权提示:`,m===`bilibili`?`B站`:`小红书`,`视频将以官方播放器嵌入,版权归原作者所有。`]}),(0,t.jsx)(`p`,{className:`mt-0.5 text-amber-600 dark:text-amber-500`,children:`请确保您有权限分享该内容。支持通过官方分享链接导入。`})]})]}),m===`direct`&&h?(0,t.jsx)(`div`,{id:p,style:{width:`100%`,aspectRatio:`16/9`,borderRadius:12,overflow:`hidden`,background:`#000`}}):m===`bilibili`&&h?(0,t.jsx)(`div`,{className:`relative rounded-xl overflow-hidden bg-black aspect-video`,children:(0,t.jsx)(`iframe`,{src:`https://player.bilibili.com/player.html?bvid=${r(s.trim())}&page=1&high_quality=1&autoplay=0`,className:`w-full h-full`,allowFullScreen:!0,style:{border:`none`},sandbox:`allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox`,referrerPolicy:`no-referrer-when-downgrade`})}):m===`xiaohongshu`&&h?(0,t.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-6 rounded-xl border border-dashed border-default-200 bg-default-50 dark:bg-default-100/10`,children:[(0,t.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-[#ff2442]/10 flex items-center justify-center text-lg`,children:`📌`}),(0,t.jsxs)(`div`,{children:[(0,t.jsx)(`p`,{className:`text-sm font-medium`,children:`小红书笔记`}),(0,t.jsx)(`p`,{className:`text-xs text-default-400`,children:`导入后将显示为卡片样式,点击跳转至小红书查看`})]})]}):s.trim()&&!h?(0,t.jsx)(`div`,{className:`flex items-center justify-center py-10 rounded-xl border border-dashed border-default-200 text-sm text-default-400`,children:`无法识别该链接类型,请检查后重试`}):(0,t.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-10 rounded-xl border-2 border-dashed border-default-200 bg-default-50 dark:bg-default-100/10 text-default-400`,children:[(0,t.jsx)(`svg`,{className:`w-10 h-10`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:1,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z`})}),(0,t.jsxs)(`div`,{className:`text-center`,children:[(0,t.jsx)(`p`,{className:`text-sm`,children:`粘贴链接后自动识别并预览`}),(0,t.jsx)(`p`,{className:`text-xs mt-1`,children:`支持直链 mp4/m3u8 · B站 · 小红书`})]})]}),l&&(0,t.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2.5 rounded-lg bg-danger-50 dark:bg-danger-900/20 text-sm text-danger`,children:[(0,t.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,t.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z`})}),l]}),(0,t.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,t.jsx)(`button`,{type:`button`,className:`flex-1 py-2.5 rounded-xl bg-primary text-white text-sm font-medium hover:opacity-90 disabled:opacity-40 transition-opacity`,disabled:!h,onClick:_,children:`导入视频`}),(0,t.jsx)(`button`,{type:`button`,className:`px-4 py-2.5 rounded-xl border border-default-200 text-sm hover:bg-default-50 dark:hover:bg-default-100/10 transition-colors`,onClick:v,children:`取消`})]})]}),(0,t.jsx)(`div`,{className:`px-5 py-2.5 border-t border-default-100 text-[11px] text-default-300 text-center`,children:`直链使用 xgplayer 播放 · B站/小红书使用官方播放器`})]})]}):null};exports.VideoEmbedDialog=i;
|