From fa2a88121bfa4720a61a8dcbe653d9b4de788567 Mon Sep 17 00:00:00 2001
From: scarqin <1054139596@qq.com>
Date: Thu, 30 Jun 2022 15:30:54 +0800
Subject: [PATCH] vercel redirects
---
src/app/electron-main/main.ts | 2 +-
src/workbench/browser/angular.json | 161 +-----------
.../common/language-swtcher.componet.ts | 4 +-
.../browser/src/locale/messages.zh-Hans.xlf | 244 +++++++++++++-----
vercel.json | 10 +-
5 files changed, 195 insertions(+), 226 deletions(-)
diff --git a/src/app/electron-main/main.ts b/src/app/electron-main/main.ts
index 01158be9..7de20a40 100644
--- a/src/app/electron-main/main.ts
+++ b/src/app/electron-main/main.ts
@@ -59,7 +59,7 @@ function createWindow(): BrowserWindow {
proxyOpenExternal(win);
let loadPage = async () => {
let currentUrl = win.webContents.getURL();
- let locale = ['zh-Hans', 'en-US'].find((val) => currentUrl.includes(val));
+ let locale = ['zh', 'en'].find((val) => currentUrl.includes(val));
const file: string =
processEnv === 'development'
? 'http://localhost:4200'
diff --git a/src/workbench/browser/angular.json b/src/workbench/browser/angular.json
index 4dac5d34..1f73aa43 100644
--- a/src/workbench/browser/angular.json
+++ b/src/workbench/browser/angular.json
@@ -1,160 +1 @@
-{
- "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
- "cli": { "analytics": false, "defaultCollection": "@angular-eslint/schematics" },
- "version": 1,
- "newProjectRoot": "projects",
- "projects": {
- "eoapi": {
- "root": "",
- "i18n": {
- "sourceLocale": { "code": "en-US" },
- "locales": { "zh-Hans": { "translation": "src/locale/messages.zh-Hans.xlf" } }
- },
- "sourceRoot": "src",
- "projectType": "application",
- "schematics": { "@schematics/angular:application": { "strict": true } },
- "architect": {
- "build": {
- "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",
- {
- "glob": "**/*",
- "input": "../../../node_modules/@ant-design/icons-angular/src/inline-svg/",
- "output": "/assets/"
- }
- ],
- "styles": [
- { "input": "src/assets/theme/classic_forest.scss", "bundleName": "classic_forest", "inject": false },
- "src/styles.scss",
- "src/assets/theme/antd.less",
- "src/assets/font/iconfont.css",
- "src/ng1/index.css"
- ],
- "scripts": [
- "src/ng1/lib/angular/angular.js",
- "src/ng1/app.module.js",
- "src/ng1/component/select-default.js",
- "src/ng1/component/sort-and-filter.js",
- "src/ng1/component/auto-complete.js",
- "src/ng1/component/list-block.js",
- "src/ng1/directive/get-dom-length.directive.js",
- "src/ng1/directive/drop-down-menu.directive.js",
- "src/ng1/directive/sort.directive.js",
- "src/ng1/directive/drop-change-space.directive.js",
- "src/ng1/directive/inner-html.directive.js",
- "src/ng1/directive/insert-html.directive.js",
- "src/ng1/directive/copy-common.directive.js"
- ],
- "customWebpackConfig": { "path": "./angular.webpack.js", "replaceDuplicatePlugins": true },
- "allowedCommonJsDependencies": ["brace", "qs", "rxjs"]
- },
- "configurations": {
- "dev": {
- "optimization": false,
- "outputHashing": "none",
- "sourceMap": true,
- "namedChunks": false,
- "extractLicenses": true,
- "vendorChunk": false,
- "buildOptimizer": false,
- "fileReplacements": [
- { "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.ts" }
- ]
- },
- "web": {
- "optimization": false,
- "outputHashing": "none",
- "sourceMap": true,
- "namedChunks": false,
- "localize": false,
- "extractLicenses": true,
- "vendorChunk": false,
- "buildOptimizer": false,
- "fileReplacements": [
- { "replace": "src/environments/environment.ts", "with": "src/environments/environment.web.ts" }
- ]
- },
- "webCn": {
- "optimization": false,
- "outputHashing": "none",
- "sourceMap": true,
- "namedChunks": false,
- "localize": ["zh-Hans"],
- "extractLicenses": true,
- "vendorChunk": false,
- "buildOptimizer": false,
- "fileReplacements": [
- { "replace": "src/environments/environment.ts", "with": "src/environments/environment.web.ts" }
- ]
- },
- "production": {
- "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" }
- ]
- }
- }
- },
- "serve": {
- "builder": "@angular-builders/custom-webpack:dev-server",
- "options": { "browserTarget": "eoapi:build" },
- "configurations": {
- "dev": { "browserTarget": "eoapi:build:dev" },
- "web": { "browserTarget": "eoapi:build:web" },
- "webCn": { "browserTarget": "eoapi:build:webCn" },
- "production": { "browserTarget": "eoapi:build:production" }
- }
- },
- "extract-i18n": {
- "builder": "@angular-devkit/build-angular:extract-i18n",
- "options": { "browserTarget": "eoapi:build" }
- },
- "test": {
- "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"] }
- }
- }
- },
- "eoapi-e2e": {
- "root": "e2e",
- "projectType": "application",
- "architect": {
- "lint": { "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": ["e2e/**/*.ts"] } }
- }
- }
- },
- "defaultProject": "eoapi",
- "schematics": {
- "@schematics/angular:component": { "prefix": "eo", "style": "scss" },
- "@schematics/angular:directive": { "prefix": "eo" }
- }
-}
+{"$schema":"./node_modules/@angular/cli/lib/config/schema.json","cli":{"analytics":false,"defaultCollection":"@angular-eslint/schematics"},"version":1,"newProjectRoot":"projects","projects":{"eoapi":{"root":"","i18n":{"sourceLocale":{"code":"en","baseHref":""},"locales":{"zh":{"translation":"src/locale/messages.zh-Hans.xlf","baseHref":""}}},"sourceRoot":"src","projectType":"application","schematics":{"@schematics/angular:application":{"strict":true}},"architect":{"build":{"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",{"glob":"**/*","input":"../../../node_modules/@ant-design/icons-angular/src/inline-svg/","output":"/assets/"}],"styles":[{"input":"src/assets/theme/classic_forest.scss","bundleName":"classic_forest","inject":false},"src/styles.scss","src/assets/theme/antd.less","src/assets/font/iconfont.css","src/ng1/index.css"],"scripts":["src/ng1/lib/angular/angular.js","src/ng1/app.module.js","src/ng1/component/select-default.js","src/ng1/component/sort-and-filter.js","src/ng1/component/auto-complete.js","src/ng1/component/list-block.js","src/ng1/directive/get-dom-length.directive.js","src/ng1/directive/drop-down-menu.directive.js","src/ng1/directive/sort.directive.js","src/ng1/directive/drop-change-space.directive.js","src/ng1/directive/inner-html.directive.js","src/ng1/directive/insert-html.directive.js","src/ng1/directive/copy-common.directive.js"],"customWebpackConfig":{"path":"./angular.webpack.js","replaceDuplicatePlugins":true},"allowedCommonJsDependencies":["brace","qs","rxjs"]},"configurations":{"dev":{"optimization":false,"outputHashing":"none","sourceMap":true,"namedChunks":false,"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.dev.ts"}]},"web":{"optimization":false,"outputHashing":"none","sourceMap":true,"namedChunks":false,"localize":false,"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.web.ts"}]},"webCn":{"optimization":false,"outputHashing":"none","sourceMap":true,"namedChunks":false,"localize":["zh"],"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.web.ts"}]},"production":{"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"}]}}},"serve":{"builder":"@angular-builders/custom-webpack:dev-server","options":{"browserTarget":"eoapi:build"},"configurations":{"dev":{"browserTarget":"eoapi:build:dev"},"web":{"browserTarget":"eoapi:build:web"},"webCn":{"browserTarget":"eoapi:build:webCn"},"production":{"browserTarget":"eoapi:build:production"}}},"extract-i18n":{"builder":"@angular-devkit/build-angular:extract-i18n","options":{"browserTarget":"eoapi:build"}},"test":{"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"]}}}},"eoapi-e2e":{"root":"e2e","projectType":"application","architect":{"lint":{"builder":"@angular-eslint/builder:lint","options":{"lintFilePatterns":["e2e/**/*.ts"]}}}}},"defaultProject":"eoapi","schematics":{"@schematics/angular:component":{"prefix":"eo","style":"scss"},"@schematics/angular:directive":{"prefix":"eo"}}}
\ No newline at end of file
diff --git a/src/workbench/browser/src/app/shared/components/setting/common/language-swtcher.componet.ts b/src/workbench/browser/src/app/shared/components/setting/common/language-swtcher.componet.ts
index fbe9e0ac..57b91964 100644
--- a/src/workbench/browser/src/app/shared/components/setting/common/language-swtcher.componet.ts
+++ b/src/workbench/browser/src/app/shared/components/setting/common/language-swtcher.componet.ts
@@ -38,10 +38,12 @@ export class LanguageSwticherComponent implements OnInit {
{
name: 'English',
value: 'en-US',
+ path: 'en',
},
{
name: '简体中文',
value: 'zh-Hans',
+ path: 'zh',
},
];
constructor(private modal: NzModalService, private electron: ElectronService) {}
@@ -54,7 +56,7 @@ export class LanguageSwticherComponent implements OnInit {
let changeCallback = (localeID) => {
this.model['eoapi-language'] = localeID;
this.modelChange.emit(this.model);
- window.location.href = `/${localeID}`;
+ window.location.href = `/${(this.languages.find((val) => val.value === localeID) || this.languages[0]).path}`;
};
// if (this.electron.isElectron) {
// this.modal.warning({
diff --git a/src/workbench/browser/src/locale/messages.zh-Hans.xlf b/src/workbench/browser/src/locale/messages.zh-Hans.xlf
index 68cb9b15..42fbe9e5 100644
--- a/src/workbench/browser/src/locale/messages.zh-Hans.xlf
+++ b/src/workbench/browser/src/locale/messages.zh-Hans.xlf
@@ -215,6 +215,10 @@
src/app/pages/api/edit/api-edit.component.html
67
+
+ src/app/pages/api/test/api-test.component.html
+ 66
+
src/app/pages/api/test/api-test.component.html
122
@@ -301,6 +305,14 @@
src/app/pages/api/detail/api-detail.service.ts
133
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 167
+
+
+ src/app/pages/api/edit/extra-setting/api-params-extra-setting.component.ts
+ 22
+
@@ -323,6 +335,14 @@
src/app/pages/api/detail/api-detail.service.ts
140
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 174
+
+
+ src/app/pages/api/edit/extra-setting/api-params-extra-setting.component.ts
+ 28
+
src/app/shared/components/env/env.component.ts
30
@@ -338,6 +358,10 @@
src/app/pages/api/detail/api-detail.service.ts
148
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 183
+
@@ -345,6 +369,18 @@
src/app/pages/api/detail/api-detail.service.ts
119
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 147
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 150
+
+
+ src/app/pages/api/edit/extra-setting/api-params-extra-setting.component.ts
+ 17
+
src/app/pages/api/test/api-test.service.ts
96
@@ -360,11 +396,26 @@
src/app/pages/api/detail/api-detail.service.ts
126
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 155
+
+
+ src/app/pages/api/edit/extra-setting/api-params-extra-setting.component.ts
+ 33
+
src/app/pages/api/test/api-test.service.ts
104
+
+
+
+ src/app/pages/api/detail/api-detail.service.ts
+ 155
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.component.ts
+ 62
+
+
@@ -558,6 +616,64 @@
9
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 177
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 186
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 196
+
+
+ src/app/pages/api/test/api-test.service.ts
+ 131
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 201
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 213
+
+
+
+
+
+ src/app/pages/api/edit/api-edit.service.ts
+ 218
+
+
+ src/app/pages/api/test/api-test.service.ts
+ 53
+
+
+ src/app/pages/api/test/api-test.service.ts
+ 136
+
+
+ src/app/pages/api/test/history/api-test-history.component.ts
+ 113
+
+
@@ -621,43 +737,43 @@
src/app/pages/api/group/tree/api-group-tree.component.html
- 54
+ 55
src/app/pages/api/group/tree/api-group-tree.component.html
- 57
+ 58
src/app/pages/api/group/tree/api-group-tree.component.html
- 60
+ 61
src/app/pages/api/group/tree/api-group-tree.component.html
- 88
+ 89
src/app/pages/api/group/tree/api-group-tree.component.html
- 63
+ 64
src/app/pages/api/group/tree/api-group-tree.component.html
- 96
+ 97
src/app/pages/api/group/tree/api-group-tree.component.html
- 92
+ 93
@@ -744,6 +860,10 @@
src/app/shared/components/env/env.component.html
51
+
+ src/app/shared/components/params-import/params-import.component.html
+ 36
+
@@ -891,18 +1011,18 @@
src/app/pages/api/tab/api-tab.component.ts
- 247
+ 254
src/app/pages/api/tab/api-tab.component.ts
- 256
+ 263
-
-
+
+
src/app/pages/api/test/api-test.component.html
31,33
@@ -915,13 +1035,6 @@
43,45
-
-
-
- src/app/pages/api/test/api-test.component.html
- 66
-
-
@@ -929,21 +1042,6 @@
13
-
-
-
- src/app/pages/api/test/api-test.service.ts
- 53
-
-
- src/app/pages/api/test/api-test.service.ts
- 136
-
-
- src/app/pages/api/test/history/api-test-history.component.ts
- 113
-
-
@@ -963,15 +1061,8 @@
29
-
-
-
- src/app/pages/api/test/api-test.service.ts
- 131
-
-
-
-
+
+
src/app/pages/api/test/body/api-test-body.component.html
12
@@ -1200,35 +1291,35 @@
src/app/pages/navbar/navbar.component.html
- 25
+ 26
src/app/pages/navbar/navbar.component.html
- 27
+ 28
-
-
+
+
src/app/pages/navbar/navbar.component.html
- 34
+ 32
-
-
+
+
src/app/pages/navbar/navbar.component.html
- 52
+ 39
src/app/pages/navbar/navbar.component.html
- 60
+ 44
@@ -1245,32 +1336,39 @@
6
+
+
+
+ src/app/shared/components/env/env.component.html
+ 6
+
+
src/app/shared/components/env/env.component.html
- 15
+ 13
src/app/shared/components/env/env.component.html
- 25
+ 24
src/app/shared/components/env/env.component.html
- 31
+ 30
src/app/shared/components/env/env.component.html
- 36
+ 35
@@ -1368,6 +1466,34 @@
3
+
+
+
+ src/app/shared/components/params-import/params-import.component.html
+ 24
+
+
+
+
+
+ src/app/shared/components/params-import/params-import.component.html
+ 33
+
+
+
+
+
+ src/app/shared/components/params-import/params-import.component.html
+ 34
+
+
+
+
+
+ src/app/shared/components/params-import/params-import.component.html
+ 35
+
+
@@ -1499,21 +1625,21 @@
src/app/shared/components/setting/setting.component.ts
- 90
+ 99
src/app/shared/components/setting/setting.component.ts
- 94
+ 103
src/app/shared/components/setting/setting.component.ts
- 98
+ 107
src/app/shared/components/sidebar/sidebar.component.ts
@@ -1524,7 +1650,7 @@
src/app/shared/components/setting/setting.component.ts
- 102
+ 111
diff --git a/vercel.json b/vercel.json
index f9713957..995681a9 100644
--- a/vercel.json
+++ b/vercel.json
@@ -1,7 +1,7 @@
{
- "rewrites": [
+ "redirects": [
{
- "source": "/:path((?!en-US/).*)",
+ "source": "/:path((?!en/).*)",
"has": [
{
"type": "header",
@@ -9,10 +9,10 @@
"value": "en"
}
],
- "destination": "/en-US/:path*"
+ "destination": "/en/:path*"
},
{
- "source": "/:path((?!zh-Hans/).*)",
+ "source": "/:path((?!zh/).*)",
"has": [
{
"type": "header",
@@ -20,7 +20,7 @@
"value": "zh"
}
],
- "destination": "/zh-Hans/:path*"
+ "destination": "/zh/:path*"
}
]
}