filecat 7.31.1 → 7.32.1

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.
Files changed (42) hide show
  1. package/README.md +21 -18
  2. package/build/dist/1448.ec0a69fe6ffca6c8df19.js +1 -0
  3. package/build/dist/1852.16cec79aa004d7d496ee.js +1 -0
  4. package/build/dist/1922.87a099397741d80df6ad.js +2 -0
  5. package/build/dist/2136.20ea58a65c7fb22d5e43.js +1 -0
  6. package/build/dist/2515.df3393e66df975984e10.js +1 -0
  7. package/build/dist/26.63fd77a3075a6e071bc8.js +1 -0
  8. package/build/dist/3187.03c9284e30214b476487.js +1 -0
  9. package/build/dist/3322.36f73d119334675d9bc4.js +1 -0
  10. package/build/dist/{3355.fde87101c5a125b8b35f.js → 3355.80b3ed1fdc66b35bd95a.js} +1 -1
  11. package/build/dist/4350.7412b41befe12857677f.js +1 -0
  12. package/build/dist/{4598.0a8c8a04d718951d6692.js → 4598.4d016ea700f650cd1023.js} +1 -1
  13. package/build/dist/{47.1990e4d7ad6e60650aa0.js → 47.8c46e919a7977a77bc14.js} +1 -1
  14. package/build/dist/{4935.d07d9ef7e03632dcb51c.js → 4935.72f92a4a0e80fd72c68d.js} +1 -1
  15. package/build/dist/{6097.9ec647296d88d8025198.js → 6097.da228e297f45f3ec882d.js} +1 -1
  16. package/build/dist/610.9b08d7248340d26dead2.js +1 -0
  17. package/build/dist/6439.b1b588626009af7ba7cb.js +1 -0
  18. package/build/dist/{7678.7ad7da19e968caed935a.js → 7678.926d8c2225731a655537.js} +1 -1
  19. package/build/dist/7759.14e1e0dbbcfc86f3e4f1.js +1 -0
  20. package/build/dist/914.bb6f2b6d8ca806f9366a.js +1 -0
  21. package/build/dist/{9260.da294480ffc3c674bde0.js → 9260.7fbe354ea4e6bee93817.js} +1 -1
  22. package/build/dist/9290.6fd29c7dd03124235217.js +1 -0
  23. package/build/dist/9345.9342b70ddc66397cafce.js +1 -0
  24. package/build/dist/9546.fde8cbe4ebe2dafb6c27.js +1 -0
  25. package/build/dist/{9765.7f8eaa343038f1f21810.js → 9765.7f02ad22213339511811.js} +1 -1
  26. package/build/dist/9861.f266cc5eabb83fc5fa4b.js +1 -0
  27. package/build/dist/index.html +1 -1
  28. package/build/dist/main.6e543784024f3ed07f70.js +2 -0
  29. package/build/main.js +1 -1
  30. package/package.json +6 -1
  31. package/build/dist/1448.2340fca4e068db687c5c.js +0 -1
  32. package/build/dist/1922.c114fe6ee22d708a2a57.js +0 -2
  33. package/build/dist/2136.60e61c9c37b92af2c0d5.js +0 -1
  34. package/build/dist/4350.c743128b55202fecc4d7.js +0 -1
  35. package/build/dist/621.965609c72555c936154d.js +0 -1
  36. package/build/dist/6439.3747e3eab0dfe59ae24b.js +0 -1
  37. package/build/dist/7759.0860534bbc24ba31f42c.js +0 -1
  38. package/build/dist/9345.1dbe1ec2d934dc5ca747.js +0 -1
  39. package/build/dist/9546.827d973d735209b0b43e.js +0 -1
  40. package/build/dist/main.4d786381d17f4a7df3dd.js +0 -2
  41. /package/build/dist/{1922.c114fe6ee22d708a2a57.js.LICENSE.txt → 1922.87a099397741d80df6ad.js.LICENSE.txt} +0 -0
  42. /package/build/dist/{main.4d786381d17f4a7df3dd.js.LICENSE.txt → main.6e543784024f3ed07f70.js.LICENSE.txt} +0 -0
