@tplc/business 0.7.24 → 0.7.26

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,28 @@
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.7.26](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.25...v0.7.26) (2025-12-22)
6
+
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ * 修改兼容尺寸 ([9079ff7](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/9079ff74d88162468a3528b533f9492ca7c2dfaa))
11
+ * 新增优化版本 ([aac61bb](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/aac61bbc06a90fc8ade33c8c1765f4df5d4ba37e))
12
+
13
+ ### [0.7.25](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.23...v0.7.25) (2025-12-22)
14
+
15
+
16
+ ### 🚀 Chore | 构建/工程依赖/工具
17
+
18
+ * **release:** 0.7.24 ([a8d4228](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/a8d4228a98f33d853e333cecf223731cf737091a))
19
+
20
+
21
+ ### ✨ Features | 新功能
22
+
23
+ * 优化lcb ([4508077](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/45080773f73d2f9329de373d2b713eb5b644dea0))
24
+ * 优化渲染 ([7ad9de0](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/7ad9de0f1effd3ba99d341927ce71ae8de2deec6))
25
+ * 去掉异步 ([ee2e200](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/ee2e2000d17f36ba049727aab365631b8652ab50))
26
+
5
27
  ### [0.7.24](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.19...v0.7.24) (2025-12-21)
6
28
 
7
29
 
@@ -72,7 +72,7 @@
72
72
  :submitRequestInfo="submitRequestInfo"
73
73
  v-if="['144'].includes(getJumpType(jumpType)) && showPay && requestInfo && submitRequestInfo"
74
74
  />
75
- <SharePopup v-model="showPoster" :params="requestParam" />
75
+ <SharePopup v-model="showPoster" :params="requestParam" v-if="showPoster" />
76
76
  <CustomPopup
77
77
  v-model="showCustomPopup"
78
78
  v-if="['145'].includes(getJumpType(jumpType)) && showCustomPopup"
@@ -1,9 +1,6 @@
1
1
  <template>
2
2
  <lcb-block v-bind="$props" v-if="showArea">
3
- <lcb-action-view
4
- v-bind="actionProps"
5
- :renderMode="actionProps?.jumpType ? 'button' : 'noClick'"
6
- >
3
+ <lcb-action-view v-bind="actionProps" v-if="actionProps?.jumpType">
7
4
  <view :style="containerStyle" class="h-full">
8
5
  <view
9
6
  v-for="(item, index) in list"
@@ -15,11 +12,21 @@
15
12
  </view>
16
13
  </view>
17
14
  </lcb-action-view>
15
+ <view :style="containerStyle" class="h-full" v-else>
16
+ <view
17
+ v-for="(item, index) in list"
18
+ :key="item.id"
19
+ class="slot-wrapper"
20
+ :style="getItemStyle(index)"
21
+ >
22
+ <slot :item="item" />
23
+ </view>
24
+ </view>
18
25
  </lcb-block>
19
26
  </template>
20
27
 
21
28
  <script setup lang="ts">
22
- import { computed, watch, ref } from 'vue'
29
+ import { computed, watch } from 'vue'
23
30
  import { LcbAreaProps } from './types'
24
31
  import { getFlexStyle, transformValueUnit } from '@tplc/business/utils/transform'
25
32
  import { get } from 'lodash-es'
