hy-app 0.2.4 → 0.2.5

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.
@@ -22,9 +22,7 @@
22
22
  :color="iconColor"
23
23
  :size="iconSize ? iconSize : addUnit(getPx(getFloatBtnSize) * 0.7)"
24
24
  />
25
- <text v-if="text" :style="{ color: textColor, fontSize: fontSize }">{{
26
- text
27
- }}</text>
25
+ <text v-if="text" :style="{ color: textColor, fontSize: fontSize }">{{ text }}</text>
28
26
  </slot>
29
27
  </view>
30
28
 
@@ -43,10 +41,11 @@
43
41
  }"
44
42
  @click="handleMenuItemClick(item, i)"
45
43
  >
46
- {{ typeof item === "string" ? item : item.label }}
44
+ {{ typeof item === 'string' ? item : item.label }}
47
45
  </view>
48
46
  <HyLine
49
47
  v-if="i !== menus.length - 1"
48
+ color="#FFFFFF"
50
49
  :length="addUnit(getPx(getFloatBtnSize) * 0.7)"
51
50
  :direction="direction === 'row' ? 'column' : 'row'"
52
51
  :custom-style="{ margin: 'auto' }"
@@ -63,30 +62,23 @@ export default {
63
62
  options: {
64
63
  addGlobalClass: true,
65
64
  virtualHost: true,
66
- styleIsolation: 'shared'
67
- }
65
+ styleIsolation: 'shared',
66
+ },
68
67
  }
69
68
  </script>
70
69
 
71
70
  <script lang="ts" setup>
72
- import {
73
- computed,
74
- type CSSProperties,
75
- getCurrentInstance,
76
- onMounted,
77
- ref,
78
- toRefs,
79
- } from "vue";
80
- import type IProps from "./typing";
81
- import type { MenusType } from "./typing";
82
- import defaultProps from "./props";
83
- import { addUnit, getPx, getRect, getWindowInfo, guid } from "../../utils";
71
+ import { computed, type CSSProperties, getCurrentInstance, onMounted, ref, toRefs } from 'vue'
72
+ import type IProps from './typing'
73
+ import type { MenusType } from './typing'
74
+ import defaultProps from './props'
75
+ import { addUnit, getPx, getRect, getWindowInfo, guid } from '../../utils'
84
76
 
85
77
  // 组件
86
- import HyIcon from "../hy-icon/hy-icon.vue";
87
- import HyLine from "../hy-line/hy-line.vue";
78
+ import HyIcon from '../hy-icon/hy-icon.vue'
79
+ import HyLine from '../hy-line/hy-line.vue'
88
80
 
89
- const props = withDefaults(defineProps<IProps>(), defaultProps);
81
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
90
82
  const {
91
83
  menus,
92
84
  customStyle,
@@ -99,33 +91,30 @@ const {
99
91
  size,
100
92
  fixed,
101
93
  direction,
102
- } = toRefs(props);
103
- const emit = defineEmits(["click", "clickItem"]);
94
+ } = toRefs(props)
95
+ const emit = defineEmits(['click', 'clickItem'])
104
96
 
105
- const instance = getCurrentInstance();
97
+ const instance = getCurrentInstance()
106
98
  const btnSize: AnyObject = {
107
- small: "50px",
108
- medium: "60px",
109
- large: "70px",
110
- };
111
- const open = ref(false);
112
- const rotate = computed(() => (open.value && !text.value ? "45deg" : "0deg"));
113
- const soleId = `hy-float-button__${guid()}`;
114
- const showLeft = ref(false);
99
+ small: '50px',
100
+ medium: '60px',
101
+ large: '70px',
102
+ }
103
+ const open = ref(false)
104
+ const rotate = computed(() => (open.value && !text.value ? '45deg' : '0deg'))
105
+ const soleId = `hy-float-button__${guid()}`
106
+ const showLeft = ref(false)
115
107
 
116
108
  /**
117
109
  * @description 获取组件大小
118
110
  * */
