@tplc/business 0.5.18 → 0.5.19

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.5.19](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.18...v0.5.19) (2025-10-16)
6
+
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ * tab支持变更属性 ([3e8390b](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/3e8390be463525f4988d5ae36034a83d69031dc2))
11
+ * 支持 stackRight stackLeft ([81d1fd4](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/81d1fd488395196cf28ef6a8df269564d87376bd))
12
+
5
13
  ### [0.5.18](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.17...v0.5.18) (2025-10-14)
6
14
 
7
15
 
@@ -40,7 +40,7 @@ export interface LcbBlockProps {
40
40
  borderColor?: string
41
41
  borderWidth?: number
42
42
  textAlign?: 'left' | 'center' | 'right'
43
- customStyle?: StyleValue
43
+ customStyle?: Record<string, any>
44
44
  align?:
45
45
  | 'top-left'
46
46
  | 'top-center'
@@ -11,16 +11,7 @@
11
11
  :key="i"
12
12
  class="carousel-block"
13
13
  @click="changeBlock(item)"
14
- :style="{
15
- left: item.left,
16
- top: item.top,
17
- zIndex: item.zIndex,
18
- width: itemWidth + 'rpx',
19
- height: itemHeight + 'rpx',
20
- transition: item.transition + 's all',
21
- transform: 'translate3d(-50%, -50%, 0) scale(' + item.scale + ')',
22
- opacity: item.opacity,
23
- }"
14
+ :style="getItemStyle(item)"
24
15
  >
25
16
  <lcb-action-view
26
17
  v-bind="item.item.link"
@@ -54,10 +45,11 @@ defineOptions({
54
45
  })
55
46
 
56
47
  const props = withDefaults(defineProps<LcbSwiperProps>(), {
57
- mode: 'multiple',
58
48
  itemWidth: 450,
59
49
  itemHeight: 300,
60
50
  enableOpacity: false,
51
+ mode: 'stackCenter',
52
+ scaleStep: 0.1,
61
53
  })
62
54
  type DataRecord = Record<string, any>
63
55
 
@@ -92,23 +84,53 @@ const slotStyles = ref<SlotStyle[]>([])
92
84
 
93
85
  const visible = computed<number>(() => {
94
86
  if (props.visibleCount && props.visibleCount > 0) return props.visibleCount
95
- if (props.mode === 'single') return 3
96
- if (props.mode === 'multiple') return 5
97
87
  return 5
98
88
  })
99
89
 
