fixed bugs about env & params-import

This commit is contained in:
kungfuboy 2022-01-25 21:53:41 +08:00
parent 982011ed45
commit cc52d37d05
4 changed files with 30 additions and 9 deletions

View File

@ -21,7 +21,6 @@ export class EnvComponent implements OnInit, OnDestroy {
envInfo: any = {};
envList: any[] = [];
activeUuid = 0;
selectUuid = null;
envListColumns = [
{ title: '变量名', key: 'name', isEdit: true },
{ title: '变量值', key: 'value', isEdit: true },
@ -36,9 +35,9 @@ export class EnvComponent implements OnInit, OnDestroy {
return Number(localStorage.getItem('env:selected')) || 0;
}
set envUuid(value) {
this.activeUuid = value || 0;
this.activeUuid = value;
if (value) {
localStorage.setItem('env:selected', value.toString());
localStorage.setItem('env:selected', value == null ? '' : value.toString());
} else {
localStorage.removeItem('env:selected');
}
@ -47,6 +46,7 @@ export class EnvComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.getAllEnv();
this.changeStoreEnv(localStorage.getItem('env:selected'));
}
ngOnDestroy() {
this.destroy$.next();
@ -143,7 +143,16 @@ export class EnvComponent implements OnInit, OnDestroy {
}
private changeStoreEnv(uuid) {
const data = this.envList.find((val) => val.uuid === uuid);
this.store.dispatch(new Change(data));
if (uuid == null) {
this.store.dispatch(new Change(null));
return;
}
this.envService.loadAll().subscribe((result: Array<Environment>) => {
if (result.length === 0) {
return;
}
const data = result.find((val) => val.uuid === Number(uuid));
this.store.dispatch(new Change(data));
});
}
}

View File

@ -83,9 +83,10 @@ export class ParamsImportComponent {
// TODO Perhaps should be handled about format compatibility later.
console.warn('The code that you input is no-equal to the root type.');
}
// if (whatType(paramCode) === 'object') {
// * transform to array of table format.
// }
if (whatType(paramCode) === 'object') {
// console.log('kk', paramCode);
// * transform to array of table format.
}
if (this.rootType === 'array' && whatType(paramCode) === 'array') {
// * only select first data
const [data] = paramCode;

View File

@ -18,7 +18,7 @@ export class EnvState {
@Action(Change)
changeEnv({ setState }, { data }) {
setState({
env: data,
env: data || {},
});
}
}

View File

@ -18,7 +18,18 @@ export const parseTree = (key, value, level = 0) => {
};
}
if (whatType(value) === 'array') {
// * just by first
const [data] = value;
if (whatType(data) === 'string') {
return {
name: key,
required: true,
example: JSON.stringify(value),
type: 'array',
description: '',
listDepth: level,
};
}
return {
name: key,
required: true,