119
111
  const getFloatBtnSize = computed(() => {
120
- if (
121
- typeof size.value === "string" &&
122
- Object.keys(btnSize).includes(size.value)
123
- ) {
124
- return btnSize[size.value];
112
+ if (typeof size.value === 'string' && Object.keys(btnSize).includes(size.value)) {
113
+ return btnSize[size.value]
125
114
  } else {
126
- return addUnit(size.value);
115
+ return addUnit(size.value)
127
116
  }
128
- });
117
+ })
129
118
 
130
119
  /**
131
120
  * @description 悬浮按钮样式
@@ -137,85 +126,79 @@ const FloatButtonStyle = computed(() => {
137
126
  backgroundColor: bgColor.value,
138
127
  zIndex: zIndex.value,
139
128
  color: textColor.value,
140
- };
141
- if (fixed.value) style.position = "fixed";
129
+ }
130
+ if (fixed.value) style.position = 'fixed'
142
131
 
143
- style.height = getFloatBtnSize.value;
144
- style.width = getFloatBtnSize.value;
145
- return Object.assign(style, customStyle.value);
146
- });
132
+ style.height = getFloatBtnSize.value
133
+ style.width = getFloatBtnSize.value
134
+ return Object.assign(style, customStyle.value)
135
+ })
147
136
  const menusStyle = computed(() => {
148
137
  const style: CSSProperties = {
149
138
  backgroundColor: bgColor.value,
150
- };
139
+ }
151
140
 
152
141
  // 判断横向展示还是纵向展示
153
- if (direction.value === "row") {
142
+ if (direction.value === 'row') {
154
143
  if (showLeft.value) {
155
- style.transform = "translateX(-100%)";
156
- style.left = "100%";
157
- style.paddingRight = getFloatBtnSize.value;
158
- style.flexDirection = "row-reverse";
144
+ style.transform = 'translateX(-100%)'
145
+ style.left = '100%'
146
+ style.paddingRight = getFloatBtnSize.value
147
+ style.flexDirection = 'row-reverse'
159
148
  } else {
160
- style.paddingLeft = getFloatBtnSize.value;
149
+ style.paddingLeft = getFloatBtnSize.value
161
150
  }
162
- style.bottom = 0;
163
- style.transition = "width 0.5s ease";
164
- style.height = getFloatBtnSize.value;
151
+ style.bottom = 0
152
+ style.transition = 'width 0.5s ease'
153
+ style.height = getFloatBtnSize.value
165
154
  style.width = open.value
166
- ? addUnit(
167
- getPx(getFloatBtnSize.value) * menus.value.length +
168
- getPx(getFloatBtnSize.value),
169
- )
170
- : 0;
155
+ ? addUnit(getPx(getFloatBtnSize.value) * menus.value.length + getPx(getFloatBtnSize.value))
156
+ : 0
171
157
  } else {
172
- style.bottom = 0;
173
- style.left = 0;
174
- style.transition = "height 0.5s ease";
175
- style.width = getFloatBtnSize.value;
158
+ style.bottom = 0
159
+ style.left = 0
160
+ style.transition = 'height 0.5s ease'
161
+ style.width = getFloatBtnSize.value
176
162
  style.height = open.value
177
- ? addUnit(
178
- getPx(getFloatBtnSize.value) * menus.value.length +
179
- getPx(getFloatBtnSize.value),
180
- )
181
- : 0;
182
- style.paddingBottom = getFloatBtnSize.value;
163
+ ? addUnit(getPx(getFloatBtnSize.value) * menus.value.length + getPx(getFloatBtnSize.value))
164
+ : 0
165
+ style.paddingBottom = getFloatBtnSize.value
183
166
  }
184
- return style;
185
- });
167
+ return style
168
+ })
186
169
 
187
170
  onMounted(() => {
188
- const { windowWidth } = getWindowInfo();
171
+ const { windowWidth } = getWindowInfo()
189
172
  getRect(`#${soleId}`, false, instance).then((rect) => {
190
- const { left } = rect as UniApp.NodeInfo;
191
- if (left && left > windowWidth / 2) showLeft.value = true;
192
- });
193
- });
173
+ const { left } = rect as UniApp.NodeInfo
174
+ if (left && left > windowWidth / 2) showLeft.value = true
175
+ })
176
+ })
194
177
 
195
178
  /**
196
179
  * @description 点击悬浮按钮
197
180
  * */
