mirror of https://github.com/msgbyte/tailchat
feat: 增加插件安装方法到window对象
parent
02095aa628
commit
65d1e916f8
@ -0,0 +1,15 @@
|
|||||||
|
type TailchatTypeMap = NonNullable<typeof window.tailchat>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入tailchat全局变量到window
|
||||||
|
*/
|
||||||
|
export function injectTailchatGlobalValue<T extends keyof TailchatTypeMap>(
|
||||||
|
key: T,
|
||||||
|
value: TailchatTypeMap[T]
|
||||||
|
) {
|
||||||
|
if (!window.tailchat) {
|
||||||
|
window.tailchat = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
window.tailchat[key] = value;
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Copy from `tailchat/client/shared/model/plugin.ts`
|
||||||
|
*/
|
||||||
|
interface PluginManifest {
|
||||||
|
/**
|
||||||
|
* 插件用于显示的名称
|
||||||
|
* @example 网页面板插件
|
||||||
|
*/
|
||||||
|
label: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件名, 插件唯一标识
|
||||||
|
* @example com.msgbyte.webview
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件地址
|
||||||
|
*/
|
||||||
|
url: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件图标
|
||||||
|
* 推荐大小: 128x128
|
||||||
|
*/
|
||||||
|
icon?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件版本号
|
||||||
|
* 遵循 semver 规则
|
||||||
|
*
|
||||||
|
* major.minor.patch
|
||||||
|
* @example 1.0.0
|
||||||
|
*/
|
||||||
|
version: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件维护者
|
||||||
|
*/
|
||||||
|
author: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插件描述
|
||||||
|
*/
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需要重启才能应用插件
|
||||||
|
*/
|
||||||
|
requireRestart: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文档的链接
|
||||||
|
* 如果是markdown则解析, 如果是html则使用iframe
|
||||||
|
*/
|
||||||
|
documentUrl?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface Window {
|
||||||
|
tailchat?: {
|
||||||
|
installPlugin?: (manifest: PluginManifest) => Promise<void>;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue