From 8aa173524391e3c441f6c3d24b4e61862abf5f36 Mon Sep 17 00:00:00 2001 From: Scarqin Date: Fri, 20 Jan 2023 19:36:09 +0800 Subject: [PATCH] Feat/new api (#218) * logon/workspace/project java frontend * support custom theme --- .gitignore | 1 + donkey.config.js | 6 +- e2e/api.t | 2 +- e2e/group.spec.ts | 2 +- e2e/package.json | 7 +- e2e/yarn.lock | 55 + package.json | 4 +- scripts/upgradeComponent.js | 10 - src/app/electron-main/main.ts | 5 +- src/platform/common/i18n.ts | 4 +- .../node/extension-manager/lib/core.ts | 53 +- .../node/extension-manager/lib/manager.ts | 53 +- src/platform/node/i18n.ts | 8 +- src/shared/electron-main/constant.ts | 1 - src/workbench/browser/.gitignore | 1 + src/workbench/browser/LICENSE | 370 +-- src/workbench/browser/README.md | 12 +- src/workbench/browser/angular.json | 38 +- src/workbench/browser/angular.webpack.js | 12 +- src/workbench/browser/build/build.js | 16 +- src/workbench/browser/locale/messages.xlf | 2300 +++++---------- src/workbench/browser/locale/messages.zh.xlf | 2497 +++++------------ src/workbench/browser/package.json | 28 +- src/workbench/browser/proxy.conf.json | 23 + src/workbench/browser/src/app/app.module.ts | 26 +- .../feature-control.service.ts | 13 + .../services/feature-control/feature.json | 7 + .../services/language/language.service.ts | 1 + .../browser/src/app/core/services/theme.json | 169 -- .../src/app/core/services/theme.service.ts | 110 - .../app/core/services/theme/theme-colors.json | 223 ++ .../services/theme/theme-extension.service.ts | 33 + .../services/theme/theme-variable.service.ts | 588 ++++ .../app/core/services/theme/theme.constant.ts | 106 + .../app/core/services/theme/theme.model.ts | 235 ++ .../app/core/services/theme/theme.service.ts | 214 ++ .../src/app/core/services/web/web.service.ts | 9 +- .../local-workspace-tip.component.scss | 7 +- .../local-workspace-tip.component.ts | 31 +- .../breadcrumb/nav-breadcrumb.component.scss | 5 + .../breadcrumb/nav-breadcrumb.component.ts | 10 +- .../select-workspace.component.scss | 19 +- .../select-workspace.component.ts | 60 +- .../navbar/get-share-link.component.ts | 7 +- .../app/layouts/navbar/navbar.component.html | 50 +- .../app/layouts/navbar/navbar.component.scss | 12 +- .../app/layouts/navbar/navbar.component.ts | 41 +- .../src/app/layouts/navbar/navbar.module.ts | 4 +- .../page-not-found.component.ts | 9 +- .../layouts/sidebar/sidebar.component.html | 2 +- .../layouts/sidebar/sidebar.component.scss | 25 +- .../app/layouts/sidebar/sidebar.component.ts | 36 +- .../app/layouts/sidebar/sidebar.service.ts | 10 +- .../layouts/toolbar/toolbar.component.html | 2 +- .../layouts/toolbar/toolbar.component.scss | 25 +- .../api-shared/api-mock-table.component.ts | 34 +- .../modules/api-shared/api-param-num.pipe.ts | 5 +- .../modules/api-shared/api-table.service.ts | 89 +- .../api-test-header.component.html | 1 + .../api-test-header.component.ts | 20 +- .../api-test-query.component.ts | 12 +- .../api-test-result-header.component.ts | 12 +- .../api-shared/api-test-util.service.ts | 254 +- .../src/app/modules/api-shared/api.model.ts | 340 +-- .../params-import/params-import.component.ts | 11 +- .../download-client.component.ts | 35 + .../download-client/download-client.module.ts | 14 + .../collapse/collapse-panel.component.ts | 10 +- .../eo-ui/collapse/collapse.component.scss | 33 +- .../eo-iconpark-icon.component.ts | 3 + .../eo-ui/monaco-editor/defaultCompletions.ts | 210 +- .../monaco-editor.component.scss | 6 +- .../monaco-editor/monaco-editor.component.ts | 2 +- .../eo-ui/shadow/eo-shadow-dom.component.scss | 8 +- .../shadow-dom-encapsulation.component.ts | 10 +- .../modules/eo-ui/tab/tab-operate.service.ts | 10 +- .../modules/eo-ui/tab/tab-storage.service.ts | 2 +- .../app/modules/eo-ui/tab/tab.component.html | 8 +- .../app/modules/eo-ui/tab/tab.component.scss | 15 +- .../src/app/modules/eo-ui/tab/tab.model.ts | 2 +- .../eo-ui/table-pro/table-pro.component.html | 4 +- .../eo-ui/table-pro/table-pro.component.scss | 4 +- .../eo-ui/table-pro/table-pro.component.ts | 41 +- .../eo-ui/table-pro/table-pro.token.ts | 4 +- .../export-api/export-api.component.ts | 49 +- .../import-api/import-api.component.ts | 83 +- .../select/extension-select.component.html | 4 +- .../select/extension-select.component.scss | 18 +- .../sync-api/sync-api.component.ts | 2 +- .../src/app/modules/logo/logo.component.scss | 7 + .../src/app/modules/logo/logo.component.ts | 41 + .../src/app/modules/logo/logo.module.ts | 9 + .../member-list/member-list.component.scss | 2 +- .../member-list/member-list.component.ts | 57 +- .../app/modules/member-list/member.service.ts | 14 +- .../system-setting/common/about.component.ts | 15 +- .../common/account.component.ts | 10 +- .../common/data-storage.component.ts | 4 +- .../select-theme/select-theme.component.scss | 18 +- .../select-theme/select-theme.component.ts | 35 +- .../common/select-theme/theme.model.ts | 62 - .../system-setting.component.scss | 2 +- .../system-setting/system-setting.module.ts | 3 +- .../extensions-settings.component.ts | 4 +- .../detail/extension-detail.component.scss | 4 +- .../detail/extension-detail.component.ts | 9 +- .../pages/extension/extension.component.html | 2 +- .../pages/extension/extension.component.scss | 4 +- .../pages/extension/extension.component.ts | 6 +- .../app/pages/extension/extension.model.ts | 6 +- .../list/extension-list.component.html | 13 +- .../list/extension-list.component.ts | 31 +- .../src/app/pages/pages.component.scss | 16 +- .../browser/src/app/pages/pages.component.ts | 5 +- .../app/pages/services/redirect.services.ts | 2 +- .../src/app/pages/user-modal.component.ts | 186 +- .../edit/workspace-edit.component.ts | 33 +- .../member/workspace-member.component.ts | 48 +- .../member/workspace-member.service.ts | 141 +- .../project-list/project-list.component.html | 2 +- .../project-list/project-list.component.scss | 2 +- .../project-list/project-list.component.ts | 48 +- .../workspace-overview.component.html | 10 +- .../workspace-overview.component.scss | 4 +- .../overview/workspace-overview.component.ts | 22 +- .../overview/workspace-overview.module.ts | 2 + .../workspace/project/api/api-tab.service.ts | 16 +- .../workspace/project/api/api.component.html | 87 +- .../workspace/project/api/api.component.scss | 74 +- .../workspace/project/api/api.component.ts | 33 +- .../pages/workspace/project/api/api.module.ts | 4 +- .../workspace/project/api/api.service.ts | 104 +- .../group/edit/api-group-edit.component.ts | 53 +- .../group/tree/api-group-tree.component.html | 46 +- .../group/tree/api-group-tree.component.scss | 61 +- .../tree/api-group-tree.component.spec.ts | 10 +- .../group/tree/api-group-tree.component.ts | 623 ++-- .../history/eo-history.component.html | 15 +- .../history/eo-history.component.scss | 6 +- .../history/eo-history.component.ts | 72 +- .../api/env/env-edit/env-edit.component.html | 2 +- .../api/env/env-edit/env-edit.component.ts | 70 +- .../api/env/env-list/env-list.component.html | 56 +- .../api/env/env-list/env-list.component.scss | 26 +- .../api/env/env-list/env-list.component.ts | 17 +- .../env/env-select/env-select.component.scss | 44 +- .../env/env-select/env-select.component.ts | 134 +- .../workspace/project/api/env/env.module.ts | 2 + .../api/http/detail/api-detail.component.html | 73 +- .../api/http/detail/api-detail.component.scss | 7 - .../api/http/detail/api-detail.component.ts | 23 +- .../api/http/detail/api-detail.module.ts | 4 +- .../body/api-detail-body.component.html | 8 +- .../detail/body/api-detail-body.component.ts | 16 +- .../eo-api-methods-tag.component.scss | 2 +- .../detail/form/api-detail-form.component.ts | 5 +- .../api/http/edit/api-edit-util.service.ts | 99 +- .../api/http/edit/api-edit.component.html | 275 +- .../api/http/edit/api-edit.component.scss | 2 +- .../api/http/edit/api-edit.component.ts | 219 +- .../project/api/http/edit/api-edit.module.ts | 4 +- .../project/api/http/edit/api-edit.service.ts | 79 +- .../edit/body/api-edit-body.component.html | 30 +- .../http/edit/body/api-edit-body.component.ts | 117 +- .../api-params-extra-setting.component.html | 16 +- .../api-params-extra-setting.component.scss | 8 +- .../api-params-extra-setting.component.ts | 41 +- .../edit/header/api-edit-header.component.ts | 13 +- .../edit/query/api-edit-query.component.ts | 13 +- .../http/edit/rest/api-edit-rest.component.ts | 13 +- .../api/http/mock/api-mock.component.html | 3 +- .../api/http/mock/api-mock.component.ts | 28 +- .../project/api/http/mock/api-mock.module.ts | 4 +- .../project/api/http/mock/api-mock.service.ts | 72 +- .../http/mock/edit/api-mock-edit.component.ts | 4 +- .../test/api-script/api-script.component.html | 2 +- .../test/api-script/api-script.component.scss | 4 + .../api/http/test/api-script/constant.ts | 1140 ++++---- .../api/http/test/api-test.component.html | 72 +- .../api/http/test/api-test.component.scss | 15 +- .../api/http/test/api-test.component.ts | 265 +- .../project/api/http/test/api-test.model.ts | 252 +- .../project/api/http/test/api-test.module.ts | 1 - .../project/api/http/test/api-test.service.ts | 76 +- .../test/body/api-test-body.component.html | 24 +- .../http/test/body/api-test-body.component.ts | 110 +- .../http/test/rest/api-test-rest.component.ts | 17 +- ...pi-test-result-request-body.component.html | 6 +- ...pi-test-result-request-body.component.scss | 2 +- .../api-test-result-request-body.component.ts | 10 +- .../api-test-result-response.component.html | 4 +- .../api-test-result-response.component.scss | 28 +- .../api-test-result-response.component.ts | 4 +- .../api/service/api-test/api-test.utils.ts | 204 +- .../local-node/api-server-data.model.ts | 4 - .../api/service/api-test/test-server.model.ts | 64 +- .../service/api-test/test-server.service.ts | 4 +- .../api/websocket/websocket.component.html | 18 +- .../api/websocket/websocket.component.scss | 32 +- .../api/websocket/websocket.component.ts | 28 +- .../member/project-member.component.ts | 20 +- .../project/member/project-member.service.ts | 135 +- .../setting/project-setting.component.html | 4 +- .../setting/project-setting.component.ts | 27 +- .../pages/workspace/workspace.component.ts | 27 +- .../browser/src/app/services/mock.service.ts | 103 +- .../extension-app/extension-app.component.ts | 13 +- .../directives/focus-form-input.directive.ts | 14 +- .../models/extension-manager/handler.ts | 2 +- .../shared/models/extension-manager/module.ts | 34 +- .../src/app/shared/models/shared.model.ts | 6 +- .../browser/src/app/shared/pipes/api.pipe.ts | 18 + .../data-source/data-source.service.ts | 50 +- .../services/extensions}/extension.service.ts | 163 +- .../extensions/webExtension.service.ts | 214 ++ .../src/app/shared/services/globalProvider.ts | 131 +- .../storage/IndexedDB/lib/index.constant.ts | 444 ++- .../services/storage/IndexedDB/lib/index.ts | 28 +- .../storage/IndexedDB/lib/validate.ts | 8 +- .../{apiData.json => apiData.schema.json} | 0 .../schema/{env.json => env.schema.json} | 0 .../shared/services/storage/api.service.ts | 437 ++- .../src/app/shared/services/storage/api.ts | 137 +- .../services/storage/db/dataSource/convert.ts | 110 + .../services/storage/db/dataSource/index.ts | 85 + .../storage/db/dataSource/migration.ts | 144 + .../storage/db/dataSource/oldApiData.ts | 292 ++ .../storage/db/dataSource/versions.ts | 50 + .../db/decorators/api-response.decorator.ts | 64 + .../db/decorators/base-hook.decorator.ts | 32 + .../services/storage/db/dto/apiData.dto.ts | 374 +++ .../services/storage/db/dto/common.dto.ts | 13 + .../services/storage/db/dto/group.dto.ts | 20 + .../services/storage/db/dto/project.dto.ts | 36 + .../app/shared/services/storage/db/index.ts | 22 + .../services/storage/db/initData/apiData.ts | 571 ++++ .../services/storage/db/models/apiData.ts | 249 ++ .../services/storage/db/models/index.ts | 60 + .../storage/db/services/apiData.service.ts | 100 + .../db/services/apiTestHistory.service.ts | 19 + .../storage/db/services/base.service.ts | 103 + .../db/services/environment.service.ts | 9 + .../storage/db/services/group.service.ts | 50 + .../storage/db/services/mock.service.ts | 9 + .../storage/db/services/project.service.ts | 176 ++ .../storage/db/services/workspace.service.ts | 9 + .../services/storage/db/tests/apiData.test.ts | 44 + .../storage/db/tests/apiGroup.test.ts | 54 + .../storage/db/tests/environment.test.ts | 54 + .../shared/services/storage/db/tests/index.ts | 7 + .../services/storage/db/tests/project.test.ts | 51 + .../storage/http/lib/baseUrl.service.ts | 50 +- .../shared/services/storage/http/model.d.ts | 11 +- .../shared/services/storage/index.model.ts | 181 +- .../shared/services/storage/local.service.ts | 1409 +++++----- .../shared/services/storage/remote.service.ts | 2354 +++++++++++----- .../web-extension/webExtension.service.ts | 91 - .../browser/src/app/shared/shared.module.ts | 11 +- .../src/app/shared/store/effect.service.ts | 553 ++-- .../src/app/shared/store/state.service.ts | 194 +- src/workbench/browser/src/app/utils/api.ts | 32 +- .../data-transfer/data-transfer.utils.spec.ts | 78 +- .../data-transfer/data-transfer.utils.ts | 103 +- .../browser/src/app/utils/index.utils.ts | 42 +- .../browser/src/app/utils/tree/tree.utils.ts | 97 +- .../browser/src/assets/font/iconpark.js | 2 +- .../browser/src/assets/icons/icon.ico | Bin 4286 -> 9170 bytes .../browser/src/assets/theme/blue.css | 20 - .../browser/src/assets/theme/orange.css | 20 - .../browser/src/assets/theme/purple.css | 20 - .../src/environments/environment.dev.ts | 3 +- .../src/environments/environment.docker.ts | 3 +- .../src/environments/environment.prod.ts | 3 +- .../browser/src/extensions/themes/blue.json | 5 + .../browser/src/extensions/themes/dark.json | 22 + .../browser/src/extensions/themes/debug.json | 53 + .../browser/src/extensions/themes/green.json | 5 + .../browser/src/extensions/themes/light.json | 22 + .../browser/src/extensions/themes/orange.json | 5 + src/workbench/browser/src/index.html | 1 + src/workbench/browser/src/polyfills.ts | 11 + src/workbench/browser/src/proxy.conf.json | 7 - src/workbench/browser/src/styles.scss | 156 +- src/workbench/browser/src/styles/antd.less | 192 +- src/workbench/browser/src/styles/atom.scss | 70 +- src/workbench/browser/src/styles/dark.less | 2 +- src/workbench/browser/src/styles/light.less | 5 - .../browser/src/styles/themes/base.less | 94 - .../browser/src/styles/themes/dark.css | 53 - .../browser/src/styles/themes/default.css | 96 - .../browser/src/styles/themes/light.css | 54 - .../browser/src/styles/variables.css | 29 + src/workbench/browser/src/tsconfig.app.json | 27 +- src/workbench/browser/src/typings.d.ts | 1 + src/workbench/browser/stylelint.config.js | 58 +- src/workbench/node/request/libs/apiUtil.js | 2 + tools/debugComponents.js | 29 + tools/getVSCodeThemes.js | 93 + tools/replaceCssVariable.js | 121 + tools/unlinkComponents.js | 29 + tools/upgradeComponent.js | 9 + yarn.lock | 995 ++++--- 302 files changed, 15590 insertions(+), 11705 deletions(-) delete mode 100644 scripts/upgradeComponent.js create mode 100644 src/workbench/browser/proxy.conf.json create mode 100644 src/workbench/browser/src/app/core/services/feature-control/feature-control.service.ts create mode 100644 src/workbench/browser/src/app/core/services/feature-control/feature.json delete mode 100644 src/workbench/browser/src/app/core/services/theme.json delete mode 100644 src/workbench/browser/src/app/core/services/theme.service.ts create mode 100644 src/workbench/browser/src/app/core/services/theme/theme-colors.json create mode 100644 src/workbench/browser/src/app/core/services/theme/theme-extension.service.ts create mode 100644 src/workbench/browser/src/app/core/services/theme/theme-variable.service.ts create mode 100644 src/workbench/browser/src/app/core/services/theme/theme.constant.ts create mode 100644 src/workbench/browser/src/app/core/services/theme/theme.model.ts create mode 100644 src/workbench/browser/src/app/core/services/theme/theme.service.ts create mode 100644 src/workbench/browser/src/app/modules/download-client/download-client.component.ts create mode 100644 src/workbench/browser/src/app/modules/download-client/download-client.module.ts create mode 100644 src/workbench/browser/src/app/modules/logo/logo.component.scss create mode 100644 src/workbench/browser/src/app/modules/logo/logo.component.ts create mode 100644 src/workbench/browser/src/app/modules/logo/logo.module.ts delete mode 100644 src/workbench/browser/src/app/modules/system-setting/common/select-theme/theme.model.ts create mode 100644 src/workbench/browser/src/app/shared/pipes/api.pipe.ts rename src/workbench/browser/src/app/{pages/extension => shared/services/extensions}/extension.service.ts (65%) create mode 100644 src/workbench/browser/src/app/shared/services/extensions/webExtension.service.ts rename src/workbench/browser/src/app/shared/services/storage/IndexedDB/schema/{apiData.json => apiData.schema.json} (100%) rename src/workbench/browser/src/app/shared/services/storage/IndexedDB/schema/{env.json => env.schema.json} (100%) create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dataSource/convert.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dataSource/index.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dataSource/migration.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dataSource/oldApiData.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dataSource/versions.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/decorators/api-response.decorator.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/decorators/base-hook.decorator.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dto/apiData.dto.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dto/common.dto.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dto/group.dto.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/dto/project.dto.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/index.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/initData/apiData.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/models/apiData.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/models/index.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/apiData.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/apiTestHistory.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/base.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/environment.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/group.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/mock.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/project.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/services/workspace.service.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/tests/apiData.test.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/tests/apiGroup.test.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/tests/environment.test.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/tests/index.ts create mode 100644 src/workbench/browser/src/app/shared/services/storage/db/tests/project.test.ts delete mode 100644 src/workbench/browser/src/app/shared/services/web-extension/webExtension.service.ts delete mode 100644 src/workbench/browser/src/assets/theme/blue.css delete mode 100644 src/workbench/browser/src/assets/theme/orange.css delete mode 100644 src/workbench/browser/src/assets/theme/purple.css create mode 100644 src/workbench/browser/src/extensions/themes/blue.json create mode 100644 src/workbench/browser/src/extensions/themes/dark.json create mode 100644 src/workbench/browser/src/extensions/themes/debug.json create mode 100644 src/workbench/browser/src/extensions/themes/green.json create mode 100644 src/workbench/browser/src/extensions/themes/light.json create mode 100644 src/workbench/browser/src/extensions/themes/orange.json delete mode 100644 src/workbench/browser/src/proxy.conf.json delete mode 100644 src/workbench/browser/src/styles/themes/base.less delete mode 100644 src/workbench/browser/src/styles/themes/dark.css delete mode 100644 src/workbench/browser/src/styles/themes/default.css delete mode 100644 src/workbench/browser/src/styles/themes/light.css create mode 100644 src/workbench/browser/src/styles/variables.css create mode 100644 tools/debugComponents.js create mode 100644 tools/getVSCodeThemes.js create mode 100644 tools/replaceCssVariable.js create mode 100644 tools/unlinkComponents.js create mode 100644 tools/upgradeComponent.js diff --git a/.gitignore b/.gitignore index 7362ebf0e..3005730a0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ out/ !src/workbench/node/server/**/*.js !/api/*.js !/scripts/*.js +!/tools/*.js !*.config.js !.*.js !upload.js diff --git a/donkey.config.js b/donkey.config.js index 98068ed9a..f238be461 100644 --- a/donkey.config.js +++ b/donkey.config.js @@ -23,5 +23,9 @@ module.exports = { // schema: "./output/entities" // typeorm: "./output/typeorm" ], - remoteBase: '' + remoteBase: '', + paramsFill: { + projectUuid: 'this.store.getCurrentProjectID', + workSpaceUuid: 'this.store.getCurrentWorkspaceUuid' + } }; diff --git a/e2e/api.t b/e2e/api.t index d076ce4aa..6ef769bb4 100644 --- a/e2e/api.t +++ b/e2e/api.t @@ -32,7 +32,7 @@ wait goto "http://localhost:4200" find: - [input "Search"] [button { width: 32px }]=addBtn + [input 'Search'] [button 'xpath:body > eo-root > eo-pages > div > div > div > eo-api > nz-layout > nz-sider > div > nz-content > nz-tabset > div > div > div.ant-tabs-tabpane.ant-tabs-tabpane-active.ng-star-inserted > div > pc-api-group-tree > header > div']=addBtn addBtn -> hover diff --git a/e2e/group.spec.ts b/e2e/group.spec.ts index 97cb0b34a..9ddaeca21 100644 --- a/e2e/group.spec.ts +++ b/e2e/group.spec.ts @@ -4,7 +4,7 @@ test('test', async ({ page }) => { await page.goto('http://www.postcat.com'); await page.locator('body').click(); //Add group - await page.locator('eo-api-group-tree:has-text("GET获取城市今日天气GET新冠全国疫情") path').nth(1).hover(); + await page.locator('pc-api-group-tree:has-text("GET获取城市今日天气GET新冠全国疫情") path').nth(1).hover(); await page.getByText('新建分组').click(); await page.getByLabel('分组名称').click(); await page.getByLabel('分组名称').fill('test'); diff --git a/e2e/package.json b/e2e/package.json index 42f11adc0..db6fc802c 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -5,10 +5,13 @@ "license": "MIT", "scripts": { "test": "playwright test", - "test:watch":"playwright test --headed" + "test:watch": "playwright test --headed" }, "devDependencies": { "@playwright/test": "^1.27.0", "playwright": "^1.27.0" + }, + "dependencies": { + "ark-pkg": "0.5.1" } -} \ No newline at end of file +} diff --git a/e2e/yarn.lock b/e2e/yarn.lock index d9f3b42cb..1b5a9470a 100644 --- a/e2e/yarn.lock +++ b/e2e/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@lukeed/csprng@^1.0.0": + version "1.0.1" + resolved "https://registry.npmmirror.com/@lukeed/csprng/-/csprng-1.0.1.tgz#625e93a0edb2c830e3c52ce2d67b9d53377c6a66" + integrity sha512-uSvJdwQU5nK+Vdf6zxcWAY2A8r7uqe+gePwLWzJ+fsQehq18pc0I2hJKwypZ2aLM90+Er9u1xn4iLJPZ+xlL4g== + "@playwright/test@^1.27.0": version "1.27.1" resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.27.1.tgz#9364d1e02021261211c8ff586d903faa79ce95c4" @@ -15,6 +20,44 @@ resolved "https://registry.npmjs.org/@types/node/-/node-18.7.11.tgz#486e72cfccde88da24e1f23ff1b7d8bfb64e6250" integrity sha512-KZhFpSLlmK/sdocfSAjqPETTMd0ug6HIMIAwkwUpU79olnZdQtMxpQP+G1wDzCH7na+FltSIhbaZuKdwZ8RDrw== +ark-pkg@0.5.1: + version "0.5.1" + resolved "https://registry.npmmirror.com/ark-pkg/-/ark-pkg-0.5.1.tgz#4690d6d8cf9053f8a55339a22b6ba0b7885baff4" + integrity sha512-lDyI6jq9b/gHrkSAXlnUL8hAvNRX8pUZVyxxaBQ7TKXQx1Os3AwwSzYHZY9USbSeTe5RwGbb67wOZ/X1o/T/Ng== + dependencies: + uid "^2.0.0" + colors "^1.4.0" + commander "^9.4.0" + figlet "^1.5.2" + js-md5 "^0.7.3" + lodash "^4.17.21" + prettier "^2.7.1" + +colors@^1.4.0: + version "1.4.0" + resolved "https://registry.npmmirror.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + +commander@^9.4.0: + version "9.5.0" + resolved "https://registry.npmmirror.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" + integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== + +figlet@^1.5.2: + version "1.5.2" + resolved "https://registry.npmmirror.com/figlet/-/figlet-1.5.2.tgz#dda34ff233c9a48e36fcff6741aeb5bafe49b634" + integrity sha512-WOn21V8AhyE1QqVfPIVxe3tupJacq1xGkPTB4iagT6o+P2cAgEOOwIxMftr4+ZCTI6d551ij9j61DFr0nsP2uQ== + +js-md5@^0.7.3: + version "0.7.3" + resolved "https://registry.npmmirror.com/js-md5/-/js-md5-0.7.3.tgz#b4f2fbb0b327455f598d6727e38ec272cd09c3f2" + integrity sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ== + +lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + playwright-core@1.27.1: version "1.27.1" resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.27.1.tgz#840ef662e55a3ed759d8b5d3d00a5f885a7184f4" @@ -26,3 +69,15 @@ playwright@^1.27.0: integrity sha512-xXYZ7m36yTtC+oFgqH0eTgullGztKSRMb4yuwLPl8IYSmgBM88QiB+3IWb1mRIC9/NNwcgbG0RwtFlg+EAFQHQ== dependencies: playwright-core "1.27.1" + +prettier@^2.7.1: + version "2.8.2" + resolved "https://registry.npmmirror.com/prettier/-/prettier-2.8.2.tgz#c4ea1b5b454d7c4b59966db2e06ed7eec5dfd160" + integrity sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw== + +uid@^2.0.0: + version "2.0.1" + resolved "https://registry.npmmirror.com/uid/-/uid-2.0.1.tgz#a3f57c962828ea65256cd622fc363028cdf4526b" + integrity sha512-PF+1AnZgycpAIEmNtjxGBVmKbZAQguaa4pBUq6KNaGEcpzZ2klCNZLM34tsjp76maN00TttiiUf6zkIBpJQm2A== + dependencies: + "@lukeed/csprng" "^1.0.0" diff --git a/package.json b/package.json index f97e9e886..c1dd8bca5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "postcat", "souceLocale": "zh-Hans", - "version": "0.0.1-beta", + "version": "0.1.0-beta", "main": "out/app/electron-main/main.js", "description": "A lightweight, extensible API tool", "homepage": "https://github.com/eolinker/postcat.git", @@ -41,7 +41,6 @@ "@grpc/proto-loader": "0.7.3", "@koa/cors": "3.3.0", "axios": "0.27.2", - "content-disposition": "^0.5.4", "cors": "2.8.5", "crypto-js": "4.1.1", "electron-log": "^4.4.8", @@ -49,7 +48,6 @@ "electron-updater": "^5.0.5", "express": "4.18.1", "fix-path": "3.0.0", - "form-data": "^4.0.0", "http-server": "14.1.1", "iconv-lite": "^0.6.3", "jquery": "3.6.1", diff --git a/scripts/upgradeComponent.js b/scripts/upgradeComponent.js deleted file mode 100644 index 3214d668f..000000000 --- a/scripts/upgradeComponent.js +++ /dev/null @@ -1,10 +0,0 @@ -//If stuck,check yarn.lock file,maybe has conflict -// upgrade.js -const child_process = require("child_process"); -const pkg = require("../src/workbench/browser/package.json"); -const filterRegex = /eo-ng-.*/; - -const dependencies = pkg["dependencies"]; - -const dependencyList = Object.keys(dependencies).filter((dependency) => filterRegex.test(dependency)); -child_process.execSync(`cd ../src/workbench/browser&&yarn upgrade ${dependencyList.join('@latest ')}`); \ No newline at end of file diff --git a/src/app/electron-main/main.ts b/src/app/electron-main/main.ts index 2e87992b2..58ba0ba36 100644 --- a/src/app/electron-main/main.ts +++ b/src/app/electron-main/main.ts @@ -72,8 +72,9 @@ class EoBrowserWindow { //Watch win event private watch() { // Reload page when load page url error - this.win.webContents.on('did-fail-load', (event, errorCode) => { - console.error('did-fail-load', errorCode); + this.win.webContents.on('did-fail-load', (event, errorCode, errorDescription, validatedURL, isMainFrame) => { + //* Extension url error + if (!isMainFrame) return; this.loadURL(); }); this.win.on('resize', () => { diff --git a/src/platform/common/i18n.ts b/src/platform/common/i18n.ts index a963c502f..ac86df8e9 100644 --- a/src/platform/common/i18n.ts +++ b/src/platform/common/i18n.ts @@ -1,11 +1,11 @@ -import { ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; +import { ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; /** * Single extension i18 service,chain call */ export class TranslateService { // Default key in package.json translate replace directly defaultKeys = ['title', 'description', 'author', 'logo']; - constructor(private module: ModuleInfo, private locale) {} + constructor(private module: ExtensionInfo, private locale) {} translate() { return this.translateDefaultKey().translateVariableKey().get(); } diff --git a/src/platform/node/extension-manager/lib/core.ts b/src/platform/node/extension-manager/lib/core.ts index aa50e50ab..a7df3e042 100644 --- a/src/platform/node/extension-manager/lib/core.ts +++ b/src/platform/node/extension-manager/lib/core.ts @@ -1,11 +1,13 @@ -import * as path from 'path'; -import { ModuleHandlerOptions, ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; -import { fileExists, readFile, readJson } from 'eo/shared/node/file'; -import { getLocaleData } from 'eo/platform/node/i18n'; import { LanguageService } from 'eo/app/electron-main/language.service'; import { TranslateService } from 'eo/platform/common/i18n'; +import { getLocaleData } from 'eo/platform/node/i18n'; +import { fileExists, readFile, readJson } from 'eo/shared/node/file'; +import { ModuleHandlerOptions, ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; + +import * as path from 'path'; /** * 核心模块管理器 + * * @class CoreHandler */ export class CoreHandler { @@ -28,51 +30,48 @@ export class CoreHandler { throw new Error(`Package file [${packageJsonFile}] does not exist.`); } } - /** * 获取模块package.json信息 + * * @param {string} name 模块名称 */ - info(name: string): ModuleInfo { - let moduleInfo: ModuleInfo; + info(name: string): ExtensionInfo { + let extensionInfo: ExtensionInfo; try { const baseDir: string = this.getModuleDir(name); - moduleInfo = readJson(path.join(baseDir, 'package.json')) as ModuleInfo; - moduleInfo.baseDir = baseDir; + extensionInfo = readJson(path.join(baseDir, 'package.json')) as ExtensionInfo; + extensionInfo.baseDir = baseDir; // Get language locale //!Warn:baseDir must be set before get locale file const lang = LanguageService.get(); - if (moduleInfo.features?.i18n) { - const locale = getLocaleData(moduleInfo, lang); + if (extensionInfo.features?.i18n) { + const locale = getLocaleData(extensionInfo, lang); if (locale) { - let translateService = new TranslateService(moduleInfo, locale); - moduleInfo = translateService.translate(); + let translateService = new TranslateService(extensionInfo, locale); + extensionInfo = translateService.translate(); } } // Check that the file exists locally - moduleInfo.introduction = - readFile(path.join(baseDir, `README.${lang}.md`)) || readFile(path.join(baseDir, `README.md`)); - if(moduleInfo.main){ - moduleInfo.main = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.main); - } - if(moduleInfo.node){ - moduleInfo.node = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.node); + extensionInfo.introduction = readFile(path.join(baseDir, `README.${lang}.md`)) || readFile(path.join(baseDir, `README.md`)); + if (extensionInfo.main) { + extensionInfo.main = `file://${path.join(extensionInfo.baseDir, extensionInfo.main)}`; } - if (moduleInfo.logo?.length > 0 && !moduleInfo.logo.startsWith('http') && !moduleInfo.logo.includes('icon-')) { - moduleInfo.logo = 'file://' + path.join(moduleInfo.baseDir, moduleInfo.logo); + if (extensionInfo.node) { + extensionInfo.node = `file://${path.join(extensionInfo.baseDir, extensionInfo.node)}`; } - if (typeof moduleInfo.author === 'object') { - moduleInfo.author = moduleInfo.author['name'] || ''; + if (extensionInfo.logo?.length > 0 && !extensionInfo.logo.startsWith('http') && !extensionInfo.logo.includes('icon-')) { + extensionInfo.logo = `file://${path.join(extensionInfo.baseDir, extensionInfo.logo)}`; } } catch (e) { - console.log(`Get module ${moduleInfo?.name} error:${e}`); - moduleInfo = {} as ModuleInfo; + console.log(`Get module ${extensionInfo?.name} error:${e}`); + extensionInfo = {} as ExtensionInfo; } - return moduleInfo; + return extensionInfo; } /** * 获取模块目录 + * * @param name * @returns */ diff --git a/src/platform/node/extension-manager/lib/manager.ts b/src/platform/node/extension-manager/lib/manager.ts index 1a5b0ea66..bcede8fa2 100644 --- a/src/platform/node/extension-manager/lib/manager.ts +++ b/src/platform/node/extension-manager/lib/manager.ts @@ -1,9 +1,9 @@ import http from 'axios'; import { isNotEmpty } from 'eo/shared/common/common'; -import { HOME_DIR, MODULE_DIR as baseDir } from 'eo/shared/electron-main/constant'; +import { HOME_DIR } from 'eo/shared/electron-main/constant'; import { ModuleHandlerResult, - ModuleInfo, + ExtensionInfo, ModuleManagerInfo, SidebarView, FeatureInfo @@ -41,7 +41,7 @@ export class ModuleManager { /** * 模块集合 */ - private readonly modules: Map; + private readonly modules: Map; /** * 功能点集合 @@ -49,7 +49,7 @@ export class ModuleManager { private readonly features: Map>; constructor() { - this.moduleHandler = new ModuleHandler({ baseDir: baseDir }); + this.moduleHandler = new ModuleHandler({ baseDir: HOME_DIR }); this.modules = new Map(); this.features = new Map(); this.init(); @@ -74,7 +74,7 @@ export class ModuleManager { async install(module: ModuleManagerInfo): Promise { const result = await this.moduleHandler.install([module], module?.isLocal || false); if (result.code === 0) { - const moduleInfo: ModuleInfo = this.moduleHandler.info(module.name); + const moduleInfo: ExtensionInfo = this.moduleHandler.info(module.name); this.set(moduleInfo); } return result; @@ -86,7 +86,7 @@ export class ModuleManager { * @param module */ async uninstall(module: ModuleManagerInfo): Promise { - const moduleInfo: ModuleInfo = this.moduleHandler.info(module.name); + const moduleInfo: ExtensionInfo = this.moduleHandler.info(module.name); const result = await this.moduleHandler.uninstall([{ name: module.name }], module.isLocal || false); if (result.code === 0) { this.delete(moduleInfo); @@ -128,7 +128,7 @@ export class ModuleManager { * @param module */ refresh(module: ModuleManagerInfo): void { - const moduleInfo: ModuleInfo = this.moduleHandler.info(module.name); + const moduleInfo: ExtensionInfo = this.moduleHandler.info(module.name); this.set(moduleInfo); } /** @@ -149,7 +149,7 @@ export class ModuleManager { * * @param belongs */ - getModules(): Map { + getModules(): Map { return this.modules; } /** @@ -176,7 +176,7 @@ export class ModuleManager { * * @param belongs */ - getModule(id: string): ModuleInfo { + getModule(id: string): ExtensionInfo { return this.modules.get(id); } @@ -195,7 +195,7 @@ export class ModuleManager { * * @param moduleInfo */ - private set(moduleInfo: ModuleInfo) { + private set(moduleInfo: ExtensionInfo) { // 避免重置 this.modules.set(moduleInfo.name, moduleInfo); this.setFeatures(moduleInfo); @@ -206,13 +206,28 @@ export class ModuleManager { * * @param moduleInfo */ - private setFeatures(moduleInfo: ModuleInfo) { + private setFeatures(moduleInfo: ExtensionInfo) { if (moduleInfo.features && typeof moduleInfo.features === 'object' && isNotEmpty(moduleInfo.features)) { - Object.entries(moduleInfo.features).forEach(([key, value]) => { + Object.entries(moduleInfo.features).forEach(([key, featureVal]) => { if (!this.features.has(key)) { this.features.set(key, new Map()); } - this.features.get(key).set(moduleInfo.name, { extensionID: moduleInfo.name, ...value }); + switch (key) { + case 'theme': { + if (!(featureVal instanceof Array)) { + return; + } + featureVal.forEach((theme: any) => { + Object.assign(theme, require(path.join(moduleInfo.baseDir, theme.path))); + }); + this.features.get(key).set(moduleInfo.name, { extensionID: moduleInfo.name, theme: featureVal } as any); + break; + } + default: { + this.features.get(key).set(moduleInfo.name, { extensionID: moduleInfo.name, ...featureVal }); + break; + } + } }); } } @@ -222,7 +237,7 @@ export class ModuleManager { * * @param moduleInfo */ - private delete(moduleInfo: ModuleInfo) { + private delete(moduleInfo: ExtensionInfo) { // 避免删除核心 this.modules.delete(moduleInfo.name); this.deleteFeatures(moduleInfo); @@ -233,7 +248,7 @@ export class ModuleManager { * * @param moduleInfo */ - private deleteFeatures(moduleInfo: ModuleInfo) { + private deleteFeatures(moduleInfo: ExtensionInfo) { if (moduleInfo.features && typeof moduleInfo.features === 'object' && isNotEmpty(moduleInfo.features)) { for (const key in moduleInfo.features) { if (this.features.has(key)) { @@ -248,7 +263,7 @@ export class ModuleManager { * * @param moduleInfo */ - private setup(moduleInfo: ModuleInfo) { + private setup(moduleInfo: ExtensionInfo) { if (moduleInfo && isNotEmpty(moduleInfo.name)) { this.set(moduleInfo); } @@ -260,13 +275,12 @@ export class ModuleManager { private init() { const names: string[] = this.moduleHandler.list(); names.forEach((name: string) => { - // 这里要加上try catch,避免异常 - const moduleInfo: ModuleInfo = this.moduleHandler.info(name); + const moduleInfo: ExtensionInfo = this.moduleHandler.info(name); this.setup(moduleInfo); }); } - getExtFeatures(extName: string): ModuleInfo['features'] { + getExtFeatures(extName: string): ExtensionInfo['features'] { const extPath = this.moduleHandler.getModuleDir(extName); return require(path.join(extPath, 'package.json')).features; } @@ -300,7 +314,6 @@ export class ModuleManager { } const port = await portfinder.getPortPromise(); const pageDir = path.parse(path.join(extPath, feature?.url)).dir; - console.log('extension pageDir', pageDir); const server = createServer({ root: pageDir }); server.listen(port); const url = `http://127.0.0.1:${port}`; diff --git a/src/platform/node/i18n.ts b/src/platform/node/i18n.ts index 766af0de1..25df5cfc8 100644 --- a/src/platform/node/i18n.ts +++ b/src/platform/node/i18n.ts @@ -1,4 +1,4 @@ -import { ModuleInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; +import { I18nLocale, ExtensionInfo } from 'eo/workbench/browser/src/app/shared/models/extension-manager'; interface LooseObject { [key: string]: any; } @@ -9,14 +9,14 @@ const localeStorage: LooseObject = {}; * @param module * @returns json */ -function getLocaleFile(module: ModuleInfo, lang): Object { +function getLocaleFile(module: ExtensionInfo, lang): Object { let result = {}; try { result = require(`${module.baseDir}/i18n/${lang}.json`); } catch (e) {} return result; } -function getSupportLang(module: ModuleInfo) { +function getSupportLang(module: ExtensionInfo) { return [module.features.i18n.sourceLocale, ...module.features.i18n.locales].filter(val => val); } /** @@ -24,7 +24,7 @@ function getSupportLang(module: ModuleInfo) { * * @returns json */ -export function getLocaleData(module: ModuleInfo, lang): Object | null { +export function getLocaleData(module: ExtensionInfo, lang) { let supportLang = getSupportLang(module); if (!supportLang.includes(lang)) { console.error(`Error: extension ${module.title} can't find the i18n package ${lang}`); diff --git a/src/shared/electron-main/constant.ts b/src/shared/electron-main/constant.ts index 398e44a25..bc2f8a1df 100644 --- a/src/shared/electron-main/constant.ts +++ b/src/shared/electron-main/constant.ts @@ -4,5 +4,4 @@ import * as path from 'path'; export const home: string = app.getPath('home'); export const HOME_DIR = path.join(home, '.postcat'); -export const MODULE_DIR = HOME_DIR; export const STORAGE_TEMP = path.join(HOME_DIR, 'tmp.storage'); diff --git a/src/workbench/browser/.gitignore b/src/workbench/browser/.gitignore index aceaa8c61..3e83507fd 100644 --- a/src/workbench/browser/.gitignore +++ b/src/workbench/browser/.gitignore @@ -13,6 +13,7 @@ src/**/*.js !src/assets/libs/*.js *.js.map + # dependencies node_modules diff --git a/src/workbench/browser/LICENSE b/src/workbench/browser/LICENSE index c6ccb4188..7ce74cc6a 100644 --- a/src/workbench/browser/LICENSE +++ b/src/workbench/browser/LICENSE @@ -2,180 +2,180 @@ Version 2.0, January 2004 http://www.apache.org/licenses/ - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" @@ -186,21 +186,21 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2022] [eoapi] +Copyright [2022] [Postcat] - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. -Copyright (c) 2022 eoapi +Copyright (c) 2022 Postcat Copyright (c) 2020 Maxime GRIS Permission is hereby granted, free of charge, to any person obtaining a copy @@ -219,4 +219,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/src/workbench/browser/README.md b/src/workbench/browser/README.md index 8feb8ce9e..9876ddbe4 100644 --- a/src/workbench/browser/README.md +++ b/src/workbench/browser/README.md @@ -1,9 +1,11 @@ # Postcat Workbench + Postcat browser code + # Run -| Command | Desc | -| --------------------- | ------------------------------------ | -| `yarn start` | Only run frontend,local workspace | -| `yarn serve` | Use proxy | -| `yarn build` | Pack static frontend resource | \ No newline at end of file +| Command | Desc | +| ------------ | --------------------------------- | +| `yarn start` | Only run frontend,local workspace | +| `yarn serve` | Use proxy | +| `yarn build` | Pack static frontend resource | diff --git a/src/workbench/browser/angular.json b/src/workbench/browser/angular.json index 178ee2476..e4cd5ee52 100644 --- a/src/workbench/browser/angular.json +++ b/src/workbench/browser/angular.json @@ -1,12 +1,15 @@ { "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "cli": { "analytics": false, "defaultCollection": "@angular-eslint/schematics" }, + "cli": { "analytics": false, "defaultCollection": "@angular-eslint/schematics", "cache": { "enabled": true } }, "version": 1, "newProjectRoot": "projects", "projects": { - "eoapi": { + "postcat": { "root": "", - "i18n": { "sourceLocale": { "code": "en" }, "locales": { "zh": { "translation": "locale/messages.zh.xlf" } } }, + "i18n": { + "sourceLocale": { "code": "en", "baseHref": "" }, + "locales": { "zh": { "translation": "locale/messages.zh.xlf", "baseHref": "" } } + }, "sourceRoot": "src", "projectType": "application", "schematics": { "@schematics/angular:application": { "strict": true } }, @@ -25,14 +28,10 @@ "assets": [ "src/icon.ico", "src/assets", + "src/extensions", { "glob": "**/*", "input": "../../../node_modules/monaco-editor/min/vs", "output": "/assets/vs/" } ], - "styles": [ - { "input": "src/styles/light.less", "bundleName": "light", "inject": false }, - { "input": "src/styles/dark.less", "bundleName": "dark", "inject": false }, - "src/styles.scss" - ], - "stylePreprocessorOptions": { "includePaths": ["src/styles/themes"] }, + "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"] @@ -44,6 +43,7 @@ "sourceMap": true, "namedChunks": false, "localize": false, + "preserveSymlinks": true, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": false, @@ -54,6 +54,7 @@ "outputHashing": "none", "sourceMap": true, "namedChunks": false, + "preserveSymlinks": true, "localize": ["zh"], "extractLicenses": true, "vendorChunk": false, @@ -61,6 +62,7 @@ "fileReplacements": [{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.ts" }] }, "production": { + "preserveSymlinks": false, "optimization": true, "outputHashing": "all", "sourceMap": false, @@ -84,14 +86,14 @@ }, "serve": { "builder": "@angular-builders/custom-webpack:dev-server", - "options": { "browserTarget": "eoapi:build", "proxyConfig": "src/proxy.conf.json" }, + "options": { "browserTarget": "postcat:build", "proxyConfig": "proxy.conf.json" }, "configurations": { - "dev": { "browserTarget": "eoapi:build:dev" }, - "devCn": { "browserTarget": "eoapi:build:devCn" }, - "production": { "browserTarget": "eoapi:build:production" } + "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": "eoapi:build" } }, + "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "postcat:build" } }, "test": { "inlineStyleLanguage": "scss", "builder": "@angular-builders/custom-webpack:karma", @@ -109,15 +111,15 @@ "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } } } }, - "eoapi-e2e": { + "postcat-e2e": { "root": "e2e", "projectType": "application", "architect": { "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["e2e/**/*.ts"] } } } } }, - "defaultProject": "eoapi", + "defaultProject": "postcat", "schematics": { - "@schematics/angular:component": { "prefix": "eo", "style": "scss", "inlineStyle": true, "inlineTemplate": true }, - "@schematics/angular:directive": { "prefix": "eo" } + "@schematics/angular:component": { "prefix": "pc", "style": "scss", "inlineStyle": true, "inlineTemplate": true }, + "@schematics/angular:directive": { "prefix": "pc" } } } diff --git a/src/workbench/browser/angular.webpack.js b/src/workbench/browser/angular.webpack.js index 5fc6e4057..eb8475bba 100644 --- a/src/workbench/browser/angular.webpack.js +++ b/src/workbench/browser/angular.webpack.js @@ -22,23 +22,27 @@ module.exports = (config, options) => { config.plugins = [ ...config.plugins, new NodePolyfillPlugin({ - excludeAliases: ['console'], + excludeAliases: ['console'] }) ]; config.module.rules = [ { test: /\.css$/, use: ['style-loader', 'css-loader'], - resourceQuery: { not: [/\?ngResource/] }, + resourceQuery: { not: [/\?ngResource/] } }, { test: /\.ttf$/, type: 'asset/resource', - resourceQuery: { not: [/\?ngResource/] }, + resourceQuery: { not: [/\?ngResource/] } }, - ...config.module.rules, + ...config.module.rules ]; + config.experiments = { + topLevelAwait: true + }; + // console.log('config', config.module.rules); return config; diff --git a/src/workbench/browser/build/build.js b/src/workbench/browser/build/build.js index 754e4ebd7..aa5e93b8f 100644 --- a/src/workbench/browser/build/build.js +++ b/src/workbench/browser/build/build.js @@ -5,9 +5,9 @@ class webPlatformBuilder { this.environment = environment; } resetBuildConfig(json) { - delete json.projects.eoapi.i18n.sourceLocale.baseHref; - Object.keys(json.projects.eoapi.i18n.locales).forEach(val => { - delete json.projects.eoapi.i18n.locales[val].baseHref; + delete json.projects.postcat.i18n.sourceLocale.baseHref; + Object.keys(json.projects.postcat.i18n.locales).forEach(val => { + delete json.projects.postcat.i18n.locales[val].baseHref; }); return json; } @@ -21,11 +21,11 @@ class webPlatformBuilder { - Eoapi - Easy & Open Source API Ecosystem + Postcat - Easy & Open Source API Ecosystem