Skip to content

Commit

Permalink
fix/v0.3.1 (Postcatlab#245)
Browse files Browse the repository at this point in the history
* fix: open multiple add api tab cause navigation error

* refactor: tab jump multiple time

* wip: merge e2e

* chore: update build script

* style: rename variable

* fix(api-test): rest/query params change but send still use old data

* refactor: unified replication logic

* fix: local workspace global tip

* fix(api-detail): change env but url not change

* fix: formdata limit max length 255

* build: update reliace

* fix:  Illegal return statement

* fix: some bug

* fix: some bug

* fix: some bug

* feat: 0.3.1

---------

Co-authored-by: bqy_fe <1743369777@qq.com>
  • Loading branch information
scarqin and buqiyuan authored Mar 2, 2023
1 parent 08d5ed8 commit 0697626
Show file tree
Hide file tree
Showing 64 changed files with 499 additions and 278 deletions.
5 changes: 0 additions & 5 deletions e2e/playwright.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "Postcat",
"souceLocale": "zh-Hans",
"version": "0.3.0",
"name": "postcat",
"version": "0.3.1",
"main": "out/app/electron-main/main.js",
"description": "A lightweight, extensible API tool",
"homepage": "https://github.com/Postcatlab/postcat.git",
Expand All @@ -23,7 +22,8 @@
"electron:static": "npm run electron:tsc && electron .",
"release": "npm-run-all -s electron:build:web electron:tsc && npx esno scripts/build.ts --publish=always && node upload.js",
"test": "npm-run-all --serial test:*",
"e2e": "yarn build:prod && npx playwright test -c e2e/playwright.config.ts e2e/",
"e2e": "cd test/e2e&&npx playwright test -c playwright.config.ts",
"test:e2e":"npm-run-all -s start:web test:e2e",
"clear:electron:tsc": "tsc --build --clean",
"electron:tsc": "tsc -p tsconfig.json",
"electron:dev": "npm run electron:tsc && electron . --development",
Expand Down
2 changes: 2 additions & 0 deletions src/app/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class EoBrowserWindow {
const opts = {
useContentSize: true, // 这个要设置,不然计算显示区域尺寸不准
frame: os.type() === 'Darwin' ? true : false, //mac use default frame
minWidth: 400,
minHeight: 300,
webPreferences: {
webSecurity: false,
preload: path.join(__dirname, '../../', 'platform', 'electron-browser', 'preload.js'),
Expand Down
126 changes: 125 additions & 1 deletion src/workbench/browser/angular.json
Original file line number Diff line number Diff line change
@@ -1 +1,125 @@
{"$schema":"./node_modules/@angular/cli/lib/config/schema.json","cli":{"analytics":false,"defaultCollection":"@angular-eslint/schematics","cache":{"enabled":true}},"version":1,"newProjectRoot":"projects","projects":{"postcat":{"root":"","i18n":{"sourceLocale":{"code":"en","baseHref":""},"locales":{"zh":{"translation":"locale/messages.zh.xlf","baseHref":""}}},"sourceRoot":"src","projectType":"application","schematics":{"@schematics/angular:application":{"strict":true}},"architect":{"build":{"inlineStyleLanguage":"scss","builder":"@angular-builders/custom-webpack:browser","options":{"localize":true,"aot":true,"outputPath":"dist","index":"src/index.html","main":"src/main.ts","tsConfig":"src/tsconfig.app.json","polyfills":"src/polyfills.ts","assets":["src/icon.ico","src/assets","src/extensions",{"glob":"**/*","input":"../../../node_modules/monaco-editor/min/vs","output":"/assets/vs/"}],"styles":["src/styles/antd.less","src/styles.scss"],"scripts":["src/assets/libs/protocolcheck.js"],"customWebpackConfig":{"path":"./angular.webpack.js","replaceDuplicatePlugins":true},"allowedCommonJsDependencies":["brace","qs","rxjs"]},"configurations":{"dev":{"optimization":false,"outputHashing":"none","sourceMap":true,"namedChunks":false,"localize":false,"preserveSymlinks":true,"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.dev.ts"}]},"devCn":{"optimization":false,"outputHashing":"none","sourceMap":true,"namedChunks":false,"preserveSymlinks":true,"localize":["zh"],"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.dev.ts"}]},"production":{"preserveSymlinks":false,"optimization":true,"outputHashing":"all","sourceMap":false,"namedChunks":false,"extractLicenses":true,"vendorChunk":false,"buildOptimizer":true,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.prod.ts"}]},"docker":{"optimization":true,"outputHashing":"all","sourceMap":false,"namedChunks":false,"extractLicenses":true,"vendorChunk":false,"buildOptimizer":true,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.docker.ts"}]}}},"serve":{"builder":"@angular-builders/custom-webpack:dev-server","options":{"browserTarget":"postcat:build","proxyConfig":"proxy.conf.json"},"configurations":{"dev":{"browserTarget":"postcat:build:dev"},"devCn":{"browserTarget":"postcat:build:devCn"},"production":{"browserTarget":"postcat:build:production"}}},"extract-i18n":{"builder":"@angular-devkit/build-angular:extract-i18n","options":{"browserTarget":"postcat:build"}},"test":{"inlineStyleLanguage":"scss","builder":"@angular-builders/custom-webpack:karma","options":{"main":"src/test.ts","polyfills":"src/polyfills-test.ts","tsConfig":"src/tsconfig.spec.json","karmaConfig":"src/karma.conf.js","scripts":[],"styles":["src/styles.scss"],"assets":["src/assets"],"customWebpackConfig":{"path":"./angular.webpack.js","replaceDuplicatePlugins":true}}},"lint":{"builder":"@angular-eslint/builder:lint","options":{"lintFilePatterns":["src/**/*.ts","src/**/*.html"]}}}},"postcat-e2e":{"root":"e2e","projectType":"application","architect":{"lint":{"builder":"@angular-eslint/builder:lint","options":{"lintFilePatterns":["e2e/**/*.ts"]}}}}},"defaultProject":"postcat","schematics":{"@schematics/angular:component":{"prefix":"pc","style":"scss","inlineStyle":true,"inlineTemplate":true},"@schematics/angular:directive":{"prefix":"pc"}}}
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": { "analytics": false, "defaultCollection": "@angular-eslint/schematics", "cache": { "enabled": true } },
"version": 1,
"newProjectRoot": "projects",
"projects": {
"postcat": {
"root": "",
"i18n": {
"sourceLocale": { "code": "en", "baseHref": "" },
"locales": { "zh": { "translation": "locale/messages.zh.xlf", "baseHref": "" } }
},
"sourceRoot": "src",
"projectType": "application",
"schematics": { "@schematics/angular:application": { "strict": true } },
"architect": {
"build": {
"inlineStyleLanguage": "scss",
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"localize": true,
"aot": true,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/icon.ico",
"src/assets",
"src/extensions",
{ "glob": "**/*", "input": "../../../node_modules/monaco-editor/min/vs", "output": "/assets/vs/" }
],
"styles": ["src/styles/antd.less", "src/styles.scss"],
"scripts": ["src/assets/libs/protocolcheck.js"],
"customWebpackConfig": { "path": "./angular.webpack.js", "replaceDuplicatePlugins": true },
"allowedCommonJsDependencies": ["brace", "qs", "rxjs"]
},
"configurations": {
"dev": {
"optimization": false,
"outputHashing": "none",
"sourceMap": true,
"namedChunks": false,
"localize": false,
"preserveSymlinks": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.ts" }]
},
"devCn": {
"optimization": false,
"outputHashing": "none",
"sourceMap": true,
"namedChunks": false,
"preserveSymlinks": true,
"localize": ["zh"],
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.ts" }]
},
"production": {
"preserveSymlinks": false,
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" }]
},
"docker": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.docker.ts" }]
}
}
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": { "browserTarget": "postcat:build", "proxyConfig": "proxy.conf.json" },
"configurations": {
"dev": { "browserTarget": "postcat:build:dev" },
"devCn": { "browserTarget": "postcat:build:devCn" },
"production": { "browserTarget": "postcat:build:production" }
}
},
"extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "postcat:build" } },
"test": {
"inlineStyleLanguage": "scss",
"builder": "@angular-builders/custom-webpack:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills-test.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"scripts": [],
"styles": ["src/styles.scss"],
"assets": ["src/assets"],
"customWebpackConfig": { "path": "./angular.webpack.js", "replaceDuplicatePlugins": true }
}
},
"lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } }
}
},
"postcat-e2e": {
"root": "e2e",
"projectType": "application",
"architect": { "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["e2e/**/*.ts"] } } }
}
},
"defaultProject": "postcat",
"schematics": {
"@schematics/angular:component": { "prefix": "pc", "style": "scss", "inlineStyle": true, "inlineTemplate": true },
"@schematics/angular:directive": { "prefix": "pc" }
}
}
28 changes: 14 additions & 14 deletions src/workbench/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@
"ajv": "8.12.0",
"color": "^4.2.3",
"core-js": "3.27.2",
"eo-ng-auto-complete": "0.1.5",
"eo-ng-button": "0.1.5",
"eo-ng-checkbox": "0.1.5",
"eo-ng-dropdown": "0.1.5",
"eo-ng-feedback": "0.1.5",
"eo-ng-input": "0.1.5",
"eo-ng-layout": "0.1.5",
"eo-ng-menu": "0.1.5",
"eo-ng-radio": "0.1.5",
"eo-ng-select": "0.1.5",
"eo-ng-switch": "0.1.5",
"eo-ng-table": "0.1.5",
"eo-ng-tabs": "0.1.5",
"eo-ng-tree": "0.1.5",
"eo-ng-auto-complete": "0.1.11",
"eo-ng-button": "0.1.10",
"eo-ng-checkbox": "0.1.10",
"eo-ng-dropdown": "0.1.10",
"eo-ng-feedback": "0.1.10",
"eo-ng-input": "0.1.10",
"eo-ng-layout": "0.1.10",
"eo-ng-menu": "0.1.10",
"eo-ng-radio": "0.1.10",
"eo-ng-select": "0.1.10",
"eo-ng-switch": "0.1.10",
"eo-ng-table": "0.1.11",
"eo-ng-tabs": "0.1.10",
"eo-ng-tree": "0.1.10",
"is-xml": "0.1.0",
"js-beautify": "1.14.7",
"lodash-es": "4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,13 @@ export class ThemeVariableService {
'tableRowHoverBackground',
'treeHoverBackground',
'buttonDefaultHoverBackground',
'layoutFooterItemHoverBackground',
'buttonTextHoverBackground'
'layoutFooterItemHoverBackground'
]
},
{
action: 'darken',
alpha: 0.05,
target: ['buttonTextHoverBackground']
}
]
},
Expand Down Expand Up @@ -449,7 +453,7 @@ export class ThemeVariableService {
const barBackgroundRule = colorsDefaultRule.find(val => val.source === 'barBackground');
barBackgroundRule.rule.push({
action: 'darken',
alpha: 0.03,
alpha: 0.01,
target: ['itemHoverBackground', 'itemActiveBackground', 'layoutFooterItemHoverBackground']
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export type ThemeColorRule = {
rule?: ThemeColorSingleRule[];
};
export type ThemeColorSingleRule = {
action?: 'replace' | 'filter' | string;
action?: 'replace' | 'filter' | 'darken' | string;
alpha?: number;
target?: Array<keyof ThemeColors> | string[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ import { StorageUtil } from '../../utils/storage/storage.utils';
export class LocalWorkspaceTipComponent implements OnInit {
@Input() isShow: boolean;
@Output() readonly isShowChange: EventEmitter<boolean> = new EventEmitter<boolean>();

manualClose = StorageUtil.get(IS_SHOW_REMOTE_SERVER_NOTIFICATION) === 'false';
constructor(
private eoMessage: EoNgFeedbackMessageService,
private message: MessageService,
private store: StoreService,
private effect: EffectService
) {}
ngOnInit(): void {
this.isShow = StorageUtil.get(IS_SHOW_REMOTE_SERVER_NOTIFICATION) !== 'false';
autorun(() => {
const status = this.store.isLocal && this.store.isLogin && this.isShow;
Promise.resolve().then(() => {
this.isShowChange.emit(status);
});
this.updateIsShow();
});
}
updateIsShow() {
const status = this.store.isLocal && this.store.isLogin && !this.manualClose;
Promise.resolve().then(() => {
this.isShowChange.emit(status);
});
}

switchToTheCloud = () => {
const workspaces = this.store.getWorkspaceList;
if (workspaces.length === 1) {
Expand All @@ -61,7 +62,8 @@ export class LocalWorkspaceTipComponent implements OnInit {
};

closeNotification() {
this.isShow = false;
StorageUtil.set(IS_SHOW_REMOTE_SERVER_NOTIFICATION, 'false');
this.manualClose = true;
StorageUtil.set(IS_SHOW_REMOTE_SERVER_NOTIFICATION, 'false', 60 * 60 * 24 * 15);
this.updateIsShow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ import { DataSourceService } from '../../shared/services/data-source/data-source
<nz-spin *ngIf="!link" class="flex-1 mt-[10px]"></nz-spin>
</div>
<ng-container *ngIf="link">
<p nz-typography nzCopyable nzEllipsis [nzCopyText]="link" [nzCopyIcons]="[copedIcon, copedIcon]">
{{ link }}
</p>
<p nz-typography [nzContent]="link" nzCopyable nzEllipsis [nzCopyText]="link" [nzCopyIcons]="[copedIcon, copedIcon]"> </p>
<ng-template #copedIcon>
<button eo-ng-button nzType="text"><eo-iconpark-icon name="copy"></eo-iconpark-icon></button>
</ng-template>
Expand All @@ -56,23 +54,6 @@ export class GetShareLinkComponent {
public dataSourceService: DataSourceService,
private message: EoNgFeedbackMessageService
) {}
handleCopy() {
if (this.isCopy) {
return;
}
if (!this.link) {
this.isCopy = false;
return;
}
const isOk = copy(this.link);
if (isOk) {
this.message.success($localize`Copied`);
this.isCopy = true;
interval(700).subscribe(() => {
this.isCopy = false;
});
}
}
handleGetShareLink() {
this.dataSourceService.checkRemoteCanOperate(async () => {
if (this.store.isLocal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EoNgFeedbackMessageService } from 'eo-ng-feedback';
import { ApiMockService } from 'eo/workbench/browser/src/app/pages/workspace/project/api/http/mock/api-mock.service';
import { ApiMockEditComponent } from 'eo/workbench/browser/src/app/pages/workspace/project/api/http/mock/edit/api-mock-edit.component';
import { ModalService } from 'eo/workbench/browser/src/app/shared/services/modal.service';
import { copyText, eoDeepCopy, copy } from 'eo/workbench/browser/src/app/utils/index.utils';
import { eoDeepCopy, copy } from 'eo/workbench/browser/src/app/utils/index.utils';

import { ApiData } from '../../shared/services/storage/db/models/apiData';
import { ApiMockEntity } from '../../shared/services/storage/index.model';
Expand All @@ -12,12 +12,19 @@ import { ApiMockEntity } from '../../shared/services/storage/index.model';
selector: 'eo-api-mock-table',
template: ` <eo-ng-table-pro [columns]="mockListColumns" [nzData]="mockList"></eo-ng-table-pro>
<ng-template #urlCell let-item="item" let-index="index">
<div class="flex items-center">
<span class="truncate flex-1">
{{ item.url }}
</span>
<button eo-ng-button nzType="text" (click)="copyText(item.url)"><eo-iconpark-icon name="copy"></eo-iconpark-icon></button>
</div>
<p
class="flex-1"
[nzContent]="item.url"
nz-typography
nzCopyable
nzEllipsis
[nzCopyText]="item.url"
[nzCopyIcons]="[copedIcon, copedIcon]"
>
</p>
<ng-template #copedIcon>
<button eo-ng-button nzType="text"><eo-iconpark-icon name="copy"></eo-iconpark-icon></button>
</ng-template>
</ng-template>`
})
export class ApiMockTableComponent implements OnInit, OnChanges {
Expand Down Expand Up @@ -122,10 +129,6 @@ export class ApiMockTableComponent implements OnInit, OnChanges {
});
}

async copyText(text: string) {
await copyText(text);
this.message.success($localize`Copied`);
}
async addOrEditModal(item, index?) {
if (item.id) {
await this.apiMock.updateMock(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class ApiTableService {
left: true,
type: 'input',
columnVisible: 'fixed',
maxlength: 65535,
key: 'name'
},
dataType: {
Expand All @@ -94,6 +95,7 @@ export class ApiTableService {
example: {
title: $localize`Example`,
type: 'input',
maxlength: 65535,
key: 'paramAttr.example'
},
editOperate: {
Expand Down Expand Up @@ -233,6 +235,7 @@ export class ApiTableService {
title: $localize`Name`,
left: true,
type: 'input',
maxlength: 65535,
columnVisible: 'fixed',
disabledFn: inArg.in === 'header' ? item => has(item, 'editable') && !item.editable : undefined,
key: 'name'
Expand All @@ -252,6 +255,7 @@ export class ApiTableService {
value: {
title: $localize`Value`,
type: 'input',
maxlength: 65535,
key: 'paramAttr.example'
},
editOperate: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<eo-monaco-editor
class="mt-[15px] border-all"
[(code)]="paramCode"
[maxHeight]="400"
[minHeight]="150"
[editorType]="contentTypeEditor"
[eventList]="['type', 'format', 'copy', 'search', 'replace']"
></eo-monaco-editor>
Expand Down
Loading

0 comments on commit 0697626

Please sign in to comment.