@tplc/wot 0.1.12 → 0.1.14

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.1.14](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.0.28...v0.1.14) (2024-10-19)
6
+
7
+ ### [0.1.13](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.0.27...v0.1.13) (2024-10-10)
8
+
5
9
  ### [0.1.12](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.1.11...v0.1.12) (2024-09-27)
6
10
 
7
11
  ### [0.1.11](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.0.26...v0.1.11) (2024-09-27)
@@ -43,7 +43,7 @@ $-color-aid: var(--wot-color-aid,
43
43
  $-color-tip: var(--wot-color-tip, #bfbfbf) !default; // 失效、默认提示文字 bfbfbf
44
44
  $-color-border: var(--wot-color-border, #d9d9d9) !default; // 控件边框线 d9d9d9
45
45
  $-color-border-light: var(--wot-color-border-light, #e8e8e8) !default; // 分割线颜色 e8e8e8
46
- $-color-bg: var(--wot-color-bg, #f5f5f5) !default; // 背景色、禁用填充色 f5f5f5
46
+ $-color-bg: var(--wot-color-bg, #F4F5F7) !default; // 背景色、禁用填充色 f5f5f5
47
47
  /* 暗黑模式 */
48
48
  $-dark-background: var(--wot-dark-background, #131313) !default;
49
49
  $-dark-background2: var(--wot-dark-background2, #1b1b1b) !default;
@@ -58,7 +58,7 @@ $-dark-color3: var(--wot-dark-color3, rgba(232, 230, 227, 0.8)) !default;
58
58
  $-dark-color-gray: var(--wot-dark-color-gray, $-color-secondary) !default;
59
59
  $-dark-border-color: var(--wot-dark-border-color, #3a3a3c) !default;
60
60
  /* 图形颜色 */
61
- $-color-icon: var(--wot-color-icon, #d9d9d9) !default; // icon颜色
61
+ $-color-icon: var(--wot-color-icon, #969696) !default; // icon颜色
62
62
  $-color-icon-active: var(--wot-color-icon-active, #eee) !default; // icon颜色hover
63
63
  $-color-icon-disabled: var(--wot-color-icon-disabled, #a7a7a7) !default; // icon颜色disabled
64
64
  /*----------------------------------------- Theme color. end -------------------------------------------*/
@@ -618,7 +618,7 @@ $-search-icon-color: var(--wot-search-icon-color, $-color-icon) !default; // 图
618
618
  $-search-icon-size: var(--wot-search-icon-size, 18px) !default; // 图标大小
619
619
  $-search-clear-icon-size: var(--wot-search-clear-icon-size, $-fs-title) !default; // 清除图标大小
620
620
  $-search-placeholder-color: var(--wot-search-placeholder-color,
621
- #bfbfbf) !default; // placeholder 颜色
621
+ #969696) !default; // placeholder 颜色
622
622
  $-search-cancel-padding: var(--wot-search-cancel-padding,
623
623
  0 $-search-side-padding 0 10px) !default; // 取消按钮间距
624
624
  $-search-cancel-fs: var(--wot-search-cancel-fs, $-fs-title) !default; // 取消按钮字号
@@ -16,7 +16,7 @@ export const useTranslate = (name?: string) => {
16
16
  const translate = (key: string, ...args: unknown[]) => {
17
17
  const currentMessages = Locale.messages()
18
18
  const message = getPropByPath(currentMessages, prefix + key)
19
- return isFunction(message) ? message(...args) : message
19
+ return (isFunction(message) ? message(...args) : message) || key
20
20
  }
21
21
 
22
22
  return { translate }
@@ -50,4 +50,6 @@ export const imgProps = {
50
50
  * 是否允许预览
51
51
  */
52
52
  enablePreview: makeBooleanProp(false),
53
- }
53
+
54
+ lazyPlaceWidth: numericProp,
55
+ }
@@ -1,10 +1,14 @@
1
1
  <template>
2
2
  <view :class="rootClass" @click="handleClick" :style="rootStyle">
3
3
  <image
4
- :class="`wd-img__image ${customImage}`"
5
- :style="status !== 'success' ? 'width: 0;height: 0;' : ''"
6
- :src="src"
4
+ :class="`wd-img__image coverImg ${customImage}`"
5
+ :src="wrapPhoto({ photo: src, width, type: 2 })"
7
6
  :mode="mode"
7
+ :style="
8
+ status != 'success' && {
9
+ ...wrapPhoto({ photo: src, width: lazyPlaceWidth }),
10
+ }
11
+ "
8
12
  :lazy-load="lazyLoad"
9
13
  @load="handleLoad"
10
14
  @error="handleError"
@@ -22,6 +26,7 @@ export default {
22
26
  styleIsolation: 'shared',
23
27
  },
24
28
  }
29
+ // :style="`${status !== 'success' ? 'width: 0;height: 0;' : ''}`"
25
30
  </script>
26
31
 
27
32
  <script lang="ts" setup>
@@ -69,8 +74,27 @@ function handleLoad(event: Event) {
69
74
  status.value = 'success'
70
75
  emit('load', event)
71
76
  }
77
+
78
+ function wrapPhoto({ photo, width = 200, otherParams = {}, type = 1 }: any) {
79
+ const isctyun = photo?.indexOf('.ctyun') >= 0
80
+ const sym = photo?.indexOf('?') > 0 ? '&' : '?'
81
+ const suffix = isctyun
82
+ ? `${sym}x-amz-process=image/resize,w_${width},m_lfit`
83
+ : `${sym}x-oss-process=image/resize,m_mfit,w_${width}&imageView2/2/w/${width}`
84
+ const url = `${photo}${width > 0 ? suffix : ''}`
85
+ return type === 2
86
+ ? url
87
+ : photo
88
+ ? { backgroundImage: `url('${url}')`, ...otherParams }
89
+ : otherParams
90
+ }
72
91
  </script>
73
92
 
74
93
  <style lang="scss" scoped>
75
94
  @import './index.scss';
95
+
96
+ .coverImg {
97
+ background-repeat: no-repeat;
98
+ background-size: cover;
99
+ }
76
100
  </style>
@@ -1,5 +1,5 @@
1
1
  import type { ExtractPropTypes } from 'vue'
2
- import { baseProps, makeRequiredProp } from '../common/props'
2
+ import { baseProps, makeRequiredProp, makeStringProp } from '../common/props'
3
3
 
4
4
  export const indexAnchorProps = {
5
5
  ...baseProps,
@@ -31,6 +31,8 @@ const indexAnchorId = ref<string>(`indexBar${uuid()}`)
31
31
 
32
32
  const { proxy } = getCurrentInstance()!
33
33
 
34
+ const top = ref<number>(0)
35
+
34
36
  const isSticky = computed(() => {
35
37
  return indexBar && indexBar.props.sticky && indexBar.anchorState.activeIndex === props.index
36
38
  })
@@ -38,20 +40,22 @@ const isSticky = computed(() => {
38
40
  function getInfo() {
39
41
  getRect(`#${indexAnchorId.value}`, false, proxy).then((res) => {
40
42
  if (isDef(indexBar)) {
41
- const anchor = indexBar.anchorState.anchorList.find((v) => v.index === props.index)!
42
- anchor.top = Math.floor(res.top!)
43
+ top.value = Math.floor(res.top!)
43
44
  }
44
45
  })
45
46
  }
46
47
 
47
48
  onMounted(() => {
48
- if (isDef(indexBar)) {
49
- indexBar.anchorState.anchorList.push({ top: 0, index: props.index })
50
- }
51
- getInfo()
49
+ setTimeout(() => {
50
+ getInfo()
51
+ }, 200)
52
+ })
53
+
54
+ defineExpose({
55
+ top,
52
56
  })
53
57
  </script>
54
58
 
55
59
  <style lang="scss" scoped>
56
- @import './index';
60
+ @import './index.scss';
57
61
  </style>
@@ -28,9 +28,9 @@
28
28
 
29
29
  @include e(index) {
30
30
  padding: 4px 6px;
31
- font-size: 12px;
31
+ font-size: 20rpx;
32
32
  font-weight: $-fw-medium;
33
- color: $-color-title;
33
+ color: $-color-theme;
34
34
 
35
35
  @include when(active) {
36
36
  color: $-color-theme;
@@ -1,13 +1,8 @@
1
- import type { Ref, InjectionKey, ExtractPropTypes } from 'vue'
1
+ import type { InjectionKey, ExtractPropTypes } from 'vue'
2
2
  import { makeBooleanProp } from '../common/props'
3
3
 
4
4
  export type AnchorIndex = number | string
5
5
 
6
- export interface AnchorItem {
7
- top: number
8
- index: AnchorIndex
9
- }
10
-
11
6
  export const indexBarProps = {
12
7
  /**
13
8
  * @description 索引是否吸顶
@@ -20,7 +15,6 @@ export type IndexBarProps = ExtractPropTypes<typeof indexBarProps>
20
15
  export type InderBarProvide = {
21
16
  props: { sticky?: boolean }
22
17
  anchorState: {
23
- anchorList: AnchorItem[] // 锚点列表
24
18
  activeIndex: AnchorIndex | null // 当前激活的索引
25
19
  }
26
20
  }
@@ -19,9 +19,9 @@
19
19
  @touchcancel.stop.prevent="handleTouchEnd"
20
20
  >
21
21
  <view
22
- class="wd-index-bar__index"
22
+ class="wd-index-bar__index text-center"
23
23
  :class="{ 'is-active': item.index === state.activeIndex }"
24
- v-for="item in state.anchorList"
24
+ v-for="item in children"
25
25
  :key="item.index"
26
26
  >
27
27
  {{ item.index }}
@@ -30,16 +30,18 @@
30
30
  <!-- #ifdef MP-DINGTALK -->
31
31
  </view>
32
32
  <!-- #endif -->
33
+ <wd-toast />
33
34
  </view>
34
35
  </template>
35
36
 
36
37
  <script setup lang="ts">
37
- import type { AnchorItem, AnchorIndex } from './type'
38
+ import type { AnchorIndex } from './type'
38
39
  import { indexBarInjectionKey, indexBarProps } from './type'
39
- import { ref, getCurrentInstance, onMounted, reactive, nextTick } from 'vue'
40
+ import { ref, getCurrentInstance, onMounted, reactive, nextTick, watch } from 'vue'
40
41
  import { getRect, isDef, uuid, requestAnimationFrame } from '../common/util'
41
42
  import { useChildren } from '../composables/useChildren'
42
-
43
+ import { useToast } from '../wd-toast'
44
+ const toast = useToast()
43
45
  const props = defineProps(indexBarProps)
44
46
 
45
47
  const indexBarId = ref<string>(`indexBar${uuid()}`)
@@ -48,13 +50,27 @@ const { proxy } = getCurrentInstance()!
48
50
 
49
51
  const state = reactive({
50
52
  activeIndex: null as AnchorIndex | null,
51
- anchorList: [] as AnchorItem[],
52
53
  })
53
54
 
54
- const { linkChildren } = useChildren(indexBarInjectionKey)
55
+ const { linkChildren, children } = useChildren(indexBarInjectionKey)
55
56
 
56
57
  linkChildren({ props, anchorState: state })
57
58
 
59
+ watch(
60
+ () => children,
61
+ (newValue) => {
62
+ if (!newValue.length) {
63
+ state.activeIndex = null // 或者设置为一个默认值,如第一个子项的索引
64
+ return
65
+ }
66
+
67
+ if (!isDef(state.activeIndex) || !newValue.find((item) => item.index === state.activeIndex)) {
68
+ state.activeIndex = newValue[0].index
69
+ }
70
+ },
71
+ { deep: true, immediate: true },
72
+ )
73
+
58
74
  const scrollState = reactive({
59
75
  scrollTop: 0, // 即将滚动到的位置
60
76
  prevScrollTop: 0, // 上次记录的位置
@@ -73,7 +89,6 @@ const sidebarInfo = {
73
89
 
74
90
  function init() {
75
91
  setTimeout(() => {
76
- state.activeIndex = state.anchorList[0]?.index
77
92
  Promise.all([
78
93
  getRect(`#${indexBarId.value}`, false, proxy),
79
94
  getRect('.wd-index-bar__sidebar', false, proxy),
@@ -83,7 +98,7 @@ function init() {
83
98
  sidebarInfo.offsetTop = sidebar.top!
84
99
  sidebarInfo.indexHeight = index.height!
85
100
  })
86
- }, 100)
101
+ }, 200)
87
102
  }
88
103
 
89
104
  onMounted(() => {
@@ -96,16 +111,16 @@ function hanleScroll(scrollEvent: any) {
96
111
  }
97
112
  const { detail } = scrollEvent
98
113
  const scrolltop = Math.floor(detail.scrollTop)
99
- const anchor = state.anchorList.find((item, index) => {
100
- if (!isDef(state.anchorList[index + 1])) return true
114
+ const anchor = children.find((item, index) => {
115
+ if (!isDef(children[index + 1])) return true
101
116
  if (
102
- item.top - offsetTop <= scrolltop &&
103
- state.anchorList[index + 1].top - offsetTop > scrolltop
117
+ item.$.exposed!.top.value - offsetTop <= scrolltop &&
118
+ children[index + 1].$.exposed!.top.value - offsetTop > scrolltop
104
119
  )
105
120
  return true
106
121
  return false
107
- })!
108
- if (state.activeIndex !== anchor.index) {
122
+ })
123
+ if (isDef(anchor) && state.activeIndex !== anchor.index) {
109
124
  state.activeIndex = anchor.index
110
125
  }
111
126
  scrollState.prevScrollTop = scrolltop
@@ -115,8 +130,8 @@ function getAnchorByPageY(pageY: number) {
115
130
  const y = pageY - sidebarInfo.offsetTop
116
131
  let idx = Math.floor(y / sidebarInfo.indexHeight)
117
132
  if (idx < 0) idx = 0
118
- else if (idx > state.anchorList.length - 1) idx = state.anchorList.length - 1
119
- return state.anchorList[idx]
133
+ else if (idx > children.length - 1) idx = children.length - 1
134
+ return children[idx]
120
135
  }
121
136
 
122
137
  function handleTouchStart() {
@@ -129,13 +144,21 @@ function handleTouchMove(e: TouchEvent) {
129
144
  return
130
145
  }
131
146
  state.activeIndex = getAnchorByPageY(clientY).index
132
- setScrollTop(getAnchorByPageY(clientY).top - offsetTop)
147
+ setScrollTop(getAnchorByPageY(clientY).$.exposed!.top.value - offsetTop)
148
+ }
149
+ function showToast() {
150
+ if (state.activeIndex)
151
+ toast.show({
152
+ msg: `${state.activeIndex}`,
153
+ duration: 1500,
154
+ })
133
155
  }
134
156
 
135
157
  function handleTouchEnd(e: TouchEvent) {
136
158
  const clientY = e.changedTouches[0].pageY
137
159
  state.activeIndex = getAnchorByPageY(clientY).index
138
- setScrollTop(getAnchorByPageY(clientY).top - offsetTop)
160
+ showToast()
161
+ setScrollTop(getAnchorByPageY(clientY).$.exposed!.top.value - offsetTop)
139
162
  requestAnimationFrame(() => {
140
163
  scrollState.touching = false
141
164
  })
@@ -151,6 +174,17 @@ function setScrollTop(top: number) {
151
174
  scrollState.scrollTop = top
152
175
  }
153
176
  }
177
+ function scrollToIndex(index: AnchorIndex) {
178
+ const anchor = children.find((item) => item.index === index)
179
+ state.activeIndex = index
180
+ showToast()
181
+ if (anchor) {
182
+ setScrollTop(anchor.$.exposed!.top.value - offsetTop)
183
+ }
184
+ }
185
+ defineExpose({
186
+ scrollToIndex,
187
+ })
154
188
  </script>
155
189
 
156
190
  <style lang="scss" scoped>
@@ -44,25 +44,25 @@ const imgUrl = computed(() => {
44
44
  let img: string = ''
45
45
  switch (props.image) {
46
46
  case 'collect':
47
- img = 'https://img.wot-design-uni.cn/wdu/collect.png'
47
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/collect.png'
48
48
  break
49
49
  case 'comment':
50
- img = 'https://img.wot-design-uni.cn/wdu/comment.png'
50
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/comment.png'
51
51
  break
52
52
  case 'content':
53
- img = 'https://img.wot-design-uni.cn/wdu/content.png'
53
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/content.png'
54
54
  break
55
55
  case 'halo':
56
- img = 'https://img.wot-design-uni.cn/wdu/halo.png'
56
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/halo.png'
57
57
  break
58
58
  case 'message':
59
- img = 'https://img.wot-design-uni.cn/wdu/message.png'
59
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/message.png'
60
60
  break
61
61
  case 'network':
62
- img = 'https://img.wot-design-uni.cn/wdu/network.png'
62
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/network.png'
63
63
  break
64
64
  case 'search':
65
- img = 'https://img.wot-design-uni.cn/wdu/search.png'
65
+ img = 'https://qdll-lycs.oss-cn-nanjing.aliyuncs.com/staticSaas/basis/search.png'
66
66
  break
67
67
  default:
68
68
  img = props.image
@@ -49,7 +49,7 @@
49
49
  transform: translate3d(0, -40vh, 0);
50
50
  }
51
51
  @include m(middle) {
52
- transform: translate3d(0%, -18.8vh, 0);
52
+ transform: translate3d(0%, -4vh, 0);
53
53
  }
54
54
  @include m(bottom) {
55
55
  transform: translate3d(0, 40vh, 0);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "@tplc/wot",
3
3
  "name": "@tplc/wot",
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
5
5
  "keywords": [
6
6
  "wot-design-uni",
7
7
  "国际化",
@@ -62,6 +62,7 @@ export declare const imgProps: {
62
62
  type: BooleanConstructor
63
63
  default: boolean
64
64
  }
65
+ lazyPlaceWidth: (NumberConstructor | StringConstructor)[]
65
66
  customStyle: {
66
67
  type: import('vue').PropType<string>
67
68
  default: string
@@ -25,6 +25,7 @@ declare const _default: __VLS_WithTemplateSlots<
25
25
  type: BooleanConstructor
26
26
  default: boolean
27
27
  }
28
+ lazyPlaceWidth: (NumberConstructor | StringConstructor)[]
28
29
  customStyle: {
29
30
  type: import('vue').PropType<string>
30
31
  default: string
@@ -73,6 +74,7 @@ declare const _default: __VLS_WithTemplateSlots<
73
74
  type: BooleanConstructor
74
75
  default: boolean
75
76
  }
77
+ lazyPlaceWidth: (NumberConstructor | StringConstructor)[]
76
78
  customStyle: {
77
79
  type: import('vue').PropType<string>
78
80
  default: string
@@ -16,7 +16,9 @@ declare const __VLS_component: import('vue').DefineComponent<
16
16
  default: string
17
17
  }
18
18
  },
19
- {},
19
+ {
20
+ top: import('vue').Ref<number>
21
+ },
20
22
  unknown,
21
23
  {},
22
24
  {},
@@ -1,9 +1,5 @@
1
1
  import type { InjectionKey, ExtractPropTypes } from 'vue'
2
2
  export type AnchorIndex = number | string
3
- export interface AnchorItem {
4
- top: number
5
- index: AnchorIndex
6
- }
7
3
  export declare const indexBarProps: {
8
4
  /**
9
5
  * @description 索引是否吸顶
@@ -19,7 +15,6 @@ export type InderBarProvide = {
19
15
  sticky?: boolean
20
16
  }
21
17
  anchorState: {
22
- anchorList: AnchorItem[]
23
18
  activeIndex: AnchorIndex | null
24
19
  }
25
20
  }
@@ -1,3 +1,5 @@
1
+ import type { AnchorIndex } from './type'
2
+ declare function scrollToIndex(index: AnchorIndex): void
1
3
  declare function __VLS_template(): {
2
4
  default?(_: {}): any
3
5
  }
@@ -8,7 +10,9 @@ declare const __VLS_component: import('vue').DefineComponent<
8
10
  default: boolean
9
11
  }
10
12
  },
11
- {},
13
+ {
14
+ scrollToIndex: typeof scrollToIndex
15
+ },
12
16
  unknown,
13
17
  {},
14
18
  {},