@@ -114,16 +121,17 @@ const getData = async () => {
114
121
 
115
122
  /** 处理跳转链接中的动态参数 */
116
123
  const actionProps = computed(() => {
124
+ const jumpUrl = props.action?.jumpUrl
125
+ if (!jumpUrl) {
126
+ return props.action
127
+ }
128
+
117
129
  // 优化: 提前返回,避免不必要的计算
118
130
  if (props.dynamicActionKey) {
119
131
  return get(innerDynamicData.value, props.dynamicActionKey)
120
132
  }
121
133
 
122
134
  // 优化: 只在 jumpUrl 存在时才调用 getDynamicData
123
- const jumpUrl = props.action?.jumpUrl
124
- if (!jumpUrl) {
125
- return props.action
126
- }
127
135
 
128
136
  return {
129
137
  ...props.action,
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <lcb-action-view
3
+ v-bind="actionProps"
4
+ @avatar="onAvatar"
5
+ @click="handleClick"
6
+ :customStyle="actionPaddingStyle"
7
+ :renderMode="!actionProps?.jumpType && mode !== 'image' ? 'noClick' : 'button'"
8
+ >
9
+ <lcb-button-content
10
+ v-bind="props"
11
+ :innerValue="innerValue"
12
+ :store="store"
13
+ :dynamicValue="dynamicValue"
14
+ />
15
+ </lcb-action-view>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ import { LcbButtonProps } from '../../types'
20
+ import { computed } from 'vue'
21
+ import { getDynamicData } from '../../../../utils/utils'
22
+ import { transformValueUnit } from '../../../../utils/transform'
23
+ import { LcbActionViewProps } from '../../../lcb-action-view/types'
24
+ import LcbButtonContent from '../lcb-button-content/index.vue'
25
+ defineOptions({
26
+ name: 'LcbButtonActionContent',
27
+ options: {
28
+ addGlobalClass: true,
29
+ virtualHost: true,
30
+ styleIsolation: 'shared',
31
+ },
32
+ })
33
+ const props = defineProps<
34
+ LcbButtonProps & {
35
+ innerValue?: string
36
+ actionProps: LcbActionViewProps
37
+ store: any
38
+ userStore: any
39
+ dynamicValue?: string
40
+ }
41
+ >()
42
+ // 优化: 分离 padding 计算和 block props,避免解构整个 props
43
+ const actionPaddingStyle = computed(() => {
44
+ const top = transformValueUnit(props.paddingTop || props.paddingVertical)
45
+ const right = transformValueUnit(props.paddingRight || props.paddingHorizontal)
46
+ const bottom = transformValueUnit(props.paddingBottom || props.paddingVertical)
47
+ const left = transformValueUnit(props.paddingLeft || props.paddingHorizontal)
48
+ return `width: 100%; padding:${top} ${right} ${bottom} ${left}`
49
+ })
50
+
51
+ const onAvatar = (headImgUrl) => {
52
+ props.userStore?.updateUser(
53
+ {
54
+ headImgUrl,
55
+ },
56
+ true,
57
+ )
58
+ }
59
+
60
+ const handleClick = () => {
61
+ if (props.mode === 'image' && innerValue.value && props.enablePreview) {
62
+ uni.previewImage({
63
+ urls: [innerValue.value],
64
+ current: innerValue.value,
65
+ })
66
+ }
67
+ }
68
+ const innerValue = computed(() => {
69
+ if (props.mode === 'image') {
70
+ return props.dynamicValue || props.url
71
+ }
72
+ return getDynamicData(props.text, {
73
+ store: props.store,
74
+ defaultText: props.textDefaultValue,
75
+ })
76
+ })
77
+ </script>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <view class="!flex items-center justify-center" :style="iconGapStyle">
3
+ <wd-icon
4
+ v-if="icon"
5
+ :name="icon"
6
+ class-prefix="lcb"
7
+ :size="transformValueUnit(iconSize)"
8
+ :color="iconColor"
9
+ />
10
+ <template v-if="mode === 'image'">
11
+ <wd-img
12
+ :src="innerValue"
13
+ :width="transformValueUnit(imageWidth)"
14
+ :mode="imageHeight ? 'aspectFill' : 'widthFix'"
15
+ :height="imageHeight ? transformValueUnit(imageHeight) : 'auto'"
16
+ />
17
+ </template>
18
+ <template v-else-if="mode === 'qrcode'">
19
+ <wd-qr-code :size="qrCodeSize" canvasId="qrCode" :value="innerValue" v-if="innerValue" />
20
+ </template>
21
+ <template v-else-if="mode === 'progress'">
22
+ <wd-progress :value="innerValue" v-bind="progressProps" />
23
+ </template>
24
+ <text
25
+ v-else
26
+ style="line-height: 1.54"
27
+ class="whitespace-pre-wrap"
28
+ :class="lineClamp ? `line-clamp-${lineClamp}` : ''"
29
+ >
30
+ {{ innerValue }}
31
+ </text>
32
+ </view>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import { LcbButtonProps } from '../../types'
37
+ import { transformValueUnit } from '../../../../utils/transform'
38
+ import { computed } from 'vue'
39
+ defineOptions({
40
+ name: 'LcnButtonContent',
41
+ options: {
42
+ addGlobalClass: true,
43
+ virtualHost: true,
44
+ styleIsolation: 'shared',
45
+ },
46
+ })
47
+ const props = defineProps<
48
+ LcbButtonProps & { innerValue?: string; store: any; dynamicValue?: string }
49
+ >()
50
+
51
+ // 优化: 将 iconGap 样式单独提取,避免模板字符串
52
+ const iconGapStyle = computed(() => `gap: ${props.iconGap}rpx`)
53
+ </script>
@@ -1,64 +1,37 @@
1
1
  <template>
2
2
  <template v-if="mode === 'noStyle'">{{ innerValue }}</template>
3
- <view class="w-full h-full" :style="wrapperStyle" v-else-if="shouldRender">
4
- <lcb-block
5
- v-bind="blockProps"
6
- :customClass="`${customClass} border-solid`"
7
- :customStyle="blockCustomStyle"
8
- >
9
- <lcb-action-view
10
- v-bind="actionProps"
11
- @avatar="onAvatar"
12
- @click="handleClick"
13
- :customStyle="actionPaddingStyle"
14
- :renderMode="!actionProps?.jumpType && mode !== 'image' ? 'noClick' : 'button'"
15
- >
16
- <view class="!flex items-center justify-center" :style="iconGapStyle">
17
- <wd-icon
18
- v-if="icon"
19
- :name="icon"
20
- class-prefix="lcb"
21
- :size="transformValueUnit(iconSize)"
22
- :color="iconColor"
23
- />
24
- <template v-if="mode === 'image'">
25
- <wd-img
26
- :src="innerValue"
27
- :width="transformValueUnit(imageWidth)"
28
- :mode="imageHeight ? 'aspectFill' : 'widthFix'"
29
- :height="imageHeight ? transformValueUnit(imageHeight) : 'auto'"
30
- />
31
- </template>
32
- <template v-else-if="mode === 'qrcode'">
33
- <wd-qr-code
34
- :size="qrCodeSize"
35
- canvasId="qrCode"
36
- :value="innerValue"
37
- v-if="innerValue"
38
- />
39
- </template>
40
- <template v-else-if="mode === 'progress'">
41
- <wd-progress :value="innerValue" v-bind="progressProps" />
42
- </template>
43
- <text
44
- v-else
45
- style="line-height: 1.54"
46
- class="whitespace-pre-wrap"
47
- :class="lineClamp ? `line-clamp-${lineClamp}` : ''"
48
- >
49
- {{ innerValue }}
50
- </text>
51
- </view>
52
- </lcb-action-view>
53
- </lcb-block>
54
- </view>
3
+ <lcb-block
4
+ v-bind="blockProps"
5
+ :customClass="`${customClass} border-solid w-full h-full`"
6
+ :customStyle="blockCustomStyle"
7
+ v-else-if="shouldRender"
8
+ >
9
+ <lcb-button-action
10
+ v-bind="props"
11
+ v-if="actionProps?.jumpType || mode === 'image'"
12
+ :innerValue="innerValue"
13
+ :actionProps="actionProps"
14
+ :store="store"
15
+ :userStore="userStore"
16
+ :dynamicValue="dynamicValue"
17
+ />
18
+ <lcb-button-content
19
+ v-else
20
+ v-bind="props"
21
+ :innerValue="innerValue"
22
+ :store="store"
23
+ :dynamicValue="dynamicValue"
24
+ />
25
+ </lcb-block>
55
26
  </template>
56
27
 
57
28
  <script setup lang="ts">
58
29
  import { get } from 'lodash-es'
59
30
  import { computed } from 'vue'
60
31
  import useDynamicData from '../../hooks/useDynamicData'
61
- import { getFlexStyle, transformValueUnit } from '../../utils/transform'
32
+ import { getFlexStyle } from '../../utils/transform'
33
+ import LcbButtonAction from './components/lcb-button-action/index.vue'
34
+ import LcbButtonContent from './components/lcb-button-content/index.vue'
62
35
  import { getDynamicData } from '../../utils/utils'
63
36
  import { LcbButtonProps } from './types'
64
37
  defineOptions({
@@ -101,14 +74,6 @@ const shouldRender = computed(() => {
101
74
  return !!dynamicValue.value
102
75
  })
103
76
 
104
- const handleClick = () => {
105
- if (props.mode === 'image' && innerValue.value && props.enablePreview) {
106
- uni.previewImage({
107
- urls: [innerValue.value],
108
- current: innerValue.value,
109
- })
110
- }
111
- }
112
77
  const innerValue = computed(() => {
113
78
  if (props.mode === 'image') {
114
79
  return dynamicValue.value || props.url
@@ -121,17 +86,17 @@ const innerValue = computed(() => {
121
86
 
122
87
  /** 处理跳转链接中的动态参数 */
123
88
  const actionProps = computed(() => {
124
- // 优化: 提前返回,避免不必要的计算
125
- if (props.dynamicActionKey) {
126
- return get(innerDynamicData.value, props.dynamicActionKey)
127
- }
128
-
129
89
  // 优化: 只在 jumpUrl 存在时才调用 getDynamicData
130
90
  const jumpUrl = props.action?.jumpUrl
131
91
  if (!jumpUrl) {
132
92
  return props.action
133
93
  }
134
94
 
95
+ // 优化: 提前返回,避免不必要的计算
96
+ if (props.dynamicActionKey) {
97
+ return get(innerDynamicData.value, props.dynamicActionKey)
98
+ }
99
+
135
100
  return {
136
101
  ...props.action,
137
102
  jumpUrl: getDynamicData(jumpUrl, {
@@ -140,46 +105,14 @@ const actionProps = computed(() => {
140
105
  }
141
106
  })
142
107
 
143
- const onAvatar = (headImgUrl) => {
144
- userStore?.updateUser(
145
- {
146
- headImgUrl,
147
- },
148
- true,
149
- )
150
- }
151
-
152
- // 优化: 缓存样式对象,避免在模板中创建新对象
153
- const innerStyle = computed(() => {
154
- return getFlexStyle(props.align)
155
- })
156
-
157
- const innerItemStyle = computed(() => {
158
- return getFlexStyle(props.itemAlign)
159
- })
160
-
161
- // 优化: 将 wrapper 样式单独提取
162
- const wrapperStyle = computed(() => innerStyle.value)
163
-
164
- // 优化: 将 iconGap 样式单独提取,避免模板字符串
165
- const iconGapStyle = computed(() => `gap: ${props.iconGap}rpx`)
166
-
167
108
  // 优化: 将 block customStyle 单独提取
168
109
  const blockCustomStyle = computed(() => ({
169
110
  width: props.fillWidth ? '100%' : 'fit-content',
170
111
  height: props.fillHeight ? '100%' : 'fit-content',
171
- ...innerItemStyle.value,
112
+ ...getFlexStyle(props.itemAlign),
113
+ ...getFlexStyle(props.align),
172
114
  }))
173
115
 
174
- // 优化: 分离 padding 计算和 block props,避免解构整个 props
175
- const actionPaddingStyle = computed(() => {
176
- const top = transformValueUnit(props.paddingTop || props.paddingVertical)
177
- const right = transformValueUnit(props.paddingRight || props.paddingHorizontal)
178
- const bottom = transformValueUnit(props.paddingBottom || props.paddingVertical)
179
- const left = transformValueUnit(props.paddingLeft || props.paddingHorizontal)
180
- return `width: 100%; padding:${top} ${right} ${bottom} ${left}`
181
- })
182
-
183
116
  const blockProps = computed(() => {
184
117
  const {
185
118
  paddingVertical,
@@ -13,7 +13,7 @@
13
13
 
14
14
  <script setup lang="ts">
15
15
  import { transformValueUnit } from '@tplc/business/utils/transform'
16
- import { computed, ref, watch, shallowRef } from 'vue'
16
+ import { computed, watch, shallowRef } from 'vue'
17
17
  import useDynamicData from '../../hooks/useDynamicData'
18
18
  import { dynamicRequest } from '../../utils/request'
19
19
  import { LcbWrapperListProps } from './types'
@@ -32,7 +32,6 @@ const props = withDefaults(defineProps<LcbWrapperListProps>(), {
32
32
  const { userStore, innerDynamicData } = useDynamicData()
33
33
  // 使用 shallowRef 优化大数组的响应式性能
34
34
  const renderList = shallowRef<unknown[]>([])
35
- const isLoading = ref(false)
36
35
 
37
36
  // 优化:检查是否需要转换,避免不必要的遍历
38
37
  const transformStringArrayToObjectArray = (data: unknown[]): unknown[] => {
@@ -48,33 +47,18 @@ const transformStringArrayToObjectArray = (data: unknown[]): unknown[] => {
48
47
  })
49
48
  }
50
49
 
51
- // 优化:使用 watch 替代 watchEffect,明确依赖并添加防抖和加载状态
52
- let loadingTimer: ReturnType<typeof setTimeout> | null = null
53
50
  watch(
54
51
  () => [props.dataSource, innerDynamicData.value, userStore?.userInfo] as const,
52
+
55
53
  async ([dataSource, dynamicData, userInfo]) => {
56
- // 防抖处理,避免频繁请求
57
- if (loadingTimer) {
58
- clearTimeout(loadingTimer)
54
+ // 防止重复请求
55
+ let data: unknown[] = []
56
+ const result = await dynamicRequest(dataSource, dynamicData, userInfo)
57
+ if (result) {
58
+ data = result
59
59
  }
60
-
61
- loadingTimer = setTimeout(async () => {
62
- // 防止重复请求
63
- if (isLoading.value) return
64
-
65
- isLoading.value = true
66
- try {
67
- let data: unknown[] = []
68
- const result = await dynamicRequest(dataSource, dynamicData, userInfo)
69
- if (result) {
70
- data = result
71
- }
72
- // 使用 shallowRef 时需要重新赋值整个数组
73
- renderList.value = Array.isArray(data) ? transformStringArrayToObjectArray(data) : []
74
- } finally {
75
- isLoading.value = false
76
- }
77
- }, 100) // 100ms 防抖
60
+ // 使用 shallowRef 时需要重新赋值整个数组
61
+ renderList.value = Array.isArray(data) ? transformStringArrayToObjectArray(data) : []
78
62
  },
79
63
  { immediate: true },
80
64
  )
@@ -84,9 +68,6 @@ const getItemKey = (item: any, index: number) => {
84
68
  return item?.id ?? item?.key ?? index
85
69
  }
86
70
 
87
- // 优化:提取 gap 计算,避免在 listStyle 中重复计算
88
- const gapValue = computed(() => transformValueUnit(props.gap))
89
-
90
71
  // 优化:简化条件判断逻辑
91
72
  const itemStyle = computed(() => {
92
73
  let width = '100%'
@@ -104,7 +85,7 @@ const listStyle = computed(() => {
104
85
  width: '100%',
105
86
  display: props.display,
106
87
  'flex-direction': props.flexDirection,
107
- gap: gapValue.value,
88
+ gap: transformValueUnit(props.gap),
108
89
  'align-items': 'stretch',
109
90
  'grid-template-columns': `repeat(${props.gridColumns}, minmax(0, 1fr))`,
110
91
  'overflow-x': props.scrollX ? 'auto' : 'hidden',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.7.24",
3
+ "version": "0.7.26",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -1,6 +1,7 @@
1
1
  import { LcbAreaProps } from './types'
2
2
  declare function __VLS_template(): {
3
3
  default?(_: { item: LcbAreaProps }): any
4
+ default?(_: { item: LcbAreaProps }): any
4
5
  }
5
6
  declare const __VLS_component: import('vue').DefineComponent<
6
7
  __VLS_WithDefaults<
@@ -0,0 +1,49 @@
1
+ import { LcbButtonProps } from '../../types'
2
+ import { LcbActionViewProps } from '../../../lcb-action-view/types'
3
+ declare const _default: import('vue').DefineComponent<
4
+ __VLS_TypePropsToOption<
5
+ LcbButtonProps & {
6
+ innerValue?: string
7
+ actionProps: LcbActionViewProps
8
+ store: any
9
+ userStore: any
10
+ dynamicValue?: string
11
+ }
12
+ >,
13
+ {},
14
+ unknown,
15
+ {},
16
+ {},
17
+ import('vue').ComponentOptionsMixin,
18
+ import('vue').ComponentOptionsMixin,
19
+ {},
20
+ string,
21
+ import('vue').PublicProps,
22
+ Readonly<
23
+ import('vue').ExtractPropTypes<
24
+ __VLS_TypePropsToOption<
25
+ LcbButtonProps & {
26
+ innerValue?: string
27
+ actionProps: LcbActionViewProps
28
+ store: any
29
+ userStore: any
30
+ dynamicValue?: string
31
+ }
32
+ >
33
+ >
34
+ >,
35
+ {},
36
+ {}
37
+ >
38
+ export default _default
39
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
40
+ type __VLS_TypePropsToOption<T> = {
41
+ [K in keyof T]-?: {} extends Pick<T, K>
42
+ ? {
43
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>
44
+ }
45
+ : {
46
+ type: import('vue').PropType<T[K]>
47
+ required: true
48
+ }
49
+ }
@@ -0,0 +1,44 @@
1
+ import { LcbButtonProps } from '../../types'
2
+ declare const _default: import('vue').DefineComponent<
3
+ __VLS_TypePropsToOption<
4
+ LcbButtonProps & {
5
+ innerValue?: string
6
+ store: any
7
+ dynamicValue?: string
8
+ }
9
+ >,
10
+ {},
11
+ unknown,
12
+ {},
13
+ {},
14
+ import('vue').ComponentOptionsMixin,
15
+ import('vue').ComponentOptionsMixin,
16
+ {},
17
+ string,
18
+ import('vue').PublicProps,
19
+ Readonly<
20
+ import('vue').ExtractPropTypes<
21
+ __VLS_TypePropsToOption<
22
+ LcbButtonProps & {
23
+ innerValue?: string
24
+ store: any
25
+ dynamicValue?: string
26
+ }
27
+ >
28
+ >
29
+ >,
30
+ {},
31
+ {}
32
+ >
33
+ export default _default
34
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
35
+ type __VLS_TypePropsToOption<T> = {
36
+ [K in keyof T]-?: {} extends Pick<T, K>
37
+ ? {
38
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>
39
+ }
40
+ : {
41
+ type: import('vue').PropType<T[K]>
42
+ required: true
43
+ }
44
+ }