Skip to content

Commit 073f2e1

Browse files
committed
fix: 优化代码
1 parent 40005e1 commit 073f2e1

File tree

8 files changed

+74
-25
lines changed

8 files changed

+74
-25
lines changed

demo-album/lib/cos-wx-sdk-v5.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12067,8 +12067,14 @@ var utils = {
1206712067
wxSystem: 'can_not_get_system_info',
1206812068
wxSdkVersion: 'can_not_get_system_info'
1206912069
};
12070-
var appBaseInfo = wx.getAppBaseInfo() || {};
12071-
var deviceInfo = wx.getDeviceInfo() || {};
12070+
var appBaseInfo = {};
12071+
var deviceInfo = {};
12072+
if (wx.canIUse('getAppBaseInfo')) {
12073+
appBaseInfo = wx.getAppBaseInfo() || {};
12074+
}
12075+
if (wx.canIUse('getDeviceInfo')) {
12076+
deviceInfo = wx.getDeviceInfo() || {};
12077+
}
1207212078
var sdkVersion = appBaseInfo.SDKVersion || 'can_not_get_system_info';
1207312079
var version = appBaseInfo.version || 'can_not_get_system_info';
1207412080
var platform = deviceInfo.platform || 'can_not_get_system_info';
@@ -13116,8 +13122,14 @@ var compareVersion = function compareVersion(v1, v2) {
1311613122
return 0;
1311713123
};
1311813124
var canFileSlice = function () {
13119-
var appBaseInfo = wx.getAppBaseInfo() || {};
13120-
var deviceInfo = wx.getDeviceInfo() || {};
13125+
var appBaseInfo = {};
13126+
var deviceInfo = {};
13127+
if (wx.canIUse('getAppBaseInfo')) {
13128+
appBaseInfo = wx.getAppBaseInfo() || {};
13129+
}
13130+
if (wx.canIUse('getDeviceInfo')) {
13131+
deviceInfo = wx.getDeviceInfo() || {};
13132+
}
1312113133
var sdkVersion = appBaseInfo.SDKVersion;
1312213134
var platform = deviceInfo.platform;
1312313135
var support = compareVersion(sdkVersion, '2.10.0') >= 0;

demo-album/lib/cos-wx-sdk-v5.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/lib/cos-wx-sdk-v5.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12067,8 +12067,14 @@ var utils = {
1206712067
wxSystem: 'can_not_get_system_info',
1206812068
wxSdkVersion: 'can_not_get_system_info'
1206912069
};
12070-
var appBaseInfo = wx.getAppBaseInfo() || {};
12071-
var deviceInfo = wx.getDeviceInfo() || {};
12070+
var appBaseInfo = {};
12071+
var deviceInfo = {};
12072+
if (wx.canIUse('getAppBaseInfo')) {
12073+
appBaseInfo = wx.getAppBaseInfo() || {};
12074+
}
12075+
if (wx.canIUse('getDeviceInfo')) {
12076+
deviceInfo = wx.getDeviceInfo() || {};
12077+
}
1207212078
var sdkVersion = appBaseInfo.SDKVersion || 'can_not_get_system_info';
1207312079
var version = appBaseInfo.version || 'can_not_get_system_info';
1207412080
var platform = deviceInfo.platform || 'can_not_get_system_info';
@@ -13116,8 +13122,14 @@ var compareVersion = function compareVersion(v1, v2) {
1311613122
return 0;
1311713123
};
1311813124
var canFileSlice = function () {
13119-
var appBaseInfo = wx.getAppBaseInfo() || {};
13120-
var deviceInfo = wx.getDeviceInfo() || {};
13125+
var appBaseInfo = {};
13126+
var deviceInfo = {};
13127+
if (wx.canIUse('getAppBaseInfo')) {
13128+
appBaseInfo = wx.getAppBaseInfo() || {};
13129+
}
13130+
if (wx.canIUse('getDeviceInfo')) {
13131+
deviceInfo = wx.getDeviceInfo() || {};
13132+
}
1312113133
var sdkVersion = appBaseInfo.SDKVersion;
1312213134
var platform = deviceInfo.platform;
1312313135
var support = compareVersion(sdkVersion, '2.10.0') >= 0;

demo/lib/cos-wx-sdk-v5.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cos-wx-sdk-v5.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12067,8 +12067,14 @@ var utils = {
1206712067
wxSystem: 'can_not_get_system_info',
1206812068
wxSdkVersion: 'can_not_get_system_info'
1206912069
};
12070-
var appBaseInfo = wx.getAppBaseInfo() || {};
12071-
var deviceInfo = wx.getDeviceInfo() || {};
12070+
var appBaseInfo = {};
12071+
var deviceInfo = {};
12072+
if (wx.canIUse('getAppBaseInfo')) {
12073+
appBaseInfo = wx.getAppBaseInfo() || {};
12074+
}
12075+
if (wx.canIUse('getDeviceInfo')) {
12076+
deviceInfo = wx.getDeviceInfo() || {};
12077+
}
1207212078
var sdkVersion = appBaseInfo.SDKVersion || 'can_not_get_system_info';
1207312079
var version = appBaseInfo.version || 'can_not_get_system_info';
1207412080
var platform = deviceInfo.platform || 'can_not_get_system_info';
@@ -13116,8 +13122,14 @@ var compareVersion = function compareVersion(v1, v2) {
1311613122
return 0;
1311713123
};
1311813124
var canFileSlice = function () {
13119-
var appBaseInfo = wx.getAppBaseInfo() || {};
13120-
var deviceInfo = wx.getDeviceInfo() || {};
13125+
var appBaseInfo = {};
13126+
var deviceInfo = {};
13127+
if (wx.canIUse('getAppBaseInfo')) {
13128+
appBaseInfo = wx.getAppBaseInfo() || {};
13129+
}
13130+
if (wx.canIUse('getDeviceInfo')) {
13131+
deviceInfo = wx.getDeviceInfo() || {};
13132+
}
1312113133
var sdkVersion = appBaseInfo.SDKVersion;
1312213134
var platform = deviceInfo.platform;
1312313135
var support = compareVersion(sdkVersion, '2.10.0') >= 0;

dist/cos-wx-sdk-v5.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tracker.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ const utils = {
6262
wxSystem: 'can_not_get_system_info',
6363
wxSdkVersion: 'can_not_get_system_info',
6464
};
65-
const appBaseInfo = wx.getAppBaseInfo() || {};
66-
const deviceInfo = wx.getDeviceInfo() || {};
65+
66+
let appBaseInfo = {};
67+
let deviceInfo = {};
68+
if (wx.canIUse('getAppBaseInfo')) {
69+
appBaseInfo = wx.getAppBaseInfo() || {};
70+
}
71+
if (wx.canIUse('getDeviceInfo')) {
72+
deviceInfo = wx.getDeviceInfo() || {};
73+
}
6774
const sdkVersion = appBaseInfo.SDKVersion || 'can_not_get_system_info';
6875
const version = appBaseInfo.version || 'can_not_get_system_info';
6976
const platform = deviceInfo.platform || 'can_not_get_system_info';

src/util.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,14 @@ var compareVersion = function (v1, v2) {
741741
};
742742

743743
var canFileSlice = (function () {
744-
var appBaseInfo = wx.getAppBaseInfo() || {};
745-
var deviceInfo = wx.getDeviceInfo() || {};
744+
var appBaseInfo = {};
745+
var deviceInfo = {};
746+
if (wx.canIUse('getAppBaseInfo')) {
747+
appBaseInfo = wx.getAppBaseInfo() || {};
748+
}
749+
if (wx.canIUse('getDeviceInfo')) {
750+
deviceInfo = wx.getDeviceInfo() || {};
751+
}
746752
var sdkVersion = appBaseInfo.SDKVersion;
747753
var platform = deviceInfo.platform;
748754
var support = compareVersion(sdkVersion, '2.10.0') >= 0;

0 commit comments

Comments
 (0)