Skip to content

Commit 9ed09d2

Browse files
jackshen310shenxiaojie.316
andauthored
feat: init coze-js-uniapp for vue2 version (#132)
Co-authored-by: shenxiaojie.316 <shenxiaojie.316@bytedance.com>
1 parent 6322803 commit 9ed09d2

26 files changed

Lines changed: 16208 additions & 19 deletions

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Find usage examples for each package in the [examples](./examples) directory:
2323
- [coze-js-web](./examples/coze-js-web) - React Web Demo for @coze/api, [Preview](https://coze-js-web-example.surge.sh/)
2424
- [coze-js-taro](./examples/coze-js-taro) - Taro4 Mini Program Demo for @coze/taro-api
2525
- [coze-js-taro3](./examples/coze-js-taro3) - Taro3 Mini Program Demo for @coze/taro-api
26+
- [coze-js-uniapp](./examples/coze-js-uniapp) - UniApp(V3) Mini Program Demo for @coze/uniapp-api
27+
- [coze-js-uniapp-v2](./examples/coze-js-uniapp-v2) - UniApp(V2) Mini Program Demo for @coze/api
2628
- [realtime-console](./examples/realtime-console) - Full Console Demo for @coze/realtime-api, [Preview](https://coze.cn/open-platform/realtime/playground)
2729
- [realtime-call-up](./examples/realtime-call-up) - Sample Call Up Demo for @coze/realtime-api
2830
- [realtime-quickstart-react](./examples/realtime-quickstart-react) - Quickstart React Demo for @coze/realtime-api

README.zh-CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
- [coze-js-web](./examples/coze-js-web) - @coze/api 的 React Web 使用示例,[预览](https://coze-js-web-example.surge.sh/)
2222
- [coze-js-taro](./examples/coze-js-taro) - @coze/taro-api Taro4 小程序示例
2323
- [coze-js-taro3](./examples/coze-js-taro3) - @coze/taro-api Taro3 小程序示例
24+
- [coze-js-uniapp](./examples/coze-js-uniapp) - UniApp(V3) 小程序示例
25+
- [coze-js-uniapp-v2](./examples/coze-js-uniapp-v2) - UniApp(V2) 小程序示例
2426
- [realtime-console](./examples/realtime-console) - @coze/realtime-api 完整版实时语音示例,[预览](https://coze.cn/open-platform/realtime/playground)
2527
- [realtime-call-up](./examples/realtime-call-up) - @coze/realtime-api 简化版实时语音示例
2628
- [realtime-quickstart-react](./examples/realtime-quickstart-react) - @coze/realtime-api 快速入门 React 示例

common/config/subspaces/default/common-versions.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@
7575
"@tarojs/webpack5-runner": ["4.0.7", "3.6.35"],
7676
"babel-preset-taro": ["4.0.7", "3.6.35"],
7777
"@coze/api": ["workspace:*", "^1.0.17"],
78-
"vite": ["5.2.8", "^4.2.0"]
78+
"vite": ["5.2.8", "^4.2.0"],
79+
"@dcloudio/uni-app": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
80+
"@dcloudio/uni-app-plus": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
81+
"@dcloudio/uni-h5": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
82+
"@dcloudio/uni-mp-alipay": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
83+
"@dcloudio/uni-mp-baidu": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
84+
"@dcloudio/uni-mp-jd": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
85+
"@dcloudio/uni-mp-kuaishou": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
86+
"@dcloudio/uni-mp-lark": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
87+
"@dcloudio/uni-mp-qq": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
88+
"@dcloudio/uni-mp-toutiao": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
89+
"@dcloudio/uni-mp-weixin": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
90+
"@dcloudio/uni-mp-xhs": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
91+
"@dcloudio/uni-quickapp-webview": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
92+
"@dcloudio/types": ["^3.4.8", "^3.3.2"],
93+
"@dcloudio/uni-automator": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
94+
"@dcloudio/uni-cli-shared": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
95+
"@dcloudio/uni-stacktracey": ["3.0.0-4030620241128001", "^2.0.2-4060620250520001"],
96+
"vue": ["^3.0.0", ">= 2.6.14 < 2.7"]
7997
}
8098
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 25 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
VUE_APP_COZE_TOKEN=your_token
2+
VUE_APP_COZE_BASE_URL=https://api.coze.cn
3+
VUE_APP_COZE_BOT_ID=your_bot_id
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# coze-js-uniapp-v2
2+
3+
## Project setup
4+
```
5+
pnpm install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
pnpm run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
pnpm run build
16+
```
17+
18+
### Customize configuration
19+
See [Configuration Reference](https://cli.vuejs.org/config/).
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const webpack = require('webpack')
2+
const plugins = []
3+
4+
if (process.env.UNI_OPT_TREESHAKINGNG) {
5+
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
6+
}
7+
8+
if (
9+
(
10+
process.env.UNI_PLATFORM === 'app-plus' &&
11+
process.env.UNI_USING_V8
12+
) ||
13+
(
14+
process.env.UNI_PLATFORM === 'h5' &&
15+
process.env.UNI_H5_BROWSER === 'builtin'
16+
)
17+
) {
18+
const path = require('path')
19+
20+
const isWin = /^win/.test(process.platform)
21+
22+
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
23+
24+
const input = normalizePath(process.env.UNI_INPUT_DIR)
25+
try {
26+
plugins.push([
27+
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
28+
{
29+
file (file) {
30+
file = normalizePath(file)
31+
if (file.indexOf(input) === 0) {
32+
return path.relative(input, file)
33+
}
34+
return false
35+
}
36+
}
37+
])
38+
} catch (e) { }
39+
}
40+
41+
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
42+
process.UNI_LIBRARIES.forEach(libraryName => {
43+
plugins.push([
44+
'import',
45+
{
46+
'libraryName': libraryName,
47+
'customName': (name) => {
48+
return `${libraryName}/lib/${name}/${name}`
49+
}
50+
}
51+
])
52+
})
53+
54+
if (process.env.UNI_PLATFORM !== 'h5') {
55+
plugins.push('@babel/plugin-transform-runtime')
56+
}
57+
58+
const config = {
59+
presets: [
60+
[
61+
'@vue/app',
62+
{
63+
modules: webpack.version[0] > 4 ? 'auto' : 'commonjs',
64+
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
65+
}
66+
]
67+
],
68+
plugins
69+
}
70+
71+
const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js'
72+
if (process.env.NODE_ENV === 'production') {
73+
config.overrides = [{
74+
test: UNI_H5_TEST,
75+
compact: true,
76+
}]
77+
} else {
78+
config.ignore = [UNI_H5_TEST]
79+
}
80+
81+
module.exports = config
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"operationSettings": [
3+
{
4+
"operationName": "build",
5+
"outputFolderNames": ["dist"]
6+
}
7+
]
8+
}

0 commit comments

Comments
 (0)