The official explanation of the WPS add-in:
WPS Add-in is a set of web-based solutions for extending WPS applications. Each WPS add-in opens a corresponding web page, and completes its functional logic by calling the JavaScript method in the web page. The web pages opened by the WPS add-in can directly interact with the WPS application. At the same time, multiple web pages in a WPS add-in form a whole and can share data with each other. Developers don't have to worry about browser compatibility issues, because the bottom layer of the WPS add-on is an optimized extension based on the Chromium open source browser project. The WPS add-in has the characteristics of rapid development, light weight, and cross-platform, and has been adapted for Windows/Linux operating systems. WPS add-in features are as follows:
- full functionality. Documents, spreadsheets, and presentations can be authored, formatted, and manipulated in many different ways; almost anything you can do with a mouse or keyboard can be done with a WPS add-in; repetitive tasks can be easily performed and automated.
- Three ways to interact. The custom functional area adopts the open CustomUI standard to quickly organize all functions; the task pane , which displays web pages, has richer content; the web dialog box , combined with event monitoring, realizes free interaction.
- Standardized integration. It does not affect the JavaScript language features, and the running effect of the web page is exactly the same as that in the browser; the development documentation of the WPS add-in is complete, and the interface design conforms to the JavaScript syntax specification, avoiding unnecessary learning costs and shortening the development cycle.
If you want to really know what this so-called "add-in" is, it is better to practice it on paper, and follow the steps below. First of all, you need to install wps (nonsense) and Node.js on the computer.
1. Administrator privileges (if the WPS personal version is installed, administrator privileges are not required), start the command line and install the wpsjs development kit globally through npm: npm install -g wpsjs , if it has been installed before, you can update it: npm update -g wpsjs .
It is recommended to use Taobao mirror: npm config set registry https://registry.npm.taobao.org
2. Create a new wps add-in, assuming the name is "HelloWps": wpsjs create HelloWps , several options will appear as shown below:
3. After we select " Spreadsheet ", we will let you choose the front-end framework:
4. If you are familiar with vue, after selecting "Vue", wpsjs will create the following project structure in the current directory
- Provides a hot update service for front-end pages. When the wpsjs toolkit detects changes in web page data, it automatically refreshes the page.
- Provides the online service of WPS add-in. The code sample generated by wpsjs is an online mode. The WPS client program actually requests the online WPS add-in related code and resources through the http service.
6. Open a new tab page in wps, select New Blank Spreadsheet, if the following "wps add-in instance" appears, it means that the add-in is installed successfully.
- The publish mode is packaged through the wpsjs publish command of the wpsjs toolkit, and all files in the generated folder are deployed to the server address when packaging. Inform users of the address of publish.html, and business system developers can integrate the functions of publish.html into their own pages as needed to facilitate basic environmental monitoring. This page can also be reused for users, who can control which add-ons are enabled and disabled.
- The jsplugins.xml mode is to control the loading of the add-in by setting the value of the JSPluginsServer of the oem.ini configuration file to the add-in management file jsplugins.xml (equivalent to the WPS add-in list file). During the secondary packaging, the business developer needs to inform The configuration address of our JSPluginsServer is configured in the oem.ini file, and the business developer will distribute the installation package. For the control of subsequent add-ins, business developers can freely change the jsplugins.xml file to add and modify add-ins.
publish mode:
jsplugins.xml schema
- Advantages: The loading is relatively smooth, the user's first access time after the first load or version update will be higher than the offline mode, and the latest code is used every time
- Disadvantages: Every time it is executed, it is to request resources on the server, which wastes network resources, and cannot be accessed when the network is not good.
- Summary: Online mode is suitable for use when resources are frequently changed and the network is stable
- Advantages: As long as name_version is equal to the name of the add-in folder, the add-in will not update the add-in package, and the local add-in package resources are used, which greatly saves network resources and user time.
- Disadvantages: When loading for the first time or when the version is changed, the entire add-on package will be downloaded first and decompressed, which will take more time
- Summary: Offline mode is suitable for situations where resource changes are infrequent