From c52d99a4b69c1445e23d2d33deada68593846867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Wed, 28 Feb 2024 22:39:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webview/src/apps/pages.ts | 6 +++ webview/src/apps/profile/create.html | 59 ++++++++++++++++++++++++++++ webview/src/apps/profile/create.scss | 0 webview/src/apps/profile/create.ts | 58 +++++++++++++++++++++++++++ webview/src/apps/profile/list.html | 4 ++ webview/src/apps/profile/list.ts | 12 +++--- 6 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 webview/src/apps/profile/create.html create mode 100644 webview/src/apps/profile/create.scss create mode 100644 webview/src/apps/profile/create.ts diff --git a/webview/src/apps/pages.ts b/webview/src/apps/pages.ts index fa041ee2..21ba665f 100644 --- a/webview/src/apps/pages.ts +++ b/webview/src/apps/pages.ts @@ -4,6 +4,7 @@ import { WelcomeComponent } from './welcome'; import { Alert404Component } from './alert/404'; import { ChatroomListComponent } from './chatroom/list'; +import { ChatroomCreateComponent } from './chatroom/create'; import { LLModelCreateComponent } from './llmodel/create'; import { LLModelListComponent } from './llmodel/list'; @@ -12,6 +13,7 @@ import { KeywordListComponent } from './keyword/list'; import { KeywordCreateComponent } from './keyword/create'; import { ProfileListComponent } from './profile/list'; +import { ProfileCreateComponent } from './profile/create'; import { WcferryChatroomComponent } from './wcferry/chatroom'; import { WcferryContactComponent } from './wcferry/contact'; @@ -23,6 +25,7 @@ export const AppComponents = [ Alert404Component, ChatroomListComponent, + ChatroomCreateComponent, LLModelCreateComponent, LLModelListComponent, @@ -31,6 +34,7 @@ export const AppComponents = [ KeywordCreateComponent, ProfileListComponent, + ProfileCreateComponent, WcferryChatroomComponent, WcferryContactComponent, @@ -45,6 +49,7 @@ export const AppRoutes: Routes = [ { path: 'welcome', component: WelcomeComponent }, { path: 'chatroom/list', component: ChatroomListComponent, canActivate: [LoginGuard] }, + { path: 'chatroom/create', component: ChatroomCreateComponent, canActivate: [LoginGuard] }, { path: 'llmodel/create', component: LLModelCreateComponent, canActivate: [LoginGuard] }, { path: 'llmodel/list', component: LLModelListComponent, canActivate: [LoginGuard] }, @@ -53,6 +58,7 @@ export const AppRoutes: Routes = [ { path: 'keyword/create', component: KeywordCreateComponent, canActivate: [LoginGuard] }, { path: 'profile/list', component: ProfileListComponent, canActivate: [LoginGuard] }, + { path: 'profile/create', component: ProfileCreateComponent, canActivate: [LoginGuard] }, { path: 'wcferry/chatroom', component: WcferryChatroomComponent, canActivate: [LoginGuard] }, { path: 'wcferry/contact', component: WcferryContactComponent, canActivate: [LoginGuard] }, diff --git a/webview/src/apps/profile/create.html b/webview/src/apps/profile/create.html new file mode 100644 index 00000000..4e55b255 --- /dev/null +++ b/webview/src/apps/profile/create.html @@ -0,0 +1,59 @@ + + + + +
+
+
+ + +
+ 用户所属类别,暂用作生效范围 +
+
+
+ + +
+ 用于违规检测,暂不支持统配符 +
+
+
+ + +
+ 机器人使用权限 +
+
+
+ + +
+ 备注信息 +
+
+
+ +
+
+
\ No newline at end of file diff --git a/webview/src/apps/profile/create.scss b/webview/src/apps/profile/create.scss new file mode 100644 index 00000000..e69de29b diff --git a/webview/src/apps/profile/create.ts b/webview/src/apps/profile/create.ts new file mode 100644 index 00000000..93941cc8 --- /dev/null +++ b/webview/src/apps/profile/create.ts @@ -0,0 +1,58 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; + +import { RobotApi, ProfileCreateParam } from '../../openapi/wrobot'; +import { WrestApi, WcfrestContactPayload } from '../../openapi/wcfrest'; + + +@Component({ + selector: 'page-profile-create', + templateUrl: 'create.html', + styleUrls: ['create.scss'] +}) +export class ProfileCreateComponent { + + public conacts: Array = []; + public friends: Array = []; + public chatrooms: Array = []; + + public formdata = {} as ProfileCreateParam; + + constructor(private router: Router) { + this.getChatrooms(); + this.getFriends(); + } + + public createProfile() { + RobotApi.profileCreate(this.formdata).then(() => { + this.router.navigate(['profile/list']); + }); + } + + public changeRoomid() { + if (this.formdata.roomid == '-') { + this.conacts = this.friends; + } else { + this.getRoomMembers(this.formdata.roomid); + } + } + + public getFriends() { + WrestApi.friends().then((data) => { + this.friends = data || []; + }); + } + + public getChatrooms() { + WrestApi.chatrooms().then((data) => { + this.chatrooms = data || []; + }); + } + + public getRoomMembers(id: string) { + WrestApi.chatroomMembers({ roomid: id }).then((data) => { + this.conacts = data || []; + }); + } + +} diff --git a/webview/src/apps/profile/list.html b/webview/src/apps/profile/list.html index 8d867f59..cc09e74d 100644 --- a/webview/src/apps/profile/list.html +++ b/webview/src/apps/profile/list.html @@ -8,6 +8,10 @@
+
+ +
+ diff --git a/webview/src/apps/profile/list.ts b/webview/src/apps/profile/list.ts index 78ab6c3c..f55cf22e 100644 --- a/webview/src/apps/profile/list.ts +++ b/webview/src/apps/profile/list.ts @@ -27,12 +27,6 @@ export class ProfileListComponent { this.timestamp = new Date().getTime(); } - public getContacts() { - WrestApi.contacts().then((data) => { - data.forEach((item) => this.contacts[item.wxid] = item); - }); - } - public getProfiles() { const rq = {} as ProfileFetchAllParam; RobotApi.profileList(rq).then((data) => { @@ -49,6 +43,12 @@ export class ProfileListComponent { }); } + public getContacts() { + WrestApi.contacts().then((data) => { + data.forEach((item) => this.contacts[item.wxid] = item); + }); + } + public getRoomMembers(ids: string[]) { [...new Set(ids)].forEach((id) => { if (id === '-' || this.roomMembers[id]) {