{"id":18373487,"url":"https://github.com/silianpan/seal-uniplugin-uts-demo","last_synced_at":"2025-04-11T01:49:58.329Z","repository":{"id":167502605,"uuid":"643052209","full_name":"silianpan/Seal-UniPlugin-UTS-Demo","owner":"silianpan","description":"跨平台Office文档、图片在线预览，音视频播放UTS插件seal-office-online-uts【非X5离线、组件嵌入、水印、WPS预览编辑】","archived":false,"fork":false,"pushed_at":"2024-06-11T07:25:52.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T01:49:53.188Z","etag":null,"topics":["aar","android","android-native-plugin","android-plugin","file-preview","framework","ios","ios-native","ios-plugin","tbs","tencent-x5","uniapp-plugin","webview","wps","x5"],"latest_commit_sha":null,"homepage":"https://ext.dcloud.net.cn/plugin?id=12731","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silianpan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-20T01:09:40.000Z","updated_at":"2024-06-11T07:25:55.000Z","dependencies_parsed_at":"2024-11-06T00:10:43.607Z","dependency_job_id":"2cf88176-7ca1-4904-b43e-852b8359f783","html_url":"https://github.com/silianpan/Seal-UniPlugin-UTS-Demo","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"69a5ecbfe7bd0fdad33d3877a35884aa64fd838b"},"previous_names":["silianpan/seal-uniplugin-uts-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silianpan%2FSeal-UniPlugin-UTS-Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silianpan%2FSeal-UniPlugin-UTS-Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silianpan%2FSeal-UniPlugin-UTS-Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silianpan%2FSeal-UniPlugin-UTS-Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silianpan","download_url":"https://codeload.github.com/silianpan/Seal-UniPlugin-UTS-Demo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328104,"owners_count":21085258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aar","android","android-native-plugin","android-plugin","file-preview","framework","ios","ios-native","ios-plugin","tbs","tencent-x5","uniapp-plugin","webview","wps","x5"],"created_at":"2024-11-06T00:10:35.001Z","updated_at":"2025-04-11T01:49:58.312Z","avatar_url":"https://github.com/silianpan.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Github访问](https://github.com/silianpan/Seal-UniPlugin-UTS-Demo)\r\n\r\n[国内Gitee访问](https://gitee.com/twofloor/Seal-UniPlugin-UTS-Demo)\r\n\r\n\r\n\u003cdiv class=\"half\"\u003e\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OoXoqx.gif\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OoXOVt.gif\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\u003c/div\u003e\r\n\r\n\r\n## 〇、前言\r\n\r\n2023年3月13日，腾讯发布了调整公告：[关于腾讯浏览服务内核SDK-内核文档能力调整公告](https://mp.weixin.qq.com/s/rmSa4Fs77MDdjFioRKwXPA)，公告里面明确说明了：**2023年4月13日零时起，内核文档能力正式下线**。插件2.x版本使用了腾讯X5云服务能力，**已经上线的项目需要及时升级插件到3.x版本哟**，3.x版本不再依赖腾讯X5以及任何第三方插件，完全可以在内网环境中使用，同时支持在线文档和设备本地文档。\r\n\r\n\r\n\r\n支持wps、doc、docx、xls、xlsx、csv、ppt、pptx、txt、properties、log、Log、ini、lua、conf、m、cpp、java、h、xml、html、htm等常见文档格式。\r\n\r\n\r\n\r\n### 原生Android项目离线集成，查看Demo工程及README文档： [Seal-Office-Android-Demo](https://github.com/silianpan/Seal-Office-Android-Demo)\r\n\r\n\u003cspan style=\"color:red\"\u003e各位同学，对于插件使用还有疑问的，可以加QQ群（170683293）咨询，也可以扫下面二维码进微信群。\u003c/span\u003e\r\n\r\n\u003cimg src=\"http://silianpan.cn/upload/2022/01/01/Seal-UniPlugin-WeiXin.jpeg\" width=\"240\" style=\"width:240px;\" /\u003e\r\n\r\n\r\n\r\n## 一、注意事项\r\n\r\n* ##### 本插件不需要其他任何配置，也不需要依赖其他任何库，不要在manifest.json-\u003eApp模块配置中勾选Android X5 Webview`\r\n\r\n* ##### 不要同时使用其他同类文档预览插件，否则，可能会引起包冲突\r\n\r\n* ##### url或参数中是否含有中文字符串，请使用encodeURIComponent**或**encodeURI进行转码（新版可以不用转码，支持中文），详细说明见下面“问题一”\r\n\r\n## 二、问题解决\r\n\r\n### 问题一（新版可以不用转码，支持中文）：\r\n\r\n\u003e 插件安装成功，但是文档预览失败。\r\n\r\n解决方案：检查文档url或参数中是否含有**中文字符串**，如果有，请使用**encodeURIComponent**或**encodeURI**进行转码。\r\n\r\n如果参数有http://链接，使用**encodeURIComponent**；如果要对整个url进行转码，使用**encodeURI**\r\n\r\n\u003e encodeURIComponent和encodeURI区别\r\n\u003e\r\n\u003e 它们都是编码URL，唯一区别就是编码的字符范围，其中\r\n\u003e\r\n\u003e encodeURI方法***不会***对下列字符编码 **ASCII字母 数字 ~!@#$\u0026\\*()=:/,;?+'**\r\n\u003e\r\n\u003e encodeURIComponent方法***不会***对下列字符编码 **ASCII字母 数字 ~!\\*()'**\r\n\u003e\r\n\u003e 所以encodeURIComponent比encodeURI编码的范围更大。\r\n\r\n\r\n\r\n## 三、快速上手\r\n\r\nGithub克隆（[demo工程地址](https://github.com/silianpan/Seal-UniPlugin-UTS-Demo) ）或在右上角直接下载示例工程\r\n\r\n安装开发工具：[HBuilderX](https://www.dcloud.io/hbuilderx.html)\r\n\r\n### Step1. 下载demo工程，使用HBuilderX打开\r\n\r\n### Step2. 添加本文插件\r\n\r\n插件名称：[seal-office-online-uts](https://ext.dcloud.net.cn/plugin?id=12669)\r\n\r\n点击右上角`试用`或者`购买`，添加插件\r\n\r\n### Step3. 使用插件\r\n\r\n* 在vue或nvue组件中，导入插件\r\n\r\n```js\r\nimport * as UTSSealOfficeOnline from '../../uni_modules/seal-office-online-uts'\r\n```\r\n\r\n* **initEngine**方法：插件首次初始化（在应用启动时进行调用）\r\n\r\n* **openFile**方法（推荐）：支持Android和IOS，预览Office文件，支持如下格式：pdf、txt、doc、docx、xls、xlsx、ppt、pptx、epub等近50种类型文件，同时支持常见的音视频格式。\r\n* **openFileImage**方法（推荐）：支持Android（IOS端采用openFile方法），预览图片（jpg、png、jpeg、bmp等）。\r\n* **openFileVideo**方法（推荐）：播放音视频（mp3、flac、wma、wav、mp4、mkv等）。\r\n* **openFileWPS**方法（推荐）：采用本机WPS客户端预览或编辑文档，支持pdf、txt、doc、xls、ppt等多种文件格式。\r\n* **checkWps**方法：检查本机WPS客户端是否已经安装。\r\n\r\n**\u003cspan style=\"color:red\"\u003e接口使用方法，参考如下章节《四、使用方法》\u003c/span\u003e**\r\n\r\n### Step5. 调试\r\n\r\n* 制作自定义调试基座：在开发工具中点击“运行到手机或模拟器-》制作自定义调试基座”\r\n* 选择自定义调试基座：然后“运行到手机或模拟器-》基座运行选择-》自定义调试基座”\r\n* 连接真机，运行到手机或模拟器-》运行到Android App基座，进行运行调试\r\n\r\n## 四、使用方法\r\n\r\n### 1、插件首次初始化（在应用启动时进行调用）\r\n\r\n使用接口：initEngine\r\n\r\n```javascript\r\nuni.showLoading({\r\n  title: '插件首次初始化中'\r\n});\r\nUTSSealOfficeOnline.initEngine((code, msg) =\u003e {\r\n  if (code === 1) {\r\n    this.initPluginFirstSuccess = true;\r\n    uni.showToast({\r\n      title: '插件首次初始化成功',\r\n      duration: 2000\r\n    });\r\n  } else {\r\n    this.initPluginFirstSuccess = false;\r\n  }\r\n  uni.hideLoading();\r\n});\r\n```\r\n\r\n\r\n\r\n### 2、打开Office文档\r\n\r\n使用接口：openFIle，参数参考章节《五、openFile接口参数说明》。\r\n\r\n支持wps、doc、docx、xls、xlsx、csv、ppt、pptx、txt、properties、log、Log、ini、lua、conf、m、cpp、java、h、xml、html、 htm等常见文件格式。\r\n\r\n```javascript\r\n/**\r\n* 打开文档，非腾讯TBS，无内核加载，真正离线\r\n* @param {Object} fileUrl 文档url\r\n*/\r\nopenFile(fileUrl, otherOptions) {\r\n  UTSSealOfficeOnline.openFile({\r\n    waterMarkText: '水印水印换行',\r\n    url: fileUrl,\r\n    ...otherOptions\r\n  }, (code, msg) =\u003e {\r\n    console.log('openFile', code, msg);\r\n  });\r\n}\r\n```\r\n\r\n\r\n\r\n### 3、WPS预览或编辑\r\n\r\n使用接口：openFileWPS，参数参考章节《六、openFileWPS接口参数说明》。\r\n\r\n```javascript\r\n/**\r\n* WPS预览或编辑文档\r\n* @param {String} fileUrl 文档url\r\n* @param {String} openMode 打开模式\r\n* openMode取值：\r\n* Normal：正常模式，正常打开，WPS默认打开方式\r\n* ReadOnly：只读模式，以只读的方式打开，WPS会隐藏编辑按钮\r\n* EditMode：编辑模式，可对文档进行编辑\r\n* ReadMode：阅读器模式，支持左右翻页，仅Word、TXT文档支持\r\n* SaveOnly：另存模式(打开文件,另存,关闭)，仅Word、TXT文档支持\r\n*/\r\nopenFileWPS(fileUrl, openMode) {\r\n  UTSSealOfficeOnline.openFileWPS({\r\n    url: fileUrl,\r\n    openMode\r\n  },\r\n  (code, msg) =\u003e {\r\n    console.log('openFileWPS', code, msg);\r\n  });\r\n}\r\n```\r\n\r\n\r\n\r\n### 4、检查本机是否安装WPS客户端\r\n\r\n##### 4.1、方法一（推荐）、使用接口：checkWps，无参数。\r\n\r\n\u003e 支持平台：Android、IOS\r\n\r\n\u003cspan style=\"color:red\"\u003e注意：IOS配置应用访问白名单：\u003c/span\u003e**manifest.json**—》App常用其他设置—》IOS设置—》应用访问白名单，\r\n\r\n添加：**KingsoftOfficeApp,KingsoftOfficeAppEnterprise,WPSOfficeApi**\r\n\r\n\u003cimg src=\"http://silianpan.cn/upload/2023/02/image-0c13acc0ef9e4a96a4bbd02f32361e30.png\" alt=\"应用访问白名单\" style=\"zoom: 50%;\" /\u003e\r\n\r\n```javascript\r\n/**\r\n* 检查WPS客户端是否已经安装\r\n* 返回结果：true or false\r\n*/\r\ncheckWps() {\r\n    const checkWps = UTSSealOfficeOnline.checkWps();\r\n    console.log('checkWps', checkWps);\r\n},\r\n```\r\n\r\n##### 4.2、方法二、直接调用*plus.runtime.isApplicationExist*\r\n\r\n参考链接：https://www.cnblogs.com/goloving/p/14384105.html\r\n\r\n```js\r\n// 判断第三方程序(WPS) 是否安装\r\nfunction checkApp() {\r\n    if (plus.runtime.isApplicationExist({pname:'cn.wps.moffice_eng', action:'KingsoftOfficeApp://'})) {\r\n      console.log(\"WPS应用已安装\");\r\n    } else {\r\n      console.log(\"WPS应用未安装\");\r\n    }\r\n}\r\n```\r\n\r\n\r\n\r\n### 5、图片预览\r\n\r\n使用接口：openFile（IOS）、openFileImage（Android），参数参考章节《五、openFile接口参数说明》\r\n\r\n\u003e 支持平台：Android、IOS\r\n\u003e\r\n\u003e 支持jpg、png、jpeg、bmp等\r\n\r\n```javascript\r\n/**\r\n* 图片预览，jpg、png、jpeg、bmp等\r\n* @param {Object} fileUrl 图片url\r\n* @param {Object} imageCurrentIndex 当前图片位置下标，从0开始\r\n*/\r\nopenFileImage(fileUrl, imageCurrentIndex) {\r\n  if (this.platform === 'android') {\r\n    UTSSealOfficeOnline.openFileImage({\r\n      imageUrls: JSON.parse(JSON.stringify(this.imageList)),\r\n      imageCurrentIndex, // 当前点击图片在imageUrls中的下标，从0开始，默认为0\r\n      imageIndexType: 'number', // 图片底部指示器类型，默认为'dot'，可选：'number':数字；'dot':点\r\n      isSaveImg: true,\r\n    },\r\n    (code, msg) =\u003e {\r\n      console.log('openFileImage', code, msg);\r\n    });\r\n  } else if (this.platform === 'ios') {\r\n    UTSSealOfficeOnline.openFile({\r\n      url: fileUrl,\r\n      title: 'IOS图片预览',\r\n      topBarBgColor: '#3394EC'\r\n    });\r\n  }\r\n}\r\n```\r\n\r\n\r\n\r\n### 6、音视频播放\r\n\r\n使用接口：openFile，参数参考章节《五、openFile接口参数说明》\r\n\r\n\u003e 支持平台：Android、IOS\r\n\u003e\r\n\u003e 支持mp4, flv, avi, 3gp, webm, ts, ogv, m3u8, asf, wmv, rm, rmvb, mov, mkv等18种视频格式，以及mp3，wav，wma，flac等音频格式\r\n\r\n```javascript\r\n/**\r\n* 视频播放，支持市面上几乎所有的音视频格式，包括mp4, flv, avi, 3gp, webm, ts, ogv, m3u8, asf, wmv, rm, rmvb, mov, mkv等18种视频格式，以及mp3，wav，wma，flac等音频格式\r\n* 功能包括：播放、暂停、重播、全屏播放、直播等\r\n* 支持Android和IOS\r\n* @param {String} fileUrl 音视频url\r\n*/\r\nopenFileVideo(fileUrl) {\r\n  if (this.platform === 'android') {\r\n    UTSSealOfficeOnline.openFileVideo({\r\n      videoUrl: fileUrl,\r\n      isLive: true,\r\n      title: '音视频播放标题',\r\n      isTopBar: true,\r\n      isBackArrow: false,\r\n      topBarBgColor: '#F77234',\r\n      topBarTextColor: '#FCF26B',\r\n      topBarTextLength: 12\r\n    },\r\n    (code, msg) =\u003e {\r\n      console.log('openFileVideo', code, msg);\r\n    });\r\n  } else if (this.platform === 'ios') {\r\n    UTSSealOfficeOnline.openFile({\r\n      videoUrl: fileUrl\r\n    });\r\n  }\r\n}\r\n```\r\n\r\n\r\n\r\n## 五、openFile接口参数说明\r\n\r\n支持打开在线文档，本地文档\r\n\r\n\u003e 支持平台：Android、IOS\r\n\r\n| 参数名             | 说明                                                         | 类型          | 是否必填 | 默认值            | 可选值                  |\r\n| ------------------ | ------------------------------------------------------------ | ------------- | -------- | ----------------- | ----------------------- |\r\n| url                | 支持如下三种地址方式：\u003cbr /\u003e（1）文件网络地址，如：http://113.62.127.199:8090/fileUpload/1.xlsx \u003cbr /\u003e（2）手机本地文件地址，如：/data/user/0/APP包名/files/1.xlsx 文件名，如：1.xlsx，\u003cbr /\u003e（3）访问默认目录文件，默认目录为：/data/user/0/APP包名，如：com.HBuilder.UniPlugin\u003cbr /\u003e**注意**：手机本地地址目录需要有权限访问\u003cbr/\u003e\u003cspan style=\"color:red\"\u003e**IOS端只支持在线地址**\u003c/span\u003e | string        | 是       |                   |                         |\r\n| docRequestHeaders  | 文档下载请求头，如：\u003cbr /\u003e{ 'Authorization': 'Token xxxxxxxx', 'Other': 'other' }\u003cbr /\u003e，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | object        | 否       |                   |                         |\r\n| fileType           | 可以指定文件类型，如：xlsx，在url参数无法判断文件类型时，可以指定文件类型 | string        | 否       |                   |                         |\r\n| fileName           | 指定文件名，如：file1，注意此处不带文件扩展名，如果同时指定fileName和fileType，那么最后的文件名通过这两个参数组合起来，即：fileName.fileType | string        | 否       |                   |                         |\r\n| isDeleteFile       | 退出是否删除缓存的文件，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | true              | false                   |\r\n| docDownloadTitle   | 文档下载进度框标题，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string        | 否       | 加载文档          |                         |\r\n| docDownloadBody    | 文档下载进度框内容，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string        | 否       | 请稍后...         |                         |\r\n| waterMarkText      | 水印文本，默认以**\\n**作为分隔符换行                         | string        | 否       | null              |                         |\r\n| waterMarkTextSep   | 水印文本分隔符，\u003cspan style=\"color:red\"\u003e**注意：IOS端只支持\\n换行**\u003c/span\u003e | string        | 否       | \\n                |                         |\r\n| waterMarkFontSize  | 水印字体大小，单位为sp\u003cbr\u003e使用sp作为字体大小单位,会随着系统的字体大小改变 | int           | 否       | 13                |                         |\r\n| waterMarkFontColor | 水印字体颜色                                                 | string        | 否       | #40F3F5F9         |                         |\r\n| waterMarkDegree    | 水印旋转角度，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string        | 否       | -30（逆时针30度） |                         |\r\n| isTopBar           | 是否显示顶栏，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | true              | false                   |\r\n| title              | 顶栏标题，isTopBar为true时有效                               | string        | 否       | APP名称           |                         |\r\n| topBarAutoHide     | 顶栏是否自动隐藏，isTopBar=true时生效，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | false             | true                    |\r\n| topBarHeight       | 顶栏自定义高度，isTopBar为true时有效，类型为正整数，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | int           | 否       | actionBarSize     |                         |\r\n| topBarBgColor      | 顶栏背景颜色，isTopBar为true时有效                           | string        | 否       | #3394EC（科技蓝） |                         |\r\n| topBarTextColor    | 顶栏文本颜色（isTopBar为true时有效）                         | string        | 否       | #FFFFFF（白色）   |                         |\r\n| topBarTextLength   | 顶栏标题文字长度（isTopBar为true时有效），\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | int           | 否       | 12                |                         |\r\n| isBackArrow        | 是否显示返回按钮（isTopBar为true时有效），\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | true              | false                   |\r\n| videoUrl           | 视频在线url，此参数优先于图片预览和文档预览                  | string        | 是       |                   |                         |\r\n| isLive             | 是否是视频直播，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | false             | true                    |\r\n| imageUrls          | 图片url数组，此参数优先于文档预览；长按图片底部弹出保存图片菜单，保存图片至相册，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | array\u003cstring\u003e | 是       |                   |                         |\r\n| imageCurrentIndex  | 当前点击图片在imageUrls中的下标，从0开始，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | int           | 否       | 0                 |                         |\r\n| imageIndexType     | 图片底部指示器类型，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string        | 否       | 'dot'             | 'number':数字；'dot':点 |\r\n| isSaveImg          | 是否长按保存图片，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | bool          | 否       | null              | true/false              |\r\n| canScreenshot      | 是否可以截屏，\u003cspan style=\"color:blue\"\u003e**3.0.2版本以上支持**\u003c/span\u003e | bool          | 否       | true（可以截屏）  | false（禁止截屏）       |\r\n\r\n\r\n\r\n## 六、openFileWPS接口参数说明\r\n\r\n本机WPS客户端预览或编辑文档\r\n\r\n\u003e 支持平台：Android、IOS（分享功能，第三方APP打开）\r\n\r\n| 参数名            | 说明                                                         | 类型   | 是否必填 | 默认值    | 可选值 |\r\n| ----------------- | ------------------------------------------------------------ | ------ | -------- | --------- | ------ |\r\n| url               | 支持如下三种地址方式：\u003cbr /\u003e（1）文件网络地址，如：http://113.62.127.199:8090/fileUpload/1.xlsx \u003cbr /\u003e（2）手机本地文件地址，如：/data/user/0/APP包名/files/1.xlsx 文件名，如：1.xlsx，\u003cbr /\u003e（3）访问默认目录文件，默认目录为：/data/user/0/APP包名，如：com.HBuilder.UniPlugin\u003cbr /\u003e**注意**：手机本地地址目录需要有权限访问\u003cbr/\u003e\u003cspan style=\"color:red\"\u003e**IOS端只支持在线地址**\u003c/span\u003e | string | 是       |           |        |\r\n| fileType          | 可以指定文件类型，如：xlsx，在url参数无法判断文件类型时，可以指定文件类型，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string | 否       |           |        |\r\n| fileName          | 指定文件名，如：file1，注意此处不带文件扩展名，如果同时指定fileName和fileType，那么最后的文件名通过这两个参数组合起来，即：fileName.fileType，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string | 否       |           |        |\r\n| docDownloadTitle  | 文档下载进度框标题，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string | 否       | 加载文档  |        |\r\n| docDownloadBody   | 文档下载进度框内容，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | string | 否       | 请稍后... |        |\r\n| docRequestHeaders | 文档下载请求头，如：\u003cbr /\u003e{ 'Authorization': 'Token xxxxxxxx', 'Other': 'other' }\u003cbr /\u003e，\u003cspan style=\"color:red\"\u003e**IOS端无此配置**\u003c/span\u003e | object | 否       |           |        |\r\n| openMode          | 打开模式：\u003cbr\u003e* Normal：正常模式，正常打开，WPS默认打开方式\u003cbr\u003e* ReadOnly：只读模式，以只读的方式打开，WPS会隐藏编辑按钮\u003cbr\u003e* EditMode：编辑模式，可对文档进行编辑\u003cbr\u003e* ReadMode：阅读器模式，支持左右翻页，仅Word、TXT文档支持\u003cbr\u003e* SaveOnly：另存模式(打开文件,另存,关闭)，仅Word、TXT文档支持 | string | 否       | Normal    | 见说明 |\r\n\r\n另，openMode打开模式说明：\r\n\r\n| 打开模式 | 说明                                                        |\r\n| -------- | ----------------------------------------------------------- |\r\n| Normal   | 正常模式，正常打开，WPS默认打开方式                         |\r\n| ReadOnly | 只读模式，以只读的方式打开，WPS会隐藏编辑按钮               |\r\n| EditMode | 编辑模式，可对文档进行编辑                                  |\r\n| ReadMode | 阅读器模式，支持左右翻页，仅Word、TXT文档支持               |\r\n| SaveOnly | （不常用）另存模式(打开文件,另存,关闭)，仅Word、TXT文档支持 |\r\n\r\n\r\n\r\n## 七、回调结果\r\n\r\n### 1、回调结果格式\r\n\r\n```json\r\n// openFile接口\r\n{\r\n    \"code\": 200,\r\n    \"msg\": \"文档预览成功\",\r\n    \"result\": {\r\n        // 本地文件名\r\n        \"fileName\": \"test.docx\",\r\n        // 本地文件路径，前提，参数isDeleteFile=false，否则预览预览结束，本地文件被删除\r\n        \"filePath\": \"/storage/sdcard0/Android/data/com.seal.uniplugin/files/file/test.docx\"\r\n    }\r\n}\r\n\r\n// OpenFileWPS接口\r\n{\r\n    \"code\": 1021,\r\n    \"msg\": \"WPS动作事件\",\r\n    \"result\": {\r\n        // 本地文件名\r\n        \"fileName\": \"test.docx\",\r\n        // 本地文件路径，前提，参数isDeleteFile=false，否则预览预览结束，本地文件被删除\r\n        \"filePath\": \"/storage/sdcard0/Android/data/com.seal.uniplugin/files/file/test.docx\",\r\n        // WPS动作类型：back，返回键；home，Home键；save，保存文件；close，关闭文件\r\n        \"actionType\": \"back\",\r\n        // 文件另存为本机路径\r\n        \"fileSavePath\": \"/storage/sdcard0/Android/Download/test2.docx\"\r\n    }\r\n}\r\n```\r\n\r\n### 2、回调结果状态码说明\r\n\r\n| 状态码 | 说明                        |\r\n| ------ | --------------------------- |\r\n| 200    | 文档预览成功                |\r\n|        |                             |\r\n| 301    | 文档下载失败                |\r\n| 302    | 内核下载失败，自动重新下载  |\r\n| 303    | 内核安装失败，自动重新安装  |\r\n| 304    | 内核加载失败，可忽略该错误  |\r\n| 305    | 内核下载失败，可忽略该错误  |\r\n| -6     | 参数异常，加载文件失败      |\r\n| -7     | 不支持文件类型              |\r\n| -8     | 文件不存在                  |\r\n| -9     | 文件预览失败                |\r\n|        |                             |\r\n| 1001   | 文档下载成功                |\r\n| 1002   | 开始初始化内核              |\r\n| 1003   | 开始离线安装内核            |\r\n| 1004   | 开始在线安装内核            |\r\n| 1005   | 内核下载成功                |\r\n| 1006   | 内核安装成功                |\r\n| 1007   | 内核初始化成功              |\r\n| 1008   | 缓存文档删除成功            |\r\n| 1009   | 程序员正在快马加鞭开发中... |\r\n| 1010   | 页面返回                    |\r\n|        |                             |\r\n| 1021   | WPS动作事件                 |\r\n\r\n### 3、WPS动作事件类型actionType说明\r\n\r\n\u003e 支持平台：Android\r\n\r\n| 动作类型 | 说明     |\r\n| -------- | -------- |\r\n| back     | 返回键   |\r\n| home     | Home键   |\r\n| save     | 保存文件 |\r\n| close    | 关闭文件 |\r\n\r\n\r\n\r\n## 八、预览效果\r\n\r\n### 1、Android\r\n\r\n* 嵌入预览\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolpAF.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览docx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ooltnb.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览pptx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolEms.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览xlsx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolGYK.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览pdf\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolLkB.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览txt\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolS5a.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览mp4\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ool44l.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolD6g.jpg\" style=\"width:600px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览jpg\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolJQ6.jpg\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n\r\n\r\n###  2、IOS\r\n\r\n* 嵌入预览\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolcSN.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览docx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OoldCC.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览pptx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ooljpx.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览xlsx\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ool85p.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览pdf\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ool9kt.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览txt\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Ool2Yj.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览mp4\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/Oolf6X.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n* 预览jpg\r\n\r\n  \u003cimg src=\"https://i.imgtg.com/2023/05/30/OolYDi.png\" style=\"width:200px;height:auto\" width=\"200px\" /\u003e\r\n\r\n\r\n\r\n转载请注明：[我的技术分享](http://silianpan.cn) » [跨平台Office文档预览原生插件，非腾讯X5，支持离线，稳定高可用](http://silianpan.cn/archives/filepreviewuninative)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilianpan%2Fseal-uniplugin-uts-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilianpan%2Fseal-uniplugin-uts-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilianpan%2Fseal-uniplugin-uts-demo/lists"}