WPS加载项系列(3)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则访问的是本项目该目录下的加载项。

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

注意: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 放到项目中,保证可以被访问到,同时把开发的加载项文件 或 加载项文件压缩包放到项目中。

@Controller
@RequestMapping("/publish")
public class PublishController {
    @GetMapping()
    public String template() {
        return "/publish";
    }
}

(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. 具体实现
可以参考文档附件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值