package/README.md CHANGED
@@ -49,24 +49,27 @@ FileCat是采用[filebrowser](https://github.com/filebrowser/filebrowser)的ui
49
49
 
50
50
  ## 功能特性
51
51
 
52
- | 类别 | 功能 |
53
- |------|---------------------------------------------------------------|
54
- | 文件管理 | 浏览、上传、下载、编辑、在线预览(图片、视频、Markdown、绘图等) |
55
- | 网盘与协议挂载 | 将百度网盘、SSH(SFTP)、S3、WebDAV 、SMB 挂载为本地目录,与本地文件使用同一套操作 |
56
- | 文件服务 | 反向把本地目录以 SMB、WebDAV、SFTP 协议对外提供,可被 Windows 资源管理器、各类客户端直接访问 |
57
- | Markdown 所见即所得 | 类 Typora 的 Markdown 编辑体验,所见即所得 |
58
- | AI Agent | 集成大语言模型,智能辅助运维和文件处理(需自行配置 API),支持接入 QQ, 企业微信 ,飞书 ,钉钉 第三方平台机器人 |
59
- | 内网穿透 | 将内网暴露到公网,或者多个内网之间互相通信 ,基于此功能可以实现各个客户端无缝的文件操作体验,像CI/CD这样的需求,就可以在多个机器上部署一个成为客户端,进跨机器的CI/CD自动化构建 |
60
- | SSH 终端 | 浏览器内置 Web 终端,随时连接服务器 |
61
- | Windows 远程桌面 | 浏览器中直接操作远程 Windows 桌面(RDP) |
62
- | 系统信息看板 | 实时 CPU、内存、磁盘、网络等系统监控 |
63
- | CI/CD 工作流 | 支持自定义命令流水线,实现持续集成与部署 |
64
- | 超大日志查看 | 任意大小的文本日志文件秒开,高效定位问题 |
65
- | 深度搜索 | 递归搜索文件名或文件内容,支持正则、忽略大小写与排除过滤;点击搜索框左侧放大镜图标打开 |
66
- | Excalidraw 绘图 | 内置白板绘图工具 |
67
- | 多用户管理 | 完善的权限体系 |
68
- | 可分享链接 | 生成文件分享链接,方便他人下载 |
69
- | 多路径挂载 | 支持挂载多个文件系统路径 |
52
+ | 类别 | 功能 |
53
+ |------|------|
54
+ | 文件管理 | 浏览、上传、下载、重命名、移动、复制、压缩解压,支持拖拽上传与分页滚动加载 |
55
+ | 文件预览 | 图片、视频、音频、PDF、Office 文档、Markdown、代码、日志等格式在线预览 |
56
+ | Office 编辑器 | 在线编辑 Word(docx)、Excel(xlsx)、PowerPoint(pptx),无需本地安装 Office |
57
+ | Markdown 所见即所得 | 类 Typora 的实时预览编辑,内置 7 套主题,支持 Mermaid / SVG 绘图与 KaTeX 公式 |
58
+ | 代码编辑器 | 内置 Ace 编辑器,支持语法高亮、多语言识别与 Studio 分栏代码模式 |
59
+ | 超大日志查看 | 任意大小的日志文件秒开,支持虚拟滚动、实时追踪与关键字高亮 |
60
+ | 深度搜索 | 递归搜索文件名或文件内容,支持正则、忽略大小写与排除过滤,点击搜索框左侧放大镜打开 |
61
+ | 网盘与协议挂载 | 将 百度网盘 / SSH(SFTP) / S3 / WebDAV / SMB 挂载为本地目录,与本地文件使用同一套操作 |
62
+ | 文件服务 | 反向把本地目录通过 SMB / WebDAV / SFTP 对外提供,可被 Windows 资源管理器等标准客户端直接访问 |
63
+ | 内网穿透 | 将内网服务暴露到公网,或多个内网之间互相通信;多机部署后可实现跨机器的文件同步与 CI/CD 自动化 |
64
+ | SSH 终端 | 浏览器内置 Web 终端,随时连接服务器,支持挂载的 SSH 主机直连 |
65
+ | Windows 远程桌面 | 浏览器中直接操作远程 Windows 桌面(RDP) |
66
+ | CI/CD 工作流 | 支持自定义命令流水线(.workflow.yml / .act),实现持续集成与部署 |
67
+ | 系统管理 | 系统信息看板(CPU / 内存 / 磁盘 / 网络)、进程管理、systemd 服务、防火墙(ufw / nftables)、Docker 配置 |
68
+ | Git 管理 | 内置 Git 客户端,支持变更暂存提交、提交历史树形图、分支与远程分支管理、Diff 对比、Blame、Stash、Tag |
69
+ | AI Agent | 集成大语言模型智能辅助运维与文件处理(需自行配置 API),支持接入 QQ / 企业微信 / 飞书 / 钉钉 机器人 |
70
+ | Excalidraw 绘图 | 内置白板绘图工具,可直接编辑 .draw 文件 |
71
+ | 多用户管理 | 完善的权限体系,支持角色、用户级权限配置与目录访问限制 |
72
+ | 可分享链接 | 生成文件或目录的分享链接,可设置密码与有效期 |
70
73
 
71
74
  ---
72
75
 
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1448],{74777(e,t,i){i.d(t,{Gd:()=>n,Hb:()=>s,Mu:()=>r,aM:()=>l,jk:()=>a});let l=function(e){return e[e.close=0]="close",e[e.length=1]="length",e[e.forver=2]="forver",e}({}),s=function(e){return e[e.independent=0]="independent",e[e.reuse=1]="reuse",e[e.single=2]="single",e}({});class n{mode;length;persist;session_mode}let a=function(e){return e.ffmpeg="ffmpeg",e.smartmontools="smartctl",e.ufw="ufw",e}({});let r=function(e){return e[e.auth=0]="auth",e[e.cmd=1]="cmd",e[e.cyc=2]="cyc",e[e.sys_env=3]="sys_env",e[e.private_sys_env=4]="private_sys_env",e[e.auto_upgrade=6]="auto_upgrade",e}({})},11448(e,t,i){i.r(t),i.d(t,{PLATFORM_META:()=>b,RebotCard:()=>v,RebotCardContainer:()=>f,default:()=>y});var l=i(22022),s=i(96540),n=i(85997),a=i(4412),r=i(75725),c=i(61443),d=i(7572),o=i(14284),p=i(53459),h=i(62042),m=i(78247),x=i(23430),u=i(52671),j=i(92350),_=i(74848);const b={qq:{key:"qq",label:"QQ 机器人",icon:"QQ",color:"#12B7F5",fields:[{key:"appId",label:"AppId",type:"text",placeholder:"请输入机器人 AppId",required:!0},{key:"clientSecret",label:"密钥",type:"password",placeholder:"请输入机器人密钥",required:!0}]},dingtalk:{key:"dingtalk",label:"钉钉机器人",icon:"钉钉",color:"#0089FF",fields:[{key:"appId",label:"ClientId (AppKey)",type:"text",placeholder:"请输入应用 ClientId",required:!0},{key:"clientSecret",label:"ClientSecret (AppSecret)",type:"password",placeholder:"请输入应用 ClientSecret",required:!0}]},wecom:{key:"wecom",label:"企业微信机器人",icon:"企业微信",color:"#07C160",fields:[{key:"appId",label:"botId",type:"text",placeholder:"请输入机器人 botId",required:!0},{key:"clientSecret",label:"Secret",type:"password",placeholder:"请输入机器人 Secret",required:!0}]},lark:{key:"lark",label:"飞书机器人",icon:"飞书",color:"#3370FF",fields:[{key:"appId",label:"App ID",type:"text",placeholder:"请输入应用 App ID",required:!0},{key:"clientSecret",label:"App Secret",type:"password",placeholder:"请输入应用 App Secret",required:!0}]}},g=Object.entries(b).map(([e,t])=>({value:e,title:t.label,color:t.color}));function f(e){const{t}=(0,l.Bd)(),[i,a]=(0,s.useState)(!1),[r,d]=(0,s.useState)(!1),o=(t,i)=>{const l=[...e.items];l[t]={...l[t],...i},e.setItems(l)},p=t=>{const i=[...e.items];i.splice(t,1),e.setItems(i)},h=t=>{e.setItems([...e.items,{...e.items[t],open:!1,name:(e.items[t].name||"")+" (副本)"}])};return(0,_.jsxs)(s.Fragment,{children:[(0,_.jsx)("div",{className:"airebot-setting__toolbar",children:!1!==e.have_auth_edit&&(0,_.jsxs)(_.Fragment,{children:[i?(0,_.jsxs)("div",{className:"airebot-setting__add-select",children:[(0,_.jsx)(c.l6,{options:g,defaultValue:"qq",onChange:t=>{return i=t,e.setItems([...e.items,{platform:i,name:"",open:!1,appId:"",clientSecret:"",note:""}]),void a(!1);var i},width:"180px"}),(0,_.jsx)(n.rA,{icon:"cancel",title:t("取消"),onClick:()=>a(!1)})]}):(0,_.jsx)(n.rA,{icon:"add",title:t("添加机器人"),onClick:()=>a(!0)}),(0,_.jsx)(n.rA,{icon:"save",title:t(r?"保存中...":"保存"),onClick:()=>{r||(async()=>{d(!0),await e.save(),d(!1)})()}})]})}),0===e.items.length?(0,_.jsxs)("div",{className:"airebot-setting__empty",children:[(0,_.jsx)("span",{className:"material-symbols-outlined airebot-setting__empty-icon",children:"smart_toy"}),(0,_.jsx)("p",{children:t("还没有配置任何机器人")}),(0,_.jsx)("p",{className:"airebot-setting__empty-hint",children:t("点击上方「添加机器人」按钮来开始配置")})]}):(0,_.jsx)("div",{className:"airebot-setting__grid",children:e.items.map((e,t)=>(0,_.jsx)(v,{item:e,index:t,onChange:o,onDelete:p,onCopy:h},t))})]})}const v=({item:e,index:t,onChange:i,onDelete:s,onCopy:a})=>{const{t:r}=(0,l.Bd)(),o=b[e.platform]??b.qq,p=e._status||"disconnected";e.open;return(0,_.jsx)(d.Zp,{self_title:(0,_.jsx)("div",{className:"airebot-setting__card-header",children:(0,_.jsx)("span",{className:"material-symbols-outlined airebot-setting__card-icon",style:{color:o.color},children:o.icon})}),rightTopCom:(0,_.jsxs)("div",{className:"airebot-setting__card-actions",children:[(0,_.jsx)(n.Ay,{checked:!!e.open,onChange:e=>i(t,{open:e})}),(0,_.jsx)(n.rA,{icon:"content_copy",title:r("复制"),onClick:()=>a(t)}),(0,_.jsx)(n.rA,{icon:"delete",title:r("删除"),onClick:()=>s(t)})]}),children:(0,_.jsxs)("div",{className:"airebot-setting__card-fields",children:[(0,_.jsxs)("div",{className:"airebot-setting__field",children:[(0,_.jsx)("label",{className:"airebot-setting__field-label",children:r("平台")}),(0,_.jsx)(c.l6,{options:g,value:e.platform,onChange:e=>i(t,{platform:e}),width:"100%"})]}),(0,_.jsxs)("div",{className:"airebot-setting__field",children:[(0,_.jsx)("label",{className:"airebot-setting__field-label",children:r("名称")}),(0,_.jsx)(c.Sm,{value:e.name||"",handleInputChange:e=>i(t,{name:e}),placeholder:r("给机器人起个名字")})]}),o.fields.map(l=>{const s=e[l.key]??"";return(0,_.jsxs)("div",{className:"airebot-setting__field",children:[(0,_.jsxs)("label",{className:"airebot-setting__field-label",children:[l.label,l.required&&(0,_.jsx)("span",{className:"airebot-setting__field-required",children:"*"})]}),(0,_.jsx)(c.Sm,{type:l.type,value:s,handleInputChange:e=>i(t,{[l.key]:e}),placeholder:l.placeholder})]},l.key)}),(0,_.jsxs)("div",{className:"airebot-setting__field ",children:[(0,_.jsx)("label",{className:"airebot-setting__field-label",children:r("模型编号")}),(0,_.jsx)(c.Sm,{value:e.model_index,handleInputChange:e=>i(t,{model_index:e}),placeholder:r("使用指定模型(可选)")})]}),(0,_.jsxs)("div",{className:"airebot-setting__field ",children:[(0,_.jsx)("label",{className:"airebot-setting__field-label",children:r("用户id")}),(0,_.jsx)(c.Sm,{value:e.user_id||"",handleInputChange:e=>i(t,{user_id:e}),placeholder:r("默认使用root账户(继承权限,可选)")})]}),(0,_.jsxs)("div",{className:"airebot-setting__field airebot-setting__field-full",children:[(0,_.jsx)("label",{className:"airebot-setting__field-label",children:r("备注")}),(0,_.jsx)(c.Sm,{value:e.note||"",handleInputChange:e=>i(t,{note:e}),placeholder:r("备注信息(可选)")})]})]})})};function y(){const{t:e}=(0,l.Bd)(),t=(0,u.Zp)(),{check_user_auth:i}=(0,m.MH)(),[c,d]=(0,s.useState)([]),b=(0,j.Q)(),g=async()=>{const e=await o.XO.get("ai_rebot_setting");e.code===p.m.Success&&d(e.data?.list??[])};(0,s.useEffect)(()=>{g()},[]);return(0,_.jsxs)("div",{className:"airebot-setting",children:[(0,_.jsx)(a.aZ,{position:"right",children:i(x.oV.ai_agent_setting)&&(0,_.jsx)(n.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>t(-1)})}),(0,_.jsx)(r.fI,{children:(0,_.jsxs)(r.VP,{widthPer:100,children:[(0,_.jsxs)("div",{className:"airebot-setting__page-title",children:[(0,_.jsx)("h2",{children:e("机器人配置")}),(0,_.jsx)(n.rA,{icon:"info",onClick:()=>{b("机器人配置")},title:"信息"})]}),(0,_.jsx)(f,{items:c,setItems:d,save:async()=>{const t={list:c.map((e,t)=>({...e,index:t}))};(await o.XO.post("ai_rebot_setting/save",t)).code===p.m.Success&&((0,h.SK)(e("保存成功")),await g())},have_auth_edit:i(x.oV.ai_agent_setting)})]})})]})}},92350(e,t,i){i.d(t,{Q:()=>p,o:()=>m});var l=i(34843),s=i(82893),n=i(74777),a=i(96540),r=i(22022),c=i(23430),d=i(14284),o=i(74848);function p(){const[e,t]=(0,l.fp)(s.AG.prompt_card),{t:i,i18n:a}=(0,r.Bd)();return e=>{let l;e===n.jk.ffmpeg?l=(0,o.jsx)("div",{children:"视频转换,rtsp播放器等媒体功能都需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置"}):e===n.jk.smartmontools?l=(0,o.jsx)("div",{children:"磁盘检查需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置。"}):"保护目录"===e?l=(0,o.jsxs)("div",{children:["在删除的时候保护目录会拒绝删除。",(0,o.jsxs)("ul",{children:[(0,o.jsx)("li",{children:"可以使用 /* 来表达该目录下所有文件都禁止删除"}),(0,o.jsx)("li",{children:"可以使用 /** 来表达该目录下所有子目录文件都禁止删除"})]})]}):"文件夹路径"===e?l=(0,o.jsx)("div",{children:"用于在文件夹下切换根目录"}):"环境路径"===e?l=(0,o.jsx)("div",{children:"当在不同用户环境下运行的时候由于没有执行终端去加载PATH,这里可以添加额外的PATH路径,点击这里的保存还会更新系统上的path路径"}):"pty"===e?l=(0,o.jsx)("div",{children:"一些需要Pty环境的命令"}):"文件上传"===e?l=(0,o.jsx)("div",{children:(0,o.jsxs)("ul",{children:[(0,o.jsx)("li",{children:"对于不同的目录(包括所有子目录),可能是机械或者固态硬盘,机械硬盘在处理多个小文件的时候会做随机i/o,由于一般只有一个盘头所以会影响整体效率,特别是写操作,这里提供了上传时候的最大数量限制,对于下载数量目前不做限制."}),(0,o.jsx)("li",{children:"大文件支持断点和分块并发传输,建议并发数量设置为2,分块大小设置为10MB,大文件判断为500MB,设置过大的话会上传的时候会占据较大内存"})]})}):"目录快捷命令"===e?l=(0,o.jsx)("div",{children:"右键文件夹空白处用于,打开终端快捷执行命令"}):"文件快捷命令"===e?l=(0,o.jsx)("div",{children:"用于右键特定后缀的文件,执行一些快捷命令,文件后缀可以是多个,用空格分割"}):"Workflow"===e?l=(0,o.jsx)("div",{children:(0,o.jsxs)("ul",{children:[(0,o.jsx)("li",{children:"在特定的时间启动系统中的workflow任务"}),(0,o.jsx)("li",{children:"cron表达式是定时器 格式为: 秒 分 时 日 月 星期"}),(0,o.jsxs)("li",{children:[(0,o.jsx)("li",{children:'1. "*"(通配符,所有值)'}),(0,o.jsx)("li",{children:'2. "," 是枚举: 0 0 1,15 * * *'}),(0,o.jsx)("li",{children:'3. "-" 是范围: 0 0 1-5 * * *'}),(0,o.jsx)("li",{children:'4. "/" 是步长,标识每隔n执行 */3 * * * * * 每隔三秒,必须配合 * 使用 ,/ 只能写一次 ,有了/就成了定时器,而不是指定时间执行'})]})]})}):"插件配置"===e?l=(0,o.jsx)("div",{children:i("路径可以是一个 js 文件也可以是一个node 项目目录")}):"机器人配置"===e&&(l=(0,o.jsxs)("div",{children:[(0,o.jsx)("dv",{children:"机器人功能用于开通各种第三方支持的机器人,让第三方机器人接入本地的 AI 模型。"}),(0,o.jsxs)("ul",{children:[(0,o.jsx)("li",{children:" 1. qq 机器人需要先在手机 app 中添加,然后在https://q.qq.com/qqbot/ 登录机器人配置页面,在开发管理中复制机器人的 appId,appSecret 到这里就完成了配置了。目前 qq 机器人不稳定,且创建后无法删除(2026.07.05)"}),(0,o.jsx)("li",{children:" 2. https://opensource.dingtalk.com/developerpedia/docs/explore/tutorials/stream/bot/nodejs/create-bot 这个是钉钉机器人开通教程,注意复制钉钉的 clientId 的是时候不要复制成appId 了。"}),(0,o.jsx)("li",{children:" 3. 企业微信机器人的开通甚至不需要 pc 操作,在通讯录中点击智能机器人,选择 api 模式,就创建完成了,手机上直接复制 id 和密钥。"}),(0,o.jsx)("li",{children:" 4. 飞书https://open.feishu.cn/document/develop-an-echo-bot/introduction?from=banner 登录这个开发者后台,按照这个地址教程创建机器人,使用的时候这个机器人是作为一个应用,可以在工作台内搜索你的这个机器人的名字。"})]})]})),t({open:!0,title:"信息",context_div:(0,o.jsx)("div",{children:l})})}}let h=c.Ky;function m(){const[e,t]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{try{const e=await d.XO.get("themes");if(0===e.code){const i=e.data||[];h=[...c.Ky,...i],t(h)}else console.warn("获取主题列表失败,使用默认列表"),t(h)}catch(e){t(h)}})()},[]),e}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[26,1852],{21852(e,t,n){n.r(t),n.d(t,{default:()=>h});var o=n(96540),r=n(34843),c=n(82893),i=n(42562),s=n(26),a=n(99018),l=n(93245),d=n(23430),u=n(22022),f=n(74848);function h(){const{t:e}=(0,u.Bd)(),[t,n]=(0,r.fp)(c.AG.docx_editor),[h,p]=(0,o.useState)(!1),[m,g]=(0,o.useState)(!1),v=(0,o.useRef)(),b=async(t=!1)=>{if(!v.current)return!1;g(!0);try{return await v.current(t?"":e("保存成功"))}finally{g(!1)}},y=(0,o.useRef)(h);return y.current=h,(0,l.a)(d.nE.docx,()=>y.current,()=>b(!0)),(0,f.jsx)(i.A,{name:t.name,dirty:h,loading:!1,error:"",saving:m,on_save:b,on_close:()=>{const e=t.close;n({}),e?.()},children:t.url&&(0,f.jsx)(s.default,{url:t.url,save_path:(0,a.Vi)(t.name??""),on_dirty:p,bind_save:e=>v.current=e})})}},26(e,t,n){n.r(t),n.d(t,{default:()=>f});var o=n(96540),r=n(39290),c=n(33036);const i=15;function s(e){const t=e.getBoundingClientRect().top,n=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=null;for(;o.nextNode();){const e=o.currentNode,c=e.textContent??"";if(!c.trim())continue;const i=document.createRange();for(let o=0;o<c.length;o++){i.setStart(e,o),i.setEnd(e,o+1);const c=i.getBoundingClientRect();0!==c.height&&((null===r||Math.abs(c.top-r)>1)&&(null!==r&&n.push(c.top-t),r=c.top))}}return null!==r&&n.push(e.offsetHeight),0===n.length&&n.push(e.offsetHeight),n}var a=n(74848);function l(e){const t=(0,r.OE)(e);if(!t)throw new Error(`docx 命令不存在: ${e}`);return t}function d(e){const{model:t,on_change:n,bind_save:d}=e,u=(0,o.useRef)(null),f=(0,o.useRef)([]),h=(0,o.useRef)(),p=(0,o.useRef)(new Map),m=(0,o.useRef)(""),g=(0,o.useCallback)(()=>{const e=u.current,n=t.selection?.focus;if(!e||!n)return;const o=e.querySelector(`[data-wk-block="${n.block}"]`);if(!o)return;let r=o;if(void 0!==n.inline){const e=o.querySelector(`[data-wk-inline="${n.inline}"]`);e&&(r=e)}const c=r.firstChild;if(!c)return;const i=document.createRange(),s=Math.min(n.offset??0,c.textContent?.length??0);i.setStart(c,s),i.collapse(!0);const a=window.getSelection();a?.removeAllRanges(),a?.addRange(i)},[t]),v=(0,o.useCallback)((e=!1)=>{const n=u.current;if(!n)return;let o=-1;const c=window.getSelection();if(c&&c.anchorNode&&n.contains(c.anchorNode)){const e=1===c.anchorNode.nodeType?c.anchorNode:c.anchorNode.parentElement,t=e?.closest("[data-wk-block]");t&&(o=Number(t.getAttribute("data-wk-block")))}const s=document.createElement("div");s.innerHTML=(0,r.j7)(t.document);const a=Array.from(s.children).map(e=>e.outerHTML),l=f.current;if(e||l.length!==a.length)n.innerHTML=s.innerHTML,p.current.clear(),Array.from(n.children).forEach(e=>{const t=e,n=Number(t.getAttribute("data-wk-block"));Number.isNaN(n)||p.current.set(n,t)});else for(let e=0;e<a.length;e++){if(l[e]===a[e])continue;const t=p.current.get(e);t&&(t.innerHTML=s.children[e].innerHTML)}f.current=a,h.current??=function(e){const t=(0,r.yj)(e);return{width:t.width/i,height:t.height/i,top:t.top/i,right:t.right/i,bottom:t.bottom/i,left:t.left/i,body_height:(t.height-t.top-t.bottom)/i}}(t.document);const d=h.current,{heights:m,lines:g}=b(a.length,d),v=function(e,t,n,o){const c=(0,r.Bv)(e),i=(0,r.w$)(e),s=c.map((e,o)=>{const r=t[o]??0;return{height:r,section:0,lines:()=>n[o]??[r]}}),a=i.map(()=>({start:"continuous",columns:1,titlePage:!1,vAlign:"top",bodyHeight:()=>o.body_height}));return(0,r.En)(s,a,{evenAndOddHeaders:!1,noteSeparatorHeight:0}).map(e=>{const n=[];for(const o of e.regions)for(const e of o.columns)for(const o of e.fragments)"block"===o.kind?n.push({block:o.block,from:0,to:t[o.block]??o.height}):"slice"===o.kind&&n.push({block:o.block,from:o.from,to:o.to});return{fragments:n,number:e.number}})}(t.document,m,g,d);y(n,v,d)},[t]),b=(0,o.useCallback)((e,t)=>{const n=document.createElement("div");n.className="docx-page",n.style.cssText=[`width:${t.width}px`,`padding:${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`,"position:absolute","left:-99999px","top:0","visibility:hidden","pointer-events:none"].join(";");const o=document.createElement("div");o.className="docx-page__body",n.appendChild(o),document.body.appendChild(n);const r=[];for(let t=0;t<e;t++){const e=p.current.get(t);if(!e){const e=document.createElement("div");o.appendChild(e),r.push(e);continue}o.appendChild(e),r.push(e)}const c=[],i=[],a=o.scrollHeight;for(let e=0;e<r.length;e++){const t=r[e],n=t.offsetTop,o=e+1<r.length?r[e+1].offsetTop:a;let l=Math.max(0,o-n);e===r.length-1&&(l+=parseFloat(getComputedStyle(t).marginBottom)||0),c[e]=l,i[e]=s(t)}return n.remove(),{heights:c,lines:i}},[]),y=(0,o.useCallback)((e,t,n)=>{const o=t.map(e=>e.fragments.map(e=>e.block).join(",")).join("|");m.current=o,e.innerHTML="";for(const o of t){const t=document.createElement("div");t.className="docx-page",t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.padding=`${n.top}px ${n.right}px ${n.bottom}px ${n.left}px`;const r=document.createElement("div");r.className="docx-page__body",t.appendChild(r);const c=document.createElement("div");c.className="docx-page__number",c.textContent=String(o.number),t.appendChild(c);for(const e of o.fragments){const t=p.current.get(e.block);if(!t)continue;if(0===e.from&&e.to>=t.offsetHeight-1){r.appendChild(t);continue}const n=document.createElement("div");n.className="docx-page__slice",n.style.height=e.to-e.from+"px",n.style.overflow="hidden";const o=t.cloneNode(!0);o.style.marginTop=-e.from+"px",n.appendChild(o),r.appendChild(n)}e.appendChild(t)}e.querySelectorAll(".docx-page__body").forEach(e=>{e.setAttribute("contenteditable","true"),e.setAttribute("suppresscontenteditablewarning","true")})},[]);(0,o.useEffect)(()=>{v(!0);const e=t.subscribe(()=>{const e=u.current,t=window.getSelection(),o=!!(e&&t&&t.anchorNode&&e.contains(t.anchorNode));v(!1),o&&g(),n?.(!0)});return()=>{e()}},[t,v,g,n]),(0,o.useEffect)(()=>{d?.(()=>function(e){return(0,c.FoA)(e.document)}(t))},[t,d]);const x=(0,o.useCallback)(()=>{const e=(0,r.Ff)(document);if(!e)return!1;const n=t.selection;return n&&JSON.stringify(n.anchor)===JSON.stringify(e.anchor)&&JSON.stringify(n.focus)===JSON.stringify(e.focus)||t.setSelection(e),!0},[t]),_=(0,o.useCallback)((e,n)=>{x(),(0,r.d1)(t,l(e),n)},[t,x]),k=(0,o.useCallback)(()=>{(0,r.d1)(t,l("structure.insertText"),{text:""})},[t]),N=(0,o.useCallback)(e=>{if(!x())return;const n=t.selection;if(!n)return;const{anchor:o,focus:c}=n;if(o.block!==c.block||o.inline!==c.inline||o.offset!==c.offset)return void k();const i=o.offset;if(e&&i<=0)return void(0,r.d1)(t,l("structure.mergeBack"),void 0);const s=e?i-1:i,a=e?i:i+1,d={block:o.block,para:o.para,cell:o.cell,inline:o.inline};t.setSelection({anchor:(0,r.zf)({...d,offset:s}).anchor,focus:(0,r.zf)({...d,offset:a}).anchor}),k()},[t,x,k]),w=(0,o.useCallback)(e=>{x(),(0,r.d1)(t,l("structure.insertText"),{text:e})},[t,x]);return(0,o.useEffect)(()=>{const e=u.current;if(!e)return;const n=n=>{const o=window.getSelection();if(o&&o.anchorNode&&e.contains(o.anchorNode)){if(n.ctrlKey||n.metaKey){const e=n.key.toLowerCase();return n.shiftKey||"b"!==e&&"i"!==e&&"u"!==e?"z"===e?(n.preventDefault(),void((n.shiftKey?t.canRedo():t.canUndo())&&(n.shiftKey?t.redo():t.undo()))):void 0:(n.preventDefault(),void _("b"===e?"text.bold":"i"===e?"text.italic":"text.underline"))}return"Enter"===n.key?(n.preventDefault(),void _("structure.insertParagraph")):"Backspace"===n.key?(n.preventDefault(),void N(!0)):"Delete"===n.key?(n.preventDefault(),void N(!1)):void(1!==n.key.length||n.altKey||(n.preventDefault(),w(n.key)))}},o=t=>{const n=window.getSelection();n&&n.anchorNode&&e.contains(n.anchorNode)&&t.data&&w(t.data)},r=t=>{const n=window.getSelection();if(!n||!n.anchorNode||!e.contains(n.anchorNode))return;t.preventDefault();const o=t.clipboardData?.getData("text/plain");o&&w(o)};return e.addEventListener("keydown",n),e.addEventListener("compositionend",o),e.addEventListener("paste",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("compositionend",o),e.removeEventListener("paste",r)}},[t,_,N,w]),(0,a.jsx)("div",{className:"docx-body",children:(0,a.jsx)("div",{className:"docx-pages",ref:u})})}var u=n(99018);function f(e){const{url:t,save_path:n,on_dirty:c,bind_save:i}=e,[s,l]=(0,o.useState)(),[f,h]=(0,o.useState)(""),[p,m]=(0,o.useState)(!0),[g,v]=(0,o.useState)(!1),b=(0,o.useRef)();return(0,o.useEffect)(()=>{if(!t)return;let e=!0;return m(!0),h(""),v(!1),l(void 0),(0,u.PQ)(t).then(t=>{e&&l(function(e){return(0,r.k3)(e)}(t))}).catch(t=>e&&h(String(t?.message??t))).finally(()=>e&&m(!1)),()=>{e=!1}},[t]),(0,o.useEffect)(()=>{c?.(g)},[g,c]),(0,o.useEffect)(()=>{i?.(async e=>{if(!b.current)return!1;const t=await(0,u.GB)(n,b.current(),e);return t&&v(!1),t})},[n,i]),f?(0,a.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:f}):p||!s?(0,a.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,a.jsx)(d,{model:s,on_change:v,bind_save:e=>b.current=e})}},42562(e,t,n){n.d(t,{A:()=>s});var o=n(96540),r=n(85997),c=n(45907),i=n(74848);function s(e){const{name:t,dirty:n,loading:s,error:a,saving:l,on_save:d,on_close:u,children:f,extra:h}=e,p=(0,c.y)(),m=(0,o.useRef)(u),g=(0,o.useRef)(d),v=(0,o.useRef)(n);m.current=u,g.current=d,v.current=n;const b=()=>{v.current?p({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>m.current?.()}):m.current?.()};return(0,o.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),g.current?.(!1)):"Escape"===e.key&&b()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,i.jsxs)("div",{className:"office-editor",children:[(0,i.jsxs)("div",{className:"office-editor__topbar",children:[(0,i.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,i.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,i.jsxs)("div",{className:"office-editor__ops",children:[h,l&&(0,i.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),d&&(0,i.jsx)(r.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>d()}),(0,i.jsx)(r.rA,{icon:"close",title:"关闭 (Esc)",onClick:b})]})]}),(0,i.jsxs)("div",{className:"office-editor__body",children:[s&&(0,i.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!s&&a&&(0,i.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}),!s&&!a&&f]})]})}},99018(e,t,n){n.d(t,{GB:()=>l,PQ:()=>a,Vi:()=>s});var o=n(14284),r=n(57889),c=n(34289),i=n(62042);function s(e){return`${encodeURIComponent(function(){const e=(0,c.GG)("file",(0,c.vX)());let t;try{t=decodeURIComponent(e)}catch{t=e}return t.endsWith("/")?t:`${t}/`}())}${e}`}async function a(e){return r.l.get_bytes_url(e)}function l(e,t,n){return async function(e,t,n){const r=await o.$M.post(`save_bin/${e}`,{base64:d(t)});return 0!==r.code?((0,i.zN)(r.message??"保存失败"),!1):(n&&(0,i.SK)(n),!0)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t,n)}function d(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);