From c65e0fcb0b239028335b08f2402327d7e0405370 Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Tue, 7 Mar 2023 12:18:55 +0800 Subject: [PATCH] feat: star-motivation standalone component --- .../chat-robot.component.scss | 2 +- .../chat-robot.component.ts | 24 ++++++---- .../modules/chat-robot/chat-robot.service.ts | 5 ++- .../star-motivation.component.ts | 44 +++++++++++++++++++ .../common/about.component.scss | 13 ------ .../system-setting/common/about.component.ts | 21 +++------ .../system-setting/system-setting.module.ts | 13 +++++- .../chatgpt-robot.component.scss | 14 ------ .../chatgpt-robot/chatgpt-robot.component.ts | 28 +++++------- .../browser/src/app/pages/pages.module.ts | 22 +++------- .../browser/src/app/shared/shared.module.ts | 2 +- 11 files changed, 102 insertions(+), 86 deletions(-) create mode 100644 src/workbench/browser/src/app/modules/star-motivation/star-motivation.component.ts delete mode 100644 src/workbench/browser/src/app/modules/system-setting/common/about.component.scss diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss index 515defcd..a87d917a 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss @@ -3,7 +3,7 @@ flex-direction: column; background-color: var(--background-color); width: 500px; - height: 500px; + height: 50%; border-radius: 6px; box-shadow: 0 0 10px var(--shadow-color); } diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts index cdff6f8b..a4d96f8a 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts @@ -2,20 +2,19 @@ * API Design reference: https://github.dev/akveo/nebular/blob/master/src/playground/with-layout/chat/chat.module.ts * Component Document:https://akveo.github.io/nebular/docs/components/chat-ui/overview/#nbchatcomponent */ -import { Component, ContentChildren, Input, QueryList } from '@angular/core'; +import { Component, ContentChildren, Input, QueryList, TemplateRef } from '@angular/core'; import { ChatRobotMessageComponent } from '../chat-robot-message/chat-robot-message.component'; +import { ChatRobotService } from '../chat-robot.service'; @Component({ selector: 'pc-chat-robot', template: ` -
+
{{ title }} - +
@@ -23,7 +22,9 @@ import { ChatRobotMessageComponent } from '../chat-robot-message/chat-robot-mess
-

Power by APISpace

+

Power by {{ powerBy.title }}

`, styleUrls: ['./chat-robot.component.scss'] @@ -31,4 +32,11 @@ import { ChatRobotMessageComponent } from '../chat-robot-message/chat-robot-mess export class ChatRobotComponent { @Input() title: string; @ContentChildren(ChatRobotMessageComponent) messages: QueryList; + + @Input() powerBy: { title: string; link: string }; + + constructor(private chat: ChatRobotService) {} + closeRobot() { + this.chat.close(); + } } diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts index 12279ad6..c863a043 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts @@ -4,11 +4,14 @@ import { Injectable } from '@angular/core'; providedIn: 'root' }) export class ChatRobotService { - isShow: boolean = false; + isShow: boolean = true; constructor() {} open() { this.isShow = true; } + close() { + this.isShow = false; + } toggleShowStatus() { this.isShow = !this.isShow; } diff --git a/src/workbench/browser/src/app/modules/star-motivation/star-motivation.component.ts b/src/workbench/browser/src/app/modules/star-motivation/star-motivation.component.ts new file mode 100644 index 00000000..56f6f452 --- /dev/null +++ b/src/workbench/browser/src/app/modules/star-motivation/star-motivation.component.ts @@ -0,0 +1,44 @@ +import { Component, Input } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; + +@Component({ + selector: 'pc-star-motivation', + template: `

+ Hi!~ If you like {{ subject }}, please give the Postcat a Star!
Your support is our greatest motivation~ +

