From 78786640f464f7370c14aaf14bb224c61a29ae03 Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Mon, 6 Mar 2023 09:55:07 +0800 Subject: [PATCH 1/6] feat: chat robot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 85b30b632..a2db47e6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcat", - "version": "0.3.1", + "version": "0.3.2", "main": "out/app/electron-main/main.js", "description": "A lightweight, extensible API tool", "homepage": "https://github.com/Postcatlab/postcat.git", From eb79143e6cfac257d2f263143a6eb3681a6324d4 Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Mon, 6 Mar 2023 18:56:32 +0800 Subject: [PATCH 2/6] wip: chat modal --- CHANGELOG.md | 51 +++++++ .../feature-control.service.ts | 2 + .../services/feature-control/feature.json | 3 +- .../app/layouts/sidebar/sidebar.service.ts | 2 +- .../layouts/toolbar/toolbar.component.html | 15 ++- .../app/layouts/toolbar/toolbar.component.ts | 15 +-- .../chat-robot.component.scss | 30 +++++ .../chat-robot.component.ts | 34 +++++ .../chat-robot-form.component.ts | 39 ++++++ .../chat-robot-message.component.scss | 33 +++++ .../chat-robot-message.component.ts | 53 ++++++++ .../modules/chat-robot/chat-robot.module.ts | 19 +++ .../modules/chat-robot/chat-robot.service.ts | 15 +++ .../chatgpt-robot.component.scss | 20 +++ .../chatgpt-robot/chatgpt-robot.component.ts | 124 ++++++++++++++++++ .../src/app/pages/pages.component.html | 3 + .../browser/src/app/pages/pages.module.ts | 14 +- 17 files changed, 457 insertions(+), 15 deletions(-) create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot.module.ts create mode 100644 src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts create mode 100644 src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss create mode 100644 src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a12d5c8..108e05d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,54 @@ +## [0.3.2](https://github.com/Postcatlab/postcat/compare/v0.2.1...v0.3.2) (2023-03-06) + + +### Bug Fixes + +* APISpace jump to detail page error ([e06e200](https://github.com/Postcatlab/postcat/commit/e06e200b8dc749fecb71320df6972c9a5eb13292)) +* env parameters error ([9cc5513](https://github.com/Postcatlab/postcat/commit/9cc55134e363107cf9029d3b8f1ab64493e1c986)) +* extension detail settings style ([d377eea](https://github.com/Postcatlab/postcat/commit/d377eead9a0cf13b4c45caf57ef4eb1b3f302c9e)) +* extension detail skeleton not show ([2059912](https://github.com/Postcatlab/postcat/commit/2059912f63677fce97fc8d190737faf1b78762d4)) +* fix some e2e test ([31eb8f6](https://github.com/Postcatlab/postcat/commit/31eb8f6df1459ede787f37a80b09da135b47e11e)) +* gio bind userID ([0b0ef7d](https://github.com/Postcatlab/postcat/commit/0b0ef7d22e48327df35024f335247d7429772507)) +* gio bind userID ([441322f](https://github.com/Postcatlab/postcat/commit/441322f63ee8fbc8362d75bd38b0e36c5845c256)) +* gio install extension error ([c2c87fc](https://github.com/Postcatlab/postcat/commit/c2c87fc0be7084472323c70b79f9db207181b308)) +* **i18n:** change language error ([fc65a5e](https://github.com/Postcatlab/postcat/commit/fc65a5e639161394dafbed6468649fd69ce89c15)) +* import api env validate ([d6595ec](https://github.com/Postcatlab/postcat/commit/d6595ecd518719fdb64cecfea9a7fb2777bf4e9b)) +* installed list is empty ([3ff219e](https://github.com/Postcatlab/postcat/commit/3ff219e14587f87fa395fdcbf599f62a5636b2f5)) +* installed list may be empty ([e744cbf](https://github.com/Postcatlab/postcat/commit/e744cbf71e9f10fafdea8681d87e92670ed20c36)) +* member avatar be extrusion ([11bc7ba](https://github.com/Postcatlab/postcat/commit/11bc7bab6cf47ae736414181571c8e53d2310cbe)) +* mock match bug ([7f062d4](https://github.com/Postcatlab/postcat/commit/7f062d46a3306469b79d01213e5af8cb100d613a)) +* npm install error in windows os ([8fa1b3d](https://github.com/Postcatlab/postcat/commit/8fa1b3da02d183f6332b4273eb20aa22bb0e72da)) +* register_success event error ([b5288f9](https://github.com/Postcatlab/postcat/commit/b5288f96d781916e34ee2fdcdea949f9ebc7cf4b)) +* show nps after view init ([5357d6d](https://github.com/Postcatlab/postcat/commit/5357d6d5e14950af9d8e1917a8c005c87de5c2dd)) +* sync-api not reactive ([df24b5d](https://github.com/Postcatlab/postcat/commit/df24b5d1541d218dc291f175136ef0e2fd292ac1)) + + +### Features + +* action watch ([#237](https://github.com/Postcatlab/postcat/issues/237)) ([fcd09fa](https://github.com/Postcatlab/postcat/commit/fcd09fa688dda07defa6391077cadcee749255fa)) +* add comment ([831b4bc](https://github.com/Postcatlab/postcat/commit/831b4bce2b731f9c80f6b329ad3f4472655e94da)) +* add trace about client_type & app_language ([4bd7ea2](https://github.com/Postcatlab/postcat/commit/4bd7ea2ad25722ca0a00dc0db9b4ba61bc2c1bfc)) +* API Authorization ([938ec7d](https://github.com/Postcatlab/postcat/commit/938ec7d68270c2be4c17cd2e1098377f2db180d2)) +* change description ([0341ba8](https://github.com/Postcatlab/postcat/commit/0341ba8f423cd6554fc83c50bf477dd9d1b36a9c)) +* change github project url ([42c801c](https://github.com/Postcatlab/postcat/commit/42c801c49cbd859c876e9aafc2d4bae8fb38b9b6)) +* chat robot ([7878664](https://github.com/Postcatlab/postcat/commit/78786640f464f7370c14aaf14bb224c61a29ae03)) +* delete useless code ([a558094](https://github.com/Postcatlab/postcat/commit/a55809494695b1cdcb44009ca55213ca2fc2a570)) +* delete useless log ([d878582](https://github.com/Postcatlab/postcat/commit/d87858232292f61f89e1412b259dc27b5e644a79)) +* nps ([426a08f](https://github.com/Postcatlab/postcat/commit/426a08ff1af75d401a8358dae1940f4cfd8f3268)) +* replace reg ([263cb4f](https://github.com/Postcatlab/postcat/commit/263cb4f0d10da3c7cb7ff1bc367541ce159397e8)) +* replace setFeedURL url ([4303743](https://github.com/Postcatlab/postcat/commit/43037434ac28bd4b43614f22017faf8e2a39ee2a)) +* set registry automaic ([8f64179](https://github.com/Postcatlab/postcat/commit/8f641799d63f77193cea31c2920d590c09f4aaa7)) +* sync and save by one step ([70a01fa](https://github.com/Postcatlab/postcat/commit/70a01fae0193ca180ff27a5ac666667da43f4d29)) +* translate ([f445a80](https://github.com/Postcatlab/postcat/commit/f445a806da92b9eb0181b51f3f007251612f12a3)) +* translate error ([8d5e5f3](https://github.com/Postcatlab/postcat/commit/8d5e5f3bbdb871e31d541fe6890f631e305c240b)) + + +### Performance Improvements + +* optimize old code ([4001bef](https://github.com/Postcatlab/postcat/commit/4001bef79a0274f8861b4299330ebb153b93f468)) + + + ## [0.2.1](https://github.com/Postcatlab/postcat/compare/v0.2.0...v0.2.1) (2023-02-09) diff --git a/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts b/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts index e53d9e55d..0675ec2d8 100644 --- a/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts +++ b/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts @@ -10,4 +10,6 @@ export class FeatureControlService { constructor() { this.config = featureJSON; } + openFearure() {} + closeFeature() {} } diff --git a/src/workbench/browser/src/app/core/services/feature-control/feature.json b/src/workbench/browser/src/app/core/services/feature-control/feature.json index 41a3753e8..00d15bb44 100644 --- a/src/workbench/browser/src/app/core/services/feature-control/feature.json +++ b/src/workbench/browser/src/app/core/services/feature-control/feature.json @@ -3,5 +3,6 @@ "apimanage.test": true, "apimanage.document": true, "apimanage.edit": true, - "apimanage.mock": true + "apimanage.mock": true, + "chatRobot": true } diff --git a/src/workbench/browser/src/app/layouts/sidebar/sidebar.service.ts b/src/workbench/browser/src/app/layouts/sidebar/sidebar.service.ts index 375e5fd3f..55cb7daac 100644 --- a/src/workbench/browser/src/app/layouts/sidebar/sidebar.service.ts +++ b/src/workbench/browser/src/app/layouts/sidebar/sidebar.service.ts @@ -14,7 +14,7 @@ export class SidebarService { currentID: string = StorageUtil.get(this.selectKey); private collapsedChanged$: Subject = new Subject(); constructor(private setting: SettingService) { - this.collapsed = this.setting.get('workbench.sidebar.shrink') || false; + this.collapsed = this.setting.get('workbench.sidebar.shrink'); } getCollapsed() { return this.collapsed; diff --git a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html index f44f7c69e..2eb19390b 100644 --- a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html +++ b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html @@ -1,4 +1,4 @@ -
+
+
+ +
diff --git a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.ts b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.ts index 21fbc9338..785bb601f 100644 --- a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.ts +++ b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; +import { ChatRobotService } from '../../modules/chat-robot/chat-robot.service'; import { SystemSettingComponent } from '../../modules/system-setting/system-setting.component'; import { ModalService } from '../../shared/services/modal.service'; import { SidebarService } from '../sidebar/sidebar.service'; @@ -12,19 +13,10 @@ import { SidebarService } from '../sidebar/sidebar.service'; styleUrls: ['./toolbar.component.scss'] }) export class ToolbarComponent implements OnDestroy { - sideBarCollapsed: boolean; hideSidebar = $localize`Hide Sidebar`; showSidebar = $localize`Show Sidebar`; private destroy$: Subject = new Subject(); - constructor(public sidebar: SidebarService, private modal: ModalService) { - this.sideBarCollapsed = this.sidebar.getCollapsed(); - this.sidebar - .onCollapsedChanged() - .pipe(takeUntil(this.destroy$)) - .subscribe(isCollapsed => { - this.sideBarCollapsed = isCollapsed; - }); - } + constructor(public sidebar: SidebarService, private modal: ModalService, private chat: ChatRobotService) {} toggleCollapsed() { this.sidebar.toggleCollapsed(); } @@ -39,6 +31,9 @@ export class ToolbarComponent implements OnDestroy { withoutFooter: true }); } + openRobot() { + this.chat.open(); + } ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); 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 new file mode 100644 index 000000000..515defcd0 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.scss @@ -0,0 +1,30 @@ +:host { + display: flex; + flex-direction: column; + background-color: var(--background-color); + width: 500px; + height: 500px; + border-radius: 6px; + box-shadow: 0 0 10px var(--shadow-color); +} + +.header, +.messages, +.form { + padding: 15px 20px; +} + +.header, +.messages { + border-bottom: 1px solid var(--system-border-color); +} + +.header { + font-weight: bold; + font-size: 15px; +} + +.messages { + overflow-y: auto; + overflow-x: hidden; +} 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 new file mode 100644 index 000000000..cdff6f8b4 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts @@ -0,0 +1,34 @@ +/** + * 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 { ChatRobotMessageComponent } from '../chat-robot-message/chat-robot-message.component'; + +@Component({ + selector: 'pc-chat-robot', + template: ` +
+ {{ title }} + +
+
+ +

+
+
+ +

Power by APISpace

+
+ `, + styleUrls: ['./chat-robot.component.scss'] +}) +export class ChatRobotComponent { + @Input() title: string; + @ContentChildren(ChatRobotMessageComponent) messages: QueryList; +} diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts new file mode 100644 index 000000000..1313d4831 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts @@ -0,0 +1,39 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +@Component({ + selector: 'pc-chat-robot-form', + template: `
+ + +
`, + styles: [] +}) +export class ChatRobotFormComponent { + /** + * Predefined message text + * + * @type {string} + */ + @Input() message: string = ''; + @Input() placeholder: string = ''; + + /** + * Send message triggle event + */ + @Output() readonly send = new EventEmitter<{ message: string }>(); + sendMessage() { + console.log(this.message); + if (!String(this.message).trim().length) return; + this.send.emit({ message: this.message }); + this.message = ''; + } +} diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss new file mode 100644 index 000000000..2dcbb7f13 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss @@ -0,0 +1,33 @@ +:host { + display: flex; + margin-bottom: 1.5rem; + + .message-content { + padding: 1rem; + border-radius: 0.5rem; + } + + &.not-reply { + flex-direction: row-reverse; + + .message-content { + background: var(--item-hover-background-color); + color: var(--text-color); + } + + nz-avatar { + margin-left: 5px; + } + } + + &.reply { + .message-content { + background: #36f; + color: #fff; + } + + nz-avatar { + margin-right: 5px; + } + } +} diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts new file mode 100644 index 000000000..dd2a620e1 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts @@ -0,0 +1,53 @@ +import { Component, HostBinding, Input, TemplateRef } from '@angular/core'; + +@Component({ + selector: 'pc-chat-robot-message', + template: ` + +
+

+ {{ sender }} + {{ date | date }} +

+
+ +

{{ message }}

+
+
+ `, + styleUrls: ['./chat-robot-message.component.scss'] +}) +export class ChatRobotMessageComponent { + /** + * Message sender + */ + @Input() sender: string; + + /** + * Message sender + */ + @Input() message: string; + + /** + * Message send date + */ + @Input() date: Date; + + /** + * Message send avatar + */ + @Input() avatar: string; + + /** + * Determines if a message is a reply + */ + @Input() + @HostBinding('class.reply') + reply: boolean; + + @HostBinding('class.not-reply') + get notReply() { + return !this.reply; + } + @Input() messageContent: TemplateRef; +} diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot.module.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot.module.ts new file mode 100644 index 000000000..e1fdaaeb1 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot.module.ts @@ -0,0 +1,19 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { EoNgButtonModule } from 'eo-ng-button'; +import { EoNgInputModule } from 'eo-ng-input'; +import { NzAvatarModule } from 'ng-zorro-antd/avatar'; + +import { EoIconparkIconModule } from '../eo-ui/iconpark-icon/eo-iconpark-icon.module'; +import { ChatRobotComponent } from './chat-robot-container/chat-robot.component'; +import { ChatRobotFormComponent } from './chat-robot-form/chat-robot-form.component'; +import { ChatRobotMessageComponent } from './chat-robot-message/chat-robot-message.component'; +import { ChatRobotService } from './chat-robot.service'; +@NgModule({ + declarations: [ChatRobotComponent, ChatRobotMessageComponent, ChatRobotFormComponent], + providers: [ChatRobotService], + imports: [CommonModule, EoNgInputModule, EoIconparkIconModule, NzAvatarModule, EoNgButtonModule, FormsModule], + exports: [ChatRobotComponent, ChatRobotMessageComponent, ChatRobotFormComponent] +}) +export class ChatRobotModule {} 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 new file mode 100644 index 000000000..12279ad62 --- /dev/null +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot.service.ts @@ -0,0 +1,15 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class ChatRobotService { + isShow: boolean = false; + constructor() {} + open() { + this.isShow = true; + } + toggleShowStatus() { + this.isShow = !this.isShow; + } +} 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 new file mode 100644 index 000000000..a844805d0 --- /dev/null +++ b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.scss @@ -0,0 +1,20 @@ +:host { + position: absolute; + right: 25px; + 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 new file mode 100644 index 000000000..153218359 --- /dev/null +++ b/src/workbench/browser/src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts @@ -0,0 +1,124 @@ +import { HttpClient } from '@angular/common/http'; +import { Component, OnInit } from '@angular/core'; + +import { ChatRobotService } from '../../../modules/chat-robot/chat-robot.service'; + +type messageItem = { + text: string; + date: Date; + reply: boolean; + type: string; + user: { + name: string; + avatar: string; + }; +}; + +@Component({ + selector: 'pc-chatgpt-robot', + template: ` + + + +
+

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

+ + + +
+
+
+ + +
+ `, + styleUrls: ['./chatgpt-robot.component.scss'] +}) +export class ChatgptRobotComponent implements OnInit { + title = $localize`ChatGPT Robot`; + initMessage = { + date: new Date(), + reply: true, + type: 'init', + user: { + name: 'Postcat', + avatar: './assets/images/logo.svg' + } + }; + messages: messageItem[] = []; + constructor(private http: HttpClient, public chat: ChatRobotService) {} + ngOnInit() { + this.messages.push( + { + text: 'test im user', + date: new Date(), + reply: false, + type: 'text', + user: { + name: 'Visitor', + avatar: 'https://data.eolink.com/PXMbLGmc2f0b29596764f7456eefb75478ed77b4fd172d9' + } + }, + { + text: `I'm sorry, I cannot respond to this as it is not a coherent sentence or request. Please provide a valid question or statement.`, + date: new Date(), + reply: true, + type: 'text', + user: { + name: 'ChatGPT', + avatar: 'https://data-apibee.apispace.com/license/167773762614902e10710-8d88-4d7e-b962-2df477b361ec' + } + } + ); + } + sendChatGPTMessage($event) { + this.http + .post( + 'https://eolink.o.apispace.com/chatgpt-turbo/create', + {}, + { + headers: { + 'Authorization-Type': 'apikey', + 'X-APISpace-Token': '' + } + } + ) + .subscribe((res: any) => { + console.log(res); + }); + } + sendMessage($event) { + this.messages.push({ + text: $event.message, + date: new Date(), + reply: false, + type: 'text', + user: { + name: 'Visitor', + avatar: 'https://data.eolink.com/PXMbLGmc2f0b29596764f7456eefb75478ed77b4fd172d9' + } + }); + } +} diff --git a/src/workbench/browser/src/app/pages/pages.component.html b/src/workbench/browser/src/app/pages/pages.component.html index 7fe3a09dd..1fbac22b7 100644 --- a/src/workbench/browser/src/app/pages/pages.component.html +++ b/src/workbench/browser/src/app/pages/pages.component.html @@ -19,7 +19,10 @@
+ + +

We use cookies

diff --git a/src/workbench/browser/src/app/pages/pages.module.ts b/src/workbench/browser/src/app/pages/pages.module.ts index 7c762e3a6..4b9efb583 100644 --- a/src/workbench/browser/src/app/pages/pages.module.ts +++ b/src/workbench/browser/src/app/pages/pages.module.ts @@ -6,9 +6,11 @@ import { LocalWorkspaceTipComponent } from '../layouts/local-workspace-tip/local import { NavbarModule } from '../layouts/navbar/navbar.module'; import { SidebarComponent } from '../layouts/sidebar/sidebar.component'; import { ToolbarModule } from '../layouts/toolbar/toolbar.module'; +import { ChatRobotModule } from '../modules/chat-robot/chat-robot.module'; import { NpsMaskModule } from '../modules/nps-mask/nps-mask.module'; import { SystemSettingModule } from '../modules/system-setting/system-setting.module'; import { SharedModule } from '../shared/shared.module'; +import { ChatgptRobotComponent } from './components/chatgpt-robot/chatgpt-robot.component'; import { ThirdLoginComponent } from './components/third-login/third-login.component'; import { UserModalComponent } from './components/user-modal/user-modal.component'; import { PagesRoutingModule } from './pages-routing.module'; @@ -23,9 +25,17 @@ import { PagesComponent } from './pages.component'; CommonModule, NavbarModule, ToolbarModule, - SharedModule + SharedModule, + ChatRobotModule + ], + declarations: [ + PagesComponent, + SidebarComponent, + LocalWorkspaceTipComponent, + UserModalComponent, + ThirdLoginComponent, + ChatgptRobotComponent ], - declarations: [PagesComponent, SidebarComponent, LocalWorkspaceTipComponent, UserModalComponent, ThirdLoginComponent], exports: [], providers: [], schemas: [] 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 3/6] 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 515defcd0..a87d917ae 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 cdff6f8b4..a4d96f8a4 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 12279ad62..c863a0430 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 000000000..56f6f4527 --- /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 325081950..000000000 --- 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 2ee602321..09284f0c1 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 690cc24ca..7e2cacf19 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 a844805d0..e5095fb2d 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 153218359..6e3cb4cbc 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~ -

- - - -
+
Date: Tue, 7 Mar 2023 16:07:04 +0800 Subject: [PATCH 4/6] wip: add feature show --- src/app/electron-main/updater.ts | 4 +-- src/environment.ts | 9 ++++- src/platform/node/extension-manager/core.ts | 4 +-- .../node/extension-manager/manager.ts | 4 +-- .../src/app/core/services/web/web.service.ts | 2 +- .../app/layouts/navbar/navbar.component.html | 2 +- .../app/layouts/navbar/navbar.component.ts | 2 ++ .../share-navbar/share-navbar.component.ts | 4 ++- .../star-motivation.component.ts | 5 ++- .../system-setting/common/about.component.ts | 5 +-- .../chatgpt-robot/chatgpt-robot.component.ts | 9 ++++- .../detail/extension-detail.component.html | 6 +++- .../detail/extension-detail.component.ts | 12 +++---- .../shared/models/extension-manager/module.ts | 1 + .../extensions/extension-store.service.ts | 33 +++++++++++++++++-- .../services/extensions/extension.service.ts | 26 ++++----------- .../extensions/webExtension.service.ts | 33 ++++++++----------- .../{common.ts => common.constant.ts} | 6 ++-- .../src/environments/environment.dev.ts | 2 +- .../src/environments/environment.prod.ts | 2 +- .../browser/src/environments/environment.ts | 4 +-- 21 files changed, 105 insertions(+), 70 deletions(-) rename src/workbench/browser/src/environments/{common.ts => common.constant.ts} (65%) diff --git a/src/app/electron-main/updater.ts b/src/app/electron-main/updater.ts index ee0bd6914..81a8a2218 100644 --- a/src/app/electron-main/updater.ts +++ b/src/app/electron-main/updater.ts @@ -2,7 +2,7 @@ import log from 'electron-log'; import { autoUpdater } from 'electron-updater'; -import { ELETRON_APP_CONFIG } from '../../environment'; +import { COMMON_APP_CONFIG } from '../../environment'; const appVersion = require('../../../package.json').version; @@ -11,7 +11,7 @@ export class EoUpdater { this.watchLog(); autoUpdater.setFeedURL({ provider: 'generic', - url: ELETRON_APP_CONFIG.BASE_DOWNLOAD_URL + url: COMMON_APP_CONFIG.BASE_DOWNLOAD_URL }); // 是否自动更新 // autoUpdater.autoDownload = window.pc.getExtensionSettings('common.app.autoUpdate') !== false; diff --git a/src/environment.ts b/src/environment.ts index fd6c32a57..055211864 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -1,10 +1,17 @@ -export const ELETRON_APP_CONFIG = { +const variables = { + GITHUB_ORANIZATION_NAME: 'postcatlab', + GITHUB_PROJECT_NAME: 'postcat' +}; +export const COMMON_APP_CONFIG = { // EXTENSION_URL: 'http://localhost:5000', EXTENSION_URL: 'https://extensions.postcat.com', REMOTE_SOCKET_URL: 'wss://postcat.com', // SOCKET_PORT: '', // MOCK_URL: 'http://8.219.85.124:5000', NODE_SERVER_PORT: 4201, + GITHUB_ORANIZATION_NAME: variables.GITHUB_ORANIZATION_NAME, + GITHUB_PROJECT_NAME: variables.GITHUB_PROJECT_NAME, + GITHUB_REPO_URL: `https://github.com/${variables.GITHUB_ORANIZATION_NAME}/${variables.GITHUB_PROJECT_NAME}`, BASE_DOWNLOAD_URL: 'https://data.postcat.com/download/' // BASE_DOWNLOAD_URL: 'http://127.0.0.1:8080' } as const; diff --git a/src/platform/node/extension-manager/core.ts b/src/platform/node/extension-manager/core.ts index d332ce2c1..f36d7b59c 100644 --- a/src/platform/node/extension-manager/core.ts +++ b/src/platform/node/extension-manager/core.ts @@ -58,8 +58,8 @@ export class CoreHandler { if (extensionInfo.main) { extensionInfo.main = `file://${path.join(extensionInfo.baseDir, extensionInfo.main)}`; } - if (extensionInfo.node) { - extensionInfo.node = `file://${path.join(extensionInfo.baseDir, extensionInfo.node)}`; + if (extensionInfo.browser) { + extensionInfo.browser = `file://${path.join(extensionInfo.baseDir, extensionInfo.browser)}`; } if (extensionInfo.logo?.length > 0 && !extensionInfo.logo.startsWith('http') && !extensionInfo.logo.includes('icon-')) { extensionInfo.logo = `file://${path.join(extensionInfo.baseDir, extensionInfo.logo)}`; diff --git a/src/platform/node/extension-manager/manager.ts b/src/platform/node/extension-manager/manager.ts index fcbe0f15e..e13cb8b8e 100644 --- a/src/platform/node/extension-manager/manager.ts +++ b/src/platform/node/extension-manager/manager.ts @@ -5,7 +5,7 @@ import { ExtensionInfo, SidebarView, FeatureInfo } from 'eo/workbench/browser/sr import { createServer } from 'http-server/lib/http-server'; import portfinder from 'portfinder'; -import { ELETRON_APP_CONFIG } from '../../../environment'; +import { COMMON_APP_CONFIG } from '../../../environment'; import { ModuleHandler } from './handler'; import { ModuleHandlerResult, ModuleManagerInfo } from './handler.model'; @@ -55,7 +55,7 @@ export class ModuleManager { async getRemoteExtension(): Promise { return new Promise(resolve => { let data = ''; - https.get(`${ELETRON_APP_CONFIG.EXTENSION_URL}/list`, res => { + https.get(`${COMMON_APP_CONFIG.EXTENSION_URL}/list`, res => { res.on('data', chunk => { data += chunk; }); diff --git a/src/workbench/browser/src/app/core/services/web/web.service.ts b/src/workbench/browser/src/app/core/services/web/web.service.ts index 27ca39f8f..2b1b780dc 100644 --- a/src/workbench/browser/src/app/core/services/web/web.service.ts +++ b/src/workbench/browser/src/app/core/services/web/web.service.ts @@ -64,7 +64,7 @@ export class WebService { this.getClientResource(); } getGithubUrl(opts = {}) { - const href = 'https://github.com/Postcatlab/postcat/issues/new'; + const href = `${APP_CONFIG.GITHUB_REPO_URL}/issues/new`; const query = { assignees: '', labels: '', diff --git a/src/workbench/browser/src/app/layouts/navbar/navbar.component.html b/src/workbench/browser/src/app/layouts/navbar/navbar.component.html index 6c7f1c0b7..55a73c2b1 100644 --- a/src/workbench/browser/src/app/layouts/navbar/navbar.component.html +++ b/src/workbench/browser/src/app/layouts/navbar/navbar.component.html @@ -3,7 +3,7 @@ = new Subject(); constructor( public electron: ElectronService, diff --git a/src/workbench/browser/src/app/layouts/navbar/share-navbar/share-navbar.component.ts b/src/workbench/browser/src/app/layouts/navbar/share-navbar/share-navbar.component.ts index 559084890..aab4e2b42 100644 --- a/src/workbench/browser/src/app/layouts/navbar/share-navbar/share-navbar.component.ts +++ b/src/workbench/browser/src/app/layouts/navbar/share-navbar/share-navbar.component.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { ApiService } from '../../../shared/services/storage/api.service'; import { StoreService } from '../../../shared/store/state.service'; @@ -10,7 +11,7 @@ import { StoreService } from '../../../shared/store/state.service';
- + @@ -30,6 +31,7 @@ import { StoreService } from '../../../shared/store/state.service'; }) export class ShareNavbarComponent { projectName: string; + readonly APP_CONFIG = APP_CONFIG; constructor(private api: ApiService, private store: StoreService) { this.initProjectName(); } 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 index 56f6f4527..dc1d320a1 100644 --- 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 @@ -1,4 +1,5 @@ import { Component, Input } from '@angular/core'; +import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { SharedModule } from '../../shared/shared.module'; @@ -12,7 +13,7 @@ import { SharedModule } from '../../shared/shared.module'; V{{ versionInfo?.version }}

+
-
+
Install
+
+ +

This exension only support web

+
diff --git a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts index 81807924e..fa47c4c5f 100644 --- a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts +++ b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts @@ -1,5 +1,4 @@ import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; import { ElectronService } from 'eo/workbench/browser/src/app/core/services'; import { LanguageService } from 'eo/workbench/browser/src/app/core/services/language/language.service'; import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; @@ -20,6 +19,7 @@ export class ExtensionDetailComponent implements OnInit { @Input() nzSelectedIndex = 0; isOperating = false; introLoading = false; + isAvailableElectron = true; changelogLoading = false; isNotLoaded = true; extensionDetail: EoExtensionInfo; @@ -28,7 +28,6 @@ export class ExtensionDetailComponent implements OnInit { changeLogNotFound = false; constructor( public extensionService: ExtensionService, - private route: ActivatedRoute, private webService: WebService, private electron: ElectronService, private language: LanguageService, @@ -68,14 +67,13 @@ export class ExtensionDetailComponent implements OnInit { this.introLoading = false; this.isNotLoaded = false; this.extensionDetail.introduction ||= $localize`This plugin has no documentation yet.`; - + this.isAvailableElectron = this.checkisAvailableElectron(this.extensionDetail); this.fetchChangelog(this.language.systemLanguage); setTimeout(() => { this.nzSelectedIndex = nzSelectedIndex; }); } - async fetchChangelog(locale = '') { //Default locale en-US if (locale === 'en-US') { @@ -136,13 +134,15 @@ ${log} } finally { } } - handleTabChange = e => { if (e.tab?.nzTitle === 'ChangeLog') { this.fetchChangelog(); } }; - + checkisAvailableElectron(pkgInfo): boolean { + if (this.electron.isElectron && this.extensionDetail.browser && !this.extensionDetail.main) return false; + return true; + } private async manageExtension(operate: string, id) { this.isOperating = true; switch (operate) { diff --git a/src/workbench/browser/src/app/shared/models/extension-manager/module.ts b/src/workbench/browser/src/app/shared/models/extension-manager/module.ts index 86e65d815..b047df91b 100644 --- a/src/workbench/browser/src/app/shared/models/extension-manager/module.ts +++ b/src/workbench/browser/src/app/shared/models/extension-manager/module.ts @@ -38,6 +38,7 @@ export interface ExtensionInfo { //Unique npm package name name: string; version: string; + browser: string; author: string | { name: 'string' }; //Entry js file,webRender environment main: string; diff --git a/src/workbench/browser/src/app/shared/services/extensions/extension-store.service.ts b/src/workbench/browser/src/app/shared/services/extensions/extension-store.service.ts index b2fa7308a..c3a3d29ca 100644 --- a/src/workbench/browser/src/app/shared/services/extensions/extension-store.service.ts +++ b/src/workbench/browser/src/app/shared/services/extensions/extension-store.service.ts @@ -1,17 +1,44 @@ import { Injectable } from '@angular/core'; +import { TranslateService } from 'eo/platform/common/i18n'; +import { LanguageService } from '../../../core/services/language/language.service'; import { ExtensionInfo } from '../../models/extension-manager'; - @Injectable({ providedIn: 'root' }) -export class ExtensionStoreService { +export class ExtensionCommonService { private extensionList: ExtensionInfo[]; - constructor() {} + constructor(private language: LanguageService) {} setExtensionList(list) { this.extensionList = list; } get getExtensionList() { return this.extensionList; } + private translateModule(module: ExtensionInfo) { + const lang = this.language.systemLanguage; + //If extension from web,transalte package content from http moduleInfo + //Locale extension will translate from local i18n file + + const locale = module.i18n?.find(val => val.locale === lang)?.package; + if (!locale) { + return module; + } + module = new TranslateService(module, locale).translate(); + return module; + } + /** + * Parse extension info for ui show + * such as: author, translate ... + * + * @param pkg + * @returns + */ + parseExtensionInfo(pkg): ExtensionInfo { + pkg = this.translateModule(pkg); + if (typeof pkg.author === 'object') { + pkg.author = pkg.author['name'] || ''; + } + return pkg; + } } diff --git a/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts b/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts index 924df547e..1c2f9592a 100644 --- a/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts +++ b/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts @@ -8,7 +8,7 @@ import { MessageService } from 'eo/workbench/browser/src/app/shared/services/mes import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { lastValueFrom, Subscription } from 'rxjs'; -import { ExtensionStoreService } from './extension-store.service'; +import { ExtensionCommonService } from './extension-store.service'; import { WebExtensionService } from './webExtension.service'; const defaultExtensions = ['postcat-export-openapi', 'postcat-import-openapi']; @@ -27,7 +27,7 @@ export class ExtensionService { constructor( private http: HttpClient, private electron: ElectronService, - private store: ExtensionStoreService, + private extensionCommon: ExtensionCommonService, private language: LanguageService, private webExtensionService: WebExtensionService, private messageService: MessageService @@ -66,7 +66,7 @@ export class ExtensionService { if (this.electron.isElectron) { result = window.electron.getInstalledExtensions() || new Map(); result.forEach((value, key) => { - result.set(key, this.parseExtensionInfo(value)); + result.set(key, this.extensionCommon.parseExtensionInfo(value)); }); } else { result = this.webExtensionService.getExtensions(); @@ -136,14 +136,14 @@ export class ExtensionService { ]; //Handle feature data result.data = result.data.map(module => { - let result = this.parseExtensionInfo(module); + let result = this.extensionCommon.parseExtensionInfo(module); return result; }); //Get debug extensions this.webExtensionService.debugExtensions = result.data.filter(val => val.isDebug); - this.store.setExtensionList(result.data); + this.extensionCommon.setExtensionList(result.data); this.requestPending = null; this.isFirstInit = false; resolve([result, originData]); @@ -166,7 +166,7 @@ export class ExtensionService { Object.assign(result, this.installedMap.get(name), { installed: true }); result.enable = this.isEnable(result.name); } - result = this.parseExtensionInfo(result); + result = this.extensionCommon.parseExtensionInfo(result); return result; } /** @@ -317,18 +317,4 @@ export class ExtensionService { .filter(it => it) .filter(it => !this.ignoreList.includes(it)); } - /** - * Parse extension info for ui show - * such as: author, translate ... - * - * @param pkg - * @returns - */ - private parseExtensionInfo(pkg): ExtensionInfo { - pkg = this.webExtensionService.translateModule(pkg); - if (typeof pkg.author === 'object') { - pkg.author = pkg.author['name'] || ''; - } - return pkg; - } } diff --git a/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts b/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts index 45c48bb8d..a403b622c 100644 --- a/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts +++ b/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts @@ -7,8 +7,7 @@ import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { WebService } from '../../../core/services'; import { LanguageService } from '../../../core/services/language/language.service'; -import { ExtensionInfo } from '../../models/extension-manager'; -import { ExtensionStoreService } from './extension-store.service'; +import { ExtensionCommonService } from './extension-store.service'; type ExtensionItem = { name: string; @@ -26,13 +25,19 @@ const extKey = 'ext_installed_list'; }) export class WebExtensionService { installedList: ExtensionItem[] = StorageUtil.get(extKey, []); - disabledExtensionNames = []; - debugExtensions = []; + /** + * Debug Extensions Name + */ debugExtensionNames; + /** + * Storage Debug Extensions Info + */ + debugExtensions = []; + disabledExtensionNames = []; resourceUrl = 'https://unpkg.com'; - constructor(private web: WebService, private language: LanguageService, private store: ExtensionStoreService) { + constructor(private web: WebService, private language: LanguageService, private extensionCommon: ExtensionCommonService) { const isDevEnv = !APP_CONFIG.production || this.web.isVercel || 'http://52.76.76.88:8080'.includes(window.location.hostname); - this.debugExtensionNames = isDevEnv ? [] : []; + this.debugExtensionNames = isDevEnv ? ['postcat-chat-robot'] : []; } async installExtension(extName: string, { version = 'latest' }) { //Get package.json @@ -165,7 +170,7 @@ export class WebExtensionService { } async getPkgInfo(extName: string, version = 'latest') { - const newestExt = this.store.getExtensionList.find(val => val.name === extName); + const newestExt = this.extensionCommon.getExtensionList.find(val => val.name === extName); version = version === 'latest' ? newestExt?.version || 'latest' : version; let pkgInfo; if (version === newestExt?.version) { @@ -221,20 +226,8 @@ export class WebExtensionService { if (!pkgInfo.i18n?.length && pkgInfo.features.i18n) { pkgInfo.i18n = await this.getExtI18n(pkgInfo.name); } - pkgInfo = this.translateModule(pkgInfo); + pkgInfo = this.extensionCommon.parseExtensionInfo(pkgInfo); return pkgInfo; } - translateModule(module: ExtensionInfo) { - const lang = this.language.systemLanguage; - //If extension from web,transalte package content from http moduleInfo - //Locale extension will translate from local i18n file - - const locale = module.i18n?.find(val => val.locale === lang)?.package; - if (!locale) { - return module; - } - module = new TranslateService(module, locale).translate(); - return module; - } } diff --git a/src/workbench/browser/src/environments/common.ts b/src/workbench/browser/src/environments/common.constant.ts similarity index 65% rename from src/workbench/browser/src/environments/common.ts rename to src/workbench/browser/src/environments/common.constant.ts index c5f43ee21..1e92748f6 100644 --- a/src/workbench/browser/src/environments/common.ts +++ b/src/workbench/browser/src/environments/common.constant.ts @@ -1,5 +1,7 @@ -import { ELETRON_APP_CONFIG } from 'eo/environment'; -export const COMMON_CONFIG = { ...ELETRON_APP_CONFIG }; +import { COMMON_APP_CONFIG } from 'eo/environment'; + +export const COMMON_CONFIG = { ...COMMON_APP_CONFIG }; + export type APP_CONFIG_INSTANT = { production: boolean; environment: 'DEV' | 'PROD'; diff --git a/src/workbench/browser/src/environments/environment.dev.ts b/src/workbench/browser/src/environments/environment.dev.ts index fcc3b9298..b3406b7a1 100644 --- a/src/workbench/browser/src/environments/environment.dev.ts +++ b/src/workbench/browser/src/environments/environment.dev.ts @@ -1,4 +1,4 @@ -import { COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common'; +import { COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common.constant'; export const APP_CONFIG = { serverUrl: 'http://52.76.76.88:8080', production: false, diff --git a/src/workbench/browser/src/environments/environment.prod.ts b/src/workbench/browser/src/environments/environment.prod.ts index 0a9b86859..2b985f183 100644 --- a/src/workbench/browser/src/environments/environment.prod.ts +++ b/src/workbench/browser/src/environments/environment.prod.ts @@ -1,4 +1,4 @@ -import { APP_CONFIG_INSTANT, COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common'; +import { APP_CONFIG_INSTANT, COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common.constant'; export const APP_CONFIG = { serverUrl: 'https://postcat.com', diff --git a/src/workbench/browser/src/environments/environment.ts b/src/workbench/browser/src/environments/environment.ts index e3132cf21..365cc9dd1 100644 --- a/src/workbench/browser/src/environments/environment.ts +++ b/src/workbench/browser/src/environments/environment.ts @@ -1,7 +1,7 @@ -import { APP_CONFIG_INSTANT, COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common'; +import { APP_CONFIG_INSTANT, COMMON_CONFIG } from 'eo/workbench/browser/src/environments/common.constant'; export const APP_CONFIG: APP_CONFIG_INSTANT | any = { production: false, environment: 'LOCAL', - ...COMMON_CONFIG, + ...COMMON_CONFIG }; From 83fdb933b06e48ae3e60e5e73f59a8f118938a6b Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Tue, 7 Mar 2023 16:08:42 +0800 Subject: [PATCH 5/6] wip: add feature show --- .../browser/src/app/core/services/web/web.service.ts | 2 +- .../app/pages/components/third-login/third-login.component.ts | 3 ++- .../pages/extension/detail/extension-detail.component.html | 4 ++-- .../app/pages/extension/detail/extension-detail.component.ts | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/workbench/browser/src/app/core/services/web/web.service.ts b/src/workbench/browser/src/app/core/services/web/web.service.ts index 2b1b780dc..50db805e9 100644 --- a/src/workbench/browser/src/app/core/services/web/web.service.ts +++ b/src/workbench/browser/src/app/core/services/web/web.service.ts @@ -59,7 +59,7 @@ export class WebService { if (this.isWeb) { this.settingService.putSettings({ 'backend.url': window.location.origin }); } else { - this.settingService.putSettings({ 'backend.url': APP_CONFIG.production ? 'https://postcat.com' : 'http://52.76.76.88:8080' }); + this.settingService.putSettings({ 'backend.url': APP_CONFIG.serverUrl }); } this.getClientResource(); } diff --git a/src/workbench/browser/src/app/pages/components/third-login/third-login.component.ts b/src/workbench/browser/src/app/pages/components/third-login/third-login.component.ts index ba604faba..214472151 100644 --- a/src/workbench/browser/src/app/pages/components/third-login/third-login.component.ts +++ b/src/workbench/browser/src/app/pages/components/third-login/third-login.component.ts @@ -3,6 +3,7 @@ import { WebService } from 'eo/workbench/browser/src/app/core/services'; import { LanguageService } from 'eo/workbench/browser/src/app/core/services/language/language.service'; import { ApiService } from 'eo/workbench/browser/src/app/shared/services/storage/api.service'; import { StoreService } from 'eo/workbench/browser/src/app/shared/store/state.service'; +import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { autorun, reaction } from 'mobx'; // * type(0=wechat, 1=qq, 2=github, 3=feishu, 4=corp_wechat, 5=ding_talk, 6=oauth2) @@ -77,7 +78,7 @@ export class ThirdLoginComponent implements OnInit { // * get login url const [res, err] = await this.api.api_userThirdLogin({ type: LoginType[type], - redirectUri: this.web.isWeb ? window.location.href.split('?').at(0) : 'https://postcat.com', + redirectUri: this.web.isWeb ? window.location.href.split('?').at(0) : APP_CONFIG.serverUrl, appType: 0, client: 0 }); diff --git a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.html b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.html index 5b1b876f5..12ab440cb 100644 --- a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.html +++ b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.html @@ -60,8 +60,8 @@
diff --git a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts index fa47c4c5f..5cbe94f54 100644 --- a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts +++ b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts @@ -3,6 +3,7 @@ import { ElectronService } from 'eo/workbench/browser/src/app/core/services'; import { LanguageService } from 'eo/workbench/browser/src/app/core/services/language/language.service'; import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; import { TraceService } from 'eo/workbench/browser/src/app/shared/services/trace.service'; +import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; import { WebService } from '../../../core/services/web/web.service'; import { ExtensionService } from '../../../shared/services/extensions/extension.service'; @@ -23,7 +24,7 @@ export class ExtensionDetailComponent implements OnInit { changelogLoading = false; isNotLoaded = true; extensionDetail: EoExtensionInfo; - + readonly APP_CONFIG = APP_CONFIG; changeLog = ''; changeLogNotFound = false; constructor( From e79ad0751cdb008fcecaa75224ec77ed74b20848 Mon Sep 17 00:00:00 2001 From: scarqin <1054139596@qq.com> Date: Wed, 8 Mar 2023 00:20:46 +0800 Subject: [PATCH 6/6] feat: chatGPT robot --- src/platform/node/extension-manager/core.ts | 2 +- .../node/extension-manager/handler.ts | 2 +- .../node/extension-manager/manager.ts | 1 + src/workbench/browser/locale/messages.xlf | 327 +++++++++-------- src/workbench/browser/locale/messages.zh.xlf | 340 ++++++++++-------- .../feature-control.service.ts | 36 +- .../services/feature-control/feature.json | 2 +- .../app/core/services/theme/theme.service.ts | 43 ++- .../src/app/core/services/web/web.service.ts | 2 +- .../app/layouts/sidebar/sidebar.component.ts | 2 +- .../layouts/toolbar/toolbar.component.html | 1 + .../app/layouts/toolbar/toolbar.component.ts | 8 +- .../chat-robot.component.scss | 2 +- .../chat-robot.component.ts | 30 +- .../chat-robot-form.component.ts | 8 +- .../chat-robot-message.component.scss | 7 + .../chat-robot-message.component.ts | 6 +- .../modules/chat-robot/chat-robot.service.ts | 2 +- .../export-api/export-api.component.ts | 2 +- .../import-api/import-api.component.ts | 2 +- .../push-api/push-api.component.ts | 2 +- .../sync-api/sync-api.component.ts | 2 +- .../chatgpt-robot.component.scss | 2 +- .../chatgpt-robot/chatgpt-robot.component.ts | 125 +++++-- .../detail/extension-detail.component.ts | 2 +- .../workspace/project/api/api.component.ts | 2 +- .../services/extensions/extension.service.ts | 14 +- .../extensions/webExtension.service.ts | 2 +- .../storage/http/lib/baseUrl.service.ts | 8 +- 29 files changed, 593 insertions(+), 391 deletions(-) diff --git a/src/platform/node/extension-manager/core.ts b/src/platform/node/extension-manager/core.ts index f36d7b59c..2ee99a0af 100644 --- a/src/platform/node/extension-manager/core.ts +++ b/src/platform/node/extension-manager/core.ts @@ -91,6 +91,6 @@ export class CoreHandler { // @ts-ignore modules = Object.keys(packageInfo.dependencies || {}); } - return modules; + return modules.filter(val => val); } } diff --git a/src/platform/node/extension-manager/handler.ts b/src/platform/node/extension-manager/handler.ts index faed66c6c..c5f6d7123 100644 --- a/src/platform/node/extension-manager/handler.ts +++ b/src/platform/node/extension-manager/handler.ts @@ -128,7 +128,7 @@ export class ModuleHandler extends CoreHandler { private executeByAppNpm(command: string, modules: any[], resolve, reject) { // https://www.npmjs.com/package/bin-links npmCli.load({ 'bin-links': false, verbose: true, prefix: this.baseDir, registry: this.registry }, loaderr => { - const moduleList = modules.map(({ name, version }) => (version ? `${name}@${version}` : name)); + const moduleList = modules.filter(val => val).map(({ name, version }) => (version ? `${name}@${version}` : name)); let executeCommand = ['update', 'install', 'uninstall']; if (!executeCommand.includes(command)) { return; diff --git a/src/platform/node/extension-manager/manager.ts b/src/platform/node/extension-manager/manager.ts index e13cb8b8e..b7adf7220 100644 --- a/src/platform/node/extension-manager/manager.ts +++ b/src/platform/node/extension-manager/manager.ts @@ -82,6 +82,7 @@ export class ModuleManager { * @param module */ async install(module: ModuleManagerInfo): Promise { + if (!module) return; const result = await this.moduleHandler.install([module], module?.isLocal || false); if (result.code === 0) { const moduleInfo: ExtensionInfo = await this.moduleHandler.info(module.name); diff --git a/src/workbench/browser/locale/messages.xlf b/src/workbench/browser/locale/messages.xlf index d724da976..e57c19f91 100644 --- a/src/workbench/browser/locale/messages.xlf +++ b/src/workbench/browser/locale/messages.xlf @@ -93,8 +93,8 @@ 37 - - MacOS(M1) Client + + MacOS(Apple) Client src/app/core/services/web/web.service.ts 44 @@ -108,7 +108,7 @@ src/app/pages/extension/detail/extension-detail.component.html - 93 + 97 @@ -136,7 +136,7 @@ You don't have cloud space yet, please new one src/app/layouts/local-workspace-tip/local-workspace-tip.component.ts - 56 + 57 @@ -158,7 +158,7 @@ src/app/pages/workspace/overview/member/workspace-member.component.ts - 31,30 + 32,31 src/app/pages/workspace/project/member/project-member.component.ts @@ -246,38 +246,11 @@ 33,34 - - Copied - - src/app/layouts/navbar/get-share-link.component.ts - 69 - - - src/app/modules/api-shared/api-mock-table.component.ts - 127 - - - src/app/modules/eo-ui/monaco-editor/monaco-editor.component.ts - 286 - - - src/app/modules/system-setting/common/token.component.ts - 54 - - - src/app/pages/workspace/project/api/http/detail/api-detail.component.ts - 51 - - - src/app/utils/index.utils.ts - 187 - - If you want to share API,Please switch to cloud workspace src/app/layouts/navbar/get-share-link.component.ts - 79 + 60 @@ -348,7 +321,7 @@ Extensions Hub src/app/layouts/navbar/navbar.component.ts - 43 + 45 @@ -409,25 +382,36 @@ 23 + + ChatGPT Robot + + src/app/layouts/toolbar/toolbar.component.html + 37 + + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 67 + + Hide Sidebar src/app/layouts/toolbar/toolbar.component.ts - 16 + 17 Show Sidebar src/app/layouts/toolbar/toolbar.component.ts - 17 + 18 Settings src/app/layouts/toolbar/toolbar.component.ts - 34 + 32 src/app/modules/system-setting/settings.service.ts @@ -435,25 +419,25 @@ src/app/pages/extension/detail/extension-detail.component.html - 74 + 78 Delete Succeeded src/app/modules/api-shared/api-mock-table.component.ts - 43 + 50 Name src/app/modules/api-shared/api-mock-table.component.ts - 48 + 55 src/app/modules/api-shared/api-table.service.ts - 233 + 235 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.html @@ -476,49 +460,49 @@ Created Type src/app/modules/api-shared/api-mock-table.component.ts - 50 + 57 System creation src/app/modules/api-shared/api-mock-table.component.ts - 54 + 61 Manual creation src/app/modules/api-shared/api-mock-table.component.ts - 55 + 62 Preview src/app/modules/api-shared/api-mock-table.component.ts - 63 + 70 Preview Mock src/app/modules/api-shared/api-mock-table.component.ts - 67 + 74 Edit Mock src/app/modules/api-shared/api-mock-table.component.ts - 82 + 89 Edited successfully src/app/modules/api-shared/api-mock-table.component.ts - 132 + 135 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -526,7 +510,7 @@ src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 157 + 163 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -537,7 +521,7 @@ Failed to add src/app/modules/api-shared/api-mock-table.component.ts - 139 + 142 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -548,7 +532,7 @@ Added successfully src/app/modules/api-shared/api-mock-table.component.ts - 143 + 146 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -556,7 +540,7 @@ src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 157 + 163 @@ -567,11 +551,11 @@ src/app/modules/api-shared/api-table.service.ts - 105 + 107 src/app/modules/api-shared/api-table.service.ts - 138 + 140 @@ -582,7 +566,7 @@ src/app/modules/api-shared/params-import/params-import.component.html - 20 + 22 src/app/modules/eo-ui/tab/tab.component.ts @@ -594,7 +578,7 @@ src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 235 + 234 src/app/pages/workspace/project/api/websocket/websocket.component.ts @@ -631,11 +615,11 @@ Type src/app/modules/api-shared/api-table.service.ts - 75 + 76 src/app/modules/api-shared/api-table.service.ts - 241 + 244 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.ts @@ -646,7 +630,7 @@ Required src/app/modules/api-shared/api-table.service.ts - 82 + 83 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.ts @@ -657,7 +641,7 @@ Description src/app/modules/api-shared/api-table.service.ts - 90 + 91 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -672,7 +656,7 @@ Example src/app/modules/api-shared/api-table.service.ts - 95 + 96 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.html @@ -683,7 +667,7 @@ Value src/app/modules/api-shared/api-table.service.ts - 253 + 256 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -734,21 +718,21 @@ Replace All src/app/modules/api-shared/params-import/params-import.component.html - 21 + 23 Insert at the end src/app/modules/api-shared/params-import/params-import.component.html - 22 + 24 Replace Changed src/app/modules/api-shared/params-import/params-import.component.html - 23 + 25 @@ -804,6 +788,20 @@ 125 + + Power by + + src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts + 26 + + + + Send + + src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts + 16 + + Download @@ -847,11 +845,18 @@ 26 + + Copied + + src/app/modules/eo-ui/monaco-editor/monaco-editor.component.ts + 303 + + Program will not close unsaved tabs src/app/modules/eo-ui/tab/tab-operate.service.ts - 360 + 366 @@ -988,7 +993,7 @@ src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 111 + 112 src/app/pages/workspace/overview/project-list/project-list.component.html @@ -1049,7 +1054,7 @@ src/app/pages/workspace/project/api/http/test/body/api-test-body.component.html - 66 + 67 @@ -1112,7 +1117,7 @@ Sync API from URL error: src/app/modules/extension-select/sync-api/sync-api.component.ts - 152 + 172 @@ -1164,11 +1169,12 @@ 110 - - Hi!~ If you like Postcat, please give the Postcat a Star!Your support is our greatest motivation~ + + Hi!~ If you like , please give the Postcat a Star!Your support is our greatest motivation~ - src/app/modules/system-setting/common/about.component.ts - 22,24 + src/app/modules/star-motivation/star-motivation.component.ts + 9,12 @@ -1323,28 +1329,28 @@ Token succeddfully generated src/app/modules/system-setting/common/token.component.ts - 18 + 17 Make sure to copy your token. It will never be displayed again. src/app/modules/system-setting/common/token.component.ts - 21 + 20 Personal Access Token src/app/modules/system-setting/common/token.component.ts - 33 + 41 Generate Token src/app/modules/system-setting/common/token.component.ts - 35 + 43 @@ -1375,18 +1381,39 @@ 42 + + ChatGPT Extensions + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 45 + + + + Send message to AI + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 59 + + + + Visitor + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 154 + + or src/app/pages/components/third-login/third-login.component.ts - 21 + 22 Sign In/Up with Github src/app/pages/components/third-login/third-login.component.ts - 40,41 + 41,42 @@ -1503,7 +1530,7 @@ src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 28 + 29 @@ -1645,11 +1672,25 @@ 59 + + Jump to Use + + src/app/pages/extension/detail/extension-detail.component.html + 63 + + + + * This exension only support web + + src/app/pages/extension/detail/extension-detail.component.html + 64 + + Details src/app/pages/extension/detail/extension-detail.component.html - 82 + 86 src/app/pages/extension/list/extension-list.component.html @@ -1660,63 +1701,63 @@ Support src/app/pages/extension/detail/extension-detail.component.html - 90 + 94 Author src/app/pages/extension/detail/extension-detail.component.html - 92 + 96 Repository src/app/pages/extension/detail/extension-detail.component.html - 94 + 98 Homepage src/app/pages/extension/detail/extension-detail.component.html - 99 + 103 BugReport src/app/pages/extension/detail/extension-detail.component.html - 102 + 106 ChangeLog src/app/pages/extension/detail/extension-detail.component.html - 108 + 112 Changelog failed to load src/app/pages/extension/detail/extension-detail.component.html - 111 + 115 Reacquire src/app/pages/extension/detail/extension-detail.component.html - 113 + 117 Need Client src/app/pages/extension/detail/extension-detail.component.html - 121 + 125 @@ -1857,81 +1898,81 @@ We use cookies src/app/pages/pages.component.html - 24 + 27 GOT IT src/app/pages/pages.component.html - 25 + 28 Actions src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 47 + 48 src/app/pages/workspace/project/setting/project-setting.component.html - 60 + 61 Delete Workspace src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 69 + 70 Are you sure delete this workspace? src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 110 + 111 Delete failed ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 118 + 119 Delete success ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 121 + 122 Edit workspace failed src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 142 + 143 Edit workspace successfully ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 145 + 146 Add Member To Workspace src/app/pages/workspace/overview/member/workspace-member.component.ts - 19 + 20 Add src/app/pages/workspace/overview/member/workspace-member.component.ts - 57,58 + 58,59 src/app/pages/workspace/project/member/project-member.component.ts @@ -1942,7 +1983,7 @@ Currently using local workspace, unable to invite members. src/app/pages/workspace/overview/member/workspace-member.component.ts - 69 + 70 src/app/pages/workspace/project/member/project-member.component.ts @@ -1955,7 +1996,7 @@ >"/>and invite members to collaborate. src/app/pages/workspace/overview/member/workspace-member.component.ts - 71,73 + 72,74 src/app/pages/workspace/project/member/project-member.component.ts @@ -1966,7 +2007,7 @@ Please select a member src/app/pages/workspace/overview/member/workspace-member.component.ts - 149 + 153 src/app/pages/workspace/project/member/project-member.component.ts @@ -1977,11 +2018,11 @@ Add member failed src/app/pages/workspace/overview/member/workspace-member.component.ts - 155 + 159 src/app/pages/workspace/overview/member/workspace-member.component.ts - 177 + 181 src/app/pages/workspace/project/member/project-member.component.ts @@ -1992,11 +2033,11 @@ Add member successfully src/app/pages/workspace/overview/member/workspace-member.component.ts - 159 + 163 src/app/pages/workspace/overview/member/workspace-member.component.ts - 181 + 185 src/app/pages/workspace/project/member/project-member.component.ts @@ -2007,7 +2048,7 @@ You can create a cloud workspace and invite members to collaborate. src/app/pages/workspace/overview/member/workspace-member.component.ts - 172 + 176 @@ -2088,7 +2129,7 @@ src/app/shared/components/schema-form/schema-form.component.ts - 38 + 56 @@ -2335,42 +2376,42 @@ Edit Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 178 + 177 Delete Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 187 + 186 Deletion Confirmation? src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 200 + 199 Are you sure you want to delete the data <strong title=""></strong> ? You cannot restore it once deleted! src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 201,203 + 200,202 Add Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 219 + 218 Save and Sync src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 239 + 238 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2381,7 +2422,7 @@ Confirm src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 239 + 238 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2396,7 +2437,7 @@ Failed to ,Please upgrade extension or try again later src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 246 + 245 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2407,7 +2448,7 @@ successfully src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 254 + 253 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2535,11 +2576,11 @@ Request Headers src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 21 + 18 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 51 + 58 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2550,11 +2591,11 @@ Query src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 33,32 + 30,29 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 79 + 86 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2565,11 +2606,11 @@ REST src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 44,43 + 41,40 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 92 + 99 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2580,11 +2621,11 @@ Body src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 61 + 58 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 65 + 72 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2599,15 +2640,15 @@ Response src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 80 + 77 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 104 + 111 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 125 + 132 src/app/pages/workspace/project/api/http/mock/edit/api-mock-edit.component.ts @@ -2622,11 +2663,11 @@ Response Headers src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 99 + 96 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 108 + 115 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2637,42 +2678,42 @@ MOCK src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 112,111 + 109,108 Please enter API Path src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 15 + 22 Please select an API group src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 22 + 29 Please enter API name src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 39 + 46 Request src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 46 + 53 Failed Operation src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 162 + 168 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2690,7 +2731,7 @@ Binary Description src/app/pages/workspace/project/api/http/edit/body/api-edit-body.component.html - 61 + 62 @@ -3172,14 +3213,14 @@ Send src/app/pages/workspace/project/api/websocket/websocket.component.html - 124,125 + 125,126 Messages src/app/pages/workspace/project/api/websocket/websocket.component.html - 138 + 139 @@ -3341,7 +3382,7 @@ Please Enter src/app/shared/components/schema-form/schema-form.component.ts - 29 + 47 diff --git a/src/workbench/browser/locale/messages.zh.xlf b/src/workbench/browser/locale/messages.zh.xlf index d0c860554..185080598 100644 --- a/src/workbench/browser/locale/messages.zh.xlf +++ b/src/workbench/browser/locale/messages.zh.xlf @@ -106,13 +106,13 @@ MacOS(Intel) 客户端 - - MacOS(M1) Client + + MacOS(Apple) Client src/app/core/services/web/web.service.ts 44 - MacOS(M1) 客户端 + MacOS(Apple) 客户端 Version @@ -122,7 +122,7 @@ src/app/pages/extension/detail/extension-detail.component.html - 93 + 97 版本 @@ -154,7 +154,7 @@ You don't have cloud space yet, please new one src/app/layouts/local-workspace-tip/local-workspace-tip.component.ts - 56 + 57 您还没有云空间,请新建一个 @@ -178,7 +178,7 @@ src/app/pages/workspace/overview/member/workspace-member.component.ts - 31,30 + 32,31 src/app/pages/workspace/project/member/project-member.component.ts @@ -278,39 +278,11 @@ 每个人都可以在没有登录的情况下查看最新的 API 文档 - - Copied - - src/app/layouts/navbar/get-share-link.component.ts - 69 - - - src/app/modules/api-shared/api-mock-table.component.ts - 127 - - - src/app/modules/eo-ui/monaco-editor/monaco-editor.component.ts - 286 - - - src/app/modules/system-setting/common/token.component.ts - 54 - - - src/app/pages/workspace/project/api/http/detail/api-detail.component.ts - 51 - - - src/app/utils/index.utils.ts - 187 - - 已复制 - If you want to share API,Please switch to cloud workspace src/app/layouts/navbar/get-share-link.component.ts - 79 + 60 如果您想要分享 API,请切换到云空间 @@ -390,7 +362,7 @@ Extensions Hub src/app/layouts/navbar/navbar.component.ts - 43 + 45 插件广场 @@ -458,11 +430,23 @@ 更改主题 + + ChatGPT Robot + + src/app/layouts/toolbar/toolbar.component.html + 37 + + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 67 + + ChatGPT 机器人 + Hide Sidebar src/app/layouts/toolbar/toolbar.component.ts - 16 + 17 隐藏侧边栏 @@ -470,7 +454,7 @@ Show Sidebar src/app/layouts/toolbar/toolbar.component.ts - 17 + 18 展示侧边栏 @@ -478,7 +462,7 @@ Settings src/app/layouts/toolbar/toolbar.component.ts - 34 + 32 src/app/modules/system-setting/settings.service.ts @@ -486,7 +470,7 @@ src/app/pages/extension/detail/extension-detail.component.html - 74 + 78 设置 @@ -494,7 +478,7 @@ Delete Succeeded src/app/modules/api-shared/api-mock-table.component.ts - 43 + 50 删除成功 @@ -502,11 +486,11 @@ Name src/app/modules/api-shared/api-mock-table.component.ts - 48 + 55 src/app/modules/api-shared/api-table.service.ts - 233 + 235 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.html @@ -530,7 +514,7 @@ Created Type src/app/modules/api-shared/api-mock-table.component.ts - 50 + 57 创建方式 @@ -538,7 +522,7 @@ System creation src/app/modules/api-shared/api-mock-table.component.ts - 54 + 61 系统自动创建 @@ -546,7 +530,7 @@ Manual creation src/app/modules/api-shared/api-mock-table.component.ts - 55 + 62 手动创建 @@ -554,7 +538,7 @@ Preview src/app/modules/api-shared/api-mock-table.component.ts - 63 + 70 预览 @@ -562,7 +546,7 @@ Preview Mock src/app/modules/api-shared/api-mock-table.component.ts - 67 + 74 预览 Mock @@ -570,7 +554,7 @@ Edit Mock src/app/modules/api-shared/api-mock-table.component.ts - 82 + 89 编辑 Mock @@ -578,7 +562,7 @@ Edited successfully src/app/modules/api-shared/api-mock-table.component.ts - 132 + 135 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -586,7 +570,7 @@ src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 157 + 163 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -598,7 +582,7 @@ Failed to add src/app/modules/api-shared/api-mock-table.component.ts - 139 + 142 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -610,7 +594,7 @@ Added successfully src/app/modules/api-shared/api-mock-table.component.ts - 143 + 146 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -618,7 +602,7 @@ src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 157 + 163 添加成功 @@ -630,11 +614,11 @@ src/app/modules/api-shared/api-table.service.ts - 105 + 107 src/app/modules/api-shared/api-table.service.ts - 138 + 140 更多设置 @@ -646,7 +630,7 @@ src/app/modules/api-shared/params-import/params-import.component.html - 20 + 22 src/app/modules/eo-ui/tab/tab.component.ts @@ -658,7 +642,7 @@ src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 235 + 234 src/app/pages/workspace/project/api/websocket/websocket.component.ts @@ -698,11 +682,11 @@ Type src/app/modules/api-shared/api-table.service.ts - 75 + 76 src/app/modules/api-shared/api-table.service.ts - 241 + 244 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.ts @@ -714,7 +698,7 @@ Required src/app/modules/api-shared/api-table.service.ts - 82 + 83 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.ts @@ -726,7 +710,7 @@ Description src/app/modules/api-shared/api-table.service.ts - 90 + 91 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -742,7 +726,7 @@ Example src/app/modules/api-shared/api-table.service.ts - 95 + 96 src/app/pages/workspace/project/api/http/edit/extra-setting/api-params-extra-setting.component.html @@ -754,7 +738,7 @@ Value src/app/modules/api-shared/api-table.service.ts - 253 + 256 src/app/pages/workspace/project/api/env/env-edit/env-edit.component.ts @@ -810,7 +794,7 @@ Replace All src/app/modules/api-shared/params-import/params-import.component.html - 21 + 23 全量替换 @@ -818,7 +802,7 @@ Insert at the end src/app/modules/api-shared/params-import/params-import.component.html - 22 + 24 在末端插入 @@ -826,7 +810,7 @@ Replace Changed src/app/modules/api-shared/params-import/params-import.component.html - 23 + 25 增量更新 @@ -890,6 +874,22 @@ XML 格式不正确 + + Power by + + src/app/modules/chat-robot/chat-robot-container/chat-robot.component.ts + 26 + + 技术支持: + + + Send + + src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts + 16 + + 发送 + Download @@ -938,11 +938,19 @@ 替换 + + Copied + + src/app/modules/eo-ui/monaco-editor/monaco-editor.component.ts + 303 + + 已复制 + Program will not close unsaved tabs src/app/modules/eo-ui/tab/tab-operate.service.ts - 360 + 366 程序将不会关闭未保存的标签 @@ -1094,7 +1102,7 @@ src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 111 + 112 src/app/pages/workspace/overview/project-list/project-list.component.html @@ -1158,7 +1166,7 @@ src/app/pages/workspace/project/api/http/test/body/api-test-body.component.html - 66 + 67 点击或直接拖拽文件至此区域 @@ -1230,7 +1238,7 @@ Sync API from URL error: src/app/modules/extension-select/sync-api/sync-api.component.ts - 152 + 172 从 URL 同步 API 错误: @@ -1290,13 +1298,13 @@ 移除成员成功 - - Hi!~ If you like Postcat, please give the Postcat a Star!Your support is our greatest motivation~ + + Hi!~ If you like , please give the Postcat a Star!Your support is our greatest motivation~ - src/app/modules/system-setting/common/about.component.ts - 22,24 + src/app/modules/star-motivation/star-motivation.component.ts + 9,12 - 您好~ 如果您喜欢 Postcat, 请给 Postcat 一颗星!您的支持是我们最大的动力~ + 您好~ 如果您喜欢 ,请给 Postcat 一颗星!您的支持是我们最大的动力~ Change Password @@ -1470,7 +1478,7 @@ Token succeddfully generated src/app/modules/system-setting/common/token.component.ts - 18 + 17 已成功生成令牌 @@ -1478,7 +1486,7 @@ Make sure to copy your token. It will never be displayed again. src/app/modules/system-setting/common/token.component.ts - 21 + 20 请确保复制您的令牌。它将永远不会显示。 @@ -1486,7 +1494,7 @@ Personal Access Token src/app/modules/system-setting/common/token.component.ts - 33 + 41 个人访问令牌 @@ -1494,7 +1502,7 @@ Generate Token src/app/modules/system-setting/common/token.component.ts - 35 + 43 生成令牌 @@ -1530,11 +1538,35 @@ 关于 + + ChatGPT Extensions + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 45 + + ChatGPT 插件 + + + Send message to AI + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 59 + + 发送消息给 AI + + + Visitor + + src/app/pages/components/chatgpt-robot/chatgpt-robot.component.ts + 154 + + 游客 + or src/app/pages/components/third-login/third-login.component.ts - 21 + 22 @@ -1542,7 +1574,7 @@ Sign In/Up with Github src/app/pages/components/third-login/third-login.component.ts - 40,41 + 41,42 通过 Github 注册/登录 @@ -1674,7 +1706,7 @@ src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 28 + 29 空间名称 @@ -1836,11 +1868,27 @@ 安装 + + Jump to Use + + src/app/pages/extension/detail/extension-detail.component.html + 63 + + 跳转使用 + + + * This exension only support web + + src/app/pages/extension/detail/extension-detail.component.html + 64 + + * 此插件在 Web 浏览器支持 + Details src/app/pages/extension/detail/extension-detail.component.html - 82 + 86 src/app/pages/extension/list/extension-list.component.html @@ -1852,7 +1900,7 @@ Support src/app/pages/extension/detail/extension-detail.component.html - 90 + 94 支持 @@ -1860,7 +1908,7 @@ Author src/app/pages/extension/detail/extension-detail.component.html - 92 + 96 作者 @@ -1868,7 +1916,7 @@ Repository src/app/pages/extension/detail/extension-detail.component.html - 94 + 98 代码仓库 @@ -1876,7 +1924,7 @@ Homepage src/app/pages/extension/detail/extension-detail.component.html - 99 + 103 首页 @@ -1884,7 +1932,7 @@ BugReport src/app/pages/extension/detail/extension-detail.component.html - 102 + 106 报告问题 @@ -1892,7 +1940,7 @@ ChangeLog src/app/pages/extension/detail/extension-detail.component.html - 108 + 112 更新日志 @@ -1900,7 +1948,7 @@ Changelog failed to load src/app/pages/extension/detail/extension-detail.component.html - 111 + 115 更新日志加载失败 @@ -1908,7 +1956,7 @@ Reacquire src/app/pages/extension/detail/extension-detail.component.html - 113 + 117 重新获取 @@ -1916,7 +1964,7 @@ Need Client src/app/pages/extension/detail/extension-detail.component.html - 121 + 125 需要客户端 @@ -2064,7 +2112,7 @@ We use cookies src/app/pages/pages.component.html - 24 + 27 我们使用 Cookie @@ -2072,7 +2120,7 @@ GOT IT src/app/pages/pages.component.html - 25 + 28 了解 @@ -2080,11 +2128,11 @@ Actions src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 47 + 48 src/app/pages/workspace/project/setting/project-setting.component.html - 60 + 61 操作 @@ -2092,7 +2140,7 @@ Delete Workspace src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 69 + 70 删除空间 @@ -2100,7 +2148,7 @@ Are you sure delete this workspace? src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 110 + 111 确定删除这个空间? @@ -2108,7 +2156,7 @@ Delete failed ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 118 + 119 删除失败 @@ -2116,7 +2164,7 @@ Delete success ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 121 + 122 删除成功! @@ -2124,7 +2172,7 @@ Edit workspace failed src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 142 + 143 编辑空间失败 @@ -2132,7 +2180,7 @@ Edit workspace successfully ! src/app/pages/workspace/overview/edit/workspace-edit.component.ts - 145 + 146 编辑空间成功 @@ -2140,7 +2188,7 @@ Add Member To Workspace src/app/pages/workspace/overview/member/workspace-member.component.ts - 19 + 20 添加空间成员 @@ -2148,7 +2196,7 @@ Add src/app/pages/workspace/overview/member/workspace-member.component.ts - 57,58 + 58,59 src/app/pages/workspace/project/member/project-member.component.ts @@ -2160,7 +2208,7 @@ Currently using local workspace, unable to invite members. src/app/pages/workspace/overview/member/workspace-member.component.ts - 69 + 70 src/app/pages/workspace/project/member/project-member.component.ts @@ -2172,7 +2220,7 @@ You cannew a cloud workspaceand invite members to collaborate. src/app/pages/workspace/overview/member/workspace-member.component.ts - 71,73 + 72,74 src/app/pages/workspace/project/member/project-member.component.ts @@ -2184,7 +2232,7 @@ Please select a member src/app/pages/workspace/overview/member/workspace-member.component.ts - 149 + 153 src/app/pages/workspace/project/member/project-member.component.ts @@ -2196,11 +2244,11 @@ Add member failed src/app/pages/workspace/overview/member/workspace-member.component.ts - 155 + 159 src/app/pages/workspace/overview/member/workspace-member.component.ts - 177 + 181 src/app/pages/workspace/project/member/project-member.component.ts @@ -2212,11 +2260,11 @@ Add member successfully src/app/pages/workspace/overview/member/workspace-member.component.ts - 159 + 163 src/app/pages/workspace/overview/member/workspace-member.component.ts - 181 + 185 src/app/pages/workspace/project/member/project-member.component.ts @@ -2228,7 +2276,7 @@ You can create a cloud workspace and invite members to collaborate. src/app/pages/workspace/overview/member/workspace-member.component.ts - 172 + 176 您可以创建一个云空间之后再邀请成员协作。 @@ -2318,7 +2366,7 @@ src/app/shared/components/schema-form/schema-form.component.ts - 38 + 56 @@ -2597,7 +2645,7 @@ Edit Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 178 + 177 编辑分组 @@ -2605,7 +2653,7 @@ Delete Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 187 + 186 删除分组 @@ -2613,7 +2661,7 @@ Deletion Confirmation? src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 200 + 199 确认删除? @@ -2621,7 +2669,7 @@ Are you sure you want to delete the data <strong title=""></strong> ? You cannot restore it once deleted! src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 201,203 + 200,202 确认要删除数据 <strong title=""></strong> 吗?删除后不可恢复! @@ -2629,7 +2677,7 @@ Add Group src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 219 + 218 添加分组 @@ -2637,7 +2685,7 @@ Save and Sync src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 239 + 238 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2649,7 +2697,7 @@ Confirm src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 239 + 238 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2665,7 +2713,7 @@ Failed to ,Please upgrade extension or try again later src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 246 + 245 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2677,7 +2725,7 @@ successfully src/app/pages/workspace/project/api/components/group/tree/api-group-tree.component.ts - 254 + 253 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2821,11 +2869,11 @@ Request Headers src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 21 + 18 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 51 + 58 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2837,11 +2885,11 @@ Query src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 33,32 + 30,29 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 79 + 86 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2853,11 +2901,11 @@ REST src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 44,43 + 41,40 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 92 + 99 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2869,11 +2917,11 @@ Body src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 61 + 58 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 65 + 72 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2889,15 +2937,15 @@ Response src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 80 + 77 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 104 + 111 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 125 + 132 src/app/pages/workspace/project/api/http/mock/edit/api-mock-edit.component.ts @@ -2913,11 +2961,11 @@ Response Headers src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 99 + 96 src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 108 + 115 src/app/pages/workspace/project/api/http/test/api-test.component.html @@ -2929,7 +2977,7 @@ MOCK src/app/pages/workspace/project/api/http/detail/api-detail.component.html - 112,111 + 109,108 MOCK @@ -2937,7 +2985,7 @@ Please enter API Path src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 15 + 22 请输入 API Path @@ -2945,7 +2993,7 @@ Please select an API group src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 22 + 29 请选择 API 分组 @@ -2953,7 +3001,7 @@ Please enter API name src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 39 + 46 请输入 API 名称 @@ -2961,7 +3009,7 @@ Request src/app/pages/workspace/project/api/http/edit/api-edit.component.html - 46 + 53 请求参数 @@ -2969,7 +3017,7 @@ Failed Operation src/app/pages/workspace/project/api/http/edit/api-edit.component.ts - 162 + 168 src/app/pages/workspace/project/setting/project-setting.component.ts @@ -2989,7 +3037,7 @@ Binary Description src/app/pages/workspace/project/api/http/edit/body/api-edit-body.component.html - 61 + 62 Binary 说明 @@ -3533,7 +3581,7 @@ Send src/app/pages/workspace/project/api/websocket/websocket.component.html - 124,125 + 125,126 发送 @@ -3541,7 +3589,7 @@ Messages src/app/pages/workspace/project/api/websocket/websocket.component.html - 138 + 139 报文 @@ -3725,7 +3773,7 @@ Please Enter src/app/shared/components/schema-form/schema-form.component.ts - 29 + 47 请输入 diff --git a/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts b/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts index 0675ec2d8..db4519596 100644 --- a/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts +++ b/src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts @@ -1,4 +1,6 @@ import { Injectable } from '@angular/core'; +import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; +import { Message, MessageService } from 'eo/workbench/browser/src/app/shared/services/message'; import featureJSON from './feature.json'; type configKey = keyof typeof featureJSON; @@ -7,9 +9,37 @@ type configKey = keyof typeof featureJSON; }) export class FeatureControlService { config: { [key: configKey | string]: boolean }; - constructor() { + constructor(private message: MessageService) { this.config = featureJSON; + this.watchExtensionChange(); + } + watchExtensionChange() { + this.message.get().subscribe((inArg: Message) => { + if (inArg.type !== 'extensionsChange') return; + const extension = inArg.data.extension; + if (!extension?.features?.featureControl?.length) return; + switch (inArg.data.action) { + case 'install': + case 'enable': { + this.openFearure(extension?.features?.featureControl); + break; + } + case 'disable': + case 'uninstall': { + this.closeFeature(extension?.features?.featureControl); + break; + } + } + }); + } + openFearure(features) { + features.forEach(({ id }) => { + this.config[id] = true; + }); + } + closeFeature(features) { + features.forEach(({ id }) => { + this.config[id] = false; + }); } - openFearure() {} - closeFeature() {} } diff --git a/src/workbench/browser/src/app/core/services/feature-control/feature.json b/src/workbench/browser/src/app/core/services/feature-control/feature.json index 00d15bb44..b6d2c1e3d 100644 --- a/src/workbench/browser/src/app/core/services/feature-control/feature.json +++ b/src/workbench/browser/src/app/core/services/feature-control/feature.json @@ -4,5 +4,5 @@ "apimanage.document": true, "apimanage.edit": true, "apimanage.mock": true, - "chatRobot": true + "chatRobot": false } diff --git a/src/workbench/browser/src/app/core/services/theme/theme.service.ts b/src/workbench/browser/src/app/core/services/theme/theme.service.ts index eaf05226e..a248d7196 100644 --- a/src/workbench/browser/src/app/core/services/theme/theme.service.ts +++ b/src/workbench/browser/src/app/core/services/theme/theme.service.ts @@ -194,30 +194,29 @@ export class ThemeService { } watchInstalledExtensionsChange() { this.message.get().subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { - //Rest newest theme list - this.themes = this.themes.filter(val => !val.isExtension); - this.queryExtensionThemes(); - this.afterAllThemeLoad(); + if (inArg.type !== 'extensionsChange') return; + //Rest newest theme list + this.themes = this.themes.filter(val => !val.isExtension); + this.queryExtensionThemes(); + this.afterAllThemeLoad(); - switch (inArg.data.action) { - case 'enable': - case 'install': { - const name = inArg.data.name; - const extension: ExtensionInfo = inArg.data.installedMap.get(name); - if (!extension?.features?.theme?.length) break; + switch (inArg.data.action) { + case 'enable': + case 'install': { + const name = inArg.data.name; + const extension: ExtensionInfo = inArg.data.installedMap.get(name); + if (!extension?.features?.theme?.length) break; - //Change theme after install/enable extension - const themeID = extension.features.theme[0].id; - const id = this.themeExtension.getExtensionID(name, themeID); - const theme = this.themes.find(val => val.id === id); - if (!theme) return; - this.changeTheme(theme); - break; - } - default: { - break; - } + //Change theme after install/enable extension + const themeID = extension.features.theme[0].id; + const id = this.themeExtension.getExtensionID(name, themeID); + const theme = this.themes.find(val => val.id === id); + if (!theme) return; + this.changeTheme(theme); + break; + } + default: { + break; } } }); diff --git a/src/workbench/browser/src/app/core/services/web/web.service.ts b/src/workbench/browser/src/app/core/services/web/web.service.ts index 50db805e9..b8bb65e46 100644 --- a/src/workbench/browser/src/app/core/services/web/web.service.ts +++ b/src/workbench/browser/src/app/core/services/web/web.service.ts @@ -41,7 +41,7 @@ export class WebService { }, { id: 'mac-m1', - name: $localize`MacOS(M1) Client`, + name: $localize`MacOS(Apple) Client`, icon: 'mac', suffix: 'arm64.dmg', link: 'https://data.postcat.com/download/latest/Postcat-latest-arm64.dmg' diff --git a/src/workbench/browser/src/app/layouts/sidebar/sidebar.component.ts b/src/workbench/browser/src/app/layouts/sidebar/sidebar.component.ts index e36824b09..11e0f043e 100644 --- a/src/workbench/browser/src/app/layouts/sidebar/sidebar.component.ts +++ b/src/workbench/browser/src/app/layouts/sidebar/sidebar.component.ts @@ -70,7 +70,7 @@ export class SidebarComponent implements OnInit, OnDestroy { watchInstalledExtensionsChange() { this.messageService.get().subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { if (!this.sidebar.visible) return; const installedMap = inArg.data.installedMap; const extensionIDs = Array.isArray(installedMap) ? installedMap.map(n => n.name) : [...installedMap.keys()]; diff --git a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html index 2eb19390b..fcaaeff59 100644 --- a/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html +++ b/src/workbench/browser/src/app/layouts/toolbar/toolbar.component.html @@ -29,6 +29,7 @@
-
+

-

Power by {{ powerBy.title }}

`, styleUrls: ['./chat-robot.component.scss'] }) -export class ChatRobotComponent { +export class ChatRobotComponent implements AfterViewInit { @Input() title: string; @ContentChildren(ChatRobotMessageComponent) messages: QueryList; + @ViewChild('scrollable') scrollable: ElementRef; + @Input() powerBy: { title: string; link: string }; constructor(private chat: ChatRobotService) {} closeRobot() { this.chat.close(); } + + ngAfterViewInit() { + this.messages.changes.subscribe(messages => { + this.messages = messages; + this.updateView(); + }); + + this.updateView(); + } + scrollListBottom() { + this.scrollable.nativeElement.scrollTop = this.scrollable.nativeElement.scrollHeight; + } + + updateView() { + this.scrollListBottom(); + } } diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts index 1313d4831..acc03a3fb 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-form/chat-robot-form.component.ts @@ -13,7 +13,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; [placeholder]="placeholder" (keyup.enter)="sendMessage()" > - +
`, styles: [] }) @@ -26,14 +26,16 @@ export class ChatRobotFormComponent { @Input() message: string = ''; @Input() placeholder: string = ''; + @Input() loading: boolean = false; + /** * Send message triggle event */ @Output() readonly send = new EventEmitter<{ message: string }>(); sendMessage() { - console.log(this.message); + if (this.loading) return; if (!String(this.message).trim().length) return; - this.send.emit({ message: this.message }); + this.send.emit({ message: this.message.replace(/^[\r\n]+|[\r\n]+$/g, '') }); this.message = ''; } } diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss index 2dcbb7f13..1fbbd793b 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.scss @@ -5,6 +5,13 @@ .message-content { padding: 1rem; border-radius: 0.5rem; + min-width: fit-content; + max-width: 400px; + } + + .text { + word-wrap: break-word; + white-space: pre-wrap; } &.not-reply { diff --git a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts index dd2a620e1..205d88fdc 100644 --- a/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts +++ b/src/workbench/browser/src/app/modules/chat-robot/chat-robot-message/chat-robot-message.component.ts @@ -1,17 +1,17 @@ -import { Component, HostBinding, Input, TemplateRef } from '@angular/core'; +import { AfterViewInit, Component, ElementRef, HostBinding, Input, OnInit, TemplateRef, ViewChild } from '@angular/core'; @Component({ selector: 'pc-chat-robot-message', template: ` -
+

{{ sender }} {{ date | date }}

-

{{ message }}

+
 {{ message }} 
`, 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 c863a0430..a1968d458 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,7 +4,7 @@ import { Injectable } from '@angular/core'; providedIn: 'root' }) export class ChatRobotService { - isShow: boolean = true; + isShow: boolean = false; constructor() {} open() { this.isShow = true; diff --git a/src/workbench/browser/src/app/modules/extension-select/export-api/export-api.component.ts b/src/workbench/browser/src/app/modules/extension-select/export-api/export-api.component.ts index 56642adc8..81a791ff3 100644 --- a/src/workbench/browser/src/app/modules/extension-select/export-api/export-api.component.ts +++ b/src/workbench/browser/src/app/modules/extension-select/export-api/export-api.component.ts @@ -36,7 +36,7 @@ export class ExportApiComponent implements OnInit { .get() .pipe(takeUntil(this.destroy$)) .subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { this.initData(); } }); diff --git a/src/workbench/browser/src/app/modules/extension-select/import-api/import-api.component.ts b/src/workbench/browser/src/app/modules/extension-select/import-api/import-api.component.ts index 47e50b127..681dc5d53 100644 --- a/src/workbench/browser/src/app/modules/extension-select/import-api/import-api.component.ts +++ b/src/workbench/browser/src/app/modules/extension-select/import-api/import-api.component.ts @@ -77,7 +77,7 @@ export class ImportApiComponent implements OnInit { .get() .pipe(takeUntil(this.destroy$)) .subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { this.initData(); } }); diff --git a/src/workbench/browser/src/app/modules/extension-select/push-api/push-api.component.ts b/src/workbench/browser/src/app/modules/extension-select/push-api/push-api.component.ts index 08e314804..2c1af1034 100644 --- a/src/workbench/browser/src/app/modules/extension-select/push-api/push-api.component.ts +++ b/src/workbench/browser/src/app/modules/extension-select/push-api/push-api.component.ts @@ -32,7 +32,7 @@ export class PushApiComponent implements OnInit { .get() .pipe(takeUntil(this.destroy$)) .subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { this.initData(); } }); diff --git a/src/workbench/browser/src/app/modules/extension-select/sync-api/sync-api.component.ts b/src/workbench/browser/src/app/modules/extension-select/sync-api/sync-api.component.ts index 8be389d07..7ec92aab7 100644 --- a/src/workbench/browser/src/app/modules/extension-select/sync-api/sync-api.component.ts +++ b/src/workbench/browser/src/app/modules/extension-select/sync-api/sync-api.component.ts @@ -56,7 +56,7 @@ export class SyncApiComponent implements OnInit, OnChanges { .get() .pipe(takeUntil(this.destroy$)) .subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { this.initData(() => { if (this.supportList?.length) { const { key } = this.supportList.at(0); 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 e5095fb2d..6e658cdd2 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 @@ -1,5 +1,5 @@ :host { - position: absolute; + position: fixed; right: 25px; bottom: 25px; z-index: 10; 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 2ada5ee41..4bb630d8b 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 @@ -2,11 +2,14 @@ import { animate, style, transition, trigger } from '@angular/animations'; import { CommonModule } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit } from '@angular/core'; +import { FeatureControlService } from 'eo/workbench/browser/src/app/core/services/feature-control/feature-control.service'; +import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; +import { Message, MessageService } from 'eo/workbench/browser/src/app/shared/services/message'; +import { APP_CONFIG } from 'eo/workbench/browser/src/environments/environment'; 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; @@ -25,12 +28,12 @@ type messageItem = { imports: [StarMotivationComponent, CommonModule, ChatRobotModule], animations: [ trigger('slideInOut', [ - transition(':enter', [style({ transform: 'translateX(100%)' }), animate('200ms ease-in', style({ transform: 'translateX(0)' }))]), - transition(':leave', [animate('200ms ease-in', style({ transform: 'translateX(100%)' }))]) + transition(':enter', [style({ transform: 'translateX(100%)' }), animate('300ms ease-in', style({ transform: 'translateX(0)' }))]), + transition(':leave', [animate('300ms ease-in', style({ transform: 'translateX(100%)' }))]) ]) ], template: ` - + - + `, styleUrls: ['./chatgpt-robot.component.scss'] }) export class ChatgptRobotComponent implements OnInit { title = $localize`ChatGPT Robot`; + loading = false; initMessage = { date: new Date(), reply: true, @@ -71,45 +80,68 @@ export class ChatgptRobotComponent implements OnInit { link: 'https://www.apispace.com?utm_source=postcat&utm_medium=robot&utm_term=chatgptturbo' }; messages: messageItem[] = []; - constructor(private http: HttpClient, public chat: ChatRobotService) {} + constructor( + private http: HttpClient, + public chat: ChatRobotService, + public feature: FeatureControlService, + private message: MessageService + ) {} ngOnInit() { - this.messages.push( - { - text: 'test im user', - date: new Date(), - reply: false, - type: 'text', - user: { - name: 'Visitor', - avatar: 'https://data.eolink.com/PXMbLGmc2f0b29596764f7456eefb75478ed77b4fd172d9' - } - }, - { - text: `I'm sorry, I cannot respond to this as it is not a coherent sentence or request. Please provide a valid question or statement.`, - date: new Date(), - reply: true, - type: 'text', - user: { - name: 'ChatGPT', - avatar: 'https://data-apibee.apispace.com/license/167773762614902e10710-8d88-4d7e-b962-2df477b361ec' - } - } - ); + setTimeout(() => { + this.watchExtensionChange(); + }, 5 * 1000); } sendChatGPTMessage($event) { + this.loading = true; this.http - .post( - 'https://eolink.o.apispace.com/chatgpt-turbo/create', - {}, - { - headers: { - 'Authorization-Type': 'apikey', - 'X-APISpace-Token': '' + .post(`${APP_CONFIG.EXTENSION_URL}/chatGPT`, { + message: this.messages.map(val => { + if (val.reply) { + return `assistant: ${val.text}`; + } + return `user: ${val.text}`; + }) + }) + .subscribe({ + next: (res: any) => { + this.loading = false; + if (!res?.result) { + this.messages.push({ + text: `ChatGPT Error:${res?.msg}`, + date: new Date(), + reply: true, + type: 'text', + user: { + name: 'ChatGPT', + avatar: 'https://data-apibee.apispace.com/license/167773762614902e10710-8d88-4d7e-b962-2df477b361ec' + } + }); + return; } + this.messages.push({ + text: res.result, + date: new Date(), + reply: true, + type: 'text', + user: { + name: 'ChatGPT', + avatar: 'https://data-apibee.apispace.com/license/167773762614902e10710-8d88-4d7e-b962-2df477b361ec' + } + }); + }, + error: e => { + this.loading = false; + this.messages.push({ + text: 'ChatGPT Error', + date: new Date(), + reply: true, + type: 'text', + user: { + name: 'ChatGPT', + avatar: 'https://data-apibee.apispace.com/license/167773762614902e10710-8d88-4d7e-b962-2df477b361ec' + } + }); } - ) - .subscribe((res: any) => { - console.log(res); }); } sendMessage($event) { @@ -119,9 +151,24 @@ export class ChatgptRobotComponent implements OnInit { reply: false, type: 'text', user: { - name: 'Visitor', + name: $localize`Visitor`, avatar: 'https://data.eolink.com/PXMbLGmc2f0b29596764f7456eefb75478ed77b4fd172d9' } }); + this.sendChatGPTMessage($event); + } + watchExtensionChange() { + this.message.get().subscribe((inArg: Message) => { + if (inArg.type !== 'extensionsChange') return; + const extension: ExtensionInfo = inArg.data.extension; + if (!extension?.features?.featureControl?.length) return; + switch (inArg.data.action) { + case 'install': + case 'enable': { + this.chat.open(); + break; + } + } + }); } } diff --git a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts index 5cbe94f54..c3d9e2d07 100644 --- a/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts +++ b/src/workbench/browser/src/app/pages/extension/detail/extension-detail.component.ts @@ -149,11 +149,11 @@ ${log} switch (operate) { case 'install': { const { name, version, i18n } = this.extensionDetail; + this.extensionDetail['enabled'] = true; this.extensionDetail.installed = await this.extensionService.installExtension({ name, version }); - this.extensionDetail['enabled'] = true; this.trace.report('install_extension_success', { extension_id: id }); break; } diff --git a/src/workbench/browser/src/app/pages/workspace/project/api/api.component.ts b/src/workbench/browser/src/app/pages/workspace/project/api/api.component.ts index 16df8b2cb..8f07ef037 100644 --- a/src/workbench/browser/src/app/pages/workspace/project/api/api.component.ts +++ b/src/workbench/browser/src/app/pages/workspace/project/api/api.component.ts @@ -98,7 +98,7 @@ export class ApiComponent implements OnInit, OnDestroy { } watchInstalledExtensionsChange() { this.messageService.get().subscribe((inArg: Message) => { - if (inArg.type === 'installedExtensionsChange') { + if (inArg.type === 'extensionsChange') { const name = inArg.data.name; const extension: ExtensionInfo = inArg.data.installedMap.get(name); if (!extension?.features?.apiPreviewTab) return; diff --git a/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts b/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts index 1c2f9592a..fcdbf72dc 100644 --- a/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts +++ b/src/workbench/browser/src/app/shared/services/extensions/extension.service.ts @@ -48,7 +48,6 @@ export class ExtensionService { if (this.installedList.some(m => m.name === val.name)) return; installedName.push(val.name); }); - //* Install Extension by foreach because of async const uniqueNames = [...Array.from(new Set(installedName)), ...this.webExtensionService.debugExtensionNames]; for (let i = 0; i < uniqueNames.length; i++) { @@ -85,9 +84,10 @@ export class ExtensionService { this.extensionIDs = this.updateExtensionIDs(); this.installedList = Array.from(this.installedMap.values()).filter(it => this.extensionIDs.includes(it.name)); this.messageService.send({ - type: 'installedExtensionsChange', + type: 'extensionsChange', data: { installedMap: this.installedMap, + extension: this.installedList.find(val => val.name === opts.name), ...opts } }); @@ -117,8 +117,8 @@ export class ExtensionService { } result.data = [ - ...result.data.filter(val => this.installedList.every(childVal => childVal.name !== val.name)), - //Local debug package + ...debugExtensions, + //Installed package ...this.installedList .filter(n => { const target = result.data.find(m => n.name === m.name); @@ -132,7 +132,7 @@ export class ExtensionService { } return module; }), - ...debugExtensions + ...result.data.filter(val => this.installedList.every(childVal => childVal.name !== val.name)) ]; //Handle feature data result.data = result.data.map(module => { @@ -205,10 +205,12 @@ export class ExtensionService { } } async uninstallExtension(name): Promise { + const extension = this.installedList.find(it => it.name === name); const successCallback = () => { this.updateInstalledInfo(this.getExtensions(), { action: 'uninstall', - name + name, + extension }); }; if (this.electron.isElectron) { diff --git a/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts b/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts index a403b622c..81d63db21 100644 --- a/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts +++ b/src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts @@ -37,7 +37,7 @@ export class WebExtensionService { resourceUrl = 'https://unpkg.com'; constructor(private web: WebService, private language: LanguageService, private extensionCommon: ExtensionCommonService) { const isDevEnv = !APP_CONFIG.production || this.web.isVercel || 'http://52.76.76.88:8080'.includes(window.location.hostname); - this.debugExtensionNames = isDevEnv ? ['postcat-chat-robot'] : []; + this.debugExtensionNames = isDevEnv && this.web.isWeb ? [] : []; } async installExtension(extName: string, { version = 'latest' }) { //Get package.json diff --git a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts index 3bae9d080..e6430023e 100644 --- a/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts +++ b/src/workbench/browser/src/app/shared/services/storage/http/lib/baseUrl.service.ts @@ -1,7 +1,5 @@ import { HttpErrorResponse, HttpEvent, HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { WebService } from 'eo/workbench/browser/src/app/core/services'; -import { SettingService } from 'eo/workbench/browser/src/app/modules/system-setting/settings.service'; import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message'; import { StoreService } from 'eo/workbench/browser/src/app/shared/store/state.service'; import { filter, map, tap, Observable, catchError } from 'rxjs'; @@ -17,14 +15,16 @@ export class BaseUrlInterceptor implements HttpInterceptor { constructor(private store: StoreService, private messageService: MessageService) {} intercept(req: HttpRequest, next: HttpHandler): Observable> { + const isSystemUrl = !this.protocolReg.test(req.url); + if (!isSystemUrl) return next.handle(req); + const serverUrl = this.store.remoteUrl || ''; req = req.clone({ - url: this.protocolReg.test(req.url) ? req.url : `${serverUrl}${req.url}`, + url: `${serverUrl}${req.url}`, headers: new HttpHeaders({ Authorization: this.store.getLoginInfo?.accessToken || '' }) }); - return next.handle(req).pipe( filter(event => event instanceof HttpResponse && [200, 201].includes(event.status)), map((event: HttpResponse) =>