@uxda/appkit 4.2.74 → 4.2.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "4.2.74",
3
+ "version": "4.2.76",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
package/rollup.config.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import vue from 'rollup-plugin-vue'
2
- import css from 'rollup-plugin-css-only'
3
- import esbuild from 'rollup-plugin-esbuild'
4
- import postcss from 'rollup-plugin-postcss'
5
- import atImport from 'postcss-import'
6
- import NutUIResolver from '@nutui/auto-import-resolver'
7
- import Components from 'unplugin-vue-components/rollup'
8
- import { visualizer } from "rollup-plugin-visualizer"
1
+ import vue from 'rollup-plugin-vue';
2
+ import css from 'rollup-plugin-css-only';
3
+ import esbuild from 'rollup-plugin-esbuild';
4
+ import postcss from 'rollup-plugin-postcss';
5
+ import atImport from 'postcss-import';
6
+ import NutUIResolver from '@nutui/auto-import-resolver';
7
+ import Components from 'unplugin-vue-components/rollup';
8
+ import { visualizer } from 'rollup-plugin-visualizer';
9
9
 
10
10
  export default [
11
11
  {
@@ -33,7 +33,17 @@ export default [
33
33
  postcss({
34
34
  include: /\.scss/,
35
35
  extract: 'appkit.css',
36
- plugins: [atImport()],
36
+ plugins: [
37
+ atImport(),
38
+ {
39
+ postcssPlugin: 'remove-charset',
40
+ Once(root) {
41
+ root.walkAtRules('charset', (rule) => {
42
+ rule.remove();
43
+ });
44
+ },
45
+ },
46
+ ],
37
47
  }),
38
48
  esbuild({}),
39
49
  Components({
@@ -64,4 +74,4 @@ export default [
64
74
  // })
65
75
  // ]
66
76
  // },
67
- ]
77
+ ];
@@ -389,6 +389,8 @@ watch(secondBalanceOpen, () => {
389
389
 
390
390
  function onDateReset() {
391
391
  resetDateRange()
392
+ datePickerOpen.value = false
393
+ restartSearch()
392
394
  }
393
395
 
394
396
  /**
@@ -40,6 +40,12 @@ const props = defineProps<DateFilterProps>()
40
40
  const emit = defineEmits(['complete', 'reset']),
41
41
  state = usePopup()
42
42
 
43
+
44
+ /**
45
+ * 日期范围结果
46
+ */
47
+ const result = reactive<DateFilterProps>({ ...props })
48
+
43
49
  watch(
44
50
  () => `${props.from}${props.to}`,
45
51
  () => {
@@ -48,10 +54,6 @@ watch(
48
54
  }
49
55
  )
50
56
 
51
- /**
52
- * 日期范围结果
53
- */
54
- const result = reactive<DateFilterProps>({ ...props })
55
57
 
56
58
  /**
57
59
  * 目前激活的日期输入框
@@ -98,12 +100,16 @@ function onDatePickerComplete({ selectedValue, selectedOptions }) {
98
100
  result.to = time
99
101
  }
100
102
  datePickerOpen.value = false
101
- state.couldClose = true
103
+ if (state) {
104
+ state.couldClose = true
105
+ }
102
106
  }
103
107
 
104
108
  function onDatePickerCancel() {
105
109
  datePickerOpen.value = false
106
- state.couldClose = true
110
+ if (state) {
111
+ state.couldClose = true
112
+ }
107
113
  }
108
114
 
109
115
  /**
@@ -124,9 +130,12 @@ function switchDateInput(shift: string) {
124
130
  focused.value = shift
125
131
  datePickerOpen.value = true
126
132
  // 不允许浮窗关闭
127
- state.couldClose = false
133
+ if (state) {
134
+ state.couldClose = false
135
+ }
128
136
  }
129
137
  </script>
138
+
130
139
  <style lang="scss">
131
140
  .appkit-date-filter {
132
141
  height: 100%;
@@ -4,10 +4,15 @@
4
4
  <img style="margin-top: -2px" class="time-icon"
5
5
  src="https://cdn.ddjf.com/static/images/bpms-workBench/clound-bean-down.png" />
6
6
  </div>
7
+
8
+ <nut-popup position="bottom" :style="{ height: '40%' }" round :close-on-click-overlay="true"
9
+ v-model:visible="datePickerOpen">
10
+ <date-filter :from="model.from" :to="model.to" @reset="onDateReset" @complete="onDateFilterComplete" />
11
+ </nut-popup>
7
12
  </template>
8
13
 
9
14
  <script lang="ts" setup>
10
- import { computed, PropType, ref } from 'vue'
15
+ import { computed, PropType, ref, watch } from 'vue'
11
16
  import { useNutshell } from '@uxda/nutshell/taro'
12
17
  import DateFilter from './DateFilter.vue'
13
18
  import dayjs from 'dayjs'
@@ -28,26 +33,51 @@ const model = defineModel({
28
33
  }
29
34
  })
30
35
 
31
- const openDateRangePicker = () => {
32
- const child = ref()
33
- $n.sheet({
34
- component: DateFilter,
35
- class: 'ns-sheet-reset date-filter-sheet',
36
- ref: child,
37
- props: {
38
- from: model.value.from,
39
- to: model.value.to,
40
- },
41
- modal: true, // 不允许点击 overlay 关闭弹窗
42
- mask: true,
43
- onComplete(result: any) {
44
- model.value = {
45
- from: result.from,
46
- to: result.to
47
- }
48
- }
49
- })
36
+ // 时间筛选
37
+ const datePickerOpen = ref<boolean>(false)
38
+ function openDateRangePicker() {
39
+ datePickerOpen.value = true
40
+ }
41
+ const onDateFilterComplete = (value) => {
42
+ model.value = {
43
+ from: value.from,
44
+ to: value.to
45
+ }
46
+ datePickerOpen.value = false
47
+ emit('complete', model.value)
50
48
  }
49
+ function onDateReset() {
50
+ model.value = {
51
+ from: dayjs().add(-1, 'M').format('YYYY-MM-DD'),
52
+ to: dayjs().format('YYYY-MM-DD')
53
+ }
54
+ datePickerOpen.value = false
55
+ }
56
+
57
+ const emit = defineEmits(['complete', 'reset'])
58
+
59
+ // const openDateRangePicker = () => {
60
+ // $n.sheet({
61
+ // component: DateFilter,
62
+ // class: 'ns-sheet-reset date-filter-sheet',
63
+ // props: {
64
+ // from: model.value.from,
65
+ // to: model.value.to,
66
+ // onReset() {
67
+ // model.value.from = dayjs().add(-1, 'M').format('YYYY-MM-DD')
68
+ // model.value.to = dayjs().format('YYYY-MM-DD')
69
+ // }
70
+ // },
71
+ // modal: true, // 不允许点击 overlay 关闭弹窗
72
+ // mask: true,
73
+ // onComplete(result: any) {
74
+ // model.value = {
75
+ // from: result.from,
76
+ // to: result.to
77
+ // }
78
+ // },
79
+ // })
80
+ // }
51
81
 
52
82
  const dateRangeDisplay = computed(() => {
53
83
  let startTime = (model.value.from || '').replace(/-/g, '.').substring(2)
@@ -64,6 +94,7 @@ const dateRangeDisplay = computed(() => {
64
94
  flex: 1;
65
95
  display: flex;
66
96
  align-items: center;
97
+ justify-content: flex-end;
67
98
 
68
99
  .text {
69
100
  width: fit-content;
@@ -274,8 +274,10 @@ const arrowImg = computed(() => {
274
274
  }
275
275
 
276
276
  &-tab {
277
+ position: relative;
277
278
  display: flex;
278
279
  justify-content: space-between;
280
+ align-items: center;
279
281
  margin-bottom: 12px;
280
282
 
281
283
  &-item {
package/src/index.ts CHANGED
@@ -88,4 +88,5 @@ export * from './shared'
88
88
  export * from './register'
89
89
  export * from './notice'
90
90
  export * from './user'
91
+ export * from './scenarios'
91
92
  export { type AppKitOptions }
@@ -0,0 +1,364 @@
1
+ <template>
2
+ <nut-popup round v-model:visible="sheetOpen" position="bottom">
3
+ <template v-if="sheetOpen">
4
+ <div class="share-dialog column align-stretch">
5
+ <div class="swiper-container">
6
+ <div
7
+ class="poster-display row justify-center"
8
+ v-if="posters.length === 1"
9
+ >
10
+ <poster-paste
11
+ :poster="posters[0]"
12
+ :logo="config.logo"
13
+ :nick="config.nick"
14
+ :zoom="zoom"
15
+ />
16
+ </div>
17
+ <swiper
18
+ v-if="posters.length > 1"
19
+ class="swiper"
20
+ :current="current"
21
+ :autoplay="false"
22
+ :indicator-dots="false"
23
+ :circular="true"
24
+ display-multiple-items="3"
25
+ @change="onSwiperChange"
26
+ >
27
+ <swiper-item
28
+ :class="['swiper-item', { center: isCenter(index) }]"
29
+ v-for="(poster, index) in posters"
30
+ :key="`${index}`"
31
+ >
32
+ <div class="slide">
33
+ <poster-paste
34
+ :poster="poster"
35
+ :logo="config.logo"
36
+ :nick="config.nick"
37
+ :zoom="zoom"
38
+ />
39
+ </div>
40
+ </swiper-item>
41
+ </swiper>
42
+ </div>
43
+ <div class="swiper-dots" justify="center" :gap="8">
44
+ <div
45
+ class="dot"
46
+ :class="{
47
+ current:
48
+ current === index || current - posters.length / 2 === index,
49
+ }"
50
+ v-for="(_, index) in Array(posters.length / 2).fill('')"
51
+ :key="index"
52
+ />
53
+ </div>
54
+ <div
55
+ class="text-center"
56
+ style="font-size: 13px; color: #666666; margin: 10px"
57
+ v-if="text"
58
+ >
59
+ {{ text }}
60
+ </div>
61
+ <div class="line"></div>
62
+ <div class="bottom">
63
+ <nut-button class="cancel-btn" @click="onCancelClick"
64
+ >取消</nut-button
65
+ >
66
+ <nut-button type="primary" @click="onPosterShare">确定</nut-button>
67
+ </div>
68
+ </div>
69
+ <canvas
70
+ type="2d"
71
+ id="poster-canvas"
72
+ :style="`height: ${o.h}px;width:${o.w}px;transform:translate3d(-5000px, 0, 0);position: absolute;`"
73
+ >
74
+ </canvas>
75
+ </template>
76
+ </nut-popup>
77
+ </template>
78
+
79
+ <script lang="ts" setup>
80
+ import { ref, watch } from 'vue';
81
+ import Taro from '@tarojs/taro';
82
+ import PosterPaste from '../components/poster-paste.vue';
83
+ import { dataURItoBlob, isWeb } from '../../utils/utils';
84
+ import { Swiper, SwiperItem } from '@tarojs/components';
85
+
86
+ const emit = defineEmits(['share']);
87
+
88
+ export type ShareDialogProps = {
89
+ // 海报列表
90
+ posters: any[];
91
+ text?: string;
92
+ };
93
+
94
+ const props = defineProps<ShareDialogProps>();
95
+
96
+ const o = {
97
+ // 图片原始大小
98
+ w: 375,
99
+ h: 812,
100
+ },
101
+ z = 480, // 缩放后高度
102
+ zoom = z / o.h;
103
+
104
+ const config = ref();
105
+ config.value = {
106
+ nick: '',
107
+ logo: '',
108
+ qr: '',
109
+ };
110
+
111
+ // 真实的 current
112
+ const current = ref(0);
113
+
114
+ const getCentered = () => {
115
+ // change 事件返回的 current 为三张图中最左侧一张
116
+ // 为了中间放大的效果, 将 swiper 属性 current 设置为 下一张
117
+ if (props.posters.length === 1) return 0;
118
+ // 多张海报, *假选中*中间一张
119
+ let centered: number = current.value + 1;
120
+ centered = centered === props.posters.length ? 0 : centered;
121
+ return centered;
122
+ };
123
+
124
+ const isCenter = (index: number) => {
125
+ return getCentered() === index;
126
+ };
127
+
128
+ const onSwiperChange = ({ detail }) => {
129
+ current.value = detail.current;
130
+ };
131
+
132
+ const initCanvas = () => {
133
+ return new Promise((resolve) => {
134
+ setTimeout(() => {
135
+ if (Taro.getEnv() === 'WEB') {
136
+ const canvas = document.getElementById(
137
+ 'poster-canvas'
138
+ ) as HTMLCanvasElement;
139
+ const context = canvas.getContext('2d');
140
+ canvas.height = o.h * 2;
141
+ canvas.width = o.w * 2;
142
+ resolve({ context, canvas });
143
+ } else {
144
+ const pageInstance = Taro.getCurrentInstance()?.page || {}; // 拿到当前页面实例
145
+ const query = Taro.createSelectorQuery().in(pageInstance); // 确定在当前页面内匹配子元素
146
+ query
147
+ .select('#poster-canvas')
148
+ .fields({ node: true, size: true, context: true }, (res) => {
149
+ const canvas = res.node;
150
+ const context = canvas.getContext('2d');
151
+ canvas.height = o.h * 2;
152
+ canvas.width = o.w * 2;
153
+ canvas.destHeight = o.h * 2;
154
+ canvas.destWidth = o.w * 2;
155
+ resolve({ context, canvas });
156
+ })
157
+ .exec();
158
+ }
159
+ }, 300);
160
+ });
161
+ };
162
+
163
+ const drawImage = async (
164
+ canvas: any,
165
+ context: any,
166
+ src: string,
167
+ x?: number,
168
+ y?: number,
169
+ w?: number,
170
+ h?: number
171
+ ) => {
172
+ return new Promise((resolve, reject) => {
173
+ if (!src) {
174
+ resolve(void 0);
175
+ return;
176
+ }
177
+ const image = !isWeb() ? canvas.createImage() : new Image();
178
+ image.crossOrigin = 'Anonymous';
179
+ image.src = src;
180
+ image.onload = function () {
181
+ context.drawImage(image, x || 0, y || 0, w || o.w, h || o.h);
182
+ resolve(void 0);
183
+ };
184
+ image.onerror = (e) => {
185
+ resolve(image);
186
+ };
187
+ });
188
+ };
189
+ const onPosterShare = async () => {
190
+ !isWeb() && Taro.showLoading({ title: '加载中...', mask: true });
191
+ // @ts-ignore
192
+ const { context, canvas } = await initCanvas(),
193
+ c = getCentered();
194
+ const p = props.posters[c];
195
+ await drawImage(canvas, context, p.back, 0, 0, o.w * 2, o.h * 2);
196
+ if (p.qr) {
197
+ await drawImage(
198
+ canvas,
199
+ context,
200
+ p.qr,
201
+ p.qrX * 2,
202
+ p.qrY * 2,
203
+ p.qrW * 2,
204
+ p.qrH * 2
205
+ );
206
+ }
207
+ if (config.value.nick) {
208
+ context.font = '24px sans-serif';
209
+ context.fillText(config.value.nick, p.nickX * 2 - 10, p.nickY * 2 + 34);
210
+ }
211
+ if (config.value.logo) {
212
+ await drawImage(
213
+ canvas,
214
+ context,
215
+ config.value.logo,
216
+ p.logoX * 2,
217
+ p.logoY * 2,
218
+ 54,
219
+ 54
220
+ );
221
+ }
222
+ context.save();
223
+ if (isWeb()) {
224
+ const dataURL = canvas.toDataURL('image/png');
225
+ const blob = dataURItoBlob(dataURL);
226
+ const imgUrl = URL.createObjectURL(blob);
227
+ emit('share', imgUrl);
228
+ } else {
229
+ Taro.canvasToTempFilePath({
230
+ canvas,
231
+ success: (result) => {
232
+ Taro.hideLoading();
233
+ Taro.showShareImageMenu({
234
+ path: result.tempFilePath,
235
+ });
236
+ },
237
+ fail: () => {
238
+ Taro.showToast({
239
+ title: '海报生成失败,请重试',
240
+ icon: 'none',
241
+ });
242
+ },
243
+ });
244
+ }
245
+ };
246
+
247
+ watch(
248
+ () => props.posters,
249
+ () => {
250
+ if (props.posters[0]?.nick) {
251
+ config.value.nick = props.posters[0].nick;
252
+ }
253
+ if (props.posters[0]?.logo) {
254
+ config.value.logo = props.posters[0].logo;
255
+ }
256
+ }
257
+ );
258
+
259
+ const sheetOpen = ref(false);
260
+ const onCancelClick = () => {
261
+ sheetOpen.value = false;
262
+ };
263
+ function openShareDialog() {
264
+ sheetOpen.value = !sheetOpen.value;
265
+ }
266
+
267
+ defineExpose({
268
+ openShareDialog,
269
+ });
270
+ </script>
271
+
272
+ <style lang="scss">
273
+ .share-dialog {
274
+ padding: 40px 0 0;
275
+ overflow: hidden auto;
276
+
277
+ .swiper-container {
278
+ position: relative;
279
+ width: 100%;
280
+ height: 480px;
281
+ overflow: hidden;
282
+ }
283
+
284
+ .swiper {
285
+ width: 180%;
286
+ height: 100%;
287
+ margin: 0 -40%;
288
+ }
289
+
290
+ .swiper-item {
291
+ width: 100%;
292
+ display: flex;
293
+ flex-direction: row;
294
+ align-items: center;
295
+
296
+ .poster-paste {
297
+ transform: scale(0.8);
298
+ }
299
+
300
+ &.center {
301
+ .poster-paste {
302
+ transform: scale(1);
303
+ }
304
+ }
305
+ }
306
+
307
+ .swiper-dots {
308
+ margin-top: 10px;
309
+ height: 20px;
310
+ display: flex;
311
+ justify-content: center;
312
+ align-items: center;
313
+ .dot {
314
+ width: 6px;
315
+ height: 6px;
316
+ background-color: #b0b7c4;
317
+ border-radius: 3px;
318
+ transition: width 0.5s;
319
+ margin: 0 2px;
320
+
321
+ &.current {
322
+ background-color: #017fff;
323
+ width: 15px;
324
+ }
325
+ }
326
+ }
327
+
328
+ .slide {
329
+ width: 100%;
330
+ }
331
+
332
+ .buttons {
333
+ margin-top: 60px;
334
+
335
+ .btn {
336
+ width: 50px;
337
+ height: 50px;
338
+ background-size: 100% 100%;
339
+ background-color: #f8f8f8;
340
+ border-radius: 10px;
341
+ }
342
+ }
343
+
344
+ .bottom {
345
+ padding: 12px;
346
+ display: flex;
347
+ .nut-button {
348
+ flex: 1;
349
+ }
350
+ .cancel-btn {
351
+ margin-right: 12px;
352
+ flex: 1;
353
+ border: 1px solid #017fff;
354
+ color: #017fff;
355
+ background: #fff;
356
+ }
357
+ }
358
+
359
+ .line {
360
+ background: #f1f5f9;
361
+ height: 8.5px;
362
+ }
363
+ }
364
+ </style>
@@ -0,0 +1,3 @@
1
+ import SharePoster from './SharePoster.vue'
2
+
3
+ export { SharePoster }
@@ -0,0 +1,93 @@
1
+ <template>
2
+ <div class="poster-paste">
3
+ <div
4
+ :class="['picture']"
5
+ :style="{ backgroundImage: `url(${poster.back})` }"
6
+ ></div>
7
+ <div
8
+ class="logo"
9
+ v-if="logo"
10
+ :style="{
11
+ width: `${tx(25)}%`,
12
+ height: `${ty(25)}%`,
13
+ ...(poster.logoX ? { left: `${tx(20)}%` } : {}),
14
+ ...(poster.logoX ? { top: `${ty(25)}%` } : {}),
15
+ backgroundImage: `url(${logo})`,
16
+ backgroundRepeat: 'no-repeat',
17
+ }"
18
+ ></div>
19
+ <div
20
+ v-if="nick"
21
+ class="nick"
22
+ :style="{
23
+ ...(poster.nickX ? { left: `${t(poster.nickX)}px` } : {}),
24
+ ...(poster.nickY ? { top: `${t(28)}px` } : {}),
25
+ fontSize: `${t(16)}px`,
26
+ color: '#353535',
27
+ }"
28
+ >
29
+ {{ nick }}
30
+ </div>
31
+ <div
32
+ class="qr"
33
+ v-if="poster.qr"
34
+ :style="{
35
+ ...(poster.qrW ? { width: `${tx(poster.qrW)}%` } : {}),
36
+ ...(poster.qrH ? { height: `${ty(poster.qrW)}%` } : {}),
37
+ ...(poster.qrX ? { left: `${tx(poster.qrX)}%` } : {}),
38
+ ...(poster.qrY ? { top: `${ty(poster.qrY)}%` } : {}),
39
+ backgroundImage: `url(${poster.qr})`,
40
+ }"
41
+ ></div>
42
+ </div>
43
+ </template>
44
+
45
+ <script lang="ts" setup>
46
+ const props = defineProps<{
47
+ poster: any;
48
+ logo: string;
49
+ nick: string;
50
+ zoom: number;
51
+ }>();
52
+
53
+ const t = (s: number) => Math.round(s * (props.zoom || 1)); // 缩放后坐标值
54
+ const tx = (s: number) => (100 * Math.round(s * (props.zoom || 1))) / 221; // 缩放后坐标值
55
+ const ty = (s: number) => (100 * Math.round(s * (props.zoom || 1))) / 480; // 缩放后坐标值
56
+ </script>
57
+
58
+ <style lang="scss">
59
+ .poster-paste {
60
+ position: relative;
61
+ width: auto;
62
+ height: 480px;
63
+ aspect-ratio: 375/812;
64
+ transition: transform 0.5s;
65
+ .picture {
66
+ position: absolute;
67
+ background-size: cover;
68
+ background-position: center;
69
+ height: 100%;
70
+ width: 100%;
71
+ border-radius: 10px;
72
+ }
73
+ .logo {
74
+ position: absolute;
75
+ width: 30px;
76
+ height: 30px;
77
+ left: 25px;
78
+ top: 25px;
79
+ background-size: contain;
80
+ background-position: center;
81
+ }
82
+ .nick {
83
+ position: absolute;
84
+ top: 24px;
85
+ line-height: 15px;
86
+ }
87
+ .qr {
88
+ position: absolute;
89
+ background-size: contain;
90
+ background-position: center;
91
+ }
92
+ }
93
+ </style>