|
|
@@ -8,14 +8,15 @@
|
|
|
v-model:value="pathType"
|
|
|
style="width: 120px; margin-right: 8px"
|
|
|
>
|
|
|
- <a-select-option v-if="!props.noParams" value="dynamic-list">动态页面列表</a-select-option>
|
|
|
+ <a-select-option v-if="!props.noParams" value="dynamic-list">动态列表页面</a-select-option>
|
|
|
+ <a-select-option v-if="!props.noParams" value="dynamic-detail">动态详情页面</a-select-option>
|
|
|
<a-select-option value="internal">程序内置页面</a-select-option>
|
|
|
<a-select-option value="custom">自定义输入</a-select-option>
|
|
|
</a-select>
|
|
|
|
|
|
<!-- 动态页面地址 -->
|
|
|
<a-select
|
|
|
- v-if="pathType === 'dynamic-list'"
|
|
|
+ v-if="pathType === 'dynamic-list' || pathType === 'dynamic-detail'"
|
|
|
v-model:value="localPageConfigName"
|
|
|
style="flex: 1"
|
|
|
@change="updateLink"
|
|
|
@@ -57,11 +58,12 @@
|
|
|
/>
|
|
|
</div>
|
|
|
</a-form-item>
|
|
|
- <a-form-item v-if="!props.noParams && pathType !== 'dynamic-list'" label="参数设置">
|
|
|
+ <a-form-item v-if="!props.noParams && pathType !== 'dynamic-list' && pathType !== 'dynamic-detail'" label="参数设置">
|
|
|
<KeyValueEditor
|
|
|
- v-model="localParams"
|
|
|
+ :modelValue="localParams"
|
|
|
:forceOneLevel="true"
|
|
|
:defaultCreateTemplate="{ key: '', value: '', type: 'string' }"
|
|
|
+ @update:modelValue="localParams = $event"
|
|
|
/>
|
|
|
</a-form-item>
|
|
|
</a-collapse-panel>
|
|
|
@@ -74,7 +76,7 @@ import { inject, ref, watch, computed } from 'vue';
|
|
|
import KeyValueEditor from './KeyValueEditor.vue';
|
|
|
import type { IHomeCommonCategoryDefine } from '@/pages/article/data/CommonCategoryDefine';
|
|
|
import PagesJson from '@/pages.json';
|
|
|
-import { CommonCategoryListPath } from '@/pages/article/data/CommonCategoryPathDefine';
|
|
|
+import { CommonCategoryDetailPath, CommonCategoryListPath } from '@/pages/article/data/CommonCategoryPathDefine';
|
|
|
|
|
|
/** 从 URL 字符串中解析路径和 ? 后面的查询参数 */
|
|
|
function parseUrlParams(url: string): { path: string; params: Record<string, string> } {
|
|
|
@@ -130,7 +132,7 @@ const pageList = inject<(IHomeCommonCategoryDefine['page'][0])[]>('pageList', []
|
|
|
const activeKey = ref('');
|
|
|
|
|
|
// 跳转路径类型
|
|
|
-const pathType = ref<'dynamic-list' | 'internal' | 'custom'>('custom');
|
|
|
+const pathType = ref<'dynamic-list' | 'dynamic-detail' | 'internal' | 'custom'>('custom');
|
|
|
// 跳转路径
|
|
|
const linkPath = ref('');
|
|
|
const localPageConfigName = ref('');
|
|
|
@@ -146,13 +148,10 @@ const internalPages = computed(() => {
|
|
|
}));
|
|
|
});
|
|
|
|
|
|
-let noUpdate = false;
|
|
|
-
|
|
|
// 监听 modelValue:从 URL 字符串解析路径与 ? 后参数
|
|
|
watch(
|
|
|
() => props.modelValue,
|
|
|
(newValue) => {
|
|
|
- noUpdate = true;
|
|
|
const urlStr = typeof newValue === 'string' ? newValue : '';
|
|
|
const { path, params } = parseUrlParams(urlStr);
|
|
|
linkPath.value = path;
|
|
|
@@ -160,30 +159,20 @@ watch(
|
|
|
if (linkPath.value === CommonCategoryListPath) {
|
|
|
pathType.value = 'dynamic-list';
|
|
|
localPageConfigName.value = localParams.value.pageConfigName || '';
|
|
|
- } else if (linkPath.value.startsWith('/pages/')) {
|
|
|
+ } else if (linkPath.value === CommonCategoryDetailPath) {
|
|
|
+ pathType.value = 'dynamic-detail';
|
|
|
+ localPageConfigName.value = localParams.value.pageConfigName || '';
|
|
|
+ } else if (linkPath.value.startsWith('/pages/')) {
|
|
|
pathType.value = 'internal';
|
|
|
} else {
|
|
|
pathType.value = 'custom';
|
|
|
}
|
|
|
- setTimeout(() => {
|
|
|
- noUpdate = false;
|
|
|
- }, 200);
|
|
|
},
|
|
|
{ deep: true, immediate: true }
|
|
|
);
|
|
|
-watch(
|
|
|
- localParams,
|
|
|
- () => {
|
|
|
- updateLink();
|
|
|
- },
|
|
|
- { deep: true }
|
|
|
-);
|
|
|
|
|
|
// 更新链接:输出为带 ? 参数的完整 URL 字符串
|
|
|
const updateLink = () => {
|
|
|
- if (noUpdate) {
|
|
|
- return;
|
|
|
- }
|
|
|
if (props.noParams) {
|
|
|
emit('update:modelValue', linkPath.value);
|
|
|
return;
|
|
|
@@ -193,6 +182,11 @@ const updateLink = () => {
|
|
|
pageConfigName: localPageConfigName.value || '',
|
|
|
};
|
|
|
linkPath.value = CommonCategoryListPath;
|
|
|
+ } else if (pathType.value === 'dynamic-detail') {
|
|
|
+ localParams.value = {
|
|
|
+ pageConfigName: localPageConfigName.value || '',
|
|
|
+ };
|
|
|
+ linkPath.value = CommonCategoryDetailPath;
|
|
|
}
|
|
|
emit('update:modelValue', buildUrlWithParams(linkPath.value, localParams.value));
|
|
|
};
|