198
181
  const handleClick = () => {
199
- emit("click");
200
- open.value = !open.value;
201
- };
182
+ emit('click')
183
+ open.value = !open.value
184
+ }
202
185
 
203
186
  /**
204
187
  * @description 点击单条菜单栏
205
188
  * */
206
189
  const handleMenuItemClick = (temp: MenusType, index: number) => {
207
- emit("clickItem", temp, index);
208
- open.value = false;
209
- if (typeof temp !== "string" && temp?.url) {
190
+ emit('clickItem', temp, index)
191
+ open.value = false
192
+ if (typeof temp !== 'string' && temp?.url) {
210
193
  uni.navigateTo({
211
194
  url: temp.url,
212
- });
195
+ })
213
196
  }
214
- };
197
+ }
215
198
  </script>
216
199
 
217
200
  <style scoped lang="scss">
218
- @import "./index.scss";
201
+ @import './index.scss';
219
202
  .hy-float-button {
220
203
  &__container {
221
204
  rotate: v-bind(rotate);
@@ -26,7 +26,7 @@
26
26
  }
27
27
  &-warning {
28
28
  color: $hy-error;
29
- font-size: $hy-font-size-hint;
29
+ font-size: $hy-font-size-sm;
30
30
  }
31
31
  }
32
32
  }
@@ -47,10 +47,10 @@
47
47
  flex-direction: column;
48
48
  text-align: center;
49
49
  &--title {
50
- font-size: $hy-font-size-subtitle;
50
+ font-size: $hy-font-size-base;
51
51
  }
52
52
  &--sub {
53
- font-size: $hy-font-size-hint;
53
+ font-size: $hy-font-size-sm;
54
54
  color: $hy-text-color--grey;
55
55
  }
56
56
  }
@@ -11,7 +11,7 @@
11
11
  overflow: hidden;
12
12
  padding: 9px 12px;
13
13
  flex: 1;
14
- background-color: $hy-warning-light;
14
+ background-color: #FFF6C8;
15
15
  color: $hy-warning;
16
16
  border-radius: $hy-border-radius-sm;
17
17
  }
@@ -64,7 +64,7 @@
64
64
 
65
65
  &__text {
66
66
  font-size: 14px;
67
- color: $u-warning;
67
+ color: $hy-warning;
68
68
  }
69
69
  }
70
70
  }
@@ -80,4 +80,4 @@
80
80
  transform: translate3d(-100%, 0, 0);
81
81
  }
82
82
  }
83
- /* #endif */
83
+ /* #endif */
@@ -63,27 +63,28 @@
63
63
 
64
64
  <!-- 选择器内容 -->
65
65
  <picker-view
66
- class="hy-picker__view"
66
+ class="hy-picker--view"
67
67
  :indicatorStyle="`height: ${addUnit(itemHeight)}`"
68
68
  :value="innerIndex"
69
69
  :immediateChange="immediateChange"
70
70
  :style="{
71
71
  height: `${addUnit(visibleItemCount * itemHeight)}`,
72
72
  }"
73
+ mask-class="hy-picker--view__mask"
73
74
  maskStyle="backgroundImage: none;"
74
75
  @change="changeHandler"
75
76
  >
76
77
  <picker-view-column
77
78
  v-for="(item, index) in innerColumns"
78
79
  :key="index"
79
- class="hy-picker__view__column"
80
+ class="hy-picker--view__column"
80
81
  >
81
82
  <view
82
83
  v-if="Array.isArray(item)"
83
- class="hy-picker__view__column__item u-line-1"
84
+ class="hy-picker--view__column__item u-line-1"
84
85
  :class="[
85
86
  index1 === innerIndex[index] &&
86
- 'hy-picker__view__column__item--selected',
87
+ 'hy-picker--view__column__item--selected',
87
88
  ]"
88
89
  v-for="(item1, index1) in item"
89
90
  :key="index1"
@@ -111,13 +112,13 @@
111
112
 
112
113
  <script lang="ts">
113
114
  export default {
114
- name: 'hy-picker',
115
+ name: "hy-picker",
115
116
  options: {
116
117
  addGlobalClass: true,
117
118
  virtualHost: true,
118
- styleIsolation: 'shared'
119
- }
120
- }
119
+ styleIsolation: "shared",
120
+ },
121
+ };
121
122
  </script>
122
123
 
123
124
  <script setup lang="ts">
@@ -22,7 +22,7 @@
22
22
  justify-content: space-between;
23
23
  padding: $hy-border-margin-padding-lg;
24
24
  &--center {
25
- font-size: $hy-font-size-subtitle;
25
+ font-size: $hy-font-size-base;
26
26
  color: $hy-text-color--grey;
27
27
  }
28
28
 
@@ -31,7 +31,7 @@
31
31
  }
32
32
  }
33
33
 
34
- &__view {
34
+ @include m(view) {
35
35
  &__column {
36
36
  @include flex;
37
37
  flex: 1;
@@ -59,6 +59,10 @@
59
59
  }
60
60
  }
61
61
  }
62
+
63
+ :deep(.hy-picker--view__mask) {
64
+ background-image: none;
65
+ }
62
66
  }
63
67
 
64
68
  @include m(loading) {
@@ -19,8 +19,8 @@
19
19
  }
20
20
 
21
21
  &--column {
22
- @include flex(column);
23
22
  margin: $hy-border-margin-padding-lg 0;
23
+ @include flex(column);
24
24
  }
25
25
  }
26
26
 
@@ -100,4 +100,4 @@
100
100
  color: $hy-text-color--disabled;
101
101
  }
102
102
  }
103
- }
103
+ }
@@ -40,4 +40,4 @@
40
40
  }
41
41
  }
42
42
  }
43
- }
43
+ }
@@ -4,8 +4,9 @@
4
4
  :class="['hy-text__price', type && `hy-text__value--${type}`]"
5
5
  v-if="mode === 'price'"
6
6
  :style="[valueStyle]"
7
- >¥</text
8
7
  >
8
+
9
+ </text>
9
10
  <view class="hy-text__prefix-icon" v-if="prefixIcon">
10
11
  <HyIcon :name="prefixIcon" :customStyle="iconStyle"></HyIcon>
11
12
  </view>
@@ -41,8 +42,9 @@
41
42
  lines && `hy-text__value--lines`,
42
43
  mode === 'link' && `hy-text__value--link`,
43
44
  ]"
44
- >{{ value }}</text
45
45
  >
46
+ {{ value }}
47
+ </text>
46
48
  <view class="hy-text__suffix-icon" v-if="suffixIcon">
47
49
  <HyIcon :name="suffixIcon" :customStyle="iconStyle"></HyIcon>
48
50
  </view>
@@ -51,32 +53,25 @@
51
53
 
52
54
  <script lang="ts">
53
55
  export default {
54
- name: "hy-text",
56
+ name: 'hy-text',
55
57
  options: {
56
58
  addGlobalClass: true,
57
59
  virtualHost: true,
58
- styleIsolation: "shared",
60
+ styleIsolation: 'shared',
59
61
  },
60
- };
62
+ }
61
63
  </script>
62
64
 
63
65
  <script setup lang="ts">
64
- import { computed, type CSSProperties, nextTick, toRefs } from "vue";
65
- import type IProps from "./typing";
66
- import defaultProps from "./props";
67
- import {
68
- addUnit,
69
- error,
70
- formatName,
71
- formatTime,
72
- isDate,
73
- priceFormat,
74
- } from "../../utils";
66
+ import { computed, type CSSProperties, nextTick, toRefs } from 'vue'
67
+ import type IProps from './typing'
68
+ import defaultProps from './props'
69
+ import { addUnit, error, formatName, formatTime, isDate, priceFormat } from '../../utils'
75
70
 
76
71
  // 组件
77
- import HyIcon from "../hy-icon/hy-icon.vue";
72
+ import HyIcon from '../hy-icon/hy-icon.vue'
78
73
 