+ + + +
`, + standalone: true, + imports: [SharedModule], + styles: [ + ` + .favor-image-link { + background-color: #eee; + border-radius: 50%; + padding: 13px; + } + + .favor-image { + transition: all 0.3s; + } + .favor-image:hover { + transform: scale(1.2); + } + ` + ] +}) +export class StarMotivationComponent { + @Input() subject: string = 'Postcat'; +} diff --git a/src/workbench/browser/src/app/modules/system-setting/common/about.component.scss b/src/workbench/browser/src/app/modules/system-setting/common/about.component.scss deleted file mode 100644 index 32508195..00000000 --- a/src/workbench/browser/src/app/modules/system-setting/common/about.component.scss +++ /dev/null @@ -1,13 +0,0 @@ -.favor-image { - transition: all 0.3s; - - &:hover { - transform: scale(1.2); - } -} - -.favor-image-link { - background-color: #eee; - border-radius: 50%; - padding: 13px; -} diff --git a/src/workbench/browser/src/app/modules/system-setting/common/about.component.ts b/src/workbench/browser/src/app/modules/system-setting/common/about.component.ts index 2ee60232..09284f0c 100644 --- a/src/workbench/browser/src/app/modules/system-setting/common/about.component.ts +++ b/src/workbench/browser/src/app/modules/system-setting/common/about.component.ts @@ -8,7 +8,7 @@ import { WebService } from '../../../core/services';

Postcat

V{{ versionInfo?.version }}

- + -

- Hi!~ If you like Postcat, please give the Postcat a Star!
Your support is our greatest motivation~ -

- - - + + +

{{ item.label }}: {{ item.value }}

- `, - styleUrls: ['./about.component.scss'] + ` }) export class AboutComponent implements OnInit { list; diff --git a/src/workbench/browser/src/app/modules/system-setting/system-setting.module.ts b/src/workbench/browser/src/app/modules/system-setting/system-setting.module.ts index 690cc24c..7e2cacf1 100644 --- a/src/workbench/browser/src/app/modules/system-setting/system-setting.module.ts +++ b/src/workbench/browser/src/app/modules/system-setting/system-setting.module.ts @@ -11,6 +11,7 @@ import { NzTreeViewModule } from 'ng-zorro-antd/tree-view'; import { EoSettingModule } from '../eo-ui/setting/setting.module'; import { LogoModule } from '../logo/logo.module'; +import { StarMotivationComponent } from '../star-motivation/star-motivation.component'; import { AboutComponent, DataStorageComponent, LanguageSwticherComponent, TokenComponent } from './common'; import { AccountComponent } from './common/account.component'; import { SelectThemeComponent } from './common/select-theme/select-theme.component'; @@ -27,7 +28,17 @@ const ANTDMODULES = [NzDividerModule, NzInputNumberModule, NzEmptyModule, NzDesc LanguageSwticherComponent, AboutComponent ], - imports: [EoSettingModule, LogoModule, FormsModule, EoNgTabsModule, ReactiveFormsModule, SharedModule, CommonModule, ...ANTDMODULES], + imports: [ + EoSettingModule, + StarMotivationComponent, + LogoModule, + FormsModule, + EoNgTabsModule, + ReactiveFormsModule, + SharedModule, + CommonModule, + ...ANTDMODULES + ], exports: [SystemSettingComponent] }) export class SystemSettingModule {} diff --git a/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss index a844805d..e5095fb2 100644 --- a/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss +++ b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss @@ -4,17 +4,3 @@ bottom: 25px; z-index: 10; } - -.favor-image-link { - background-color: #eee; - border-radius: 50%; - padding: 13px; -} - -.favor-image { - transition: all 0.3s; - - &:hover { - transform: scale(1.2); - } -} diff --git a/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts index 15321835..6e3cb4cb 100644 --- a/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts +++ b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts @@ -1,7 +1,11 @@ +import { CommonModule } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; +import { ChatRobotModule } from '../../../modules/chat-robot/chat-robot.module'; import { ChatRobotService } from '../../../modules/chat-robot/chat-robot.service'; +import { StarMotivationComponent } from '../../../modules/star-motivation/star-motivation.component'; +import { TraceService } from '../../../shared/services/trace.service'; type messageItem = { text: string; @@ -16,8 +20,10 @@ type messageItem = { @Component({ selector: 'pc-chatgpt-robot', + standalone: true, + imports: [StarMotivationComponent, CommonModule, ChatRobotModule], template: ` - + -
-

- Hi!~ If you like ChatGPT Extensions, please give the Postcat a Star!
Your support is our greatest motivation~ -

- - - -
+