100
- function buildSlots(n: number): SlotStyle[] {
90
+ function buildSlots(n: number, mode: string): SlotStyle[] {
101
91
  const center = Math.floor(n / 2)
102
92
  const spacing = 14 // percent per slot
103
- const scaleStep = 0.15
93
+ const stepValue = props.scaleStep || 0.1 // 使用 props 中的缩放步长(仅用于 stackLeft/Right)
94
+
104
95
  return Array.from({ length: n }, (_, i) => {
105
96
  const d = Math.abs(i - center)
97
+
98
+ let leftValue: string
99
+ let topValue: string
100
+ let scale: number
101
+ let zIndex: number
102
+
103
+ let opacity: number
104
+
105
+ if (mode === 'stackLeft') {
106
+ // 左排列:从左到右,依次缩小
107
+ leftValue = `calc(0% + ${i * 8}%)`
108
+ topValue = '50%'
109
+ scale = Math.max(1 - i * stepValue, 0.5) // 根据 scaleStep 缩放
110
+ zIndex = n - i // 第1张在最上层
111
+ opacity = props.enableOpacity ? (i === 0 ? 1 : i === 1 ? 0.8 : 0.6) : 1
112
+ } else if (mode === 'stackRight') {
113
+ // 右排列:从右到左,依次缩小
114
+ leftValue = `calc(100% - ${i * 8}%)`
115
+ topValue = '50%'
116
+ scale = Math.max(1 - i * stepValue, 0.5) // 根据 scaleStep 缩放
117
+ zIndex = n - i // 第1张在最上层
118
+ opacity = props.enableOpacity ? (i === 0 ? 1 : i === 1 ? 0.8 : 0.6) : 1
119
+ } else {
120
+ // 居中:从中心向两侧分布,使用固定的 0.15 缩放步长
121
+ leftValue = `calc(50% + ${(i - center) * spacing}%)`
122
+ topValue = '50%'
123
+ scale = Math.max(1 - d * 0.15, 0.6) // center 模式使用固定 0.15
124
+ zIndex = 100 - d
125
+ opacity = props.enableOpacity ? (d === 0 ? 1 : d === 1 ? 0.4 : 0.7) : 1
126
+ }
127
+
106
128
  return {
107
- left: `calc(50% + ${(i - center) * spacing}% )`,
108
- top: '50%',
109
- zIndex: 100 - d,
110
- scale: Math.max(1 - d * scaleStep, 0.6),
111
- opacity: props.enableOpacity ? (d === 0 ? 1 : d === 1 ? 0.4 : 0.7) : 1,
129
+ left: leftValue,
130
+ top: topValue,
131
+ zIndex,
132
+ scale,
133
+ opacity,
112
134
  transition: 0.2,
113
135
  }
114
136
  })
@@ -118,7 +140,7 @@ function initData() {
118
140
  datalist.value = Array.isArray(props.items) ? props.items.slice() : []
119
141
  const desired = visible.value
120
142
  const n = Math.min(desired, datalist.value.length)
121
- slotStyles.value = buildSlots(n)
143
+ slotStyles.value = buildSlots(n, props.mode || 'stackCenter')
122
144
  imagelist.value = slotStyles.value.map((s, i) => ({
123
145
  ...s,
124
146
  isIndex: i,
@@ -183,23 +205,66 @@ function RightSliding() {
183
205
  })
184
206
  }
185
207
 
208
+ function getItemStyle(item: any) {
209
+ let transform: string
210
+ const baseScale = `scale(${item.scale})`
211
+
212
+ if (props.mode === 'stackLeft') {
213
+ // 左排列:从左边开始,不居中
214
+ transform = `translate3d(0, -50%, 0) ${baseScale}`
215
+ } else if (props.mode === 'stackRight') {
216
+ // 右排列:从右边开始,向左对齐
217
+ transform = `translate3d(-100%, -50%, 0) ${baseScale}`
218
+ } else {
219
+ // 居中:保持居中
220
+ transform = `translate3d(-50%, -50%, 0) ${baseScale}`
221
+ }
222
+
223
+ return {
224
+ left: item.left,
225
+ top: item.top,
226
+ zIndex: item.zIndex,
227
+ width: props.itemWidth + 'rpx',
228
+ height: props.itemHeight + 'rpx',
229
+ transition: item.transition + 's all',
230
+ transform,
231
+ opacity: item.opacity,
232
+ }
233
+ }
234
+
186
235
  function changeBlock(item: ImageItem) {
187
236
  const n = imagelist.value.length
188
- const center = Math.floor(n / 2)
189
237
  const toor = item.slotIndex
190
- if (toor < center) {
191
- RightSliding()
192
- if (toor < center - 1) {
193
- setTimeout(() => RightSliding(), 100)
194
- }
195
- } else if (toor > center) {
196
- LeftSliding()
197
- if (toor > center + 1) {
198
- setTimeout(() => LeftSliding(), 100)
238
+
239
+ if (props.mode === 'stackLeft' || props.mode === 'stackRight') {
240
+ // stackLeft/Right 模式:点击的卡片移动到第一个位置(slotIndex = 0)
241
+ if (toor === 0) {
242
+ // 已经是第一张,触发选中事件
243
+ const selected = datalist.value[item.isIndex]
244
+ if (selected) emit('selection', selected)
245
+ } else {
246
+ // 需要移动到第一个位置,执行 toor 次 LeftSliding
247
+ for (let i = 0; i < toor; i++) {
248
+ setTimeout(() => LeftSliding(), i * 100)
249
+ }
199
250
  }
200
251
  } else {
201
- const selected = datalist.value[item.isIndex]
202
- if (selected) emit('selection', selected)
252
+ // stackCenter 模式:保持原有逻辑,移动到中心
253
+ const center = Math.floor(n / 2)
254
+ if (toor < center) {
255
+ RightSliding()
256
+ if (toor < center - 1) {
257
+ setTimeout(() => RightSliding(), 100)
258
+ }
259
+ } else if (toor > center) {
260
+ LeftSliding()
261
+ if (toor > center + 1) {
262
+ setTimeout(() => LeftSliding(), 100)
263
+ }
264
+ } else {
265
+ const selected = datalist.value[item.isIndex]
266
+ if (selected) emit('selection', selected)
267
+ }
203
268
  }
204
269
  }
205
270
 
@@ -226,7 +291,7 @@ onMounted(() => {
226
291
 
227
292
  // Re-init when count-related inputs change or array length changes
228
293
  watch(
229
- () => [props.visibleCount, props.mode, props.items?.length],
294
+ () => [props.visibleCount, props.mode, props.scaleStep, props.items?.length],
230
295
  () => initData(),
231
296
  )
232
297
 
@@ -9,8 +9,10 @@ export interface LcbSwiperProps extends LcbBlockProps {
9
9
  >[]
10
10
  itemWidth?: number
11
11
  itemHeight?: number
12
- mode?: string
12
+ mode?: 'stackLeft' | 'stackRight' | 'stackCenter' | 'tinder'
13
13
  visibleCount?: number
14
14
  imageRadius?: number
15
15
  enableOpacity?: boolean
16
+ /** 缩放步长:仅针对 stackLeft/stackRight 模式,每张卡片缩小的比例,默认 0.1 (10%) */
17
+ scaleStep?: number
16
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.5.18",
3
+ "version": "0.5.19",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -1,4 +1,3 @@
1
- import { StyleValue } from 'vue'
2
1
  export interface LcbBlockProps {
3
2
  /** 左右外距 */
4
3
  marginHorizontal?: number
@@ -39,7 +38,7 @@ export interface LcbBlockProps {
39
38
  borderColor?: string
40
39
  borderWidth?: number
41
40
  textAlign?: 'left' | 'center' | 'right'
42
- customStyle?: StyleValue
41
+ customStyle?: Record<string, any>
43
42
  align?:
44
43
  | 'top-left'
45
44
  | 'top-center'
@@ -22,7 +22,7 @@ declare const __VLS_component: import('vue').DefineComponent<
22
22
  mode: 'map' | 'list'
23
23
  backgroundColor: string
24
24
  color: string
25
- customStyle: string | false | import('vue').CSSProperties | import('vue').StyleValue[] | null
25
+ customStyle: Record<string, any>
26
26
  customClass: string
27
27
  zIndex: number
28
28
  radius: number
@@ -4,10 +4,11 @@ declare const _default: import('vue').DefineComponent<
4
4
  __VLS_WithDefaults<
5
5
  __VLS_TypePropsToOption<LcbSwiperProps>,
6
6
  {
7
- mode: string
8
7
  itemWidth: number
9
8
  itemHeight: number
10
9
  enableOpacity: boolean
10
+ mode: string
11
+ scaleStep: number
11
12
  }
12
13
  >,
13
14
  {},
@@ -26,10 +27,11 @@ declare const _default: import('vue').DefineComponent<
26
27
  __VLS_WithDefaults<
27
28
  __VLS_TypePropsToOption<LcbSwiperProps>,
28
29
  {
29
- mode: string
30
30
  itemWidth: number
31
31
  itemHeight: number
32
32
  enableOpacity: boolean
33
+ mode: string
34
+ scaleStep: number
33
35
  }
34
36
  >
35
37
  >
@@ -37,10 +39,11 @@ declare const _default: import('vue').DefineComponent<
37
39
  onSelection?: ((item: DataRecord) => any) | undefined
38
40
  },
39
41
  {
40
- mode: string
42
+ mode: 'stackLeft' | 'stackRight' | 'stackCenter' | 'tinder'
41
43
  itemWidth: number
42
44
  itemHeight: number
43
45
  enableOpacity: boolean
46
+ scaleStep: number
44
47
  },
45
48
  {}
46
49
  >
@@ -8,8 +8,10 @@ export interface LcbSwiperProps extends LcbBlockProps {
8
8
  >[]
9
9
  itemWidth?: number
10
10
  itemHeight?: number
11
- mode?: string
11
+ mode?: 'stackLeft' | 'stackRight' | 'stackCenter' | 'tinder'
12
12
  visibleCount?: number
13
13
  imageRadius?: number
14
14
  enableOpacity?: boolean
15
+ /** 缩放步长:仅针对 stackLeft/stackRight 模式,每张卡片缩小的比例,默认 0.1 (10%) */
16
+ scaleStep?: number
15
17
  }