ONES开放平台插件生命周期有哪些?

提供文档和介绍生命周期

阅读 264
1 个回答
✓ 已被采纳

image.png

使用生命周期方法

生命周期方法声明在插件工程的/backend/src/index.ts文件中,每个插件工程在初始化时,会预先生成生命周期函数的模版。
文档地址:https://developer.ones.cn/zh-CN/docs/guide/advanced/lifecycle

// Method called when the team level plugin is being installed.
export async function Install(request: PluginRequest) {
  Logger.info('[Plugin] Install')
}

// Method called when the team level plugin is being launched.
export async function Enable(request: PluginRequest) {
  Logger.info('[Plugin] Enable')
}

// Method called when the team level plugin is being suspended.
export function Disable(request: PluginRequest) {
  Logger.info('[Plugin] Disable')
}

// Method called when the team level plugin is being uninstalled.
export function UnInstall(request: PluginRequest) {
  Logger.info('[Plugin] UnInstall')
}

// Method called when the team level plugin is being upgraded.
export function Upgrade(oldPluginInfo: any, request: PluginRequest) {
  const oldVersion = oldPluginInfo.version
  Logger.info('[Plugin] Upgrade', 'old version:', oldVersion)
}

// Method called when the organization level plugin is being installed.
export async function OrgInstall(
  request: PluginRequest,
  teamUUIDList: string[],
  firstInstall: boolean,
) {
  Logger.info('[Plugin] OrgInstall')
}

// Method called when the organization level plugin is being launched.
export function OrgEnable(
  request: PluginRequest,
  teamUUIDList: string[],
): void | string[] | Promise<string[]> {
  Logger.info('[Plugin] OrgEnable')
  return []
}

// Method called when the organization level plugin is being suspended.
export function OrgDisable(
  request: PluginRequest,
  teamUUIDList: string[],
): void | string[] | Promise<string[]> {
  Logger.info('[Plugin] OrgDisable')
  return []
}

// Method called when the organization level plugin is being uninstalled.
export function OrgUnInstall(request: PluginRequest, teamUUIDList: string[]) {
  Logger.info('[Plugin] OrgUnInstall')
}

// Method called when the organization level plugin is being upgraded.
export function OrgUpgrade(oldPluginInfo: any, request: PluginRequest, teamUUIDList: string[]) {
  Logger.info('[Plugin] OrgUpgrade')
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
项目管理
子站问答
访问
宣传栏