@zeppos/zeus-cli 1.3.5 → 1.3.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.
- package/bin/main.js +8 -8
- package/modules/build.js +5 -3
- package/modules/create.js +6 -5
- package/package.json +1 -1
- package/private-modules/zeppos-app-utils/dist/config/device.js +105 -45
- package/private-modules/zeppos-app-utils/dist/modules/create/local-app.js +3 -2
- package/private-modules/zeppos-app-utils/dist/modules/fetchDevices.js +87 -0
- package/private-modules/zeppos-app-utils/dist/modules/index.js +1 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/app-side/index.js +6 -18
- package/private-modules/zeppos-app-utils/dist/public/template/os1.0/app/fetch-api/pages/index.js +6 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/app-side/index.js +6 -18
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/pages/index.js +6 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/empty/assets/default.b/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/empty/assets/default.r/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/empty/assets/default.s/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/app-side/index.js +7 -35
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.js +1 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.r.layout.js +8 -8
- package/private-modules/zeppos-app-utils/dist/public/template/os3.0/app/fetch-api/page/index.s.layout.js +1 -1
- package/private-modules/zeppos-app-utils/dist/tools/index.js +2 -1
- package/private-modules/zeppos-app-utils/dist/config/device-server.js +0 -116
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/.prettierrc.js +0 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app-side/index.js +0 -45
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app.js +0 -25
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/app.json +0 -64
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/assets/gts/icon.png +0 -0
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.page.js +0 -155
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.page.json +0 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/home/index.style.js +0 -92
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/page/i18n/en-US.po +0 -9
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/secondary-widget/index.js +0 -160
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/setting/i18n/en-US.po +0 -5
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/setting/index.js +0 -143
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/data.js +0 -67
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/defer.js +0 -35
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/device-polyfill.js +0 -6
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/es6-promise.js +0 -1178
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/event.js +0 -42
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/message-side.js +0 -1190
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/shared/message.js +0 -1196
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/utils/constants.js +0 -1
- package/private-modules/zeppos-app-utils/dist/public/template/os2.0/app/fetch-api/todo-list/utils/index.js +0 -38
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { createWidget, widget, prop } from '@zos/ui'
|
|
2
|
-
import { getDeviceInfo, SCREEN_SHAPE_SQUARE } from '@zos/device'
|
|
3
|
-
import { log as Logger } from '@zos/utils'
|
|
4
|
-
|
|
5
|
-
import { TITLE_TEXT_STYLE, TIPS_TEXT_STYLE, SCROLL_LIST, ADD_BUTTON } from '../page/home/index.style'
|
|
6
|
-
import { readFileSync, writeFileSync } from '../utils/fs'
|
|
7
|
-
import { getScrollListDataConfig } from '../utils/index'
|
|
8
|
-
|
|
9
|
-
const logger = Logger.getLogger('todo-list-page')
|
|
10
|
-
const { messageBuilder } = getApp()._options.globalData
|
|
11
|
-
|
|
12
|
-
SecondaryWidget({
|
|
13
|
-
state: {
|
|
14
|
-
scrollList: null,
|
|
15
|
-
tipText: null,
|
|
16
|
-
refreshText: null,
|
|
17
|
-
addButton: null,
|
|
18
|
-
dataList: readFileSync()
|
|
19
|
-
},
|
|
20
|
-
onInit() {
|
|
21
|
-
logger.debug('page onInit invoked')
|
|
22
|
-
this.onMessage()
|
|
23
|
-
this.getTodoList()
|
|
24
|
-
},
|
|
25
|
-
build() {
|
|
26
|
-
logger.debug('page build invoked')
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
if (getDeviceInfo().screenShape !== SCREEN_SHAPE_SQUARE) {
|
|
30
|
-
this.state.title = createWidget(widget.TEXT, {
|
|
31
|
-
...TITLE_TEXT_STYLE
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
this.state.addButton = createWidget(widget.BUTTON, {
|
|
36
|
-
...ADD_BUTTON,
|
|
37
|
-
click_func: () => {
|
|
38
|
-
this.addRandomTodoItem()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
this.createAndUpdateList()
|
|
43
|
-
} catch (e) {
|
|
44
|
-
console.log('LifeCycle Error', e)
|
|
45
|
-
e && e.stack && e.stack.split(/\n/).forEach((i) => console.log('error stack', i))
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
onDestroy() {
|
|
49
|
-
logger.debug('page onDestroy invoked')
|
|
50
|
-
writeFileSync(this.state.dataList, false)
|
|
51
|
-
},
|
|
52
|
-
onMessage() {
|
|
53
|
-
messageBuilder.on('call', ({ payload: buf }) => {
|
|
54
|
-
const data = messageBuilder.buf2Json(buf)
|
|
55
|
-
const dataList = data.map((i) => ({ name: i }))
|
|
56
|
-
logger.log('call dataList', dataList)
|
|
57
|
-
this.refreshAndUpdate(dataList)
|
|
58
|
-
})
|
|
59
|
-
},
|
|
60
|
-
getTodoList() {
|
|
61
|
-
messageBuilder
|
|
62
|
-
.request({
|
|
63
|
-
method: 'GET_TODO_LIST'
|
|
64
|
-
})
|
|
65
|
-
.then(({ result }) => {
|
|
66
|
-
this.state.dataList = result.map((d) => ({ name: d }))
|
|
67
|
-
logger.log('GET_TODO_LIST dataList', this.state.dataList)
|
|
68
|
-
this.createAndUpdateList()
|
|
69
|
-
})
|
|
70
|
-
.catch((res) => {})
|
|
71
|
-
},
|
|
72
|
-
addRandomTodoItem() {
|
|
73
|
-
messageBuilder
|
|
74
|
-
.request({
|
|
75
|
-
method: 'ADD'
|
|
76
|
-
})
|
|
77
|
-
.then(({ result }) => {
|
|
78
|
-
this.state.dataList = result.map((d) => ({ name: d }))
|
|
79
|
-
this.createAndUpdateList()
|
|
80
|
-
})
|
|
81
|
-
.catch((res) => {})
|
|
82
|
-
},
|
|
83
|
-
deleteTodoItem(index) {
|
|
84
|
-
messageBuilder
|
|
85
|
-
.request({
|
|
86
|
-
method: 'DELETE',
|
|
87
|
-
params: { index }
|
|
88
|
-
})
|
|
89
|
-
.then(({ result }) => {
|
|
90
|
-
const dataList = result.map((d) => ({ name: d }))
|
|
91
|
-
|
|
92
|
-
this.refreshAndUpdate(dataList)
|
|
93
|
-
})
|
|
94
|
-
.catch((res) => {})
|
|
95
|
-
},
|
|
96
|
-
changeUI(showEmpty) {
|
|
97
|
-
const { dataList } = this.state
|
|
98
|
-
|
|
99
|
-
if (showEmpty) {
|
|
100
|
-
if (dataList.length === 0) {
|
|
101
|
-
!this.state.tipText &&
|
|
102
|
-
(this.state.tipText = createWidget(widget.TEXT, {
|
|
103
|
-
...TIPS_TEXT_STYLE
|
|
104
|
-
}))
|
|
105
|
-
}
|
|
106
|
-
const isTip = dataList.length === 0
|
|
107
|
-
|
|
108
|
-
this.state.refreshText && this.state.refreshText.setProperty(prop.VISIBLE, false)
|
|
109
|
-
this.state.tipText && this.state.tipText.setProperty(prop.VISIBLE, isTip)
|
|
110
|
-
this.state.scrollList && this.state.scrollList.setProperty(prop.VISIBLE, !isTip)
|
|
111
|
-
} else {
|
|
112
|
-
// 占位刷新
|
|
113
|
-
!this.state.refreshText &&
|
|
114
|
-
(this.state.refreshText = createWidget(widget.TEXT, {
|
|
115
|
-
...TIPS_TEXT_STYLE,
|
|
116
|
-
text: ' '
|
|
117
|
-
}))
|
|
118
|
-
|
|
119
|
-
this.state.tipText && this.state.tipText.setProperty(prop.VISIBLE, false)
|
|
120
|
-
this.state.refreshText.setProperty(prop.VISIBLE, true)
|
|
121
|
-
this.state.scrollList && this.state.scrollList.setProperty(prop.VISIBLE, false)
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
createAndUpdateList(showEmpty = true) {
|
|
125
|
-
const _scrollListItemClick = (list, index) => {
|
|
126
|
-
this.deleteTodoItem(index)
|
|
127
|
-
}
|
|
128
|
-
const { scrollList, dataList } = this.state
|
|
129
|
-
this.changeUI(showEmpty)
|
|
130
|
-
const dataTypeConfig = getScrollListDataConfig(dataList.length === 0 ? -1 : 0, dataList.length)
|
|
131
|
-
if (scrollList) {
|
|
132
|
-
scrollList.setProperty(prop.UPDATE_DATA, {
|
|
133
|
-
data_array: dataList,
|
|
134
|
-
data_count: dataList.length,
|
|
135
|
-
data_type_config: [{ start: 0, end: dataList.length, type_id: 2 }],
|
|
136
|
-
data_type_config_count: dataTypeConfig.length,
|
|
137
|
-
on_page: 1
|
|
138
|
-
})
|
|
139
|
-
} else {
|
|
140
|
-
this.state.scrollList = createWidget(widget.SCROLL_LIST, {
|
|
141
|
-
...(SCROLL_LIST || {}),
|
|
142
|
-
data_array: dataList,
|
|
143
|
-
data_count: dataList.length,
|
|
144
|
-
data_type_config: dataTypeConfig,
|
|
145
|
-
data_type_config_count: dataTypeConfig.length,
|
|
146
|
-
on_page: 1,
|
|
147
|
-
item_click_func: _scrollListItemClick
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
refreshAndUpdate(dataList = []) {
|
|
152
|
-
this.state.dataList = []
|
|
153
|
-
this.createAndUpdateList(false)
|
|
154
|
-
|
|
155
|
-
setTimeout(() => {
|
|
156
|
-
this.state.dataList = dataList
|
|
157
|
-
this.createAndUpdateList()
|
|
158
|
-
}, 20)
|
|
159
|
-
}
|
|
160
|
-
})
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { gettext } from 'i18n'
|
|
2
|
-
import { DEFAULT_TODO_LIST } from './../utils/constants'
|
|
3
|
-
AppSettingsPage({
|
|
4
|
-
state: {
|
|
5
|
-
todoList: [],
|
|
6
|
-
props: {}
|
|
7
|
-
},
|
|
8
|
-
addTodoList(val) {
|
|
9
|
-
this.state.todoList = [...this.state.todoList, val]
|
|
10
|
-
this.setItem()
|
|
11
|
-
},
|
|
12
|
-
editTodoList(val, index) {
|
|
13
|
-
this.state.todoList[index] = val
|
|
14
|
-
this.setItem()
|
|
15
|
-
},
|
|
16
|
-
deleteTodoList(index) {
|
|
17
|
-
this.state.todoList = this.state.todoList.filter((_, ind) => {
|
|
18
|
-
return ind !== index
|
|
19
|
-
})
|
|
20
|
-
this.setItem()
|
|
21
|
-
},
|
|
22
|
-
setItem() {
|
|
23
|
-
const newString = JSON.stringify(this.state.todoList)
|
|
24
|
-
this.state.props.settingsStorage.setItem('todoList', newString)
|
|
25
|
-
},
|
|
26
|
-
setState(props) {
|
|
27
|
-
this.state.props = props
|
|
28
|
-
if (props.settingsStorage.getItem('todoList')) {
|
|
29
|
-
this.state.todoList = JSON.parse(props.settingsStorage.getItem('todoList'))
|
|
30
|
-
} else {
|
|
31
|
-
this.state.todoList = [...DEFAULT_TODO_LIST]
|
|
32
|
-
}
|
|
33
|
-
console.log('todoList: ', this.state.todoList)
|
|
34
|
-
},
|
|
35
|
-
build(props) {
|
|
36
|
-
this.setState(props)
|
|
37
|
-
const contentItems = []
|
|
38
|
-
const addBTN = View(
|
|
39
|
-
{
|
|
40
|
-
style: {
|
|
41
|
-
fontSize: '12px',
|
|
42
|
-
lineHeight: '30px',
|
|
43
|
-
borderRadius: '30px',
|
|
44
|
-
background: '#409EFF',
|
|
45
|
-
color: 'white',
|
|
46
|
-
textAlign: 'center',
|
|
47
|
-
padding: '0 15px',
|
|
48
|
-
width: '30%'
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
[
|
|
52
|
-
TextInput({
|
|
53
|
-
label: gettext('addTodo'),
|
|
54
|
-
onChange: (val) => {
|
|
55
|
-
this.addTodoList(val)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
]
|
|
59
|
-
)
|
|
60
|
-
this.state.todoList.forEach((item, index) => {
|
|
61
|
-
contentItems.push(
|
|
62
|
-
View(
|
|
63
|
-
{
|
|
64
|
-
style: {
|
|
65
|
-
borderBottom: '1px solid #eaeaea',
|
|
66
|
-
padding: '6px 0',
|
|
67
|
-
marginBottom: '6px',
|
|
68
|
-
display: 'flex',
|
|
69
|
-
flexDirection: 'row'
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
[
|
|
73
|
-
View(
|
|
74
|
-
{
|
|
75
|
-
style: {
|
|
76
|
-
flex: 1,
|
|
77
|
-
display: 'flex',
|
|
78
|
-
flexDirection: 'row',
|
|
79
|
-
justfyContent: 'center',
|
|
80
|
-
alignItems: 'center'
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
[
|
|
84
|
-
TextInput({
|
|
85
|
-
label: '',
|
|
86
|
-
bold: true,
|
|
87
|
-
value: item,
|
|
88
|
-
subStyle: {
|
|
89
|
-
color: '#333',
|
|
90
|
-
fontSize: '14px'
|
|
91
|
-
},
|
|
92
|
-
maxLength: 200,
|
|
93
|
-
onChange: (val) => {
|
|
94
|
-
if (val.length > 0 && val.length <= 200) {
|
|
95
|
-
this.editTodoList(val, index)
|
|
96
|
-
} else {
|
|
97
|
-
console.log("todoList can't be empty or too long!")
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
]
|
|
102
|
-
),
|
|
103
|
-
Button({
|
|
104
|
-
label: gettext('delete'),
|
|
105
|
-
style: {
|
|
106
|
-
fontSize: '12px',
|
|
107
|
-
borderRadius: '30px',
|
|
108
|
-
background: '#D85E33',
|
|
109
|
-
color: 'white'
|
|
110
|
-
},
|
|
111
|
-
onClick: () => {
|
|
112
|
-
this.deleteTodoList(index)
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
]
|
|
116
|
-
)
|
|
117
|
-
)
|
|
118
|
-
})
|
|
119
|
-
return View(
|
|
120
|
-
{
|
|
121
|
-
style: {
|
|
122
|
-
padding: '12px 20px'
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
[
|
|
126
|
-
addBTN,
|
|
127
|
-
contentItems.length > 0 &&
|
|
128
|
-
View(
|
|
129
|
-
{
|
|
130
|
-
style: {
|
|
131
|
-
marginTop: '12px',
|
|
132
|
-
padding: '10px',
|
|
133
|
-
border: '1px solid #eaeaea',
|
|
134
|
-
borderRadius: '6px',
|
|
135
|
-
backgroundColor: 'white'
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
[...contentItems]
|
|
139
|
-
)
|
|
140
|
-
]
|
|
141
|
-
)
|
|
142
|
-
}
|
|
143
|
-
})
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export function json2buf(json) {
|
|
2
|
-
return str2buf(json2str(json))
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function json2bin(json) {
|
|
6
|
-
return str2bin(json2str(json))
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function len(binOrBuf) {
|
|
10
|
-
return binOrBuf.byteLength
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function buf2json(buf) {
|
|
14
|
-
return str2json(buf2str(buf))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function str2json(str) {
|
|
18
|
-
return JSON.parse(str)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function json2str(json) {
|
|
22
|
-
return JSON.stringify(json)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function str2buf(str) {
|
|
26
|
-
return Buffer.from(str, 'utf-8')
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function buf2str(buf) {
|
|
30
|
-
return buf.toString('utf-8')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function bin2buf(bin) {
|
|
34
|
-
return Buffer.from(bin)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function buf2bin(buf) {
|
|
38
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function buf2hex(buf) {
|
|
42
|
-
return buf.toString('hex')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function bin2hex(bin) {
|
|
46
|
-
return buf2hex(bin2buf(bin))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function bin2json(bin) {
|
|
50
|
-
return buf2json(bin2buf(bin))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function bin2str(bin) {
|
|
54
|
-
return buf2str(bin2buf(bin))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function str2bin(str) {
|
|
58
|
-
return buf2bin(str2buf(str))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function allocOfBin(size = 0) {
|
|
62
|
-
return Buffer.alloc(size).buffer
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function allocOfBuf(size = 0) {
|
|
66
|
-
return Buffer.alloc(size)
|
|
67
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export function Deferred() {
|
|
2
|
-
const defer = {}
|
|
3
|
-
|
|
4
|
-
defer.promise = new Promise(function (resolve, reject) {
|
|
5
|
-
defer.resolve = resolve
|
|
6
|
-
defer.reject = reject
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
return defer
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function delay(ms) {
|
|
13
|
-
const defer = Deferred()
|
|
14
|
-
|
|
15
|
-
setTimeout(defer.resolve, ms)
|
|
16
|
-
|
|
17
|
-
return defer.promise
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function timeout(ms, cb) {
|
|
21
|
-
const defer = Deferred()
|
|
22
|
-
ms = ms || 1000
|
|
23
|
-
|
|
24
|
-
const wait = setTimeout(() => {
|
|
25
|
-
clearTimeout(wait)
|
|
26
|
-
|
|
27
|
-
if (cb) {
|
|
28
|
-
cb && cb(defer.resolve, defer.reject)
|
|
29
|
-
} else {
|
|
30
|
-
defer.reject('Timed out in ' + ms + 'ms.')
|
|
31
|
-
}
|
|
32
|
-
}, ms)
|
|
33
|
-
|
|
34
|
-
return defer.promise
|
|
35
|
-
}
|