### GET /api/v1/project/list Source: https://www.shanhaibi.com/docs/v1/ch6gtt3l544k6aig 项目管理接口,用于获取项目列表。 ```APIDOC ## GET /api/v1/project/list ### Description 项目管理接口,用于获取项目列表。 ### Method GET ### Endpoint /api/v1/project/list ### Response #### Success Response (200) - **id** (string) - 项目ID - **name** (string) - 项目名称 - **createTime** (number) - 创建时间戳 - **folder** (string) - 文件夹id - **report** (string) - 报表系统id - **new** (boolean) - 是否是新项目 - **snapshotted** (boolean) - 是否有封面截图 - **version** (number) - 项目版本 - **boardsCount** (number) - 看板数量 - **showPlayer** (boolean) - 是否显示控制条 - **cloudRendering** (boolean) - 是否启用云服务 - **widgetPlan** (string) - 组件计划 - **visitorMode** (boolean) - 访客模式 - **directAccess** (boolean) - 直接访问 - **embedWeb** (boolean) - 嵌入网页 - **embedIpWhiteList** (array) - IP白名单 - **shareId** (string) - 分享ID - **cloudHosting** (boolean) - 云托管 - **allowZooming** (boolean) - 允许缩放 - **clientVersion** (number) - 客户端版本 - **cachedExpireTime** (number) - 缓存过期时间 #### Response Example [ { "id": "ktujbphysm4h", "name": "我的空白项目", "createTime": 1702445569332, "folder": "", "report": "", "new": true, "snapshotted": true, "version": 3, "boardsCount": 1, "showPlayer": true, "cloudRendering": false, "widgetPlan": "", "visitorMode": true, "directAccess": true, "embedWeb": true, "embedIpWhiteList": [], "shareId": "", "cloudHosting": false, "allowZooming": true, "clientVersion": 4, "cachedExpireTime": 0 } ] ``` -------------------------------- ### 项目管理接口 GET /api/v1/project/list Source: https://www.shanhaibi.com/docs/v1/ch6gtt3l544k6aig 获取项目列表,返回 JSON 数组,每个项目包含 id、name、createTime 等字段。 ```http GET /api/v1/project/list ``` ```json [ { "id": "ktujbphysm4h",//项目ID "name": "我的空白项目",//项目名称 "createTime": 1702445569332,//创建时间戳 "folder": "",//文件夹id "report": "",//报表系统id "new": true,//是否是新项目 "snapshotted": true,//是否有封面截图 "version": 3,//项目版本 "boardsCount": 1,//看板数量 "showPlayer": true,//是否显示控制条 "cloudRendering": false,//是否启用云服务 "widgetPlan": "", "visitorMode": true, "directAccess": true, "embedWeb": true, "embedIpWhiteList": [], "shareId": "", "cloudHosting": false, "allowZooming": true, "clientVersion": 4, "cachedExpireTime": 0 }, ] ``` -------------------------------- ### 使用 fetch 发起 GET 请求 Source: https://www.shanhaibi.com/docs/v1/cgw9yeqgo0zwrsxv 最简单的 fetch 请求示例,在扩展的 mounted 中为元素添加点击事件,使用 fetch 请求一个允许跨域的 URL,并解析 JSON 响应。注意:地址必须允许跨域,否则无法访问数据。 ```javascript class ExtensionSample { mounted() { this.element.addEventListener("click", async () => { //注意 这里的地址需要允许跨域 const response = await fetch("http://www.example.com/get"); //如果返回结果是json格式的话 使用response.json() //如果是纯文本 可以写成 response.text() const data = await response.json(); console.log(data); }); } } export default ExtensionSample; ``` -------------------------------- ### ready() 生命周期函数签名 Source: https://www.shanhaibi.com/docs/v1/tx9rigt2ff6e0m1h 在项目的所有组件初始化完成时调用,此时所有组件都已加载并初始化完毕,可以访问其他组件。 ```typescript ready?(): void ``` -------------------------------- ### SampleExtension - 山海鲸二开代码 Source: https://www.shanhaibi.com/docs/v1/lreauo3ern9bk88p 山海鲸二开代码文件,用于处理iFrame与山海鲸组件之间的通信。监听iFrame消息并更新多行文本组件,同时向iFrame发送按钮点击消息。 ```typescript // 二次开发API参考 https://www.shanhaibi.com/docs/v1/tx9rigt2ff6e0m1h/ export class SampleExtension { redButton = Element.empty(); greenButton = Element.empty(); infoBox = Element.empty(); async mounted() { this.iframe.onMessage((ev) => { const msg = ev.data.msg; if (msg) { const line = "收到iframe发送的消息:" + msg; const text = this.infoBox.getOption("text"); this.infoBox.setOption("text", text ? text + "\n" + line : line); } }); this.redButton.addEventListener("click", (ev) => { this.iframe.postMessage( { msg: "点击了红按钮", }, "*" ); }); this.greenButton.addEventListener("click", (ev) => { this.iframe.postMessage( { msg: "点击了绿按钮", }, "*" ); }); } } ``` -------------------------------- ### getOption()方法 Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取某个设置项的值。paths参数为设置项的路径表达,支持字符串或字符串数组。 ```typescript /** * 获取某个设置项的值 * @param paths 设置项的路径表达 * @returns 该设置项的值 */ getOption(paths: string | string[]): any ``` -------------------------------- ### SQL 语句传参后实际执行语句(以李四为例) Source: https://www.shanhaibi.com/docs/v1/eiitft 当大屏传参为 name: 李四, start, end, name_like: %三, type: 1 时,实际执行的 SQL 如下: ```sql select * from user where name = '李四' ``` ```sql select * from user where time>1634428800 and time<1637116392 ``` ```sql select * from user where name like '%三' and type=1 ``` -------------------------------- ### 获取服务器端口号 Source: https://www.shanhaibi.com/docs/v1/pdaf4qdgkc1sv6eu 查看 nohup.out 日志文件以获取服务器端口号。 ```bash cat nohup.out ``` -------------------------------- ### 触发和取消单个字段的数据联动(applyLinkage / withdrawLinkage) Source: https://www.shanhaibi.com/docs/v1/bs6qnxudp34frgq7 在按钮的 mounted 事件中监听点击,第一次点击调用 applyLinkage 传入单个字段(name: "地区", value: "华北")触发数据筛选联动,第二次点击调用 withdrawLinkage 取消联动。需要将代码挂载到按钮上,并打开按钮的数据联动功能和表格的被联动开关。 ```javascript class ButtonSample { setting = Field.default({ maxFields: 3, //最多能放几个字段 }); #linkageApplied = false; mounted() { this.element.addEventListener("click", () => { if (!this.#linkageApplied) { //点一次触发数据筛选联动 //name填入字段的名称 //value填入筛选的目标值 this.element.applyLinkage({ name: "地区", value: "华北", }); } else { //再点一次取消数据筛选联动 this.element.withdrawLinkage(); } this.#linkageApplied = !this.#linkageApplied; }); } } export default ButtonSample; ``` -------------------------------- ### API 连接 URL 使用项目参数:http://192.167.2.127:65535/v1/app/.../?type={:city} Source: https://www.shanhaibi.com/docs/v1/kkzp9pm4ifpwxyr2 在 API 连接中,将项目参数填入 URL 的查询字符串中,示例为 GET 请求的 URL,其中 {:city} 会被替换为项目参数 city 的值。 ```http http://192.167.2.127:65535/v1/app/86be13eb-55b3-4e41-a3f8-17590f3803bb/e75443f2/?type={:city} ``` -------------------------------- ### pm.variables: read accessToken and set time Source: https://www.shanhaibi.com/docs/v1/zmzxpvkrkzmh Example combining pm.variables.get and pm.variables.set: reads the accessToken variable and stores the current timestamp in the time variable. Use this pattern for variables used in API parameters, headers, or request bodies. ```javascript var accessToken = pm.variables.get("accessToken"); pm.variables.set("time", Date.now()); ``` -------------------------------- ### getOption() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取组件的设置项。 ```APIDOC ## getOption() ### Description 获取组件的设置项。 ### Method function ### Endpoint getOption(paths: string | string[]): any ### Parameters #### Path Parameters - **paths** (string | string[]) - Required - 设置项的路径表达 ### Request Example ```typescript /** * 获取某个设置项的值 * @param paths 设置项的路径表达 * @returns 该设置项的值 */ getOption(paths: string | string[]): any ``` ### Response #### Success Response - **any** - 该设置项的值 #### Response Example ```typescript any ``` ``` -------------------------------- ### 数据库 SQL 语句使用项目参数:select * from `student` where `sex`='{:sex}'; Source: https://www.shanhaibi.com/docs/v1/kkzp9pm4ifpwxyr2 在数据库 SQL 语句中使用项目参数,示例为查询 student 表中性别等于参数 sex 的数据。注意 SQL 语句中的参数只是替换,因此需要引号的地方还是需要把引号写出来。 ```sql select * from `student` where `sex`='{:sex}'; ``` -------------------------------- ### getMountedInstance() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取组件暴露的 instance 对象。通过该对象可实现一些高级功能。 ```APIDOC ## getMountedInstance() ### Description 获取组件暴露的 instance 对象。通过该对象可实现一些高级功能。 ### Method getMountedInstance() ### Signature ```typescript getMountedInstance(): any ``` ### Returns - **any** - 返回组件暴露的对象,未暴露时返回空对象 ``` -------------------------------- ### 触发和取消多个字段的数据联动(applyLinkage 数组参数) Source: https://www.shanhaibi.com/docs/v1/bs6qnxudp34frgq7 在按钮的 mounted 事件中监听点击,第一次点击调用 applyLinkage 传入包含多个字段条件的数组(地区=华北、销售员=张伟)触发数据筛选联动,第二次点击调用 withdrawLinkage 取消联动。需要将代码挂载到按钮上,并打开按钮的数据联动功能和表格的被联动开关。 ```javascript class ButtonSample { setting = Field.default({ maxFields: 3, //最多能放几个字段 }); #linkageApplied = false; mounted() { this.element.addEventListener("click", () => { if (!this.#linkageApplied) { //name填入字段的名称 //value填入筛选的目标值 this.element.applyLinkage([ { name: "地区", value: "华北", }, { name: "销售员", value: "张伟", }, ]); } else { this.element.withdrawLinkage(); } this.#linkageApplied = !this.#linkageApplied; }); } } export default ButtonSample; ``` -------------------------------- ### setOption()方法 Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 修改某个设置项的值。paths参数为设置项的路径表达,value为要设置的值。 ```typescript /** * 修改某个设置项的值 * @param paths 设置项的路径表达 * @param value 设置项的值 */ setOption(paths: string | string[], value: any): void ``` -------------------------------- ### whenMounted(): Promise - 等待组件挂载完成 Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 等待组件挂载完成,防止过早执行逻辑导致报错。返回一个 Promise,在组件挂载完成后 resolve。 ```typescript /** * 等待当前宿主挂载完成 */ whenMounted(): Promise ``` -------------------------------- ### getMountedInstance(): any - 获取组件暴露的 instance 对象 Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取组件暴露的 instance 对象,通过该对象可实现高级功能。未暴露时返回空对象。ECharts 图表组件暴露了 ECharts 实例对象。 ```typescript /** * 获取组件暴露的instance对象。 * @returns 返回组件暴露的对象,未暴露时返回空对象 */ getMountedInstance(): any ``` -------------------------------- ### whenMounted() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 等待组件挂载完成,防止过早执行逻辑导致报错。 ```APIDOC ## whenMounted() ### Description 等待组件挂载完成,防止过早执行逻辑导致报错。 ### Method whenMounted() ### Signature ```typescript whenMounted(): Promise ``` ### Returns - **Promise** - 等待当前宿主挂载完成 ``` -------------------------------- ### setOption() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 修改组件的设置项。 ```APIDOC ## setOption() ### Description 修改组件的设置项。 ### Method function ### Endpoint setOption(paths: string | string[], value: any): void ### Parameters #### Path Parameters - **paths** (string | string[]) - Required - 设置项的路径表达 - **value** (any) - Required - 设置项的值 ### Request Example ```typescript /** * 修改某个设置项的值 * @param paths 设置项的路径表达 * @param value 设置项的值 */ setOption(paths: string | string[], value: any): void ``` ### Response #### Success Response 无返回值 #### Response Example ```typescript void ``` ``` -------------------------------- ### Project 类 Source: https://www.shanhaibi.com/docs/v1/ab3ctf1zf6mxy3wd Project 类提供对当前项目的访问,包括项目名称的读取和项目参数的获取与设置。 ```APIDOC ## Project 类 ### Description Project 对象对应当前的项目,通过此对象可以获取项目名称、项目参数、修改项目参数等。Project 对象由系统创建并绑定,用户无需构造,直接通过 this.project 即可获取。 ### 属性 #### name - 类型: string - 只读 - 描述: 项目名称。 ### 方法 #### getVariable(key: string): string - 描述: 获取项目参数。 - 参数: - key (string) - 变量名 - 返回值: string - 变量值 #### setVariable(key: string, val: string): void - 描述: 设置项目参数。 - 参数: - key (string) - 变量名 - val (string) - 变量值 - 返回值: void ### 示例 ```javascript class Button { mounted() { console.log(this.project.name); } } export default Button; ``` ``` -------------------------------- ### 修改监听端口配置 Source: https://www.shanhaibi.com/docs/v1/ulubtrghlun8wfdq 在 config.json 文件中写入此内容以修改监听端口。 ```json {"listen":端口号} ``` -------------------------------- ### POST /api/v1/project/add Source: https://www.shanhaibi.com/docs/v1/ch6gtt3l544k6aig 项目管理接口,用于创建新项目。 ```APIDOC ## POST /api/v1/project/add ### Description 项目管理接口,用于创建新项目。 ### Method POST ### Endpoint /api/v1/project/add ### Parameters #### Request Body - **name** (string) - Required - 新项目名称 - **parentId** (string) - Optional - 项目文件夹 id,可留空 ``` -------------------------------- ### 组件自动向右移动的二次开发示例 Source: https://www.shanhaibi.com/docs/v1/cpgtegynwgi3fpgp 二次开发示例:组件自动在大屏上向右移动。通过 getOption 获取当前位置,再使用 setOption 更新 X 轴坐标(每次加 1 并取模 100)。 ```javascript /** * Extension.prototype.element; * Extension.prototype.enabled; * Extension.findExtensionsOfClass(className) * Element.prototype.setOption() * Element.prototype.getOption() * Element.prototype.getFullData() * Element.prototype.name */ class Button{ update(){ const position = this.element.getOption( ["position"] ); // 当前元素在X轴上移动一定的距离 this.element.setOption( ["position"], [(position[0] + 1 )%100,position[1]] ); } } export default Button; ``` -------------------------------- ### 设置可执行权限 Source: https://www.shanhaibi.com/docs/v1/pdaf4qdgkc1sv6eu 为山海鲸可视化无桌面系统版的可执行文件设置可执行权限。 ```bash chmod +x ./shanhaibi ``` -------------------------------- ### 基础代码模板(生命周期函数) Source: https://www.shanhaibi.com/docs/v1/lpm4t547so6rp0vs 系统自动创建的基础代码模板,包含四个生命周期函数:mounted、ready、update、destroy。注意格式要求:export 后面必须跟 default。 ```javascript class Demo { // 组件开发教程 https://www.shanhaibi.com/docs/v1/lpm4t547so6rp0vs/ // 更多设置项请看教程 https://www.shanhaibi.com/docs/v1/lsr5n1dmndqtxwgm/ /** * 生命周期函数 组件开始载入 */ mounted() { } /** * 生命周期函数 当前二开所处看板加载完成 */ ready() { } /** * 生命周期函数 会在ready()后启用 * 启用后每帧调用,性能消耗较多,建议隔一段时间触发以及只做一些轻量操作 */ update() { } /** * 生命周期函数 组件销毁时调用,一般在此处清空监听事件 */ destroy() { }}export default Demo; ``` -------------------------------- ### 二次开发:组件自动向右移动(JavaScript 脚本) Source: https://www.shanhaibi.com/docs/v1/aamkrdy096o6demi 二次开发示例:让组件自动在大屏上向右移动。通过 this.element.getOption(["position"]) 获取当前位置,再用 this.element.setOption(["position"], ...) 设置新位置,使 X 坐标每次增加 1 并取模 100。需要将脚本保存为 JavaScript 文件后,在组件的“代码”设置窗口中点击“选择文件”载入。 ```javascript /** * Extension.prototype.element; * Extension.prototype.enabled; * Extension.findExtensionsOfClass(className) * Element.prototype.setOption() * Element.prototype.getOption() * Element.prototype.getFullData() * Element.prototype.name */ class Button{ update(){ const position = this.element.getOption( ["position"] ); // 当前元素在X轴上移动一定的距离 this.element.setOption( ["position"], [(position[0] + 1 )%100,position[1]] ); } } export default Button; ``` -------------------------------- ### applySelection() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 触发选中。 ```APIDOC ## applySelection() ### Description 触发选中。 ### Method function ### Endpoint applySelection({ key: string, value: any }): void ### Parameters #### Path Parameters - **key** (string) - Required - 选中键 - **value** (any) - Required - 选中值 ### Request Example ```typescript /** * 触发选中 * @param key 选中键 * @param value 选中值 */ applySelection({ key: string, value: any }): void ``` ### Response #### Success Response 无返回值 #### Response Example ```typescript void ``` ``` -------------------------------- ### 执行 SQL 语句查询学生成绩 Source: https://www.shanhaibi.com/docs/v1/vy4hnt 在 MySQL 数据库的 SQLConsole 中执行此 SQL 语句,从 test 数据库的 student、course 和 score 表中筛选出学生姓名、课程和成绩。注意:此处的 SQL 语句与山海鲸可视化软件中的略有不同,需要在表名称前面增加数据库名称(此处为 test)。 ```sql SELECT student.name as 姓名, course.name as 课程, score as 成绩 FROM test.student, test.score, test.course WHERE student.id = score.sid and course.id = score.cid; ``` -------------------------------- ### 二开代码中获取项目参数值 Source: https://www.shanhaibi.com/docs/v1/kkzp9pm4ifpwxyr2 在二开代码中获取项目参数的值。在按钮的点击事件中,通过 this.project.getVariable("city") 获取项目参数 city 的值,并打印到控制台。 ```javascript class Button { init() { // 按钮点击后修改项目参数city为成都 this.element.addEventListener("click", (ev) => { console.log( "当前的项目参数city的值是:" + this.project.getVariable("city") ); }); } } export default Button; ``` -------------------------------- ### 动态修改山海鲸组件设置:通过 postMessage 发送 setOption Source: https://www.shanhaibi.com/docs/v1/oymtalfycysxrbdn 在网页中嵌入山海鲸组件 iframe,并通过 postMessage 发送 setOption 动作来动态修改组件设置(如切换白天/晚上)。需要提前获取目标元素的 elementUID 和 optionPath,可通过点击元素后在右侧面板的更多选项卡中查看 elementUID,以及通过调用代码示例获取 getOption 或 setOption 的第一个参数作为 optionPath。 ```html
``` -------------------------------- ### 监听组件自带数据字段变化 (option-changed) Source: https://www.shanhaibi.com/docs/v1/bs6qnxudp34frgq7 监听组件自带的数据字段的变化。通过监听 Element 类上的 option-changed 事件,并使用 Paths.equals 判断 paths 是否为目标值。出于性能优化考量,必须先读取一次该属性(getOption)才能监听到变化事件。 ```javascript class TableSample { mounted() { //出于性能优化考量,必须先读取一次该属性,才能监听到这个属性的变化事件 const fields = this.element.getOption(["axis-fields"]); this.element.addEventListener("option-changed", async (ev) => { const paths = ev.paths; //如果有多个属性被监听,则需要判断一下paths是否为目标值 if (Paths.equals(paths, ["axis-fields"])) { const data = await this.element.readDataAsync(["axis-fields"], { dataFormat: "object", }); console.log(data); } }); } } export default TableSample; ``` -------------------------------- ### 基础 3D 玫瑰图组件二次开发:移动位置脚本 Source: https://www.shanhaibi.com/docs/v1/by4aoz3ma5on4ud1 该示例展示基础 3D 玫瑰图组件的二次开发方法,通过在 update 方法中调用 element.getOption 获取位置并调用 setOption 实现自动向右移动。分组时移除了源内容中的无关空行和注释说明。 ```javascript class Button{ update(){ const position = this.element.getOption( ["position"] ); // 当前元素在X轴上移动一定的距离 this.element.setOption( ["position"], [(position[0] + 1 )%100,position[1]] ); } } export default Button; ``` -------------------------------- ### applyLinkage() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 触发数据联动。 ```APIDOC ## applyLinkage() ### Description 触发数据联动。 ### Method function ### Endpoint applyLinkage(linkage: {name: string, value: any} | {name: string, value: any}[]): void ### Parameters #### Path Parameters - **linkage** ({name: string, value: any} | {name: string, value: any}[]) - Required - 联动条件 ### Request Example ```typescript /** * 触发联动 * @param linkage 联动条件 */ applyLinkage(linkage: {name: string, value: any} | {name: string, value: any}[]): void ``` ### Response #### Success Response 无返回值 #### Response Example ```typescript void ``` ``` -------------------------------- ### POST /api/v1/project/copy Source: https://www.shanhaibi.com/docs/v1/ch6gtt3l544k6aig 项目管理接口,用于复制项目。 ```APIDOC ## POST /api/v1/project/copy ### Description 项目管理接口,用于复制项目。 ### Method POST ### Endpoint /api/v1/project/copy ### Parameters #### Request Body - **id** (string) - Required - 被复制的项目 ID - **parentId** (string) - Optional - 复制到的项目文件夹 id,可留空 ``` -------------------------------- ### SQL 语句不传参数时的默认执行语句 Source: https://www.shanhaibi.com/docs/v1/eiitft 当大屏不传参数时,山海鲸会使用默认值,将 SQL 语句中的参数和默认值部分替换为实际值,得到实际执行的 SQL 语句。 ```sql select * from user where name = '张三' ``` ```sql select * from user where time>0 and time<1623772800 ``` ```sql select * from user where name like '张%' and type=3 ``` -------------------------------- ### project Source: https://www.shanhaibi.com/docs/v1/tubwz902xymv1g7a 此 Extension 所属的项目。 ```APIDOC ## project ### Description 此 Extension 所属的项目。 ### Type Project ### Example readonly project: Project 参考Project 类。 ``` -------------------------------- ### 二次开发示例:组件自动向右移动(JavaScript) Source: https://www.shanhaibi.com/docs/v1/au5gxm1n8b773ypx 该示例代码展示了如何通过二次开发让组件自动在大屏上向右移动。代码中使用了Extension和Element的API,如getOption和setOption来修改组件的位置。此代码需要作为JavaScript脚本文件载入,并通过点击“选择文件”添加。 ```javascript /** * Extension.prototype.element; * Extension.prototype.enabled; * Extension.findExtensionsOfClass(className) * Element.prototype.setOption() * Element.prototype.getOption() * Element.prototype.getFullData() * Element.prototype.name */ class Button{ update(){ const position = this.element.getOption( ["position"] ); // 当前元素在X轴上移动一定的距离 this.element.setOption( ["position"], [(position[0] + 1 )%100,position[1]] ); } } export default Button; ``` -------------------------------- ### getExtensionInstance() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取当前元素的所有扩展的第一个实例,从 v4.2.0 开始支持。 ```APIDOC ## getExtensionInstance() ### Description 获取当前元素的所有扩展的第一个实例,从 v4.2.0 开始支持。 ### Method getExtensionInstance() ### Signature ```typescript getExtensionInstance(): Object ``` ### Returns - **Object** - 所有扩展的第一个实例 ``` -------------------------------- ### getExtensionInstances() Source: https://www.shanhaibi.com/docs/v1/lvvsdz58obwbxqtn 获取当前元素的所有扩展的实例列表,从 v4.2.0 开始支持。 ```APIDOC ## getExtensionInstances() ### Description 获取当前元素的所有扩展的实例列表,从 v4.2.0 开始支持。 ### Method getExtensionInstances() ### Signature ```typescript getExtensionInstances(): Array ``` ### Returns - **Array** - 所有扩展的实例列表 ``` -------------------------------- ### POST /api/v1/login Source: https://www.shanhaibi.com/docs/v1/ch6gtt3l544k6aig 授权登录接口,用于获取 accessToken,后续请求需在 Header 中添加 authorization 项,内容为 Bearer accessToken。 ```APIDOC ## POST /api/v1/login ### Description 授权登录接口,用于获取 accessToken,后续请求需在 Header 中添加 authorization 项,内容为 Bearer accessToken。 ### Method POST ### Endpoint /api/v1/login ### Parameters #### Request Body - **username** (string) - Required - 子账号名称(注意是 SaaS 的子账号) - **password** (string) - Required - 子账号密码 ### Response #### Success Response (200) - **account** (object) - 账号信息 - **user** (object) - 用户信息 - **accessToken** (string) - 访问令牌,后续请求需在 Header 中添加 authorization 项,内容为 Bearer accessToken #### Response Example { "account": { "id": "vxuc3g6ac9btj7xu0mwb", "user": "test", "nickName": "test", "avatar": "", "createTime": 1695016819752, "updateTime": 1695016819752, "loginTime": 1702970396022, "disabled": false }, "user": { "id": 1054647, "nickname": "", "loginName": "XXX@shanhaibi.com", "key": "123456AAA-MzUxZjk0YW", "keyAlias": null, "secret": "U1ODk5MGJkYjNkNz-123456AAA351f9", "money": null, "sessionId": "ShanhaiBI_1702954207876", "sessions": { "ShanhaiBI_1701844282735": { "clientIdentifier": "DESKTOP-38F8R7H-105481.70757788072", "lastVersion": "4.1.1-beta.5 win32", "loginTime": 1701844277 } }, "present": 0, "phone": "", "noPassword": false, "coin": 0, "onlineLimit": 11, "state": "none", "saas": true, "saasSeats": 5, "timeSaasEnd": 1734576606, "time_pay": 0, "coupons": [], "projectQuota": 500, "startTime": 0, "endTime": 0, "portrait": "", "author": 2 }, "accessToken": "此处返回的内容为token" } ```