@qingwu-ui/ai-editor 0.9.0-beta.3 → 0.9.0-beta.5

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.
@@ -13,13 +13,17 @@ function a() {
13
13
  return n;
14
14
  }
15
15
  function o() {
16
+ let e = n;
17
+ return !e || typeof e.owns != "function" ? () => !1 : (t) => e.owns(t);
18
+ }
19
+ function s() {
16
20
  return n ? {
17
21
  name: n.name,
18
22
  type: n.type,
19
23
  config: r
20
24
  } : null;
21
25
  }
22
- function s() {
26
+ function c() {
23
27
  try {
24
28
  let n = sessionStorage.getItem(t);
25
29
  if (n) return JSON.parse(n);
@@ -34,4 +38,4 @@ function s() {
34
38
  return null;
35
39
  }
36
40
  //#endregion
37
- export { i, a as n, s as r, o as t };
41
+ export { i as a, o as i, a as n, c as r, s as t };
@@ -0,0 +1,2 @@
1
+ var e=`qingwu_storage_config`,t=`qingwu_storage_config_session`,n=null,r=null;function i(e,i){if(n=e,i){r=i;try{sessionStorage.setItem(t,JSON.stringify(i))}catch{}}}function a(){if(!n)throw Error(`未配置存储服务。请调用 setStorageProvider() 设置。
2
+ 支持: 本地存储 / 阿里云 OSS / 腾讯云 COS`);return n}function o(){let e=n;return!e||typeof e.owns!=`function`?()=>!1:t=>e.owns(t)}function s(){return n?{name:n.name,type:n.type,config:r}:null}function c(){try{let n=sessionStorage.getItem(t);if(n)return JSON.parse(n);let r=localStorage.getItem(e);if(r){try{sessionStorage.setItem(t,r)}catch{}return localStorage.removeItem(e),JSON.parse(r)}}catch{}return null}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
@@ -1 +1 @@
1
- const e=require("./signed-fetch-D8Rk6R5t.cjs"),t=require("./storage-raz9BRoZ.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.i(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.i(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-D8Rk6R5t.cjs")).then(e=>e.i),{registerS3PreviewConfig:n}=await Promise.resolve().then(()=>require("./signed-fetch-D8Rk6R5t.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
+ const e=require("./signed-fetch-D8Rk6R5t.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-D8Rk6R5t.cjs")).then(e=>e.i),{registerS3PreviewConfig:n}=await Promise.resolve().then(()=>require("./signed-fetch-D8Rk6R5t.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,5 +1,5 @@
1
1
  import { t as e } from "./signed-fetch-CPPWCUUS.js";
2
- import { i as t, r as n, t as r } from "./storage-B6LsdlnG.js";
2
+ import { a as t, r as n, t as r } from "./storage-DUcmM2Ex.js";
3
3
  import { n as i, t as a } from "./local-B20eAPCo.js";
4
4
  import { useCallback as o, useEffect as s, useState as c } from "react";
5
5
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qingwu-ui/ai-editor",
3
- "version": "0.9.0-beta.3",
3
+ "version": "0.9.0-beta.5",
4
4
  "description": "青梧 - 一款面向中文用户的 AI 智能编辑器",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1,2 +0,0 @@
1
- var e=`qingwu_storage_config`,t=`qingwu_storage_config_session`,n=null,r=null;function i(e,i){if(n=e,i){r=i;try{sessionStorage.setItem(t,JSON.stringify(i))}catch{}}}function a(){if(!n)throw Error(`未配置存储服务。请调用 setStorageProvider() 设置。
2
- 支持: 本地存储 / 阿里云 OSS / 腾讯云 COS`);return n}function o(){return n?{name:n.name,type:n.type,config:r}:null}function s(){try{let n=sessionStorage.getItem(t);if(n)return JSON.parse(n);let r=localStorage.getItem(e);if(r){try{sessionStorage.setItem(t,r)}catch{}return localStorage.removeItem(e),JSON.parse(r)}}catch{}return null}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});