|
@@ -5,17 +5,15 @@
|
|
<div class="title adfac">角色形象<span>*</span></div>
|
|
<div class="title adfac">角色形象<span>*</span></div>
|
|
<div class="upload">
|
|
<div class="upload">
|
|
<div class="sc">
|
|
<div class="sc">
|
|
- <u-upload width="188rpx" height="188rpx"
|
|
|
|
- :fileList="fileList"
|
|
|
|
- @afterRead="afterRead"
|
|
|
|
- @delete="deletePic"
|
|
|
|
- :maxCount="1"
|
|
|
|
- >
|
|
|
|
- <div class="imgs">
|
|
|
|
|
|
+ <div class="imgs" @tap="selectImage">
|
|
|
|
+ <template v-if="!resultUrl">
|
|
<image class="img1" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/0e628447-e818-4f5e-88b4-a2af61b00bbd.png"></image>
|
|
<image class="img1" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/0e628447-e818-4f5e-88b4-a2af61b00bbd.png"></image>
|
|
<image class="img2" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/63556f0a-87ac-4d0e-b034-1b3cc65f4d4d.png"></image>
|
|
<image class="img2" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/63556f0a-87ac-4d0e-b034-1b3cc65f4d4d.png"></image>
|
|
- </div>
|
|
|
|
- </u-upload>
|
|
|
|
|
|
+ </template>
|
|
|
|
+ <template v-else>
|
|
|
|
+ <image class="img1" :src="resultUrl"></image>
|
|
|
|
+ </template>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<div class="text">上传角色形象</div>
|
|
<div class="text">上传角色形象</div>
|
|
</div>
|
|
</div>
|
|
@@ -41,7 +39,17 @@
|
|
<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/ebf6fcea-a7ba-4ba5-8f20-c70b16c7dc3f.png"></image>
|
|
<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/06/03/ebf6fcea-a7ba-4ba5-8f20-c70b16c7dc3f.png"></image>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="zt_btn" @tap="comfirmSure">{{agentId?'编辑角色':'创建角色'}}</div>
|
|
|
|
|
|
+ <div class="zt_btn" @tap="comfirmSure">{{agentId?'编辑角色':'创建角色'}}</div>
|
|
|
|
+ <tt-cropper
|
|
|
|
+ mode="free"
|
|
|
|
+ :imageUrl="imageUrl"
|
|
|
|
+ :width="500"
|
|
|
|
+ :height="500"
|
|
|
|
+ :radius="90"
|
|
|
|
+ :delay="300"
|
|
|
|
+ @cancel="onCancel"
|
|
|
|
+ @confirm="onConfirm"
|
|
|
|
+ ></tt-cropper>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -77,7 +85,9 @@
|
|
"language": "",
|
|
"language": "",
|
|
"deviceId": "",
|
|
"deviceId": "",
|
|
"chatHistoryConf": ""
|
|
"chatHistoryConf": ""
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ imageUrl:'',
|
|
|
|
+ resultUrl:''
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
@@ -105,36 +115,21 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods:{
|
|
methods:{
|
|
- // 删除图片
|
|
|
|
- deletePic(event) {
|
|
|
|
- this.fileList.splice(event.index, 1);
|
|
|
|
- },
|
|
|
|
- // 新增图片
|
|
|
|
- async afterRead(event) {
|
|
|
|
- // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
|
- let lists = [].concat(event.file);
|
|
|
|
- let fileListLen = this.fileList.length;
|
|
|
|
- lists.map((item) => {
|
|
|
|
- this.fileList.push({
|
|
|
|
- ...item,
|
|
|
|
- status: "uploading",
|
|
|
|
- message: "上传中",
|
|
|
|
- });
|
|
|
|
|
|
+ selectImage(){
|
|
|
|
+ uni.chooseImage({
|
|
|
|
+ count: 1,
|
|
|
|
+ sizeType: ['compressed'],
|
|
|
|
+ success: (res) => {
|
|
|
|
+ this.imageUrl = res.tempFilePaths[0];
|
|
|
|
+ }
|
|
});
|
|
});
|
|
- for (let i = 0; i < lists.length; i++) {
|
|
|
|
- const result = await this.uploadFilePromise(lists[i].url);
|
|
|
|
- let item = this.fileList[fileListLen];
|
|
|
|
- this.fileList.splice(
|
|
|
|
- fileListLen,
|
|
|
|
- 1,
|
|
|
|
- Object.assign(item, {
|
|
|
|
- status: "success",
|
|
|
|
- message: "",
|
|
|
|
- url: result,
|
|
|
|
- })
|
|
|
|
- );
|
|
|
|
- fileListLen++;
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ onCancel() {
|
|
|
|
+ this.imageUrl = "";
|
|
|
|
+ },
|
|
|
|
+ async onConfirm(res) {
|
|
|
|
+ this.resultUrl = await this.uploadFilePromise(res.tempFilePath);
|
|
|
|
+ this.imageUrl = "";
|
|
},
|
|
},
|
|
uploadFilePromise(url) {
|
|
uploadFilePromise(url) {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
@@ -188,7 +183,7 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
comfirmSure(){
|
|
comfirmSure(){
|
|
- if(this.fileList.length===0) return this.$showToast('请上传角色头像')
|
|
|
|
|
|
+ if(!this.resultUrl) return this.$showToast('请上传角色头像')
|
|
if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
|
|
if(!this.agentDto.agentName) return this.$showToast('请输入角色昵称')
|
|
if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
|
|
if(this.agentDto.voiceText==='请选择音色') return this.$showToast('请选择音色')
|
|
|
|
|
|
@@ -205,7 +200,7 @@
|
|
dto.langCode = 'zh';
|
|
dto.langCode = 'zh';
|
|
dto.language = '中文';
|
|
dto.language = '中文';
|
|
dto.vllmModelId = 'VLLM_ChatGLMVLLM';
|
|
dto.vllmModelId = 'VLLM_ChatGLMVLLM';
|
|
- if(this.fileList.length) dto.avatar = this.fileList[0].url;
|
|
|
|
|
|
+ dto.avatar = this.resultUrl;
|
|
this.$api.post(this.agentId?`/agent/update/${this.agentId}`:'/agent',dto).then(res=>{
|
|
this.$api.post(this.agentId?`/agent/update/${this.agentId}`:'/agent',dto).then(res=>{
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
this.$showToast(this.agentId?'编辑成功':'创建成功');
|
|
this.$showToast(this.agentId?'编辑成功':'创建成功');
|
|
@@ -218,7 +213,7 @@
|
|
this.$api.get(`/agent/${this.agentId}`).then(res=>{
|
|
this.$api.get(`/agent/${this.agentId}`).then(res=>{
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
if(res.data.code!==0) return this.$showToast(res.data.msg)
|
|
this.agentDto = {...this.agentDto,...res.data.data};
|
|
this.agentDto = {...this.agentDto,...res.data.data};
|
|
- if(this.agentDto.avatar) this.fileList.push({url:this.agentDto.avatar});
|
|
|
|
|
|
+ if(this.agentDto.avatar) this.resultUrl = this.agentDto.avatar;
|
|
if(this.agentDto.systemPrompt) this.showta = true;
|
|
if(this.agentDto.systemPrompt) this.showta = true;
|
|
this.getModelVoiceList();
|
|
this.getModelVoiceList();
|
|
})
|
|
})
|
|
@@ -248,6 +243,9 @@
|
|
bottom: -16rpx !important;
|
|
bottom: -16rpx !important;
|
|
right: -16rpx !important;
|
|
right: -16rpx !important;
|
|
}
|
|
}
|
|
|
|
+ ::v-deep .t-cropper{
|
|
|
|
+ left: 0;
|
|
|
|
+ }
|
|
|
|
|
|
.ph{
|
|
.ph{
|
|
font-family: PingFangSC, PingFang SC;
|
|
font-family: PingFangSC, PingFang SC;
|