af-mobile-client-vue3 1.5.63 → 1.5.65

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/compress.js CHANGED
@@ -1,36 +1,36 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
- import { fileURLToPath } from 'node:url'
4
- import * as tar from 'tar'
5
-
6
- // 当前文件所在目录
7
- const __filename = fileURLToPath(import.meta.url)
8
- const __dirname = path.dirname(__filename)
9
-
10
- // 压缩源目录名(即 build 后生成的目录名)
11
- const outputName = `dist_af-library-mobile-web`
12
-
13
- // 源目录路径
14
- const cwd = path.join(__dirname, 'dist', outputName)
15
-
16
- // 输出 tar.gz 文件路径
17
- const outputPath = path.join(__dirname, 'dist', `${outputName}.tar.gz`)
18
-
19
- if (!fs.existsSync(cwd)) {
20
- console.error('❌ 目录不存在:', cwd)
21
- // eslint-disable-next-line node/prefer-global/process
22
- process.exit(1)
23
- }
24
-
25
- tar.c(
26
- {
27
- gzip: true,
28
- file: outputPath,
29
- cwd,
30
- },
31
- ['.'],
32
- ).then(() => {
33
- console.log(`✅ 压缩完成: ${outputPath}`)
34
- }).catch((err) => {
35
- console.error('❌ 压缩失败:', err)
36
- })
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+ import * as tar from 'tar'
5
+
6
+ // 当前文件所在目录
7
+ const __filename = fileURLToPath(import.meta.url)
8
+ const __dirname = path.dirname(__filename)
9
+
10
+ // 压缩源目录名(即 build 后生成的目录名)
11
+ const outputName = `dist_af-library-mobile-web`
12
+
13
+ // 源目录路径
14
+ const cwd = path.join(__dirname, 'dist', outputName)
15
+
16
+ // 输出 tar.gz 文件路径
17
+ const outputPath = path.join(__dirname, 'dist', `${outputName}.tar.gz`)
18
+
19
+ if (!fs.existsSync(cwd)) {
20
+ console.error('❌ 目录不存在:', cwd)
21
+ // eslint-disable-next-line node/prefer-global/process
22
+ process.exit(1)
23
+ }
24
+
25
+ tar.c(
26
+ {
27
+ gzip: true,
28
+ file: outputPath,
29
+ cwd,
30
+ },
31
+ ['.'],
32
+ ).then(() => {
33
+ console.log(`✅ 压缩完成: ${outputPath}`)
34
+ }).catch((err) => {
35
+ console.error('❌ 压缩失败:', err)
36
+ })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.5.63",
4
+ "version": "1.5.65",
5
5
  "packageManager": "pnpm@10.13.1",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  // import cameraIcon from '@af-mobile-client-vue3/assets/img/component/camera.png'
3
3
  import { deleteFile, upload } from '@af-mobile-client-vue3/services/api/common'
4
+ import { detectEnvironment } from '@af-mobile-client-vue3/utils/environment'
4
5
  import { mobileUtil } from '@af-mobile-client-vue3/utils/mobileUtil'
5
6
  import { formatNow } from '@af-mobile-client-vue3/utils/timeUtil'
6
7
  import {
@@ -36,9 +37,8 @@ const emit = defineEmits(['updateFileList', 'updateAllFileList'])
36
37
  const imageList = ref<Array<any>>(props.imageList ?? [])
37
38
 
38
39
  const parentData: any = inject('provideParent')
39
- // 浏览器模式:隐藏的文件输入(选择 / 拍照)
40
+ // 浏览器 / 微信内 H5:统一用隐藏 file input(与单独 camera input 行为等价,均为系统选图)
40
41
  const fileInputRef = ref<HTMLInputElement | undefined>()
41
- const cameraInputRef = ref<HTMLInputElement | undefined>()
42
42
 
43
43
  function openBrowserFilePicker() {
44
44
  if (fileInputRef.value) {
@@ -47,13 +47,6 @@ function openBrowserFilePicker() {
47
47
  }
48
48
  }
49
49
 
50
- function openBrowserCameraPicker() {
51
- if (cameraInputRef.value) {
52
- cameraInputRef.value.value = ''
53
- cameraInputRef.value.click()
54
- }
55
- }
56
-
57
50
  function emitUpdatesAfterChange() {
58
51
  // 新增:对外抛出完整与ID列表
59
52
  (emit as any)('updateAllFileList', imageList.value.filter(item => item.status === 'done').map(item => item))
@@ -378,6 +371,12 @@ const actionOptions = [
378
371
  function handleUploadAreaClick() {
379
372
  if (props.readonly)
380
373
  return
374
+ const env = detectEnvironment()
375
+ // 微信内:直接走浏览器式文件选择,不弹出拍照/上传菜单
376
+ if (env.isWechat || env.isMiniprogram) {
377
+ openBrowserFilePicker()
378
+ return
379
+ }
381
380
  if (props.attr?.uploadImage) {
382
381
  showActionSheet.value = true
383
382
  }
@@ -389,29 +388,21 @@ function handleUploadAreaClick() {
389
388
  function handleActionSelect(option: any) {
390
389
  showActionSheet.value = false
391
390
  if (option.key === 'camera') {
392
- if (import.meta.env.VITE_APP_WEI_XIN) {
393
- openBrowserCameraPicker()
394
- return
395
- }
396
391
  triggerCamera()
397
392
  }
398
393
  else if (option.key === 'file') {
399
- if (import.meta.env.VITE_APP_WEI_XIN) {
400
- openBrowserFilePicker()
401
- return
402
- }
394
+ // 手机文件上传
403
395
  mobileUtil.execute({
404
396
  funcName: 'photoAlbum',
405
397
  param: {},
406
398
  callbackFunc: (result: any) => {
407
- console.log('>>>> result: ', result)
408
399
  if (result.status === 'success') {
409
400
  result.data?.photos.forEach((photo: any) => {
410
401
  handlePhotoUpload(photo)
411
402
  })
412
403
  }
413
404
  else {
414
- // 浏览器模式:打开文件选择
405
+ // 手机文件选择失败,则走浏览器式文件选择
415
406
  openBrowserFilePicker()
416
407
  }
417
408
  },
@@ -441,7 +432,7 @@ defineExpose({
441
432
 
442
433
  <template>
443
434
  <div class="uploader-container">
444
- <!-- 浏览器模式隐藏输入:文件选择 -->
435
+ <!-- 浏览器 / 微信 H5:统一隐藏文件选择(多选图片) -->
445
436
  <input
446
437
  ref="fileInputRef"
447
438
  type="file"
@@ -450,15 +441,6 @@ defineExpose({
450
441
  style="display:none"
451
442
  @change="(e:any) => handleBrowserFiles(e.target.files)"
452
443
  >
453
- <!-- 浏览器模式隐藏输入:拍照(相机) -->
454
- <input
455
- ref="cameraInputRef"
456
- type="file"
457
- accept="image/*"
458
- capture="environment"
459
- style="display:none"
460
- @change="(e:any) => handleBrowserFiles(e.target.files)"
461
- >
462
444
  <van-uploader
463
445
  ref="uploaderRef"
464
446
  v-model="imageList"