[]
插件名称/
├── src/
│ └── visual.ts # 主实现类(必需)
├── style/
│ └── visual.less # 样式文件(必需)
├── i18nResources/
│ ├── zh-CN.json # 中文资源(必需)
│ ├── en-US.json # 英文资源(必需)
│ └── zh-TW.json # 繁体资源(可选)
├── assets/
│ └── icon.png # 插件图标(建议 64x64 PNG)
├── dist/
│ ├── visual.js
│ └── visual.css
├── capabilities.json # 数据绑定与配置定义(必需)
├── visual.json # 插件元数据(必需)
├── visual.d.ts # TypeScript 类型定义(必需)
├── webpack.config.js # 构建配置(必需)
├── tsconfig.json # TypeScript 配置(必需)
└── package.json # 依赖与脚本(必需)文件 / 目录 | 作用 | 必需 |
|---|---|---|
| 插件主逻辑与生命周期实现 | 是 |
| 样式定义 | 是 |
| 数据绑定、属性、动作、分析 | 是 |
| 插件元数据与运行配置 | 是 |
| Visual API 类型定义 | 是 |
| 多语言资源 | 是 |
| 插件图标 | 是 |
| 构建产物 | 构建后生成 |
visual.json:插件元数据与运行参数interface IVisualMeta extends ILocalizable, IIconable {
name: string;
description?: string;
externalJs?: string[];
externalCss?: string[];
assets?: {
images?: {
[key: string]: string;
}
};
configuration?: {
[key: string]: string;
};
}{
"id": "唯一标识符-使用UUID",
"name": "插件名称",
"displayName": "显示名称",
"displayNameKey": "国际化键名",
"icon": "assets/icon.png",
"description": "插件描述",
"externalJs": [],
"externalCss": [],
"dependencies": [],
"assets": {
"images": {}
},
"configuration": {
"$runInIframe": false
},
"cliVersion": "6.1.8"
}字段 | 说明 |
|---|---|
| 插件唯一标识,建议使用 UUID |
| 内部名称 |
| 显示名称或其国际化键 |
| 插件图标路径 |
| 插件描述 |
| 外部 JS / CSS 依赖,可从 CDN 加载 |
| 模块依赖,例如 |
| 参与打包的图片资源定义 |
| 上传到系统后可在后台配置的运行参数 |
| 构建工具版本信息 |
configuration 的业务含义configuration 不是单纯的 JSON 片段,而是上传到系统后给管理员设置运行参数的入口。原始资料明确指出:
插件上传到系统后,可在「系统管理 > 文档管理 > 可视化组件」中对这些参数进行配置。
Visual 运行时可通过 configurationManager.get(key) 读取这些参数。
{
"configuration": {
"$runInIframe": true,
"$trusted": true
}
}说明:
$runInIframe:是否在 iFrame 中运行。
$trusted:原始接口文档将其作为与运行信任 / sandbox 相关的可配置项示例保留。
原始截图展示的是:插件上传到系统后,在后台插件管理页面里打开“设置参数”界面的入口与配置面板。
capabilities.json:总体结构interface ICapabilityDefinition {
dataBinding?: IDataBinding;
options?: IOptions;
actions?: Array<IAction>;
analysis?: Array<IAction>;
}块 | 含义 |
|---|---|
| 定义数据角色、模板、数据视图映射、条件与图表切换规则 |
| 定义属性面板、公共设置、分类、参数监听等 |
| 定义设计态/运行态操作栏与探索能力 |
| 定义联动分析,如钻取 |
capabilities.json的详细接口、枚举、参数与示例见第 4 章。
package.json、tsconfig.json、webpack.config.jspackage.json 示例{
"name": "插件名称",
"version": "1.0.0",
"scripts": {
"dev": "webpack --mode=development --watch",
"compile": "webpack --mode=development",
"release": "webpack --mode=production"
},
"devDependencies": {
"@babel/core": "7.9.0",
"babel-loader": "8.0.6",
"css-loader": "6.7.3",
"css-minimizer-webpack-plugin": "5.0.0",
"less": "4.1.3",
"less-loader": "11.1.0",
"mini-css-extract-plugin": "2.7.5",
"terser-webpack-plugin": "5.3.8",
"ts-loader": "9.4.2",
"typescript": "5.0.4",
"webpack": "5.82.1",
"webpack-cli": "5.1.1"
}
}tsconfig.json 示例{
"compilerOptions": {
"baseUrl": "./",
"sourceMap": true,
"module": "commonjs",
"target": "ES5",
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"lib": ["esnext", "dom"]
},
"include": ["./src", "./visual.d.ts"],
"exclude": ["node_modules", "assets", "dist"]
}webpack.config.js 示例const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const config = {
entry: './src/visual.ts',
output: {
filename: 'visual.js',
path: path.join(__dirname, 'dist'),
library: {
name: 'WynVisualClass',
type: 'umd',
},
libraryExport: 'default'
},
plugins: [
new MiniCssExtractPlugin({
filename: 'visual.css',
}),
],
optimization: {
minimizer: [new CssMinimizerPlugin({}), new TerserPlugin()],
},
module: {
rules: [
{
test: /\.(ts)$/,
exclude: /node_modules/,
use: ['babel-loader', 'ts-loader'],
},
{
test: /\.less|.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'less-loader'],
},
{
test: /\.(png|jpg|gif)$/i,
type: 'asset/inline',
},
],
unknownContextCritical: false,
},
resolve: {
extensions: ['.ts', '.js', '.json', '.css', '.less'],
},
mode: 'development',
};
module.exports = config;dev:监听并自动重编译。
compile:单次开发构建。
release:生产压缩构建。
package:通过 CLI 进一步打包为 .viz,不能只停留在 webpack 输出阶段。
i18nResources 与 assetszh-CN.json
{
"dropdownSelector": "下拉框选择器",
"dataBinding": {
"label": "显示字段",
"value": "值字段"
},
"property": {
"general": "常规",
"style": "样式",
"placeholder": "占位符文本",
"allowClear": "允许清除"
}
}en-US.json
{
"dropdownSelector": "Dropdown Selector",
"dataBinding": {
"label": "Label Field",
"value": "Value Field"
},
"property": {
"general": "General",
"style": "Style",
"placeholder": "Placeholder Text",
"allowClear": "Allow Clear"
}
}capabilities.json 中引用国际化键{
"dataBinding": {
"dataRoles": [
{
"name": "label",
"displayNameKey": "dataBinding.label"
}
]
},
"options": {
"visual": [
{
"displayNameKey": "property.general",
"properties": [
{
"name": "placeholder",
"displayNameKey": "property.placeholder"
}
]
}
]
}
}const displayText = this.host.localizationManager.getDisplay('property.placeholder');assets 当前文档重点说明了图片资源。
这些图片可以被打包为 base64,并在运行时通过 assetsManager.getImage() 获取。
插件图标通常定义为 assets/icon.png,供设计器面板展示。
位置 | 作用 |
|---|---|
| 声明此插件支持哪些管理员可配置参数 |
系统管理页“设置参数” | 管理员为指定插件实例配置这些参数 |
| 在运行时读取配置项 |
这也是 visual.json 中 $runInIframe、$trusted 等字段不能被当作“纯静态示例”略过的原因:它们直接影响插件在系统中的实际运行方式。