0.1.5 • Published 1 year ago

@belloai/check-plugin-version v0.1.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

检查 bello 插件版本弹出框

内置了 XiaobeiVersion 工具,提供了基础弹出框的方法 CreateDialog、judgeVersionUpdated,如有定制需要,请引用 CreateDialog 并继承,自己重写 getContentDom 方法即可

基础使用方式

import XiaobeiVersion from '@belloai/check-plugin-version'

// XiaobeiVersion(arg0: versionConfig, arg1: Config[可配置内容见 Config 参数], arg2: 注入的元素dom  )

new XiaobeiVersion(
  {
    latest: '5.0.520',
    least: '5.0.206'
  },
  {
    extension: {
      download_page: '' //插件下载页地址
    },
    web: {
      login_logo_uri:
        'https://assets.belloai.com/staging/config/login_logo.png', // 显示在弹框内的logo 的 url
      update_title: '安装插件,即刻开启AI招聘功能,实现降本增效', // 显示在弹框内的升级标题信息
      theme_color: 'black', // 弹框主题色
      features: ['吃饭', '睡觉', '打豆豆'] // 弹框内的提示文案
    }
  },
  this.$refs.xxx || document.body
)

config 参数

有值信息的为默认值

export interface DomSetting {
  dialog?: SettingItem
  modal?: SettingItem
  close?: SettingItem
  content?: {
    logo?: SettingItem
    title?: SettingItem
    features?: SettingItem
    featuresTitle?: SettingItem
    featureItem?: SettingItem
    updateBtn?: SettingItem
  }
}

export interface SettingItem {
  style?: Attributes // style关键字,挂载到style内
  text?: string // dom的内容部分
  [key: string]: any // 其他的attr,任意添加
}

interface Config {
  // UI部分
  width: number = 468
  visible: boolean = true
  showClose: boolean = true // 是否显示弹框的关闭按钮
  closeOnClickModal: boolean = false // 点击遮罩层是否可以关闭弹框
  content: HTMLElement = document.body
  status: 'update' | 'uninstall' = 'update'

  domSetting: DomSetting // 制定自己的样式
  // 信息部分
  notice_timing: string = 'unInstall,update' // unInstall 对应未安装提醒, update 对应升级提醒, 使用逗号分隔如只需要未安装功能,请传递 'unInstall'
  web: {
    login_logo_uri: string = 'https://assets.belloai.com/staging/config/login_logo.png'
    update_title: string = '安装插件,即刻开启AI招聘功能,实现降本增效'
    theme_color: string = '#5a66ff'
    features: Array<string> = []
    button_color: string = '#5a66ff'
    feature_title: string = '安装后可享用'
  }
  extension: {
    download_page: string = 'https://www.belloai.com/download'
  }
}

示例化后的方法

interface PluginInfo {
  xclientId: string
  version: string
  token: string
}

// 'least' -> 强制更新 | 'latest' -> 软更新 | 'uninstall' -> 未安装
class XiaobeiVersion {
  hasPlugin: Boolean,
  dialog: CreateDialog,
  pluginInfo: PluginInfo | null
  version: Version | null
  status: 'least' | 'latest' | 'uninstall'
  fetchXClientVersion() {
    // 搭配 window.postMessage 使用,
    // 发送 window.postMessage({ type: 'osr_inited' }, '*'),等待插件返回 插件查询信息 { type: 'bl_plugin_inited', data: PluginInfo }
  }
  checkVersion() {
    // 检查当前版本信息 和插件做对比,如果有差异就会立刻弹出弹框
  }
  destroy() {
    // 销毁事件
  }
}
0.1.5

1 year ago

0.1.4

1 year ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago