@hap-toolkit/dsl-xvm 2.1.0 → 2.1.1
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/device-json-template/config-tv.json +14 -14
- package/lib/loaders/ux-fragment-utils.js +1 -1
- package/package.json +5 -5
- package/readme.md +3 -3
- package/templates/app/demo/.eslintignore +6 -6
- package/templates/app/demo/.eslintrc.json +66 -66
- package/templates/app/demo/.prettierignore +6 -6
- package/templates/app/demo/README.md +11 -11
- package/templates/app/demo/_gitignore +16 -16
- package/templates/app/demo/package.json +54 -54
- package/templates/app/demo/scripts/gen/index.js +92 -92
- package/templates/app/demo/scripts/gen/template.ux +32 -32
- package/templates/app/demo/scripts/selfCloseInputTag.js +41 -41
- package/templates/app/demo/src/app.ux +22 -22
- package/templates/app/demo/src/assets/styles/mixins.scss +5 -5
- package/templates/app/demo/src/assets/styles/style.scss +2 -2
- package/templates/app/demo/src/assets/styles/variables.scss +11 -11
- package/templates/app/demo/src/global.js +38 -38
- package/templates/app/demo/src/helper/ajax.js +67 -67
- package/templates/app/demo/src/helper/apis/example.js +25 -25
- package/templates/app/demo/src/helper/apis/index.js +16 -16
- package/templates/app/demo/src/helper/utils.js +31 -31
- package/templates/app/demo/src/manifest.json +70 -70
- package/templates/app/demo/src/pages/Demo/index.ux +72 -72
- package/templates/app/demo/src/pages/DemoDetail/index.ux +63 -63
- package/templates/app/demo/src/sitemap.json +3 -3
- package/templates/app/demo/src/widgets/CardDemo/assets/styles.scss +16 -16
- package/templates/app/demo/src/widgets/CardDemo/index.ux +83 -83
- package/LICENSE +0 -51
- package/templates/app/demo/.gitignore +0 -26
- package/templates/app/demo/.npmrc +0 -0
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
-->
|
|
5
|
-
|
|
6
|
-
<template>
|
|
7
|
-
<div class="wrapper">
|
|
8
|
-
<text class="title">{{ title }}</text>
|
|
9
|
-
</div>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
export default {
|
|
14
|
-
private: {
|
|
15
|
-
title: '欢迎体验快应用开发'
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
onInit() {}
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<style lang="scss">
|
|
23
|
-
@import './../../assets/styles/style.scss';
|
|
24
|
-
.wrapper {
|
|
25
|
-
@include flex-box-mixins(column, center, center);
|
|
26
|
-
.title {
|
|
27
|
-
font-size: 18 * $size-factor;
|
|
28
|
-
text-align: center;
|
|
29
|
-
color: $black;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
</style>
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<template>
|
|
7
|
+
<div class="wrapper">
|
|
8
|
+
<text class="title">{{ title }}</text>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
export default {
|
|
14
|
+
private: {
|
|
15
|
+
title: '欢迎体验快应用开发'
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
onInit() {}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style lang="scss">
|
|
23
|
+
@import './../../assets/styles/style.scss';
|
|
24
|
+
.wrapper {
|
|
25
|
+
@include flex-box-mixins(column, center, center);
|
|
26
|
+
.title {
|
|
27
|
+
font-size: 18 * $size-factor;
|
|
28
|
+
text-align: center;
|
|
29
|
+
color: $black;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @file: selfCloseInputTag.js
|
|
8
|
-
* @desc: 遍历指定目录下 .ux 文件,将其中 input 标签由 <input **></input> 转换为 <input ** />
|
|
9
|
-
* @date: 2019-01-23
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const fs = require('fs')
|
|
13
|
-
const path = require('path')
|
|
14
|
-
|
|
15
|
-
const quickappCodePath = './src/'
|
|
16
|
-
|
|
17
|
-
const main = (codePath) => {
|
|
18
|
-
const traversing = (cpath) => {
|
|
19
|
-
const files = fs.readdirSync(cpath)
|
|
20
|
-
files.forEach((fileName) => {
|
|
21
|
-
const fPath = path.join(cpath, fileName)
|
|
22
|
-
const stats = fs.statSync(fPath)
|
|
23
|
-
stats.isDirectory() && traversing(fPath)
|
|
24
|
-
stats.isFile() && fPath.endsWith('.ux') && matchAndReplace(fPath)
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
traversing(codePath)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const matchAndReplace = (path) => {
|
|
31
|
-
const pageContent = fs.readFileSync(path, 'UTF-8')
|
|
32
|
-
const newContent = pageContent.replace(
|
|
33
|
-
/(<)([\s]*?)(input\b[^\/]*?)>[\s\S]*?<\/input>/gm,
|
|
34
|
-
'$1$3 />'
|
|
35
|
-
)
|
|
36
|
-
fs.writeFile(path, newContent, (error) => {
|
|
37
|
-
if (error) throw `Something went wrong: ${error}`
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
main(quickappCodePath)
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @file: selfCloseInputTag.js
|
|
8
|
+
* @desc: 遍历指定目录下 .ux 文件,将其中 input 标签由 <input **></input> 转换为 <input ** />
|
|
9
|
+
* @date: 2019-01-23
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs')
|
|
13
|
+
const path = require('path')
|
|
14
|
+
|
|
15
|
+
const quickappCodePath = './src/'
|
|
16
|
+
|
|
17
|
+
const main = (codePath) => {
|
|
18
|
+
const traversing = (cpath) => {
|
|
19
|
+
const files = fs.readdirSync(cpath)
|
|
20
|
+
files.forEach((fileName) => {
|
|
21
|
+
const fPath = path.join(cpath, fileName)
|
|
22
|
+
const stats = fs.statSync(fPath)
|
|
23
|
+
stats.isDirectory() && traversing(fPath)
|
|
24
|
+
stats.isFile() && fPath.endsWith('.ux') && matchAndReplace(fPath)
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
traversing(codePath)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const matchAndReplace = (path) => {
|
|
31
|
+
const pageContent = fs.readFileSync(path, 'UTF-8')
|
|
32
|
+
const newContent = pageContent.replace(
|
|
33
|
+
/(<)([\s]*?)(input\b[^\/]*?)>[\s\S]*?<\/input>/gm,
|
|
34
|
+
'$1$3 />'
|
|
35
|
+
)
|
|
36
|
+
fs.writeFile(path, newContent, (error) => {
|
|
37
|
+
if (error) throw `Something went wrong: ${error}`
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
main(quickappCodePath)
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
-->
|
|
5
|
-
|
|
6
|
-
<script>
|
|
7
|
-
/**
|
|
8
|
-
* 应用级别的配置,供所有页面公用
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const $utils = require('./helper/utils').default
|
|
12
|
-
const $apis = require('./helper/apis').default
|
|
13
|
-
|
|
14
|
-
/* @desc: 注入方法至全局 global,以便页面调用 */
|
|
15
|
-
const hook2global = global.__proto__ || global
|
|
16
|
-
hook2global.$utils = $utils
|
|
17
|
-
hook2global.$apis = $apis
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
onCreate() {}
|
|
21
|
-
}
|
|
22
|
-
</script>
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
/**
|
|
8
|
+
* 应用级别的配置,供所有页面公用
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const $utils = require('./helper/utils').default
|
|
12
|
+
const $apis = require('./helper/apis').default
|
|
13
|
+
|
|
14
|
+
/* @desc: 注入方法至全局 global,以便页面调用 */
|
|
15
|
+
const hook2global = global.__proto__ || global
|
|
16
|
+
hook2global.$utils = $utils
|
|
17
|
+
hook2global.$apis = $apis
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
onCreate() {}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
@mixin flex-box-mixins($direction: row, $justify: center, $align-items: center) {
|
|
2
|
-
flex-direction: $direction;
|
|
3
|
-
justify-content: $justify;
|
|
4
|
-
align-items: $align-items;
|
|
5
|
-
}
|
|
1
|
+
@mixin flex-box-mixins($direction: row, $justify: center, $align-items: center) {
|
|
2
|
+
flex-direction: $direction;
|
|
3
|
+
justify-content: $justify;
|
|
4
|
+
align-items: $align-items;
|
|
5
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
@import './variables.scss';
|
|
2
|
-
@import './mixins.scss';
|
|
1
|
+
@import './variables.scss';
|
|
2
|
+
@import './mixins.scss';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
$brand: #09ba07;
|
|
2
|
-
|
|
3
|
-
$white: #ffffff;
|
|
4
|
-
$black: #000000;
|
|
5
|
-
$grey: #9393aa;
|
|
6
|
-
$red: #fa0101;
|
|
7
|
-
$yellow: #ffff00;
|
|
8
|
-
|
|
9
|
-
// $size-factor 为 3px,对应的 designWidth 为 1080,长度使用:360的设计稿尺寸数字 * $size-factor
|
|
10
|
-
// 如果 designWidth 设置为 360,可修改 $size-factor 为 1px
|
|
11
|
-
$size-factor: 3px;
|
|
1
|
+
$brand: #09ba07;
|
|
2
|
+
|
|
3
|
+
$white: #ffffff;
|
|
4
|
+
$black: #000000;
|
|
5
|
+
$grey: #9393aa;
|
|
6
|
+
$red: #fa0101;
|
|
7
|
+
$yellow: #ffff00;
|
|
8
|
+
|
|
9
|
+
// $size-factor 为 3px,对应的 designWidth 为 1080,长度使用:360的设计稿尺寸数字 * $size-factor
|
|
10
|
+
// 如果 designWidth 设置为 360,可修改 $size-factor 为 1px
|
|
11
|
+
$size-factor: 3px;
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @file 全局能力的配置与获取
|
|
7
|
-
* 文档地址:https://doc.quickapp.cn/tutorial/framework/optimization-skills.html#%E4%BD%BF%E7%94%A8-globaljs
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
function getGlobalRef() {
|
|
11
|
-
return Object.getPrototypeOf(global) || global
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const quickappGlobal = getGlobalRef()
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 设置全局(被APP与Page共享)数据;
|
|
18
|
-
* @param key {string}
|
|
19
|
-
* @param val {*}
|
|
20
|
-
*/
|
|
21
|
-
function setGlobalData(key, val) {
|
|
22
|
-
quickappGlobal[key] = val
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 获取全局(被APP与Page共享)数据;
|
|
27
|
-
* @param key {string}
|
|
28
|
-
* @return {*}
|
|
29
|
-
*/
|
|
30
|
-
function getGlobalData(key) {
|
|
31
|
-
return quickappGlobal[key]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 两个方法默认定义在全局
|
|
35
|
-
setGlobalData('setGlobalData', setGlobalData)
|
|
36
|
-
setGlobalData('getGlobalData', getGlobalData)
|
|
37
|
-
|
|
38
|
-
export { setGlobalData, getGlobalData }
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @file 全局能力的配置与获取
|
|
7
|
+
* 文档地址:https://doc.quickapp.cn/tutorial/framework/optimization-skills.html#%E4%BD%BF%E7%94%A8-globaljs
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
function getGlobalRef() {
|
|
11
|
+
return Object.getPrototypeOf(global) || global
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const quickappGlobal = getGlobalRef()
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 设置全局(被APP与Page共享)数据;
|
|
18
|
+
* @param key {string}
|
|
19
|
+
* @param val {*}
|
|
20
|
+
*/
|
|
21
|
+
function setGlobalData(key, val) {
|
|
22
|
+
quickappGlobal[key] = val
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 获取全局(被APP与Page共享)数据;
|
|
27
|
+
* @param key {string}
|
|
28
|
+
* @return {*}
|
|
29
|
+
*/
|
|
30
|
+
function getGlobalData(key) {
|
|
31
|
+
return quickappGlobal[key]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 两个方法默认定义在全局
|
|
35
|
+
setGlobalData('setGlobalData', setGlobalData)
|
|
36
|
+
setGlobalData('getGlobalData', getGlobalData)
|
|
37
|
+
|
|
38
|
+
export { setGlobalData, getGlobalData }
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import $fetch from '@system.fetch'
|
|
7
|
-
import $utils from './utils'
|
|
8
|
-
|
|
9
|
-
Promise.prototype.finally = function (callback) {
|
|
10
|
-
const P = this.constructor
|
|
11
|
-
return this.then(
|
|
12
|
-
(value) => P.resolve(callback()).then(() => value),
|
|
13
|
-
(reason) =>
|
|
14
|
-
P.resolve(callback()).then(() => {
|
|
15
|
-
throw reason
|
|
16
|
-
})
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function requestHandle(params) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
$fetch
|
|
23
|
-
.fetch({
|
|
24
|
-
url: params.url,
|
|
25
|
-
method: params.method,
|
|
26
|
-
data: params.data,
|
|
27
|
-
})
|
|
28
|
-
.then((response) => {
|
|
29
|
-
const result = response.data
|
|
30
|
-
const content = JSON.parse(result.data)
|
|
31
|
-
/* @desc: 可跟具体不同业务接口数据,返回你所需要的部分,使得使用尽可能便捷 */
|
|
32
|
-
content.success ? resolve(content.value) : resolve(content.message)
|
|
33
|
-
})
|
|
34
|
-
.catch((error, code) => {
|
|
35
|
-
console.log(`🐛 request fail, code = ${code}`)
|
|
36
|
-
reject(error)
|
|
37
|
-
})
|
|
38
|
-
.finally(() => {
|
|
39
|
-
console.log(`✔️ request @${params.url} has been completed.`)
|
|
40
|
-
resolve()
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default {
|
|
46
|
-
post: function (url, params) {
|
|
47
|
-
return requestHandle({
|
|
48
|
-
method: 'post',
|
|
49
|
-
url: url,
|
|
50
|
-
data: params,
|
|
51
|
-
})
|
|
52
|
-
},
|
|
53
|
-
get: function (url, params) {
|
|
54
|
-
return requestHandle({
|
|
55
|
-
method: 'get',
|
|
56
|
-
url: $utils.queryString(url, params),
|
|
57
|
-
})
|
|
58
|
-
},
|
|
59
|
-
put: function (url, params) {
|
|
60
|
-
return requestHandle({
|
|
61
|
-
method: 'put',
|
|
62
|
-
url: url,
|
|
63
|
-
data: params,
|
|
64
|
-
})
|
|
65
|
-
},
|
|
66
|
-
// 如果,method 您需要更多类型,可自行添加更多方法;
|
|
67
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import $fetch from '@system.fetch'
|
|
7
|
+
import $utils from './utils'
|
|
8
|
+
|
|
9
|
+
Promise.prototype.finally = function (callback) {
|
|
10
|
+
const P = this.constructor
|
|
11
|
+
return this.then(
|
|
12
|
+
(value) => P.resolve(callback()).then(() => value),
|
|
13
|
+
(reason) =>
|
|
14
|
+
P.resolve(callback()).then(() => {
|
|
15
|
+
throw reason
|
|
16
|
+
})
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function requestHandle(params) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
$fetch
|
|
23
|
+
.fetch({
|
|
24
|
+
url: params.url,
|
|
25
|
+
method: params.method,
|
|
26
|
+
data: params.data,
|
|
27
|
+
})
|
|
28
|
+
.then((response) => {
|
|
29
|
+
const result = response.data
|
|
30
|
+
const content = JSON.parse(result.data)
|
|
31
|
+
/* @desc: 可跟具体不同业务接口数据,返回你所需要的部分,使得使用尽可能便捷 */
|
|
32
|
+
content.success ? resolve(content.value) : resolve(content.message)
|
|
33
|
+
})
|
|
34
|
+
.catch((error, code) => {
|
|
35
|
+
console.log(`🐛 request fail, code = ${code}`)
|
|
36
|
+
reject(error)
|
|
37
|
+
})
|
|
38
|
+
.finally(() => {
|
|
39
|
+
console.log(`✔️ request @${params.url} has been completed.`)
|
|
40
|
+
resolve()
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
post: function (url, params) {
|
|
47
|
+
return requestHandle({
|
|
48
|
+
method: 'post',
|
|
49
|
+
url: url,
|
|
50
|
+
data: params,
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
get: function (url, params) {
|
|
54
|
+
return requestHandle({
|
|
55
|
+
method: 'get',
|
|
56
|
+
url: $utils.queryString(url, params),
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
put: function (url, params) {
|
|
60
|
+
return requestHandle({
|
|
61
|
+
method: 'put',
|
|
62
|
+
url: url,
|
|
63
|
+
data: params,
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
// 如果,method 您需要更多类型,可自行添加更多方法;
|
|
67
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import $ajax from '../ajax'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @desc 在实际开发中,您可以将 baseUrl 替换为您的请求地址前缀;
|
|
10
|
-
*
|
|
11
|
-
* 已将 $apis 挂载在 global,您可以通过如下方式,进行调用:
|
|
12
|
-
* $apis.example.getSomeApi().then().catch().finally()
|
|
13
|
-
*
|
|
14
|
-
* 备注:如果您不需要发起请求,删除 apis 目录,以及 app.ux 中引用即可;
|
|
15
|
-
*/
|
|
16
|
-
const baseUrl = 'https://api.exampel.com/'
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
getSomeApi(data) {
|
|
20
|
-
return $ajax.get(`${baseUrl}your-project-api`, data)
|
|
21
|
-
},
|
|
22
|
-
postOtherApi(data) {
|
|
23
|
-
return $ajax.post(`${baseUrl}your-project-api`, data)
|
|
24
|
-
},
|
|
25
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import $ajax from '../ajax'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @desc 在实际开发中,您可以将 baseUrl 替换为您的请求地址前缀;
|
|
10
|
+
*
|
|
11
|
+
* 已将 $apis 挂载在 global,您可以通过如下方式,进行调用:
|
|
12
|
+
* $apis.example.getSomeApi().then().catch().finally()
|
|
13
|
+
*
|
|
14
|
+
* 备注:如果您不需要发起请求,删除 apis 目录,以及 app.ux 中引用即可;
|
|
15
|
+
*/
|
|
16
|
+
const baseUrl = 'https://api.exampel.com/'
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
getSomeApi(data) {
|
|
20
|
+
return $ajax.get(`${baseUrl}your-project-api`, data)
|
|
21
|
+
},
|
|
22
|
+
postOtherApi(data) {
|
|
23
|
+
return $ajax.post(`${baseUrl}your-project-api`, data)
|
|
24
|
+
},
|
|
25
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const files = require.context('.', true, /\.js/)
|
|
7
|
-
const modules = {}
|
|
8
|
-
|
|
9
|
-
files.keys().forEach((key) => {
|
|
10
|
-
if (key === './index.js') {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
modules[key.replace(/(^\.\/|\.js$)/g, '')] = files(key).default
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
export default modules
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const files = require.context('.', true, /\.js/)
|
|
7
|
+
const modules = {}
|
|
8
|
+
|
|
9
|
+
files.keys().forEach((key) => {
|
|
10
|
+
if (key === './index.js') {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
modules[key.replace(/(^\.\/|\.js$)/g, '')] = files(key).default
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export default modules
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 您可以将常用的方法、或系统 API,统一封装,暴露全局,以便各页面、组件调用,而无需 require / import.
|
|
8
|
-
*/
|
|
9
|
-
const prompt = require('@system.prompt')
|
|
10
|
-
|
|
11
|
-
function queryString(url, query) {
|
|
12
|
-
let str = []
|
|
13
|
-
for (let key in query) {
|
|
14
|
-
str.push(key + '=' + query[key])
|
|
15
|
-
}
|
|
16
|
-
let paramStr = str.join('&')
|
|
17
|
-
return paramStr ? `${url}?${paramStr}` : url
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function showToast(message = '', duration = 0) {
|
|
21
|
-
if (!message) return
|
|
22
|
-
prompt.showToast({
|
|
23
|
-
message: message,
|
|
24
|
-
duration,
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default {
|
|
29
|
-
showToast,
|
|
30
|
-
queryString,
|
|
31
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-present, the hapjs-platform Project Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 您可以将常用的方法、或系统 API,统一封装,暴露全局,以便各页面、组件调用,而无需 require / import.
|
|
8
|
+
*/
|
|
9
|
+
const prompt = require('@system.prompt')
|
|
10
|
+
|
|
11
|
+
function queryString(url, query) {
|
|
12
|
+
let str = []
|
|
13
|
+
for (let key in query) {
|
|
14
|
+
str.push(key + '=' + query[key])
|
|
15
|
+
}
|
|
16
|
+
let paramStr = str.join('&')
|
|
17
|
+
return paramStr ? `${url}?${paramStr}` : url
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function showToast(message = '', duration = 0) {
|
|
21
|
+
if (!message) return
|
|
22
|
+
prompt.showToast({
|
|
23
|
+
message: message,
|
|
24
|
+
duration,
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
showToast,
|
|
30
|
+
queryString,
|
|
31
|
+
}
|