@zeppos/zeus-cli 1.0.18 → 1.0.26

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.
@@ -1,16 +1,19 @@
1
- import { textStyle } from './index.style'
1
+ import { TEXT_STYLE } from './index.style'
2
2
 
3
3
  const logger = DeviceRuntimeCore.HmLogger.getLogger('helloworld')
4
+
4
5
  Page({
5
6
  build() {
6
7
  logger.debug('page build invoked')
7
- h.text(textStyle)
8
+ hmUI.createWidget(hmUI.widget.TEXT, {
9
+ ...TEXT_STYLE,
10
+ })
8
11
  },
9
12
  onInit() {
10
13
  logger.debug('page onInit invoked')
11
14
  },
12
15
 
13
- onDestory() {
14
- logger.debug('page onDestory invoked')
16
+ onDestroy() {
17
+ logger.debug('page onDestroy invoked')
15
18
  },
16
19
  })
@@ -1,32 +1,15 @@
1
1
  import { gettext } from "i18n"
2
- import { assets } from './../../../utils/index'
3
2
 
4
- const image = assets('image')
3
+ export const { width: DEVICE_WIDTH, height: DEVICE_HEIGHT } = hmSetting.getDeviceInfo()
5
4
 
6
- export const textStyle = {
7
- attrs: {
8
- text: gettext('appName')
9
- },
10
- styles: {
11
- x: 42,
12
- y: 246,
13
- w: 480 - 42 * 2,
14
- h: 138,
15
- color: 0xFFFFFF,
16
- text_size: 36,
17
- align_h: h.ALIGN.CENTER_H,
18
- text_style: hmUI.text_style.WRAP
19
- }
5
+ export const TEXT_STYLE = {
6
+ text: gettext('appName'),
7
+ x: 42,
8
+ y: 200,
9
+ w: DEVICE_WIDTH - 42 * 2,
10
+ h: 100,
11
+ color: 0xffffff,
12
+ text_size: 36,
13
+ align_h: hmUI.align.CENTER_H,
14
+ text_style: hmUI.text_style.WRAP,
20
15
  }
21
-
22
- export const imageStyle = {
23
- attrs: {
24
- src: image('logo.png')
25
- },
26
- styles: {
27
- x: 115,
28
- y: 100,
29
- w: 250,
30
- h: 56,
31
- },
32
- }
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "target": "es6",
5
+ "checkJs": true
6
+ },
7
+ "exclude": [
8
+ "node_modules",
9
+ "**/node_modules/*"
10
+ ],
11
+ "files": [
12
+ "node_modules/@zeppos/device-types/index.d.ts"
13
+ ]
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "empty",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "app.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "devDependencies": {
12
+ "@zeppos/device-types": "^1.0.0"
13
+ }
14
+ }
@@ -3,8 +3,5 @@ import './shared/device-polyfill'
3
3
  App({
4
4
  globalData: {},
5
5
  onCreate(options) {},
6
- onDestroy(options) {},
7
- onError(error) {},
8
- onPageNotFound(obj) {},
9
- onUnhandledRejection(obj) {},
6
+ onDestroy(options) {}
10
7
  })
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "i18n": {
44
44
  "en-US": {
45
- "name": "timer"
45
+ "appName": "timer"
46
46
  }
47
47
  },
48
48
  "defaultLanguage": "en-US",
@@ -432,7 +432,7 @@ WatchFace({
432
432
  this.init_view()
433
433
  },
434
434
 
435
- onDestory() {
436
- logger.log('index page.js on destory invoke')
435
+ onDestroy() {
436
+ logger.log('index page.js on destroy invoke')
437
437
  },
438
438
  })
package/utils/login.js ADDED
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ exports.__esModule = true;
42
+ exports.getUserInfo = exports.loginByLocal = void 0;
43
+ var axios_1 = __importDefault(require("axios"));
44
+ var lodash_1 = __importDefault(require("lodash"));
45
+ var qs_1 = __importDefault(require("qs"));
46
+ var project_1 = require("../config/project");
47
+ var REGISTER_TEST_URL = 'https://api-mifit-staging.huami.com';
48
+ var REGISTER_PRO_URL = 'https://api-user.huami.com';
49
+ var CUR_REGISTER_URL = project_1.ACCOUNT_ENV === 'test' ? REGISTER_TEST_URL : REGISTER_PRO_URL;
50
+ var LOGIN_URL = 'https://account.huami.com';
51
+ var postForm = function (url, data) {
52
+ return (0, axios_1["default"])({
53
+ method: 'POST',
54
+ headers: {
55
+ 'content-type': 'application/x-www-form-urlencoded'
56
+ },
57
+ data: qs_1["default"].stringify(data),
58
+ url: url
59
+ });
60
+ };
61
+ var loginByLocal = function (account, password) { return __awaiter(void 0, void 0, void 0, function () {
62
+ var data, checkInfo, loginInfo;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0:
66
+ data = {
67
+ client_id: 'HuaMi',
68
+ country_code: 'zh-CN',
69
+ json_response: 'true',
70
+ name: '',
71
+ password: password,
72
+ phoneOrEmail: account,
73
+ redirect_uri: 'https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html',
74
+ state: 'REDIRECTION',
75
+ token: 'access'
76
+ };
77
+ if (/^[1][0-9]{10}$/.test(account)) {
78
+ data.phoneOrEmail = encodeURIComponent("+86".concat(account));
79
+ }
80
+ data.name = data.phoneOrEmail.split('@')[0];
81
+ return [4 /*yield*/, postForm("".concat(CUR_REGISTER_URL, "/registrations/").concat(data.phoneOrEmail, "/tokens"), data)];
82
+ case 1:
83
+ checkInfo = _a.sent();
84
+ return [4 /*yield*/, postForm("".concat(LOGIN_URL, "/v2/client/login"), {
85
+ app_name: 'com.huami.webapp',
86
+ app_version: '4.3.0',
87
+ code: lodash_1["default"].get(checkInfo, 'data.access', ''),
88
+ country_code: 'zh-cn',
89
+ device_id: '02:00:00:00:00:00',
90
+ device_model: 'web',
91
+ grant_type: 'access_token',
92
+ third_name: 'huami'
93
+ })];
94
+ case 2:
95
+ loginInfo = (_a.sent()).data;
96
+ return [2 /*return*/, loginInfo];
97
+ }
98
+ });
99
+ }); };
100
+ exports.loginByLocal = loginByLocal;
101
+ var getUserInfo = function (host, userid, apptoken) { return __awaiter(void 0, void 0, void 0, function () {
102
+ var userInfo, data, error_1;
103
+ return __generator(this, function (_a) {
104
+ switch (_a.label) {
105
+ case 0:
106
+ _a.trys.push([0, 2, , 3]);
107
+ return [4 /*yield*/, axios_1["default"].get("https://".concat(host, "/v1/soc/user/").concat(userid), {
108
+ headers: {
109
+ app_token: apptoken,
110
+ 'Content-Type': 'application/json',
111
+ user_id: userid,
112
+ app_name: 'com.huami.webapp'
113
+ }
114
+ })];
115
+ case 1:
116
+ userInfo = _a.sent();
117
+ data = userInfo.data.data;
118
+ return [2 /*return*/, data];
119
+ case 2:
120
+ error_1 = _a.sent();
121
+ return [3 /*break*/, 3];
122
+ case 3: return [2 /*return*/];
123
+ }
124
+ });
125
+ }); };
126
+ exports.getUserInfo = getUserInfo;