|
@@ -28,6 +28,12 @@
|
|
|
@change="(e: Event) => setMainBodyColumnId('commonContent', (e.target as HTMLInputElement)?.value)"
|
|
@change="(e: Event) => setMainBodyColumnId('commonContent', (e.target as HTMLInputElement)?.value)"
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
|
|
+ <a-form-item label="其他参数 (otherParams)">
|
|
|
|
|
+ <KeyValueEditor
|
|
|
|
|
+ :modelValue="(modelValue as IHomeCommonCategoryDynamicDataCommonContent)?.otherParams"
|
|
|
|
|
+ @update:modelValue="(v: Record<string, any>) => setOtherParams(v)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-else-if="currentType === 'detailContent'">
|
|
<template v-else-if="currentType === 'detailContent'">
|
|
@@ -47,6 +53,12 @@
|
|
|
@update:value="(v: number | undefined) => setDetailContent('modelId', v)"
|
|
@update:value="(v: number | undefined) => setDetailContent('modelId', v)"
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
|
|
+ <a-form-item label="其他参数 (otherParams)">
|
|
|
|
|
+ <KeyValueEditor
|
|
|
|
|
+ :modelValue="(modelValue as IHomeCommonCategoryDynamicDataCommonContent)?.otherParams"
|
|
|
|
|
+ @update:modelValue="(v: Record<string, any>) => setOtherParams(v)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-else-if="currentType === 'serializedApi'">
|
|
<template v-else-if="currentType === 'serializedApi'">
|
|
@@ -68,6 +80,12 @@
|
|
|
@change="(e: Event) => setSerializedApiMainBodyColumnId((e.target as HTMLInputElement)?.value)"
|
|
@change="(e: Event) => setSerializedApiMainBodyColumnId((e.target as HTMLInputElement)?.value)"
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
|
|
+ <a-form-item label="其他参数 (otherParams)">
|
|
|
|
|
+ <KeyValueEditor
|
|
|
|
|
+ :modelValue="(modelValue as IHomeCommonCategoryDynamicDataSerializedApi)?.otherParams"
|
|
|
|
|
+ @update:modelValue="(v: Record<string, any>) => setOtherParams(v)"
|
|
|
|
|
+ />
|
|
|
|
|
+ </a-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-else-if="currentType === 'request'">
|
|
<template v-else-if="currentType === 'request'">
|
|
@@ -87,28 +105,26 @@
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
<a-form-item label="查询参数 (querys) JSON">
|
|
<a-form-item label="查询参数 (querys) JSON">
|
|
|
- <a-input
|
|
|
|
|
- :value="requestQuerysJson"
|
|
|
|
|
- placeholder='{"key": "value"}'
|
|
|
|
|
- :rows="2"
|
|
|
|
|
- @change="(e: Event) => setRequestQuerys((e.target as HTMLInputElement)?.value)"
|
|
|
|
|
|
|
+ <KeyValueEditor
|
|
|
|
|
+ :modelValue="(modelValue as IHomeCommonCategoryDynamicDataRequest)?.querys"
|
|
|
|
|
+ @update:modelValue="(v: Record<string, any>) => setRequest('querys', v)"
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
<a-form-item label="请求体参数 (params) JSON">
|
|
<a-form-item label="请求体参数 (params) JSON">
|
|
|
- <a-input
|
|
|
|
|
- :value="requestParamsJson"
|
|
|
|
|
- placeholder='{"key": "value"}'
|
|
|
|
|
- :rows="2"
|
|
|
|
|
- @change="(e: Event) => setRequestParams((e.target as HTMLInputElement)?.value)"
|
|
|
|
|
|
|
+ <KeyValueEditor
|
|
|
|
|
+ :modelValue="(modelValue as IHomeCommonCategoryDynamicDataRequest)?.otherParams"
|
|
|
|
|
+ @update:modelValue="(v: Record<string, any>) => setRequest('otherParams', v)"
|
|
|
/>
|
|
/>
|
|
|
</a-form-item>
|
|
</a-form-item>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
</a-form>
|
|
</a-form>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref, watch } from 'vue';
|
|
|
|
|
|
|
+import { computed } from 'vue';
|
|
|
import type {
|
|
import type {
|
|
|
IHomeCommonCategoryDynamicData,
|
|
IHomeCommonCategoryDynamicData,
|
|
|
IHomeCommonCategoryDynamicDataCommonContent,
|
|
IHomeCommonCategoryDynamicDataCommonContent,
|
|
@@ -117,6 +133,7 @@ import type {
|
|
|
IHomeCommonCategoryDynamicDataDetailContent,
|
|
IHomeCommonCategoryDynamicDataDetailContent,
|
|
|
} from '@/pages/article/data/CommonCategoryDynamicData';
|
|
} from '@/pages/article/data/CommonCategoryDynamicData';
|
|
|
import { SerializedApiMap } from '@/pages/article/data/CommonCategoryDynamicData';
|
|
import { SerializedApiMap } from '@/pages/article/data/CommonCategoryDynamicData';
|
|
|
|
|
+import KeyValueEditor from './KeyValueEditor.vue';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
modelValue?: IHomeCommonCategoryDynamicData | null;
|
|
modelValue?: IHomeCommonCategoryDynamicData | null;
|
|
@@ -179,32 +196,41 @@ function onTypeChange(type: 'commonContent' | 'serializedApi' | 'request') {
|
|
|
emit('update:modelValue', {
|
|
emit('update:modelValue', {
|
|
|
type: 'commonContent',
|
|
type: 'commonContent',
|
|
|
params: { modelId: 1, mainBodyColumnId: undefined, typeId: undefined },
|
|
params: { modelId: 1, mainBodyColumnId: undefined, typeId: undefined },
|
|
|
|
|
+ otherParams: {},
|
|
|
});
|
|
});
|
|
|
} else if (type === 'serializedApi') {
|
|
} else if (type === 'serializedApi') {
|
|
|
emit('update:modelValue', {
|
|
emit('update:modelValue', {
|
|
|
type: 'serializedApi',
|
|
type: 'serializedApi',
|
|
|
name: Object.keys(SerializedApiMap)[0] ?? 'ProjectsContent',
|
|
name: Object.keys(SerializedApiMap)[0] ?? 'ProjectsContent',
|
|
|
|
|
+ otherParams: {},
|
|
|
});
|
|
});
|
|
|
} else if (type === 'request') {
|
|
} else if (type === 'request') {
|
|
|
emit('update:modelValue', {
|
|
emit('update:modelValue', {
|
|
|
type: 'request',
|
|
type: 'request',
|
|
|
method: 'GET',
|
|
method: 'GET',
|
|
|
url: '',
|
|
url: '',
|
|
|
|
|
+ otherParams: {},
|
|
|
});
|
|
});
|
|
|
} else if (type === 'detailContent') {
|
|
} else if (type === 'detailContent') {
|
|
|
emit('update:modelValue', {
|
|
emit('update:modelValue', {
|
|
|
type: 'detailContent',
|
|
type: 'detailContent',
|
|
|
params: { id: 0, modelId: 0 },
|
|
params: { id: 0, modelId: 0 },
|
|
|
|
|
+ otherParams: {},
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function setCommonContent(key: 'modelId' | 'typeId', value: number | undefined) {
|
|
|
|
|
|
|
+function setCommonContent(key: 'modelId' | 'typeId'|'otherParams', value: number | Record<string, any> | undefined) {
|
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataCommonContent | undefined;
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataCommonContent | undefined;
|
|
|
if (!cur || cur.type !== 'commonContent') return;
|
|
if (!cur || cur.type !== 'commonContent') return;
|
|
|
const next = { ...cur, params: { ...cur.params, [key]: value } };
|
|
const next = { ...cur, params: { ...cur.params, [key]: value } };
|
|
|
emit('update:modelValue', next);
|
|
emit('update:modelValue', next);
|
|
|
}
|
|
}
|
|
|
|
|
+function setOtherParams(value: Record<string, any> | undefined) {
|
|
|
|
|
+ const cur = props.modelValue;
|
|
|
|
|
+ const next = { ...cur, otherParams: value } as IHomeCommonCategoryDynamicData ;
|
|
|
|
|
+ emit('update:modelValue', next);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function setMainBodyColumnId(source: 'commonContent' | 'serializedApi', input: string) {
|
|
function setMainBodyColumnId(source: 'commonContent' | 'serializedApi', input: string) {
|
|
|
const parsed = parseMainBodyColumnId(input);
|
|
const parsed = parseMainBodyColumnId(input);
|
|
@@ -219,7 +245,7 @@ function setMainBodyColumnId(source: 'commonContent' | 'serializedApi', input: s
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function setSerializedApi(key: 'name', value: string) {
|
|
|
|
|
|
|
+function setSerializedApi(key: 'name'|'otherParams', value: any) {
|
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataSerializedApi | undefined;
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataSerializedApi | undefined;
|
|
|
if (!cur || cur.type !== 'serializedApi') return;
|
|
if (!cur || cur.type !== 'serializedApi') return;
|
|
|
emit('update:modelValue', { ...cur, [key]: value });
|
|
emit('update:modelValue', { ...cur, [key]: value });
|
|
@@ -233,7 +259,7 @@ function setSerializedApiMainBodyColumnId(input: string) {
|
|
|
emit('update:modelValue', { ...cur, params: Object.keys(params).length ? params : undefined });
|
|
emit('update:modelValue', { ...cur, params: Object.keys(params).length ? params : undefined });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function setRequest(key: 'method' | 'url', value: string) {
|
|
|
|
|
|
|
+function setRequest(key: 'method' | 'url'|'otherParams'|'querys', value: string|Record<string, any>) {
|
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
|
if (!cur || cur.type !== 'request') return;
|
|
if (!cur || cur.type !== 'request') return;
|
|
|
emit('update:modelValue', { ...cur, [key]: value });
|
|
emit('update:modelValue', { ...cur, [key]: value });
|
|
@@ -246,49 +272,6 @@ function setDetailContent(key: 'id' | 'modelId', value: number | undefined) {
|
|
|
emit('update:modelValue', next);
|
|
emit('update:modelValue', next);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const requestQuerysJson = computed(() => {
|
|
|
|
|
- const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
|
|
|
- if (!cur?.querys) return '';
|
|
|
|
|
- try {
|
|
|
|
|
- return typeof cur.querys === 'string' ? cur.querys : JSON.stringify(cur.querys, null, 2);
|
|
|
|
|
- } catch {
|
|
|
|
|
- return '';
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-const requestParamsJson = computed(() => {
|
|
|
|
|
- const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
|
|
|
- if (!cur?.params) return '';
|
|
|
|
|
- try {
|
|
|
|
|
- return typeof cur.params === 'string' ? cur.params : JSON.stringify(cur.params, null, 2);
|
|
|
|
|
- } catch {
|
|
|
|
|
- return '';
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-function setRequestQuerys(str: string) {
|
|
|
|
|
- const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
|
|
|
- if (!cur || cur.type !== 'request') return;
|
|
|
|
|
- let querys: Record<string, any> | undefined;
|
|
|
|
|
- try {
|
|
|
|
|
- querys = str?.trim() ? JSON.parse(str) : undefined;
|
|
|
|
|
- } catch {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- emit('update:modelValue', { ...cur, querys });
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-function setRequestParams(str: string) {
|
|
|
|
|
- const cur = props.modelValue as IHomeCommonCategoryDynamicDataRequest | undefined;
|
|
|
|
|
- if (!cur || cur.type !== 'request') return;
|
|
|
|
|
- let params: Record<string, any> | undefined;
|
|
|
|
|
- try {
|
|
|
|
|
- params = str?.trim() ? JSON.parse(str) : undefined;
|
|
|
|
|
- } catch {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- emit('update:modelValue', { ...cur, params });
|
|
|
|
|
-}
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|