45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import { defineAsyncComponent } from 'vue';
|
|
import { innerRoutes, privateRoutes } from './routes';
|
|
import { FG_Plugin } from 'src/plugins';
|
|
|
|
interface EventNotification extends FG_Plugin.Notification {
|
|
data: { type: NotificationType };
|
|
}
|
|
|
|
enum NotificationType {
|
|
REQUEST = 0x10,
|
|
ACCEPTED = 0x11,
|
|
REJECTED = 0x12,
|
|
}
|
|
|
|
function transpile(n: FG.Notification) {
|
|
const notification = <EventNotification>Object.assign({}, n);
|
|
if (notification.data.type === NotificationType.REQUEST)
|
|
notification.accept = () =>
|
|
new Promise((r) => {
|
|
console.log('REQUEST ACCEPTED');
|
|
r();
|
|
});
|
|
return notification;
|
|
}
|
|
|
|
const plugin: FG_Plugin.Plugin = {
|
|
name: 'events',
|
|
innerRoutes,
|
|
internalRoutes: privateRoutes,
|
|
requiredModules: ['User'],
|
|
requiredBackendModules: ['events'],
|
|
version: '0.0.2',
|
|
notification: transpile,
|
|
widgets: [
|
|
{
|
|
priority: 0,
|
|
name: 'stats',
|
|
permissions: [],
|
|
widget: defineAsyncComponent(() => import('./components/Widget.vue')),
|
|
},
|
|
],
|
|
};
|
|
|
|
export default plugin;
|