目前尝试在线部署Wps加载项在Windows环境是可以实现自动部署的,但是在Mac不支持,
于是在探索中发现只能手动部署了。plugin_content不清楚填什么的,可以参考一下windows安装成功的publish.xml内容。
cd ~/Library/Containers/com.kingsoft.wpsoffice.mac/Data/.kingsoft/wps/jsaddons/
publish_name="publish.xml"
plugin_content='<jspluginonline debug="" name="HelloWps" install="xxxxxxx" type="et" enable="enable_dev" url="xxx>'
content="
${plugin_content}
"
if [ -f "$publish_name" ]; then
sed -i "" "$ i\
${plugin_content}
" "$publish_name"
else
echo "$content" > "$publish_name"
fi
目标:在目录 ~/Library/Containers/com.kingsoft.wpsoffice.mac/Data/.kingsoft/wps/jsaddons/ 下操作一个名为 publish.xml 的文件。
步骤:
- 定义变量:
publish_name="publish.xml"
plugin_content='<jspluginonline debug="" name="HelloWps" install="xxxxxxx" type="et" enable="enable_dev" url="xxx>'
content="
${plugin_content}
"
-
如果该目录下已经存在 publish.xml 文件,则使用 sed 命令在文件末尾(具体位置是?)插入一行(实际上是插入多行,因为plugin_content变量后面有一个换行)内容,即 plugin_content 变量的内容。
-
如果不存在,则将 content 变量的内容写入 publish.xml 文件。
参考文章: MAC系统安装加载项