chore: 迁移topic到单独插件上

pull/56/head
moonrailgun 3 years ago
parent efa3f3634c
commit db4930e36d

@ -3,7 +3,7 @@ import { run } from '../app';
export const appCommand: CommandModule = {
command: 'app',
describe: 'Tailchat cli 版本',
describe: 'Tailchat cli 版本(WIP)',
builder: undefined,
async handler() {
await run();

@ -8,5 +8,7 @@
"private": true,
"scripts": {},
"devDependencies": {},
"dependencies": {}
"dependencies": {
"tailchat-server-sdk": "*"
}
}

@ -2,7 +2,9 @@ import { TcService, TcDbService } from 'tailchat-server-sdk';
import type { {{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model } from '../models/{{pickPluginName id}}';
/**
*
* {{name}}
*
* {{desc}}
*/
interface {{pickPluginNameUp id}}Service
extends TcService,

@ -8,5 +8,7 @@
"private": true,
"scripts": {},
"devDependencies": {},
"dependencies": {}
"dependencies": {
"tailchat-server-sdk": "*"
}
}

@ -2,7 +2,7 @@ import { TcService, TcDbService } from 'tailchat-server-sdk';
import type { {{pickPluginNameUp id}}Document, {{pickPluginNameUp id}}Model } from '../models/{{pickPluginName id}}';
/**
*
* {{desc}}
*/
interface {{pickPluginNameUp id}}Service
extends TcService,

@ -837,6 +837,22 @@ importers:
server/plugins/com.msgbyte.tasks/web/plugins/com.msgbyte.tasks:
specifiers: {}
server/plugins/com.msgbyte.topic:
specifiers:
lodash: ^4.17.21
nanoid: ^3.1.23
tailchat-server-sdk: '*'
dependencies:
lodash: 4.17.21
nanoid: 3.3.4
tailchat-server-sdk: link:../../packages/sdk
server/plugins/com.msgbyte.topic/web/plugins/com.msgbyte.topic:
specifiers:
react: 17.0.2
devDependencies:
react: 17.0.2
website:
specifiers:
'@docusaurus/core': 2.0.0-beta.18

@ -1,6 +1,6 @@
{
"name": "tailchat-server-sdk",
"version": "0.0.12",
"version": "0.0.14",
"description": "",
"main": "dist/index.js",
"bin": {

@ -4,13 +4,8 @@ export enum GroupPanelType {
PLUGIN = 2,
}
export interface GroupPanelMeta {
/**
*
* topic
*/
variant?: 'topic';
}
// TODO
export type GroupPanelMeta = {};
interface GroupMemberStruct {
roles?: string[]; // 角色

@ -1,14 +1,7 @@
import {
getModelForClass,
DocumentType,
Ref,
prop,
} from '@typegoose/typegoose';
import { Base, TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
import { db } from 'tailchat-server-sdk';
const { getModelForClass, prop, TimeStamps } = db;
import type { Types } from 'mongoose';
import { nanoid } from 'nanoid';
import { User } from '../user/user';
import { Group } from './group';
class GroupTopicComment {
@prop({
@ -19,8 +12,8 @@ class GroupTopicComment {
@prop()
content: string;
@prop({ ref: () => User })
author: Ref<User>;
@prop()
author: string;
/**
* id
@ -29,18 +22,18 @@ class GroupTopicComment {
replyCommentId?: string;
}
export class GroupTopic extends TimeStamps implements Base {
export class GroupTopic extends TimeStamps implements db.Base {
_id: Types.ObjectId;
id: string;
@prop()
content: string;
@prop({ ref: () => User })
author: Ref<User>;
@prop()
author: string;
@prop({ ref: () => Group })
groupId: Ref<Group>;
@prop()
groupId: string;
/**
* id
@ -55,7 +48,7 @@ export class GroupTopic extends TimeStamps implements Base {
comment: GroupTopicComment[];
}
export type GroupTopicDocument = DocumentType<GroupTopic>;
export type GroupTopicDocument = db.DocumentType<GroupTopic>;
const model = getModelForClass(GroupTopic);

@ -0,0 +1,15 @@
{
"name": "tailchat-plugin-topic",
"version": "1.0.0",
"main": "index.js",
"author": "moonrailgun",
"description": "为群组提供话题功能",
"license": "MIT",
"private": true,
"scripts": {},
"dependencies": {
"lodash": "^4.17.21",
"nanoid": "^3.1.23",
"tailchat-server-sdk": "*"
}
}

@ -1,27 +1,28 @@
import type {
GroupTopicDocument,
GroupTopicModel,
} from '../../../models/group/topic';
import _ from 'lodash';
import {
TcService,
TcDbService,
TcContext,
call,
GroupPanelType,
db,
call,
} from 'tailchat-server-sdk';
import { Types } from 'mongoose';
import _ from 'lodash';
import type { GroupTopicDocument, GroupTopicModel } from '../models/topic';
const { Types } = db;
/**
*
*/
interface GroupTopicService
extends TcService,
TcDbService<GroupTopicDocument, GroupTopicModel> {}
class GroupTopicService extends TcService {
get serviceName(): string {
return 'group.topic';
return 'plugin:com.msgbyte.topic';
}
onInit(): void {
this.registerLocalDb(require('../../../models/group/topic').default);
this.registerLocalDb(require('../models/topic').default);
this.registerAction('create', this.create, {
params: {

@ -0,0 +1,9 @@
{
"label": "群组话题",
"name": "com.msgbyte.topic",
"url": "{BACKEND}/plugins/com.msgbyte.topic/index.js",
"version": "0.0.0",
"author": "moonrailgun",
"description": "为群组提供话题功能",
"requireRestart": true
}

@ -0,0 +1,11 @@
{
"name": "@plugins/com.msgbyte.topic",
"main": "src/index.tsx",
"version": "0.0.0",
"description": "为群组提供话题功能",
"private": true,
"dependencies": {},
"devDependencies": {
"react": "17.0.2"
}
}

@ -0,0 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"jsx": "react",
"importsNotUsedAsValues": "error"
}
}

@ -0,0 +1,2 @@
declare module '@capital/common';
declare module '@capital/component';
Loading…
Cancel
Save