Angela Access Points
Angela 对外部暴露了许多 Access Points,以便通过外部脚本拓展 Angela。
Access Point 是暴露在 window
对象上的函数。对于 Access Point getUser
,可以通过 window.getUser()
来调用。
Access Points 可以是全局的或是局部的:
- 全局的 Access Points 在每个页面上都可用
- 局部的 Access Points 仅在特定视图中可用,如帮助文档
全局 Access Points
navigate
导航到指定的应用内路径
function navigate(path: string): Promise<void>;
watchNavigation
返回一个 Observable
,在每次应用内导航完成后输出导航后的路径:
function watchNavigation(): Observable<string>;
queryAuthToken
返回一个 Observable
,当订阅时:
- 如果用户已登入,会立即输出用户的认证 token
- 如果用户未登入,会立即输出
null
用户登入状态发生变化时,会输出新的值。
用户的认证 token 可用于调用 v2board 受保护的 API。
function queryAuthToken(): Observable<string | null>;
queryUser
返回一个 Observable
,当订阅时:
- 如果用户已登入,会立即输出用户信息
- 如果用户未登入,会等待用户登入后输出用户信息
用户信息发生变化时,会输出新的值。
function queryUser(): Observable<User>;
interface User {
id: string;
email: string;
avatarUrl?: string;
planId?: Plan['id'];
planExpireAt?: Date;
trafficTotal: number;
trafficUploaded: number;
trafficDownloaded: number;
trafficResetAt?: Date;
subscriptionUrl: string;
balance: number;
commission: number;
commissionInProgress: number;
commissionTotal: number;
commissionRate: number;
referralSuccessCount: number;
receiveExpiryReminder: boolean;
receiveTrafficReminder: boolean;
createdAt: Date;
}
queryUserPlan
返回一个 Observable
,当订阅时:
- 如果用户已登入,会立即输出用户的订阅计划信息
- 如果用户未登入,会立即输出
null
用户或订阅计划信息发生变化时,会输出新的值。
function queryUserPlan(): Observable<Plan | null>;
export interface Plan {
id: string;
name: string;
description: string | PlanFeature[] | null;
prices: {
[PlanListing.UnlimitedLicense]: number | null;
[PlanListing.OneMonthLicense]: number | null;
[PlanListing.OneQuarterLicense]: number | null;
[PlanListing.HalfYearLicense]: number | null;
[PlanListing.OneYearLicense]: number | null;
[PlanListing.TwoYearLicense]: number | null;
[PlanListing.ThreeYearLicense]: number | null;
[PlanListing.TrafficSupplement]: number | null;
};
traffic: number;
trafficResetType?: PlanTrafficResetType;
selling: boolean;
order: number;
createdAt: Date;
updatedAt: Date;
}
export interface PlanFeature {
text: string;
supported: boolean;
}
export enum PlanTrafficResetType {
Never = 'Never',
Monthly = 'Monthly',
MonthlyFirstDay = 'MonthlyFirstDay',
Yearly = 'Yearly',
YearlyFirstDay = 'YearlyFirstDay',
}
export enum PlanListing {
UnlimitedLicense = 'UnlimitedLicense',
OneMonthLicense = 'OneMonthLicense',
OneQuarterLicense = 'OneQuarterLicense',
HalfYearLicense = 'HalfYearLicense',
OneYearLicense = 'OneYearLicense',
TwoYearLicense = 'TwoYearLicense',
ThreeYearLicense = 'ThreeYearLicense',
TrafficSupplement = 'TrafficSupplement',
}
watchCommands
返回一个 Observable
,Angela 内部触发 Command 时会输出该 Command 对象。
function watchCommands(): Observable<object>;
watchEvents
返回一个 Observable
,Angela 内部触发 Event 时会输出该 Event 对象。
function watchEvents(): Observable<object>;
readCommandMetadata
接受一个 Command 对象,返回该 Command 对象的元数据。
function readCommandMetadata(command: object): object;
readEventMetadata
接受一个 Event 对象,返回该 Event 对象的元数据。
function readEventMetadata(event: object): object;
帮助文档 Access Points
copy
复制文本到剪贴板并提示。
function copy(text: string): void;
jump
跳转到指定 id 的帮助文档
function jump(id: string): void;
showSubscriptionDetail
显示订阅详情对话框
function showSubscriptionDetail(): void;
installSubscription
导入订阅到指定代理客户端并提示。
function installSubscription(name: string): void;
你可以在
settings.yaml 中的proxyClients
字段中找到代理客户端的name
。