@chenminai/cloud-shared 1.0.6 → 1.0.7

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.
Files changed (3) hide show
  1. package/auth.js +5 -0
  2. package/package.json +3 -2
  3. package/storage.js +2 -8
package/auth.js CHANGED
@@ -6,6 +6,11 @@
6
6
  */
7
7
 
8
8
  const cloud = require('wx-server-sdk')
9
+
10
+ cloud.init({
11
+ env: cloud.DYNAMIC_CURRENT_ENV
12
+ })
13
+
9
14
  const db = cloud.database()
10
15
 
11
16
  /**
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@chenminai/cloud-shared",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "云函数共享工具:用户身份解析等",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "dependencies": {
10
+ "wx-server-sdk": "~2.6.3",
10
11
  "@cloudbase/node-sdk": "^3.18.1"
11
12
  }
12
- }
13
+ }
package/storage.js CHANGED
@@ -2,13 +2,7 @@ const tcb = require('@cloudbase/node-sdk')
2
2
 
3
3
  const CUSTOM_DOMAIN = process.env.STORAGE_CUSTOM_DOMAIN || ''
4
4
 
5
- let _app = null
6
- function getApp() {
7
- if (!_app) {
8
- _app = tcb.init({ env: tcb.SYMBOL_CURRENT_ENV })
9
- }
10
- return _app
11
- }
5
+ const tcbApp = tcb.init({ env: tcb.SYMBOL_CURRENT_ENV })
12
6
 
13
7
  /**
14
8
  * 将 cloud:// fileID 列表批量转为 HTTP 链接。
@@ -21,7 +15,7 @@ async function resolveCloudUrls(fileIds) {
21
15
  const cloudIds = fileIds.filter((id) => id.startsWith('cloud://'))
22
16
  if (!cloudIds.length) return new Map()
23
17
 
24
- const result = await getApp().getTempFileURL({ fileList: cloudIds })
18
+ const result = await tcbApp.getTempFileURL({ fileList: cloudIds })
25
19
  const map = new Map();
26
20
  (result.fileList || []).forEach((item) => {
27
21
  if (item.code === 'SUCCESS') {