79
- const props = withDefaults(defineProps<IProps>(), defaultProps);
74
+ const props = withDefaults(defineProps<IProps>(), defaultProps)
80
75
  const {
81
76
  type,
82
77
  show,
@@ -96,153 +91,147 @@ const {
96
91
  href,
97
92
  format,
98
93
  customStyle,
99
- } = toRefs(props);
100
- const emit = defineEmits(["click"]);
94
+ } = toRefs(props)
95
+ const emit = defineEmits(['click'])
101
96
 
102
97
  const wrapStyle = computed(() => {
103
98
  const style: CSSProperties = {
104
99
  margin: margin.value,
105
100
  justifyContent:
106
- align.value === "left"
107
- ? "flex-start"
108
- : align.value === "center"
109
- ? "center"
110
- : "flex-end",
111
- };
101
+ align.value === 'left' ? 'flex-start' : align.value === 'center' ? 'center' : 'flex-end',
102
+ }
112
103
  // 占满剩余空间
113
104
  if (flex.value) {
114
- style.flex = 1;
105
+ style.flex = 1
115
106
  // #ifndef APP-NVUE
116
- style.width = "100%";
107
+ style.width = '100%'
117
108
  // #endif
118
109
  }
119
- return style;
120
- });
110
+ return style
111
+ })
121
112
  const valueStyle = computed(() => {
122
113
  const style: CSSProperties = {
123
114
  textDecoration: decoration.value,
124
- fontWeight: bold.value ? "bold" : "normal",
115
+ fontWeight: bold.value ? 'bold' : 'normal',
125
116
  fontSize: addUnit(size.value),
126
- };
127
- !type.value && (style.color = color.value);
128
- lineHeight.value && (style.lineHeight = addUnit(lineHeight.value));
129
- block.value && (style.display = "block");
130
- return Object.assign(style, customStyle.value);
131
- });
117
+ }
118
+ !type.value && (style.color = color.value)
119
+ lineHeight.value && (style.lineHeight = addUnit(lineHeight.value))
120
+ block.value && (style.display = 'block')
121
+ return Object.assign(style, customStyle.value)
122
+ })
132
123
 
133
124
  /**
134
125
  * @description 格式化值
135
126
  * */
