@zeewain/3d-avatar-sdk 1.2.1 → 1.2.2
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/README.md +3 -4
- package/dist/assets/Build/webgl.data.unityweb +0 -0
- package/dist/assets/Build/webgl.framework.js.unityweb +0 -0
- package/dist/assets/Build/webgl.wasm.unityweb +0 -0
- package/dist/examples/test-umd/index.html +762 -0
- package/dist/examples/test-vue2/.eslintignore +45 -0
- package/dist/examples/test-vue2/.eslintrc.js +174 -0
- package/dist/examples/test-vue2/.stylelintignore +50 -0
- package/dist/examples/test-vue2/.stylelintrc.js +79 -0
- package/dist/examples/test-vue2/README.md +139 -0
- package/dist/examples/test-vue2/babel.config.js +14 -0
- package/dist/examples/test-vue2/package.json +53 -0
- package/dist/examples/test-vue2/pnpm-lock.yaml +8776 -0
- package/dist/examples/test-vue2/public/index.html +19 -0
- package/dist/examples/test-vue2/setup.js +170 -0
- package/dist/examples/test-vue2/src/App.vue +943 -0
- package/dist/examples/test-vue2/src/components/BroadcastAPI.vue +666 -0
- package/dist/examples/test-vue2/src/components/CameraAPI.vue +414 -0
- package/dist/examples/test-vue2/src/components/GlobalConfig.vue +200 -0
- package/dist/examples/test-vue2/src/components/InfoCards.vue +294 -0
- package/dist/examples/test-vue2/src/components/InitAPI.vue +334 -0
- package/dist/examples/test-vue2/src/components/LogPanel.vue +249 -0
- package/dist/examples/test-vue2/src/components/MotionControlAPI.vue +400 -0
- package/dist/examples/test-vue2/src/components/UnityPreview.vue +201 -0
- package/dist/examples/test-vue2/src/main.js +16 -0
- package/dist/examples/test-vue2/vue.config.js +41 -0
- package/dist/examples/test-vue3/.eslintrc +3 -0
- package/dist/examples/test-vue3/.stylelintignore +3 -0
- package/dist/examples/test-vue3/.stylelintrc +48 -0
- package/dist/examples/test-vue3/README.md +236 -0
- package/dist/examples/test-vue3/env.d.ts +8 -0
- package/dist/examples/test-vue3/index.html +95 -0
- package/dist/examples/test-vue3/package.json +55 -0
- package/dist/examples/test-vue3/pnpm-lock.yaml +4636 -0
- package/dist/examples/test-vue3/setup.js +167 -0
- package/dist/examples/test-vue3/src/App.vue +962 -0
- package/dist/examples/test-vue3/src/components/BroadcastAPI.vue +636 -0
- package/dist/examples/test-vue3/src/components/CameraAPI.vue +376 -0
- package/dist/examples/test-vue3/src/components/GlobalConfig.vue +213 -0
- package/dist/examples/test-vue3/src/components/InfoCards.vue +288 -0
- package/dist/examples/test-vue3/src/components/InitAPI.vue +339 -0
- package/dist/examples/test-vue3/src/components/LogPanel.vue +236 -0
- package/dist/examples/test-vue3/src/components/MotionControlAPI.vue +373 -0
- package/dist/examples/test-vue3/src/components/UnityPreview.vue +189 -0
- package/dist/examples/test-vue3/src/main.ts +12 -0
- package/dist/examples/test-vue3/src/types.ts +9 -0
- package/dist/examples/test-vue3/tsconfig.json +44 -0
- package/dist/examples/test-vue3/tsconfig.node.json +14 -0
- package/dist/examples/test-vue3/vite.config.ts +75 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.es5.js +64 -17
- package/dist/index.es5.umd.js +64 -17
- package/dist/index.esm.js +71 -16
- package/dist/index.umd.cjs +71 -16
- package/package.json +4 -3
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-card class="unity-preview" shadow="hover">
|
|
3
|
+
<template #header>
|
|
4
|
+
<div class="card-header">
|
|
5
|
+
<span>Unity 预览</span>
|
|
6
|
+
<el-tag v-if="sdkStatus.unityLoaded" type="success" size="default">已加载</el-tag>
|
|
7
|
+
<el-tag v-else type="info" size="default">未加载</el-tag>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<div class="unity-container-wrapper" v-loading="sdkStatus.unityLoaded && !sdkStatus.avatarLoaded && loadingProgress === 1" element-loading-text="数字人加载中,请稍候..." element-loading-background="rgba(0, 0, 0, 0)">
|
|
12
|
+
<div id="unity-container" class="unity-container">
|
|
13
|
+
<div v-if="!sdkStatus.unityLoaded" class="unity-tip">
|
|
14
|
+
<i class="el-icon-monitor"></i>
|
|
15
|
+
<p>Unity 内容将在此处加载...</p>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div class="unity-controls">
|
|
21
|
+
<el-button-group>
|
|
22
|
+
<el-button
|
|
23
|
+
type="warning"
|
|
24
|
+
size="default"
|
|
25
|
+
icon="close"
|
|
26
|
+
:disabled="!sdkStatus.avatarLoaded"
|
|
27
|
+
@click="handleUnloadAvatar"
|
|
28
|
+
>
|
|
29
|
+
卸载Avatar
|
|
30
|
+
</el-button>
|
|
31
|
+
<el-button
|
|
32
|
+
type="danger"
|
|
33
|
+
size="default"
|
|
34
|
+
icon="delete"
|
|
35
|
+
:disabled="!sdkStatus.unityLoaded"
|
|
36
|
+
@click="handleDestroySDK"
|
|
37
|
+
>
|
|
38
|
+
销毁实例
|
|
39
|
+
</el-button>
|
|
40
|
+
</el-button-group>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<!-- 加载进度显示 -->
|
|
44
|
+
<div v-if="loadingProgress > 0 && loadingProgress < 1" class="loading-progress">
|
|
45
|
+
<el-progress
|
|
46
|
+
:percentage="Math.round(loadingProgress * 100)"
|
|
47
|
+
:stroke-width="6"
|
|
48
|
+
text-inside
|
|
49
|
+
/>
|
|
50
|
+
<p class="progress-text">Unity 加载中,请稍候...</p>
|
|
51
|
+
</div>
|
|
52
|
+
</el-card>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { defineProps, defineEmits } from 'vue';
|
|
57
|
+
|
|
58
|
+
interface ISDKStatus {
|
|
59
|
+
unityLoaded: boolean;
|
|
60
|
+
avatarLoaded: boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const props = defineProps<{
|
|
64
|
+
sdkStatus: ISDKStatus;
|
|
65
|
+
loadingProgress: number;
|
|
66
|
+
}>();
|
|
67
|
+
|
|
68
|
+
const emit = defineEmits<{
|
|
69
|
+
(e: 'unload-avatar'): void;
|
|
70
|
+
(e: 'destroy-sdk'): void;
|
|
71
|
+
}>();
|
|
72
|
+
|
|
73
|
+
function handleUnloadAvatar() {
|
|
74
|
+
emit('unload-avatar');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function handleDestroySDK() {
|
|
78
|
+
emit('destroy-sdk');
|
|
79
|
+
}
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style lang="scss" scoped>
|
|
83
|
+
// Unity预览
|
|
84
|
+
.unity-preview {
|
|
85
|
+
position: relative;
|
|
86
|
+
display: flex;
|
|
87
|
+
width: 100%;
|
|
88
|
+
height: 100%;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
.card-header {
|
|
92
|
+
display: flex;
|
|
93
|
+
justify-content: space-between;
|
|
94
|
+
align-items: center;
|
|
95
|
+
font-weight: 600;
|
|
96
|
+
}
|
|
97
|
+
:deep(.el-card__body) {
|
|
98
|
+
display: flex;
|
|
99
|
+
width: 100%;
|
|
100
|
+
height: 100%;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
box-sizing: border-box;
|
|
103
|
+
}
|
|
104
|
+
.unity-container-wrapper {
|
|
105
|
+
position: relative;
|
|
106
|
+
width: 100%;
|
|
107
|
+
max-height: 600px; // 添加最大高度限制
|
|
108
|
+
margin-bottom: 15px;
|
|
109
|
+
overflow: hidden; // 防止内容溢出
|
|
110
|
+
flex: 1;
|
|
111
|
+
}
|
|
112
|
+
.unity-container {
|
|
113
|
+
position: relative;
|
|
114
|
+
width: 100%;
|
|
115
|
+
height: 100%;
|
|
116
|
+
max-height: 100%; // 确保不超过父容器
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
background-color: #000;
|
|
119
|
+
border-radius: 4px;
|
|
120
|
+
}
|
|
121
|
+
.unity-tip {
|
|
122
|
+
position: absolute;
|
|
123
|
+
top: 50%;
|
|
124
|
+
left: 50%;
|
|
125
|
+
color: white; // 确保在黑色背景上文字可见
|
|
126
|
+
text-align: center;
|
|
127
|
+
transform: translate(-50%, -50%);
|
|
128
|
+
i {
|
|
129
|
+
margin-bottom: 10px;
|
|
130
|
+
font-size: 48px;
|
|
131
|
+
}
|
|
132
|
+
p {
|
|
133
|
+
margin: 0;
|
|
134
|
+
font-size: 14px;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
.unity-controls {
|
|
138
|
+
display: flex;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
padding-top: 10px;
|
|
141
|
+
}
|
|
142
|
+
.loading-progress {
|
|
143
|
+
position: absolute;
|
|
144
|
+
top: 50%;
|
|
145
|
+
left: 50%;
|
|
146
|
+
width: 80%;
|
|
147
|
+
transform: translate(-50%, -50%);
|
|
148
|
+
text-align: center;
|
|
149
|
+
z-index: 10;
|
|
150
|
+
.progress-text {
|
|
151
|
+
color: white;
|
|
152
|
+
margin-top: 10px;
|
|
153
|
+
font-size: 14px;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 移动端优化
|
|
159
|
+
@media screen and (width <= 768px) {
|
|
160
|
+
.unity-preview {
|
|
161
|
+
.unity-container-wrapper {
|
|
162
|
+
height: 250px;
|
|
163
|
+
max-height: 250px; // 确保移动端不会超过设定高度
|
|
164
|
+
flex: none;
|
|
165
|
+
overflow: hidden; // 防止内容溢出
|
|
166
|
+
}
|
|
167
|
+
.unity-controls {
|
|
168
|
+
.el-button-group {
|
|
169
|
+
display: flex;
|
|
170
|
+
flex-direction: column;
|
|
171
|
+
.el-button {
|
|
172
|
+
margin: 2px 0;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 平板端优化
|
|
180
|
+
@media screen and (width <= 992px) and (width > 768px) {
|
|
181
|
+
.unity-preview {
|
|
182
|
+
.unity-container-wrapper {
|
|
183
|
+
height: 300px; // 平板端适中高度
|
|
184
|
+
max-height: 300px; // 确保平板端不会超过设定高度
|
|
185
|
+
overflow: hidden; // 防止内容溢出
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "Node",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"jsx": "preserve",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"lib": [
|
|
14
|
+
"ESNext",
|
|
15
|
+
"DOM"
|
|
16
|
+
],
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"baseUrl": "./",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": [
|
|
21
|
+
"src/*"
|
|
22
|
+
],
|
|
23
|
+
"#/*": [
|
|
24
|
+
"typings/*"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"types": [
|
|
28
|
+
"vite/client", // https://cn.vitejs.dev/guide/features.html#typescript-compiler-options
|
|
29
|
+
"element-plus/global",
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"include": [
|
|
33
|
+
"src/**/*.ts",
|
|
34
|
+
"src/**/*.d.ts",
|
|
35
|
+
"src/**/*.tsx",
|
|
36
|
+
"src/**/*.vue",
|
|
37
|
+
"typings/**/*.d.ts"
|
|
38
|
+
],
|
|
39
|
+
"references": [
|
|
40
|
+
{
|
|
41
|
+
"path": "./tsconfig.node.json"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { URL, fileURLToPath } from 'node:url';
|
|
3
|
+
import { defineConfig, loadEnv } from 'vite';
|
|
4
|
+
import vue from '@vitejs/plugin-vue';
|
|
5
|
+
import AutoImport from 'unplugin-auto-import/vite';
|
|
6
|
+
import Components from 'unplugin-vue-components/vite';
|
|
7
|
+
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
|
8
|
+
|
|
9
|
+
// https://vitejs.dev/config/
|
|
10
|
+
export default defineConfig(({ mode, command }) =>
|
|
11
|
+
{
|
|
12
|
+
// 加载环境变量
|
|
13
|
+
const env = loadEnv(mode, process.cwd(), '');
|
|
14
|
+
|
|
15
|
+
// 检查是否使用本地SDK开发模式
|
|
16
|
+
const useLocalSDK = env.VITE_USE_LOCAL_SDK === 'true';
|
|
17
|
+
const localSDKPath = resolve(fileURLToPath(new URL('.', import.meta.url)), '../../dist/index.esm.js');
|
|
18
|
+
|
|
19
|
+
console.log('🔧 Vite 配置信息:');
|
|
20
|
+
console.log(` - 运行模式: ${mode}`);
|
|
21
|
+
console.log(` - 使用本地 SDK: ${useLocalSDK ? '✅ 是' : '❌ 否'}`);
|
|
22
|
+
if (useLocalSDK)
|
|
23
|
+
{
|
|
24
|
+
console.log(` - 本地 SDK 路径: ${localSDKPath}`);
|
|
25
|
+
console.log(' - 运行模式: 开发模式');
|
|
26
|
+
}
|
|
27
|
+
else
|
|
28
|
+
{
|
|
29
|
+
console.log(' - 运行模式: npm包模式');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
base: env.VITE_PUBLIC_PATH || './',
|
|
34
|
+
plugins: [
|
|
35
|
+
vue(),
|
|
36
|
+
AutoImport({
|
|
37
|
+
resolvers: [ElementPlusResolver()],
|
|
38
|
+
imports: [
|
|
39
|
+
'vue',
|
|
40
|
+
'@vueuse/core'
|
|
41
|
+
],
|
|
42
|
+
dts: true
|
|
43
|
+
}),
|
|
44
|
+
Components({
|
|
45
|
+
resolvers: [ElementPlusResolver()],
|
|
46
|
+
dts: true
|
|
47
|
+
})
|
|
48
|
+
],
|
|
49
|
+
resolve: {
|
|
50
|
+
alias: {
|
|
51
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
52
|
+
// 如果启用本地开发模式,将 SDK 指向本地构建版本
|
|
53
|
+
...(useLocalSDK && {
|
|
54
|
+
'@zeewain/3d-avatar-sdk': localSDKPath
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
server: {
|
|
59
|
+
open: true,
|
|
60
|
+
port: 20054,
|
|
61
|
+
proxy: {
|
|
62
|
+
'/proxy': {
|
|
63
|
+
target: env.VITE_APP_API_BASEURL,
|
|
64
|
+
changeOrigin: command === 'serve' && env.VITE_OPEN_PROXY === 'true',
|
|
65
|
+
rewrite: path => path.replace(/\/proxy/, '')
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
},
|
|
70
|
+
build: {
|
|
71
|
+
outDir: mode === 'production' ? 'dist' : `dist-${mode}`,
|
|
72
|
+
sourcemap: false,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -956,13 +956,6 @@ declare class BroadcastService extends UnityBaseService<BroadcastOperationType>
|
|
|
956
956
|
destroy(): void;
|
|
957
957
|
/** 全局回调函数名称 */
|
|
958
958
|
protected get callbackFunctionName(): string;
|
|
959
|
-
/**
|
|
960
|
-
* 获取API基础URL
|
|
961
|
-
* @returns string 返回当前环境的API基础URL
|
|
962
|
-
* @description 根据当前环境配置获取API基础URL
|
|
963
|
-
* @private
|
|
964
|
-
*/
|
|
965
|
-
private getApiBaseUrl;
|
|
966
959
|
/**
|
|
967
960
|
* 获取播报API路径
|
|
968
961
|
* @param type - 播报类型
|
|
@@ -987,6 +980,13 @@ declare class BroadcastService extends UnityBaseService<BroadcastOperationType>
|
|
|
987
980
|
* @private
|
|
988
981
|
*/
|
|
989
982
|
private handleError;
|
|
983
|
+
/**
|
|
984
|
+
* 处理播报错误
|
|
985
|
+
* @param errorCode - 错误码
|
|
986
|
+
* @description 处理播报过程中的错误
|
|
987
|
+
* @private
|
|
988
|
+
*/
|
|
989
|
+
private handleBroadcastError;
|
|
990
990
|
}
|
|
991
991
|
|
|
992
992
|
/**
|
|
@@ -1020,7 +1020,7 @@ declare enum NetworkErrorCode {
|
|
|
1020
1020
|
CONNECTION_FAILED = 1001,
|
|
1021
1021
|
/** 请求超时 */
|
|
1022
1022
|
REQUEST_TIMEOUT = 1002,
|
|
1023
|
-
/**
|
|
1023
|
+
/** 服务错误 */
|
|
1024
1024
|
SERVER_ERROR = 1003,
|
|
1025
1025
|
/** 未授权访问 */
|
|
1026
1026
|
UNAUTHORIZED = 1004
|
|
@@ -1040,7 +1040,13 @@ declare enum OperationErrorCode {
|
|
|
1040
1040
|
/** 操作超时 */
|
|
1041
1041
|
OPERATION_TIMEOUT = 2004,
|
|
1042
1042
|
/** 操作被取消 */
|
|
1043
|
-
OPERATION_CANCELLED = 2005
|
|
1043
|
+
OPERATION_CANCELLED = 2005,
|
|
1044
|
+
/** 用户权益额度不存在 */
|
|
1045
|
+
BROADCAST_EQUITY_NOT_EXIST = 2006,
|
|
1046
|
+
/** 用户权益额度不足 */
|
|
1047
|
+
BROADCAST_EQUITY_NOT_ENOUGH = 2007,
|
|
1048
|
+
/** 用户权益额度冻结失败 */
|
|
1049
|
+
BROADCAST_EQUITY_FREEZE_FAILED = 2008
|
|
1044
1050
|
}
|
|
1045
1051
|
/**
|
|
1046
1052
|
* 资源错误码 (3xxx)
|
package/dist/index.es5.js
CHANGED
|
@@ -12147,7 +12147,7 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
12147
12147
|
NetworkErrorCode[NetworkErrorCode["CONNECTION_FAILED"] = 1001] = "CONNECTION_FAILED";
|
|
12148
12148
|
/** 请求超时 */
|
|
12149
12149
|
NetworkErrorCode[NetworkErrorCode["REQUEST_TIMEOUT"] = 1002] = "REQUEST_TIMEOUT";
|
|
12150
|
-
/**
|
|
12150
|
+
/** 服务错误 */
|
|
12151
12151
|
NetworkErrorCode[NetworkErrorCode["SERVER_ERROR"] = 1003] = "SERVER_ERROR";
|
|
12152
12152
|
/** 未授权访问 */
|
|
12153
12153
|
NetworkErrorCode[NetworkErrorCode["UNAUTHORIZED"] = 1004] = "UNAUTHORIZED";
|
|
@@ -12169,6 +12169,12 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
12169
12169
|
OperationErrorCode[OperationErrorCode["OPERATION_TIMEOUT"] = 2004] = "OPERATION_TIMEOUT";
|
|
12170
12170
|
/** 操作被取消 */
|
|
12171
12171
|
OperationErrorCode[OperationErrorCode["OPERATION_CANCELLED"] = 2005] = "OPERATION_CANCELLED";
|
|
12172
|
+
/** 用户权益额度不存在 */
|
|
12173
|
+
OperationErrorCode[OperationErrorCode["BROADCAST_EQUITY_NOT_EXIST"] = 2006] = "BROADCAST_EQUITY_NOT_EXIST";
|
|
12174
|
+
/** 用户权益额度不足 */
|
|
12175
|
+
OperationErrorCode[OperationErrorCode["BROADCAST_EQUITY_NOT_ENOUGH"] = 2007] = "BROADCAST_EQUITY_NOT_ENOUGH";
|
|
12176
|
+
/** 用户权益额度冻结失败 */
|
|
12177
|
+
OperationErrorCode[OperationErrorCode["BROADCAST_EQUITY_FREEZE_FAILED"] = 2008] = "BROADCAST_EQUITY_FREEZE_FAILED";
|
|
12172
12178
|
})(exports.OperationErrorCode || (exports.OperationErrorCode = {}));
|
|
12173
12179
|
/**
|
|
12174
12180
|
* 资源错误码 (3xxx)
|
|
@@ -12254,6 +12260,15 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
12254
12260
|
}, _a[exports.OperationErrorCode.OPERATION_CANCELLED] = {
|
|
12255
12261
|
category: exports.ErrorCategory.OPERATION,
|
|
12256
12262
|
message: '操作被取消'
|
|
12263
|
+
}, _a[exports.OperationErrorCode.BROADCAST_EQUITY_NOT_EXIST] = {
|
|
12264
|
+
category: exports.ErrorCategory.OPERATION,
|
|
12265
|
+
message: '用户权益额度不存在'
|
|
12266
|
+
}, _a[exports.OperationErrorCode.BROADCAST_EQUITY_NOT_ENOUGH] = {
|
|
12267
|
+
category: exports.ErrorCategory.OPERATION,
|
|
12268
|
+
message: '用户权益额度不足'
|
|
12269
|
+
}, _a[exports.OperationErrorCode.BROADCAST_EQUITY_FREEZE_FAILED] = {
|
|
12270
|
+
category: exports.ErrorCategory.OPERATION,
|
|
12271
|
+
message: '用户权益额度冻结失败'
|
|
12257
12272
|
},
|
|
12258
12273
|
// 资源错误
|
|
12259
12274
|
_a[exports.ResourceErrorCode.LOAD_FAILED] = {
|
|
@@ -12851,7 +12866,7 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
12851
12866
|
console.warn("[Unity Warning] ".concat(message), data);
|
|
12852
12867
|
};
|
|
12853
12868
|
SimpleLogger.prototype.error = function (message, error, data) {
|
|
12854
|
-
console.error("[Unity Error] ".concat(message), error, data);
|
|
12869
|
+
console.error("[Unity Error] ".concat(message), error, error instanceof SDKError ? error.code : null, data);
|
|
12855
12870
|
};
|
|
12856
12871
|
return SimpleLogger;
|
|
12857
12872
|
}();
|
|
@@ -13335,6 +13350,7 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
13335
13350
|
withModule = true;
|
|
13336
13351
|
}
|
|
13337
13352
|
if (((_a = this.config) === null || _a === void 0 ? void 0 : _a.env) === 'custom' && ((_b = this.config) === null || _b === void 0 ? void 0 : _b.apiUrl)) {
|
|
13353
|
+
// 如果环境为自定义,则直接返回配置的API,无需添加模块路径
|
|
13338
13354
|
return this.config.apiUrl;
|
|
13339
13355
|
}
|
|
13340
13356
|
return ((_d = getEnvConfig(((_c = this.config) === null || _c === void 0 ? void 0 : _c.env) || 'prod', withModule)) === null || _d === void 0 ? void 0 : _d.apiBaseUrl) || '';
|
|
@@ -13827,6 +13843,9 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
13827
13843
|
this.logger.debug('Broadcast stopped callback triggered');
|
|
13828
13844
|
break;
|
|
13829
13845
|
}
|
|
13846
|
+
} else {
|
|
13847
|
+
var error = SDKError.createFromUnityError(code, "Unity operation '".concat(operation, "' failed: ").concat(message));
|
|
13848
|
+
this.handleError(error);
|
|
13830
13849
|
}
|
|
13831
13850
|
};
|
|
13832
13851
|
/**
|
|
@@ -13900,7 +13919,7 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
13900
13919
|
_c.label = 2;
|
|
13901
13920
|
case 2:
|
|
13902
13921
|
_c.trys.push([2, 4,, 5]);
|
|
13903
|
-
apiUrl = "".concat(
|
|
13922
|
+
apiUrl = "".concat(ConfigManager.getInstance().getApiBaseUrl(true)).concat(this.getBroadcastApiPath(params.type));
|
|
13904
13923
|
requestBody = {
|
|
13905
13924
|
humanCode: params.humanCode,
|
|
13906
13925
|
speed: params.speed,
|
|
@@ -13937,7 +13956,7 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
13937
13956
|
var response = JSON.parse(event.data);
|
|
13938
13957
|
// 错误处理
|
|
13939
13958
|
if (response.code !== 0) {
|
|
13940
|
-
_this.
|
|
13959
|
+
_this.handleBroadcastError(response.code);
|
|
13941
13960
|
return;
|
|
13942
13961
|
}
|
|
13943
13962
|
// 流式播报
|
|
@@ -13976,7 +13995,10 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
13976
13995
|
},
|
|
13977
13996
|
onerror: function onerror(error) {
|
|
13978
13997
|
_this.logger.error('Broadcast stream error', error);
|
|
13979
|
-
|
|
13998
|
+
var sdkError = new SDKError(exports.OperationErrorCode.OPERATION_FAILED, '服务出错了', error);
|
|
13999
|
+
_this.handleError(sdkError);
|
|
14000
|
+
// 必须抛出错误,否则会循环重试请求
|
|
14001
|
+
throw new Error("\u670D\u52A1\u51FA\u9519\u4E86".concat(sdkError.message));
|
|
13980
14002
|
}
|
|
13981
14003
|
})];
|
|
13982
14004
|
case 3:
|
|
@@ -14148,16 +14170,6 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
14148
14170
|
enumerable: false,
|
|
14149
14171
|
configurable: true
|
|
14150
14172
|
});
|
|
14151
|
-
/**
|
|
14152
|
-
* 获取API基础URL
|
|
14153
|
-
* @returns string 返回当前环境的API基础URL
|
|
14154
|
-
* @description 根据当前环境配置获取API基础URL
|
|
14155
|
-
* @private
|
|
14156
|
-
*/
|
|
14157
|
-
BroadcastService.prototype.getApiBaseUrl = function () {
|
|
14158
|
-
var configManager = ConfigManager.getInstance();
|
|
14159
|
-
return configManager.getApiBaseUrl();
|
|
14160
|
-
};
|
|
14161
14173
|
/**
|
|
14162
14174
|
* 获取播报API路径
|
|
14163
14175
|
* @param type - 播报类型
|
|
@@ -14167,10 +14179,19 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
14167
14179
|
* @private
|
|
14168
14180
|
*/
|
|
14169
14181
|
BroadcastService.prototype.getBroadcastApiPath = function (type) {
|
|
14182
|
+
var env = ConfigManager.getInstance().getEnv();
|
|
14170
14183
|
switch (type) {
|
|
14171
14184
|
case exports.BroadcastType.TEXT:
|
|
14185
|
+
// 临时处理,开发和测试环境使用新接口
|
|
14186
|
+
if (env === 'dev' || env === 'test') {
|
|
14187
|
+
return '/aiep-openapi/avatar-interaction/v1/broadcast/text';
|
|
14188
|
+
}
|
|
14172
14189
|
return '/dh-talker/user/agent/broadcast/text';
|
|
14173
14190
|
case exports.BroadcastType.AUDIO:
|
|
14191
|
+
// 临时处理,开发和测试环境使用新接口
|
|
14192
|
+
if (env === 'dev' || env === 'test') {
|
|
14193
|
+
return '/aiep-openapi/avatar-interaction/v1/broadcast/audio';
|
|
14194
|
+
}
|
|
14174
14195
|
return '/dh-talker/user/agent/broadcast/customAudio';
|
|
14175
14196
|
default:
|
|
14176
14197
|
throw new SDKError(exports.ConfigErrorCode.INVALID_CONFIG, "\u672A\u77E5\u7684\u64AD\u62A5\u7C7B\u578B: ".concat(type));
|
|
@@ -14211,6 +14232,31 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
14211
14232
|
// 触发错误回调
|
|
14212
14233
|
(_b = (_a = this.callbacks).onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
14213
14234
|
};
|
|
14235
|
+
/**
|
|
14236
|
+
* 处理播报错误
|
|
14237
|
+
* @param errorCode - 错误码
|
|
14238
|
+
* @description 处理播报过程中的错误
|
|
14239
|
+
* @private
|
|
14240
|
+
*/
|
|
14241
|
+
BroadcastService.prototype.handleBroadcastError = function (errorCode) {
|
|
14242
|
+
// 用户权益额度不存在错误码 14001
|
|
14243
|
+
// 用户权益额度不足错误码 14002
|
|
14244
|
+
// 用户权益额度冻结失败 14003
|
|
14245
|
+
switch (errorCode) {
|
|
14246
|
+
case 14001:
|
|
14247
|
+
this.handleError(new SDKError(exports.OperationErrorCode.BROADCAST_EQUITY_NOT_EXIST, '用户权益额度不存在'));
|
|
14248
|
+
break;
|
|
14249
|
+
case 14002:
|
|
14250
|
+
this.handleError(new SDKError(exports.OperationErrorCode.BROADCAST_EQUITY_NOT_ENOUGH, '用户权益额度不足'));
|
|
14251
|
+
break;
|
|
14252
|
+
case 14003:
|
|
14253
|
+
this.handleError(new SDKError(exports.OperationErrorCode.BROADCAST_EQUITY_FREEZE_FAILED, '用户权益额度冻结失败'));
|
|
14254
|
+
break;
|
|
14255
|
+
default:
|
|
14256
|
+
this.handleError(new SDKError(exports.OperationErrorCode.OPERATION_FAILED, '播报服务错误'));
|
|
14257
|
+
break;
|
|
14258
|
+
}
|
|
14259
|
+
};
|
|
14214
14260
|
return BroadcastService;
|
|
14215
14261
|
}(UnityBaseService);
|
|
14216
14262
|
|
|
@@ -14349,11 +14395,12 @@ var ZEEAvatarSDKLib = (function (exports) {
|
|
|
14349
14395
|
* @protected
|
|
14350
14396
|
*/
|
|
14351
14397
|
ZEEAvatarLoader.prototype.initGlobalConfig = function () {
|
|
14352
|
-
var params =
|
|
14398
|
+
var params = {
|
|
14353
14399
|
token: ConfigManager.getInstance().getToken(),
|
|
14354
14400
|
apiBaseUrl: ConfigManager.getInstance().getApiBaseUrl(false),
|
|
14401
|
+
idleMotionList: ConfigManager.getInstance().getConfig().idleMotionList,
|
|
14355
14402
|
assetsUrl: ConfigManager.getInstance().getConfig().assetsUrl
|
|
14356
|
-
}
|
|
14403
|
+
};
|
|
14357
14404
|
console.warn('[ Send Unity message ]: AvatarSDK.InitializeConfig', params);
|
|
14358
14405
|
this.unityInstance.SendMessage('AvatarSDK', 'InitializeConfig', JSON.stringify(params));
|
|
14359
14406
|
};
|