@tplc/business 0.5.44 → 0.5.46

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,10 @@
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.46](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v1.0.6...v0.5.46) (2025-11-12)
6
+
7
+ ### [0.5.45](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.44...v0.5.45) (2025-11-10)
8
+
5
9
  ### [0.5.44](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.43...v0.5.44) (2025-11-08)
6
10
 
7
11
 
@@ -178,7 +178,7 @@ const getDayName = (time: number) => {
178
178
  const urlParams = computed(() => {
179
179
  return stringify({
180
180
  ...form.value,
181
- categoryTags: props.tabs[current.value].value,
181
+ categoryTags: props.tabs?.[current.value]?.value,
182
182
  })
183
183
  })
184
184
 
@@ -6,7 +6,7 @@ export interface LcbHomeSearch extends LcbBlockProps {
6
6
  placeholder?: string
7
7
  items?: ActionView[]
8
8
  btnText?: string
9
- tabs: {
9
+ tabs?: {
10
10
  label: string
11
11
  value: string
12
12
  }[]
@@ -1,4 +1,5 @@
1
1
  <template>
2
+ <view id="image-gap"></view>
2
3
  <view
3
4
  v-for="(item, index) in items"
4
5
  :key="index"
@@ -23,7 +24,7 @@
23
24
  :src="item.url"
24
25
  :enable-preview="enablePreview"
25
26
  :mode="imageHeight ? 'aspectFill' : 'widthFix'"
26
- :height="imageHeight ? transformValueUnit(imageHeight) : 'auto'"
27
+ :height="imageHeight ? transformValueUnit(imageHeight) : imagesHeight[index] || 'auto'"
27
28
  custom-class="overflow-hidden block"
28
29
  />
29
30
  </lcb-action-view>
@@ -58,10 +59,12 @@
58
59
  <script setup lang="ts">
59
60
  import { LcbImageProps } from '../types'
60
61
  import { transformValueUnit } from '../../../utils/transform'
61
-
62
+ import { calcAutoHeight, getOssImageSize } from '../../../utils/utils'
63
+ import { getCurrentInstance, onMounted, ref } from 'vue'
62
64
  const props = withDefaults(defineProps<LcbImageProps>(), {
63
65
  imageMargin: 0,
64
66
  })
67
+ const imagesHeight = ref<number[]>([])
65
68
 
66
69
  function getRealSize(size: number = 0) {
67
70
  const mode = props.styleGroup
@@ -72,4 +75,37 @@ function getRealSize(size: number = 0) {
72
75
  if (mode === 2 && imgSpan) realWidth -= (lens - 1) / 2
73
76
  return (realWidth / 375) * size
74
77
  }
78
+ const getImageSize = (width: number) => {
79
+ Promise.allSettled(
80
+ props.items!.map((item) => {
81
+ return getOssImageSize(item.url || '')
82
+ }),
83
+ ).then((sizes) => {
84
+ sizes.forEach((size) => {
85
+ if (size.status === 'fulfilled') {
86
+ imagesHeight.value.push(
87
+ calcAutoHeight({
88
+ originalWidth: size.value.width,
89
+ originalHeight: size.value.height,
90
+ targetWidth: props.styleGroup === 3 ? props.imageSize || width : width,
91
+ }),
92
+ )
93
+ }
94
+ })
95
+ })
96
+ }
97
+ const proxy = getCurrentInstance()!.proxy
98
+ onMounted(() => {
99
+ // 如果没有高度,则获取image-gap的宽度,计算图片高度,并设置到imagesHeight中
100
+ if (!props.imageHeight && props.items?.length) {
101
+ uni
102
+ .createSelectorQuery()
103
+ .in(proxy)
104
+ .select('#image-gap')
105
+ .boundingClientRect((res) => {
106
+ getImageSize((res as { width: number }).width)
107
+ })
108
+ .exec()
109
+ }
110
+ })
75
111
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.5.44",
3
+ "version": "0.5.46",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "vue": ">=3.2.47",
14
- "@tplc/wot": "0.1.100"
14
+ "@tplc/wot": "1.0.6"
15
15
  },
16
16
  "engines": {
17
17
  "node": ">=18",
@@ -5,7 +5,7 @@ export interface LcbHomeSearch extends LcbBlockProps {
5
5
  placeholder?: string
6
6
  items?: ActionView[]
7
7
  btnText?: string
8
- tabs: {
8
+ tabs?: {
9
9
  label: string
10
10
  value: string
11
11
  }[]
@@ -41,3 +41,16 @@ export declare const getDynamicData: (
41
41
  defaultText?: string
42
42
  },
43
43
  ) => string
44
+ export declare const calcAutoHeight: ({
45
+ originalWidth,
46
+ originalHeight,
47
+ targetWidth,
48
+ }: {
49
+ originalWidth: number
50
+ originalHeight: number
51
+ targetWidth: number
52
+ }) => number
53
+ export declare const getOssImageSize: (url: string) => Promise<{
54
+ width: number
55
+ height: number
56
+ }>
package/utils/utils.ts CHANGED
@@ -3,6 +3,7 @@ import { UploadMethod } from '@tplc/wot/types/components/wd-upload/types'
3
3
  import { uploadFile } from '../hooks/useUpload'
4
4
  import { parse, stringify } from 'qs'
5
5
  import { get } from 'lodash-es'
6
+ import { transformValueUnit } from './transform'
6
7
  export function formatJson(str: string | object | undefined, defVal = {}) {
7
8
  if (!str) return defVal
8
9
  if (typeof str === 'object') return str
@@ -141,3 +142,36 @@ export const getDynamicData = (
141
142
  }
142
143
  return value
143
144
  }
145
+ export const calcAutoHeight = ({
146
+ originalWidth,
147
+ originalHeight,
148
+ targetWidth,
149
+ }: {
150
+ originalWidth: number
151
+ originalHeight: number
152
+ targetWidth: number
153
+ }) => {
154
+ return (originalHeight / originalWidth) * targetWidth
155
+ }
156
+
157
+ export const getOssImageSize = async (url: string) => {
158
+ return new Promise<{
159
+ width: number
160
+ height: number
161
+ }>((resolve) => {
162
+ uni.request({
163
+ url: `${url}?x-oss-process=image/info`,
164
+ method: 'GET',
165
+ success: ({ data }) => {
166
+ const { ImageWidth, ImageHeight } = data as unknown as {
167
+ ImageWidth: { value: number }
168
+ ImageHeight: { value: number }
169
+ }
170
+ resolve({
171
+ width: Number(ImageWidth.value),
172
+ height: Number(ImageHeight.value),
173
+ })
174
+ },
175
+ })
176
+ })
177
+ }