当前位置:   article > 正文

WPS加载项系列(3)WPS项目部署

wps加载项

一、部署方式

wps加载项目有两种部署模式,publish模式和jsplugins.xml模式,可以参考实际情况自己选择部署模式。

二、publish模式

1. 原理
通过访问 publish自动安装是通过接口在客户本地的jsaddons目录下生成publish.xml文件,WPS启动时,会去读取该文件,找到相应的加载项。

2. 具体实现
(1)通过 wpsjs publish生成publish.html 部署文件。publish.html中curList的url为http://部署加载项的服务器地址:端口/xxx/,填写127.0.0.1则访问的是本项目该目录下的加载项。

  1. function LoadPublishAddons() {
  2. var addonList = document.getElementById("addonList");
  3. var curList = [{"name":"xxx","addonType":"wps","online":"true","url":"http://ip:port/wps加载项index.html路径"}];
  4. // var curList = [{"name":"xxx","version":"1.0","addonType":"wps","online":"false","url":"http://ip:port/wps加载项.7z"}];
  5. curList.forEach(function (element) {
  6. var param = JSON.stringify(element).replace("\"", "\'");
  7. UpdateElement(element, 'enable')
  8. });
  9. }

注意:publish.html 中的 curList 值为 [{"name":"xxx","addonType":"wps","online":"true","url":"http://ip:port/wps加载项index.html路径"}] 访问的是在线加载项文件,curList 值为 [{"name":"xxx","version":"1.0","addonType":"wps","online":"false","url":"http://ip:port/wps加载项.7z"}] 访问时自动下载加载项文件,可以离线使用。

(2)把 publish.html 放到项目中,保证可以被访问到,同时把开发的加载项文件 或 加载项文件压缩包放到项目中。

  1. @Controller
  2. @RequestMapping("/publish")
  3. public class PublishController {
  4. @GetMapping()
  5. public String template() {
  6. return "/publish";
  7. }
  8. }

(3)访问http://127.0.0.1:端口/xxx/publish,选择wps加载项

(4)查看本地目录C:\Users\Administrator\AppData\Roaming\kingsoft\wps\jsaddons是否生成publish.xml文件(publish模式)。如果存在jsplugins.xml文件(jsplugins模式)需要删除,两者不同时生效。同时使用两种模式时,需要保证两种模式中的加载项名称不会重复。

(5)查看http://ip:port/xxx/ribbon.xml能否访问(加载项文件)

(6)查看http://ip:port/xxx/index.html是否报错(加载项文件)

(7)做完以上步骤后,打开wps后会自动出现wps加载项

三、jsplugins.xml模式

1. 原理
两种部署方式,实现的效果一样。

2. 具体实现
可以参考文档附件

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/797451
推荐阅读
相关标签
  

闽ICP备14008679号