@freelog/tools-lib 0.1.126 → 0.1.127

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.
@@ -8,13 +8,13 @@ declare class I18nNext {
8
8
  private _taskQueue;
9
9
  private _currentLanguage;
10
10
  constructor();
11
- ready(): Promise<unknown>;
12
- t(key: string, options?: {
11
+ ready(this: I18nNext): Promise<unknown>;
12
+ t(this: I18nNext, key: string, options?: {
13
13
  [key: string]: any;
14
14
  }): string;
15
- changeLanguage(lng: LanguageKeyType): void;
16
- getAllLanguage(): typeof allLanguage;
17
- getCurrentLanguage(): LanguageKeyType;
15
+ changeLanguage(this: I18nNext, lng: LanguageKeyType): void;
16
+ getAllLanguage(this: I18nNext): typeof allLanguage;
17
+ getCurrentLanguage(this: I18nNext): LanguageKeyType;
18
18
  private _handleData;
19
19
  private _fetchData;
20
20
  }
@@ -3292,6 +3292,7 @@ var FUtil = {
3292
3292
  };
3293
3293
 
3294
3294
  var ossJsonUrl = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
3295
+ var ossJsonUrl_Test = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs-test/i18n.json';
3295
3296
  var localStorage_i18nextLng_key = 'locale';
3296
3297
  var localStorage_i18nextResources_key = 'i18nextResources';
3297
3298
  var allLanguage = [{
@@ -3301,7 +3302,6 @@ var allLanguage = [{
3301
3302
  value: 'zh_CN',
3302
3303
  label: '简体中文'
3303
3304
  }];
3304
- var self;
3305
3305
 
3306
3306
  var I18nNext = /*#__PURE__*/function () {
3307
3307
  function I18nNext() {
@@ -3309,22 +3309,28 @@ var I18nNext = /*#__PURE__*/function () {
3309
3309
  this._taskQueue = []; // private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
3310
3310
 
3311
3311
  this._currentLanguage = Cookies.get(localStorage_i18nextLng_key) || 'zh_CN';
3312
- self = this;
3313
- self.ready();
3312
+ this.ready();
3313
+ this.ready = this.ready.bind(this);
3314
+ this.t = this.t.bind(this);
3315
+ this.changeLanguage = this.changeLanguage.bind(this);
3316
+ this.getAllLanguage = this.getAllLanguage.bind(this);
3317
+ this.getCurrentLanguage = this.getCurrentLanguage.bind(this);
3314
3318
  }
3315
3319
 
3316
3320
  var _proto = I18nNext.prototype;
3317
3321
 
3318
3322
  _proto.ready = /*#__PURE__*/function () {
3319
3323
  var _ready = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
3324
+ var _this = this;
3325
+
3320
3326
  var exc, handleTasks, promise;
3321
3327
  return runtime_1.wrap(function _callee2$(_context2) {
3322
3328
  while (1) {
3323
3329
  switch (_context2.prev = _context2.next) {
3324
3330
  case 0:
3325
3331
  exc = function exc() {
3326
- while (self._taskQueue.length > 0) {
3327
- var task = self._taskQueue.shift();
3332
+ while (_this._taskQueue.length > 0) {
3333
+ var task = _this._taskQueue.shift();
3328
3334
 
3329
3335
  task && task();
3330
3336
  }
@@ -3336,7 +3342,7 @@ var I18nNext = /*#__PURE__*/function () {
3336
3342
  while (1) {
3337
3343
  switch (_context.prev = _context.next) {
3338
3344
  case 0:
3339
- if (!(self._loadingData === 'End')) {
3345
+ if (!(_this._loadingData === 'End')) {
3340
3346
  _context.next = 3;
3341
3347
  break;
3342
3348
  }
@@ -3345,7 +3351,7 @@ var I18nNext = /*#__PURE__*/function () {
3345
3351
  return _context.abrupt("return");
3346
3352
 
3347
3353
  case 3:
3348
- if (!(self._loadingData === 'Start')) {
3354
+ if (!(_this._loadingData === 'Start')) {
3349
3355
  _context.next = 5;
3350
3356
  break;
3351
3357
  }
@@ -3354,9 +3360,9 @@ var I18nNext = /*#__PURE__*/function () {
3354
3360
 
3355
3361
  case 5:
3356
3362
  // NO_START
3357
- self._loadingData = 'Start';
3363
+ _this._loadingData = 'Start';
3358
3364
  _context.next = 8;
3359
- return self._handleData();
3365
+ return _this._handleData();
3360
3366
 
3361
3367
  case 8:
3362
3368
  // console.log('######');
@@ -3376,7 +3382,7 @@ var I18nNext = /*#__PURE__*/function () {
3376
3382
  }();
3377
3383
 
3378
3384
  promise = new Promise(function (resolve) {
3379
- self._taskQueue.push(resolve);
3385
+ _this._taskQueue.push(resolve);
3380
3386
  });
3381
3387
  handleTasks();
3382
3388
  return _context2.abrupt("return", promise);
@@ -3414,7 +3420,7 @@ var I18nNext = /*#__PURE__*/function () {
3414
3420
  };
3415
3421
 
3416
3422
  _proto.getCurrentLanguage = function getCurrentLanguage() {
3417
- return self._currentLanguage;
3423
+ return this._currentLanguage;
3418
3424
  };
3419
3425
 
3420
3426
  _proto._handleData = /*#__PURE__*/function () {
@@ -3424,7 +3430,7 @@ var I18nNext = /*#__PURE__*/function () {
3424
3430
  while (1) {
3425
3431
  switch (_context3.prev = _context3.next) {
3426
3432
  case 0:
3427
- lng = self._currentLanguage;
3433
+ lng = this._currentLanguage;
3428
3434
  resource = window.localStorage.getItem(localStorage_i18nextResources_key); // const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
3429
3435
 
3430
3436
  i18nextResources = resource ? JSON.parse(resource) : null;
@@ -3435,7 +3441,7 @@ var I18nNext = /*#__PURE__*/function () {
3435
3441
  }
3436
3442
 
3437
3443
  _context3.next = 6;
3438
- return self._fetchData();
3444
+ return this._fetchData();
3439
3445
 
3440
3446
  case 6:
3441
3447
  i18nextResources = _context3.sent;
@@ -3443,7 +3449,7 @@ var I18nNext = /*#__PURE__*/function () {
3443
3449
  break;
3444
3450
 
3445
3451
  case 9:
3446
- self._fetchData();
3452
+ this._fetchData();
3447
3453
 
3448
3454
  case 10:
3449
3455
  _context3.next = 12;
@@ -3466,7 +3472,7 @@ var I18nNext = /*#__PURE__*/function () {
3466
3472
  return _context3.stop();
3467
3473
  }
3468
3474
  }
3469
- }, _callee3);
3475
+ }, _callee3, this);
3470
3476
  }));
3471
3477
 
3472
3478
  function _handleData() {
@@ -3485,7 +3491,7 @@ var I18nNext = /*#__PURE__*/function () {
3485
3491
  switch (_context4.prev = _context4.next) {
3486
3492
  case 0:
3487
3493
  _context4.next = 2;
3488
- return axios.get(ossJsonUrl, {
3494
+ return axios.get(window.location.origin.includes('.freelog.com') ? ossJsonUrl : ossJsonUrl_Test, {
3489
3495
  withCredentials: false
3490
3496
  });
3491
3497