136
127
  const value = computed(() => {
137
128
  switch (mode.value) {
138
- case "price":
129
+ case 'price':
139
130
  // 如果text不为金额进行提示
140
131
  if (!/^\d+(\.\d+)?$/.test(text.value.toString())) {
141
- error("金额模式下,text参数需要为金额格式");
132
+ error('金额模式下,text参数需要为金额格式')
142
133
  }
143
134
  // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
144
- if (typeof format.value === "function") {
135
+ if (typeof format.value === 'function') {
145
136
  // 如果用户传入的是函数,使用函数格式化
146
- return format.value(text.value);
137
+ return format.value(text.value)
147
138
  }
148
139
  // 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
149
- return priceFormat(text.value, 2);
150
- case "date":
140
+ return priceFormat(text.value, 2)
141
+ case 'date':
151
142
  // 判断是否合法的日期或者时间戳
152
- !isDate(text.value) &&
153
- error("日期模式下,text参数需要为日期或时间戳格式");
143
+ !isDate(text.value) && error('日期模式下,text参数需要为日期或时间戳格式')
154
144
  // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
155
- if (typeof format.value === "function") {
145
+ if (typeof format.value === 'function') {
156
146
  // 如果用户传入的是函数,使用函数格式化
157
- return format.value(text);
147
+ return format.value(text)
158
148
  }
159
149
  if (format.value) {
160
150
  // 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
161
- return formatTime(text.value, format.value);
151
+ return formatTime(text.value, format.value)
162
152
  }
163
- console.log(formatTime(text.value, "yyyy-MM-dd"), text.value);
164
153
  // 如果没有设置format,则设置为默认的时间格式化形式
165
- return formatTime(text.value, "yyyy-MM-dd");
166
- case "phone":
154
+ return formatTime(text.value, 'yyyy-MM-dd')
155
+ case 'phone':
167
156
  // 判断是否合法的手机号
168
157
  // !test.mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
169
- if (typeof format.value === "function") {
158
+ if (typeof format.value === 'function') {
170
159
  // 如果用户传入的是函数,使用函数格式化
171
- return format.value(text);
160
+ return format.value(text)
172
161
  }
173
- if (format.value === "encrypt") {
162
+ if (format.value === 'encrypt') {
174
163
  // 如果format为encrypt,则将手机号进行星号加密处理
175
- return `${text.value.toString().substring(0, 3)}****${text.value.toString().substring(7)}`;
164
+ return `${text.value.toString().substring(0, 3)}****${text.value.toString().substring(7)}`
176
165
  }
177
- return text.value;
178
- case "name":
166
+ return text.value
167
+ case 'name':
179
168
  // 判断是否合法的字符粗
180
- if (typeof text.value !== "string") {
181
- error("姓名模式下,text参数需要为字符串格式");
169
+ if (typeof text.value !== 'string') {
170
+ error('姓名模式下,text参数需要为字符串格式')
182
171
  } else {
183
- if (typeof format.value === "function") {
172
+ if (typeof format.value === 'function') {
184
173
  // 如果用户传入的是函数,使用函数格式化
185
- return format.value(text);
174
+ return format.value(text)
186
175
  }
187
- if (format.value === "encrypt") {
176
+ if (format.value === 'encrypt') {
188
177
  // 如果format为encrypt,则将姓名进行星号加密处理
189
- return formatName(text.value);
178
+ return formatName(text.value)
190
179
  }
191
180
  }
192
- return text.value;
193
- case "link":
194
- return text.value;
181
+ return text.value
182
+ case 'link':
183
+ return text.value
195
184
  default:
196
- return text.value;
185
+ return text.value
197
186
  }
198
- });
187
+ })
199
188
 
200
189
  const isMp = computed(() => {
201
- let mp = false;
190
+ let mp = false
202
191
  // #ifdef MP
203
- mp = true;
192
+ mp = true
204
193
  // #endif
205
- return mp;
206
- });
194
+ return mp
195
+ })
207
196
 
208
197
  const clickHandler = (e) => {
209
198
  // 如果为手机号模式,拨打电话
210
- if (call.value && mode.value === "phone") {
199
+ if (call.value && mode.value === 'phone') {
211
200
  uni.makePhoneCall({
212
201
  phoneNumber: text.value,
213
- });
202
+ })
214
203
  }
215
204
  // 如果是有链接跳转
216
- if (href.value && mode.value === "link") {
217
- toLink();
205
+ if (href.value && mode.value === 'link') {
206
+ toLink()
218
207
  }
219
- emit("click", e);
220
- };
208
+ emit('click', e)
209
+ }
221
210
 
222
211
  const toLink = () => {
223
212
  // #ifdef APP-PLUS
224
- plus.runtime.openURL(href.value);
213
+ plus.runtime.openURL(href.value)
225
214
  // #endif
226
215
  // #ifdef H5
227
- window.open(href.value);
216
+ window.open(href.value)
228
217
  // #endif
229
218
  // #ifdef MP
230
219
  uni.setClipboardData({
231
220
  data: href.value,
232
221
  success: () => {
233
- uni.hideToast();
222
+ uni.hideToast()
234
223
  nextTick(() => {
235
- uni.showToast({ title: "链接已复制,请在浏览器打开" });
236
- });
224
+ uni.showToast({ title: '链接已复制,请在浏览器打开' })
225
+ })
237
226
  },
238
- });
227
+ })
239
228
  // #endif
240
- };
229
+ }
241
230
  </script>
242
231
 
243
232
  <style scoped lang="scss">
244
- @import "./index.scss";
245
- @import "../../libs/css/mixin.scss";
233
+ @import './index.scss';
234
+ @import '../../libs/css/mixin.scss';
246
235
  /*超出出现省略号*/
247
236
  .hy-text__value--lines {
248
237
  @include multiEllipsis(v-bind(lines));