feat: keep queryParams stay in page

This commit is contained in:
scarqin 2022-10-14 15:06:28 +08:00
parent 54a8e6d46c
commit baad3038cb
5 changed files with 19 additions and 150 deletions

View File

@ -1,144 +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", "baseHref": "" },
"locales": { "zh": { "translation": "src/locale/messages.zh.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/monaco-editor/min/vs", "output": "/assets/vs/" }
],
"styles": [
{ "input": "src/assets/theme/classic_forest.scss", "bundleName": "classic_forest", "inject": false },
"src/assets/theme/antd.less",
"src/styles.scss",
"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",
"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,
"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,
"localize": ["zh"],
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{ "replace": "src/environments/environment.ts", "with": "src/environments/environment.dev.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" },
"devCn": { "browserTarget": "eoapi:build:devCn" },
"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"},"locales":{"zh":{"translation":"src/locale/messages.zh.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/monaco-editor/min/vs","output":"/assets/vs/"}],"styles":[{"input":"src/assets/theme/classic_forest.scss","bundleName":"classic_forest","inject":false},"src/assets/theme/antd.less","src/styles.scss","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","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,"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,"localize":["zh"],"extractLicenses":true,"vendorChunk":false,"buildOptimizer":false,"fileReplacements":[{"replace":"src/environments/environment.ts","with":"src/environments/environment.dev.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"},"devCn":{"browserTarget":"eoapi:build:devCn"},"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"}}}

View File

@ -18,7 +18,10 @@ const routes: Routes = [
},
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash: true })],
imports: [
//electron user hash to keep router after page refresh
RouterModule.forRoot(routes, { useHash: !!(window && window.process && window.process.type) ? true : false }),
],
exports: [RouterModule],
})
export class AppRoutingModule {}

View File

@ -256,6 +256,13 @@ export class ApiTabService {
}
handleDataBeforeCache(tabsByID) {
Object.values(tabsByID).forEach((val: TabItem) => {
//Delete gio key
if (val.params) {
['utm_campaign', 'utm_content', 'utm_source'].forEach((keyName) => {
delete val.params[keyName];
});
}
//Cancel cache testResult
if (val.module === 'test' && val.content?.test?.testResult) {
val.content.test.testResult = {
request: {},

View File

@ -106,8 +106,9 @@ export class ApiTestComponent implements OnInit, OnDestroy {
) {
//Select demo api when first open Eoapi
if (!window.localStorage.getItem('local_TabCache')) {
const utm = new URLSearchParams(window.location.search);
this.router.navigate(['/home/api/http/test'], {
queryParams: { pageID: Date.now(), uuid: 1 },
queryParams: { pageID: Date.now(), uuid: 1, ...Object.fromEntries(utm) },
});
setTimeout(() => {
const testBtn = document.getElementById('btn-test');

View File

@ -4,7 +4,6 @@ import { ApiTabStorageService } from 'eo/workbench/browser/src/app/pages/api/tab
import { TabItem, TabOperate } from 'eo/workbench/browser/src/app/pages/api/tab/tab.model';
import { MessageService } from 'eo/workbench/browser/src/app/shared/services/message';
import { EoMessageService } from 'eo/workbench/browser/src/app/eoui/message/eo-message.service';
import { ModalService } from 'eo/workbench/browser/src/app/shared/services/modal.service';
import { eoDeepCopy } from 'eo/workbench/browser/src/app/utils/index.utils';
/**
* Api tab service operate tabs array add/replace/close...
@ -25,8 +24,7 @@ export class ApiTabOperateService {
private tabStorage: ApiTabStorageService,
private messageService: MessageService,
private router: Router,
private message: EoMessageService,
private modal: ModalService
private message: EoMessageService
) {}
//Init tab info
//Maybe from tab cache info or router url
@ -88,7 +86,10 @@ export class ApiTabOperateService {
* @returns tabItem
*/
newDefaultTab(path?) {
const tabItem = Object.assign({}, eoDeepCopy(this.BASIC_TABS.find(val=>val.pathname===path)||this.BASIC_TABS[0]));
const tabItem = Object.assign(
{},
eoDeepCopy(this.BASIC_TABS.find((val) => val.pathname === path) || this.BASIC_TABS[0])
);
tabItem.params = {};
tabItem.uuid = tabItem.params.pageID = Date.now();
Object.assign(tabItem, { isLoading: false });