nvue3 1.1.19 → 1.1.21

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,12 +1,12 @@
1
1
  {
2
2
  "name": "nvue3",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "for uniapp & vue3",
5
5
  "main": "src/kernel.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
- "author": "",
9
+ "author": "fazo@qq.com",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
12
  "nodejs_patch": "^1.0.17"
package/src/http.js CHANGED
@@ -136,7 +136,7 @@ function apiAlias(api) {
136
136
  function failMessage(REQ, resolve, reject) {
137
137
 
138
138
  if (!REQ.message) REQ.message = '';
139
- if (REQ.message.indexOf('cert.CertPathValidator') > 0) {
139
+ if (REQ.message.includes('cert.CertPathValidator')) {
140
140
  //证书路径错误,基本上发生在被抓包的时候
141
141
  REQ.loading = false;
142
142
  uni.hideLoading();
@@ -288,7 +288,7 @@ function doSuccess(REQ, res, resolve, reject) {
288
288
 
289
289
  function doFail(request, res, resolve, reject) {
290
290
 
291
- if (res.errMsg.indexOf('Failed to connect') > 0) {
291
+ if (res.errMsg.includes('Failed to connect')) {
292
292
  let info = res.errMsg.match(/([\w\.]+)\/([\d\.]+)\:(\d+)/);
293
293
  if (info) res.info = {
294
294
  domain: info[1],
@@ -297,12 +297,18 @@ function doFail(request, res, resolve, reject) {
297
297
  }
298
298
  res.errMsg = "服务器连接失败:" + info[2];
299
299
  }
300
- else if (res.errMsg.indexOf('timeout') > 0) {
300
+ else if (res.errMsg.includes('timeout')) {
301
301
  res.errMsg = '连接服务器超时,请检查网络';
302
302
  }
303
- else if (res.errMsg.indexOf('Unable to resolve host') > 0) {
303
+ else if (res.errMsg.includes('Unable to resolve host')) {
304
304
  res.errMsg = '域名解析失败';
305
305
  }
306
+ else if (res.errMsg.includes('NAME_NOT_RESOLVED')) {
307
+ res.errMsg = '域名解析失败';
308
+ }
309
+
310
+ let mer = res.errMsg.match(/<title>(.+)<\/title>/);
311
+ if (mer) res.errMsg = mer[1];
306
312
 
307
313
  res.message = res.errMsg;
308
314
  request.response = res;
package/src/kernel.js CHANGED
@@ -24,15 +24,15 @@ export default {
24
24
 
25
25
  for (let k in librarys) {
26
26
  const key = `\$${k}`;
27
- const obj = new librarys[k](app);
27
+ const obj = new librarys[k](app, config);
28
28
  app.config.globalProperties[key] = obj;
29
29
  app.provide(key, obj);
30
30
  }
31
31
 
32
- const page = new pageClass(config.maps);
32
+ const page = new pageClass(config.maps || {});
33
33
  app.config.globalProperties.$pages = page;
34
34
 
35
- const soft = new softClass(config.soft);
35
+ const soft = new softClass();
36
36
  app.config.globalProperties.$soft = soft;
37
37
  app.provide('$soft', soft);
38
38
  app.provide('$size', soft.size);
package/src/page.js CHANGED
@@ -191,7 +191,7 @@ export default class {
191
191
 
192
192
  if (!icon) icon = 'success';
193
193
  if (!time) time = 1500;
194
-
194
+
195
195
  uni.navigateBack({
196
196
  delta: 1,
197
197
  animationType: outType[animation.type || 'pop'],
@@ -261,14 +261,16 @@ export default class {
261
261
 
262
262
  realUrl(uri, params, getAnimation) {
263
263
  if (uri.slice(-1) === '/') uri += 'index';
264
-
264
+
265
265
  if (undefined === params) params = {};
266
266
  let animation = {
267
267
  type: 'pop-in',
268
268
  time: 300
269
269
  };
270
270
  if (maps[uri]) uri = maps[uri]; //URI映射
271
- let lab = uri[0];
271
+
272
+ //第2个字符是/,则lab是第1个字符
273
+ let lab = uri.slice(1, 2) === '/' ? uri[0] : '/';
272
274
 
273
275
  if (lab === '.') { //当前位置的同级目录或上一级目录
274
276
  const level = uri.indexOf('/');
@@ -299,8 +301,8 @@ export default class {
299
301
  if (lab !== '/') { //当前目录的同级文件
300
302
  let path = getLevelPath(1);
301
303
  path.push(uri) //目标path纳入最后
302
- path = path.join('/').build_query(params);
303
- return { path, animation, tabbar };
304
+
305
+ return { path: path.join('/').build_query(params), animation, tabbar };
304
306
  }
305
307
 
306
308
  return { path: uri.build_query(params), animation, tabbar };
package/src/soft.js CHANGED
@@ -10,6 +10,8 @@ export default class {
10
10
  singlePage = false; //是否从朋友圈进入的单页模式
11
11
 
12
12
  // #ifdef APP-PLUS
13
+ os = '';
14
+ ua = '';
13
15
  packName = ''; //APP包名
14
16
  appid = ''; //小程序的APPID,H5和APP为在manifest中设置的appid
15
17
  name = ''; //应用名称,即在manifest中设置的应用名称
@@ -34,13 +36,13 @@ export default class {
34
36
  navbar: 0,
35
37
  };
36
38
 
37
- constructor(conf) {
39
+ constructor() {
38
40
  try {
39
41
 
40
42
  // #ifdef MP-WEIXIN
41
43
  const { scene } = uni.getLaunchOptionsSync();
42
44
  this.singlePage = (scene === 1154);
43
- console.log('weixin.singlePage=', this.singlePage, scene);
45
+ // console.log('weixin.singlePage=', this.singlePage, scene);
44
46
  // #endif
45
47
 
46
48
  // console.log('soft start')
@@ -76,7 +78,7 @@ export default class {
76
78
  this.size.top = windows.statusBarHeight || 25; //顶部状态栏高度,css中直接用var(--status-bar-height)
77
79
  this.size.ratio = windows.pixelRatio; //设备像素比
78
80
 
79
- this.size.navigation = conf.navHeight || 44; //导航栏高度 var(--status-bar-height)
81
+ this.size.navigation = 44; //导航栏高度
80
82
  this.size.bodyHeight = windows.screenHeight - this.size.top - this.size.navigation; //除去顶部和菜单的高度
81
83
  }
82
84
  else {
@@ -90,7 +92,7 @@ export default class {
90
92
  this.size.screenHeight = system.screenHeight;
91
93
  this.size.width = system.windowWidth; //屏幕尺寸
92
94
  this.size.height = system.windowHeight;
93
- this.size.navigation = conf.navHeight || 44; //导航栏高度
95
+ this.size.navigation = 44; //导航栏高度
94
96
  this.size.bodyHeight = system.screenHeight - this.size.top - this.size.navigation; //除去顶部和菜单的高度
95
97
  }
96
98
  // #endif
@@ -117,7 +119,7 @@ export default class {
117
119
  this.size.screenHeight = system.screenHeight;
118
120
  this.size.width = system.windowWidth; //屏幕尺寸
119
121
  this.size.height = system.windowHeight;
120
- this.size.navigation = conf.navHeight || 44; //导航栏高度
122
+ this.size.navigation = 44; //导航栏高度
121
123
  this.size.bodyHeight = system.screenHeight - this.size.top - this.size.navigation; //除去顶部和菜单的高度
122
124
 
123
125
  // #endif
@@ -164,7 +166,8 @@ export default class {
164
166
  // console.log('plus.runtime', plus.runtime)
165
167
  this.os = plus.os.name.toLowerCase(); //操作系统,android或ios
166
168
  this.osver = plus.os.version; //操作系统版本号
167
- this.version = import.meta.env.VITE_VERSION || conf.version; //热更包版本号
169
+ this.version = import.meta.env.VITE_VERSION; //热更包版本号
170
+ this.ua = (import.meta.env.VITE_UA || 'Mozilla/5.0 ({os}/{osver} {brand}/{model})').re(this);
168
171
 
169
172
  this.packName = plus.weex.config.env.appName; //包名
170
173
  this.appid = plus.runtime.appid; //如:__UNI__123456
@@ -180,7 +183,7 @@ export default class {
180
183
  // console.log('plus.device.getOAID', res)
181
184
  this.oaid = res.oaid;
182
185
  },
183
- fail: err => {
186
+ fail: (err) => {
184
187
  // console.error('plus.device.getOAID', this.os, err);
185
188
  this.simulator++;
186
189
  }
@@ -190,7 +193,7 @@ export default class {
190
193
  // console.log('plus.device.getAAID', res)
191
194
  this.aaid = res.aaid;
192
195
  },
193
- fail: err => {
196
+ fail: (err) => {
194
197
  // console.error('plus.device.getAAID', err);
195
198
  this.simulator++;
196
199
  }
@@ -212,18 +215,6 @@ export default class {
212
215
  });
213
216
  // #endif
214
217
 
215
-
216
- for (let k in conf) {
217
- if (k === 'ua') {
218
- //#ifndef H5 || MP
219
- //h5和小程序不可以自定义
220
- this.ua = (conf.ua || 'Mozilla/5.0 ({os}/{osver} {brand}/{model})').re(this);
221
- //#endif
222
- }
223
- else {
224
- this[k] = conf[k];
225
- }
226
- }
227
218
  }
228
219
  catch (e) {
229
220
  console.error(e);
@@ -261,6 +252,7 @@ export default class {
261
252
  theme: this.theme,
262
253
 
263
254
  //#ifdef APP-PLUS
255
+ os: this.os,
264
256
  packName: this.packName,
265
257
  simulator: this.simulator, //模拟器可能性判断,oaid,aaid,uuid其中任一个读取出错各加1
266
258
  oaid: this.oaid,