@neatui/vue 5.7.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @neatui/vue 更新记录
2
2
 
3
+ ## 5.8.0
4
+
5
+ ### IRouterView
6
+ - 新增 `source` 属性:`query`(默认)从 `route.query` 读详情 ID,`params` 从 `route.params` 读(路由声明为 `/project/:id?` 这类形状)。
7
+ - `source="params"` 时点遮罩返回列表:按匹配到的路由模式截掉 `:id` 及其后的路径段,query 原样保留,`/project/123/products/4?page=2` 回到 `/project?page=2`;不依赖路由 name,alias 路由同样适用。
8
+ - 默认行为不变:不传 `source` 仍按 query 工作,老项目零改动。
9
+ - Nuxt 页面用 `source="params"` 时需 `definePageMeta({ key })` 固定页面 key:`NuxtPage` 默认按参数生成 key,id 变化会整页重挂载。
10
+
3
11
  ## 5.5.1
4
12
 
5
13
  - 无组件改动,版本号与 `@neatui/css` 同步。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neatui/vue",
3
- "version": "5.7.0",
3
+ "version": "5.8.0",
4
4
  "description": "basic component ui",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "@fekit/scrollto": "^3.0.3",
37
37
  "@fekit/toast": "^2.7.2",
38
38
  "@fekit/utils": "^6.0.0",
39
- "@neatui/css": "^5.7.0",
39
+ "@neatui/css": "^5.8.0",
40
40
  "@rollup/plugin-commonjs": "^26.0.1",
41
41
  "@rollup/plugin-node-resolve": "^15.2.3",
42
42
  "@vue/compiler-sfc": "^3.4.30",
@@ -24,6 +24,11 @@
24
24
  animate?: boolean | 0 | 1;
25
25
  mode?: 'default' | 'preview' | 'pop-up' | 'window';
26
26
  queryName?: string;
27
+ /**
28
+ * 详情 ID 从哪里读:query(?id=1)或 params(/project/1,路由需声明 :id?)。
29
+ * params 模式下 Nuxt 页面需用 definePageMeta({ key }) 固定页面 key,否则 id 变化会整页重挂载。
30
+ */
31
+ source?: 'query' | 'params';
27
32
  listClass?: string;
28
33
  listStyle?: string;
29
34
  itemClass?: string;
@@ -35,6 +40,7 @@
35
40
  animate: 1,
36
41
  mode: 'default',
37
42
  queryName: 'id',
43
+ source: 'query',
38
44
  listClass: 'full',
39
45
  listStyle: '',
40
46
  itemClass: 'full',
@@ -71,8 +77,11 @@
71
77
  };
72
78
  };
73
79
 
80
+ // 详情 ID 的容器:query(?id=1)或 params(/project/1)
81
+ const itemSource = () => (props.source === 'params' ? route.params : route.query);
82
+
74
83
  const hasItemQuery = () => {
75
- const value = route.query[props.queryName];
84
+ const value = itemSource()[props.queryName];
76
85
  if (Array.isArray(value)) return value.some((item) => item !== undefined && item !== null && item !== '');
77
86
  return value !== undefined && value !== null && value !== '';
78
87
  };
@@ -122,12 +131,24 @@
122
131
  provide('onlist', evs('list', 'item'));
123
132
  provide('onitem', evs('item', 'list'));
124
133
  if (env.client) {
125
- watch(() => route.query[props.queryName], a);
134
+ watch(() => itemSource()[props.queryName], a);
126
135
  a();
127
136
  }
128
137
 
138
+ // params 模式回列表:按匹配到的路由模式找到 :id 段,截掉它和它之后的路径段,query 原样保留
139
+ // /project/123/products/4?page=2 → /project?page=2;不依赖路由 name,alias 路由也适用
140
+ const listLocation = () => {
141
+ const pattern = route.matched[route.matched.length - 1]?.path || '';
142
+ const idSegment = new RegExp(`^:${props.queryName}(\\(.*\\))?[?*+]?$`);
143
+ const index = pattern.split('/').findIndex((seg) => idSegment.test(seg));
144
+ if (index > 0) return { path: route.path.split('/').slice(0, index).join('/') || '/', query: route.query };
145
+ // :id 不是独立路径段(如 /project-:id?)时,按当前命名路由把它置空
146
+ return { params: { ...route.params, [props.queryName]: '' }, query: route.query };
147
+ };
148
+
129
149
  // 取消
130
150
  const cancel = () => {
151
+ if (props.source === 'params') return router.push(listLocation());
131
152
  const _query = { ...route.query };
132
153
  delete _query[props.queryName];
133
154
  router.push({ path: route.path, query: _query });