提交 4db900f8 编写于 作者: DCloud_JSON's avatar DCloud_JSON

1.0.0

上级 e5cfb4e5
......@@ -4,7 +4,7 @@
"configurations": [{
"app-plus" :
{
"launchtype" : "local"
"launchtype" : "remote"
},
"default" :
{
......@@ -16,7 +16,7 @@
},
"mp-weixin" :
{
"launchtype" : "local"
"launchtype" : "remote"
},
"type" : "uniCloud"
}
......
<template>
<view class="rich-text-box" :class="{'show-cursor':showCursor}">
<template>
<view class="rich-text-box" :class="{'show-cursor':showCursor}" ref="rich-text-box">
<rich-text v-if="nodes&&nodes.length" space="nbsp" :nodes="nodes"></rich-text>
<!-- #ifdef H5 -->
<view class="copy-box" :style="{left,top}">
<text class="copy" @click="copy">复制</text>
<!-- <view v-if="left != '-100px'" class="copy-mask" @click="left = '-100px'"></view> -->
</view>
<!-- #endif -->
</view>
</template>
......@@ -14,19 +20,46 @@
highlight: function(str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
return '<pre class="hljs" style="padding: 5px 8px;margin: 5px 0;overflow: auto;"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
return '<pre class="hljs" style="padding: 5px 8px;margin: 5px 0;overflow: auto;"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
})
export default {
name: "msg",
data() {
return {};
return {
left:"-100px",
top:"-100px"
};
},
mounted() {
// #ifdef H5
// web端限制不选中文字时出现系统右键菜单
let richTextBox = this.$refs['rich-text-box']
if (richTextBox) {
richTextBox.$el.addEventListener('contextmenu', (e) => {
if (!document.getSelection().toString()) {
console.log(e);
this.top = e.y+'px'
this.left = e.x+'px'
console.log(e.x);
console.log(e.y);
e.preventDefault()
}
})
}
document.addEventListener('click',()=>{
this.left = "-100px"
})
// #endif
},
props: {
md: {
......@@ -43,13 +76,24 @@
}
},
computed: {
html() {
// req.body.content 代表md代码
return md.render(this.md + '<span class="cursor">|</span>')
html() {
let html = md.render(this.md + '<span class="cursor">|</span>')
return html
},
nodes() {
return parseHtml(this.html)
}
},
methods:{
// #ifdef H5
copy(){
uni.setClipboardData({
data:this.md,
showToast:false,
})
this.left = "-100px"
}
// #endif
}
}
</script>
......@@ -59,10 +103,10 @@
@import "highlight.js/styles/a11y-dark.css";
/* #ifndef APP-NVUE */
pre.hljs{
.rich-text-box ::v-deep pre.hljs{
padding: 5px 8px;
margin: 5px 0;
overflow: scroll;
overflow: auto;
}
.cursor{
......@@ -84,6 +128,34 @@
opacity: 0.0;
}
}
/* #endif */
/* #endif */
/* #ifdef H5 */
.copy-box{
position: fixed;
}
// .copy-mask{
// background-color: rgba(255,255,255,0.5);
// width: 100vw;
// height: 100vh;
// position: fixed;
// top: 0;
// left: 0;
// z-index: 9;
// }
.copy{
position: fixed;
background-color: #fff;
box-shadow: 0 0 3px #aaa;
padding: 5px;
border-radius: 5px;
z-index: 999;
cursor: pointer;
font-size: 14px;
color: #222;
}
.copy:hover{
color: #00a953;
}
/* #endif */
</style>
\ No newline at end of file
......@@ -71,7 +71,7 @@
"vueVersion" : "3",
"h5" : {
"unipush" : {
"enable" : false
"enable" : true
}
}
}
......@@ -12,7 +12,8 @@
<view class="userInfo">
<image class="avatar" :src="msg.isAi?'../../static/uni-ai.png':'../../static/avatar.png'" mode="widthFix"></image>
</view>
<view class="content">
<view class="content">
<!-- <text class="copy" @click="copy">复制</text> -->
<uni-ai-msg :md="msg.content" :show-cursor="index == msgList.length-1 && msg.isAi && sseIndex"></uni-ai-msg>
</view>
<uni-icons v-if="index == msgList.length-1 && !msg.isAi && msg.state != 100 && msgStateIcon(msg)"
......@@ -155,7 +156,7 @@
fail:()=> {
this.stream = false
uni.showModal({
content: '暂未开通uni-push。不支持此功能',
content: '应用暂未开通uni-push。不支持此功能',
confirmText:"查看详情",
complete(e) {
if(!e.confirm){
......@@ -183,7 +184,8 @@
});
console.log('你暂未开通uni-push。不支持此功能。详情:https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9');
},
success:()=>{
success:(e)=>{
console.log('success',e);
this.changeStream.check = ()=>{}
}
})
......@@ -234,7 +236,7 @@
async send() {
let messages = []
// 复制一份,消息列表数据
let msgs = [...this.msgList]
let msgs = JSON.parse(JSON.stringify(this.msgList))
// 带总结的消息 index
let findIndex = [...msgs].reverse().findIndex(item => item.summarize)
// console.log('findIndex', findIndex)
......@@ -416,18 +418,20 @@
/* #endif */
.page,
.container {
background-color: #efefef;
background-color: #efefef;
/* #ifdef APP-NVUE */
flex: 1;
/* #endif */
/* #ifndef APP-NVUE */
height: 100vh;
/* #endif */
/* #ifdef H5 */
height: calc(100vh - 44px);
/* #endif */
/* #ifdef MP */
height: 100vh;
/* #endif */
flex-direction: column;
align-items: center;
justify-content: center;
......@@ -561,8 +565,25 @@
word-break: break-all;
user-select: text;
cursor: text;
/* #endif */
}
/* #endif */
}
/* #ifndef APP-NVUE */
.content {
display: inline;
}
.content ::v-deep rich-text{
max-width: 550rpx;
overflow: auto;
}
/* #endif */
/* #ifdef H5 */
.content * {
display: inline;
}
/* #endif */
.reverse {
flex-direction: row-reverse;
......@@ -635,7 +656,19 @@
.content {
background-color: #f9f9f9;
position: relative;
}
// .copy {
// color: #888888;
// position: absolute;
// right: 8px;
// top: 8px;
// font-size: 12px;
// cursor:pointer;
// }
// .copy :hover{
// color: #4b9e5f;
// }
.foot-box,
.foot-box-content,
......@@ -717,4 +750,5 @@
}
}
/* #endif */
</style>
\ No newline at end of file
......@@ -7334,7 +7334,7 @@ function S(e2) {
function b(e2) {
return e2 && "string" == typeof e2 ? JSON.parse(e2) : e2;
}
const k = true, T = "mp-weixin", P = b([]), A = T, E = b('{\n "address": [\n "127.0.0.1",\n "192.168.31.184"\n ],\n "debugPort": 9000,\n "initialLaunchType": "local",\n "servePort": 7001,\n "skipFiles": [\n "<node_internals>/**",\n "/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/unicloud/**/*.js"\n ]\n}\n'), O = b('[{"provider":"aliyun","spaceName":"test-ai","spaceId":"mp-eadf9303-2ce8-4270-b1b0-c1100b2a90ec","clientSecret":"xZRfyqUPB4zflkYS5d9UhQ==","endpoint":"https://api.next.bspapp.com"}]') || [];
const k = true, T = "mp-weixin", P = b([]), A = T, E = b('{\n "address": [\n "127.0.0.1",\n "192.168.31.184"\n ],\n "debugPort": 9000,\n "initialLaunchType": "remote",\n "servePort": 7001,\n "skipFiles": [\n "<node_internals>/**",\n "/Applications/HBuilderX-Alpha.app/Contents/HBuilderX/plugins/unicloud/**/*.js"\n ]\n}\n'), O = b('[{"provider":"aliyun","spaceName":"test-ai","spaceId":"mp-eadf9303-2ce8-4270-b1b0-c1100b2a90ec","clientSecret":"xZRfyqUPB4zflkYS5d9UhQ==","endpoint":"https://api.next.bspapp.com"}]') || [];
let R = "";
try {
R = "__UNI__8F14B14";
......@@ -6,17 +6,22 @@ const md = new common_vendor.MarkdownIt({
highlight: function(str, lang) {
if (lang && common_vendor.HighlightJS.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' + common_vendor.HighlightJS.highlight(lang, str, true).value + "</code></pre>";
return '<pre class="hljs" style="padding: 5px 8px;margin: 5px 0;overflow: auto;"><code>' + common_vendor.HighlightJS.highlight(lang, str, true).value + "</code></pre>";
} catch (__) {
}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + "</code></pre>";
return '<pre class="hljs" style="padding: 5px 8px;margin: 5px 0;overflow: auto;"><code>' + md.utils.escapeHtml(str) + "</code></pre>";
}
});
const _sfc_main = {
name: "msg",
data() {
return {};
return {
left: "-100px",
top: "-100px"
};
},
mounted() {
},
props: {
md: {
......@@ -34,12 +39,14 @@ const _sfc_main = {
},
computed: {
html() {
return md.render(this.md + '<span class="cursor">|</span>');
let html = md.render(this.md + '<span class="cursor">|</span>');
return html;
},
nodes() {
return components_uniAiMsg_htmlParser.parseHtml(this.html);
}
}
},
methods: {}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
......
<view class="{{['rich-text-box', c && 'show-cursor']}}"><rich-text wx:if="{{a}}" space="nbsp" nodes="{{b}}"></rich-text></view>
\ No newline at end of file
<view class="{{['rich-text-box', c && 'show-cursor']}}" ref="rich-text-box"><rich-text wx:if="{{a}}" space="nbsp" nodes="{{b}}"></rich-text></view>
\ No newline at end of file
......@@ -86,10 +86,10 @@ code.hljs{padding:3px 5px}
.hljs-emphasis{font-style:italic}
.hljs-strong{font-weight:700}
@media screen and (-ms-high-contrast:active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}
pre.hljs {
.rich-text-box pre.hljs {
padding: 5px 8px;
margin: 5px 0;
overflow: scroll;
overflow: auto;
}
.cursor {
display: none;
......
......@@ -48,11 +48,13 @@ const _sfc_main = {
fail: () => {
this.stream = false;
common_vendor.index.showModal({
content: "你暂未开通uni-push。不支持此功能",
showCancel: false,
content: "应用暂未开通uni-push。不支持此功能",
confirmText: "查看详情",
complete() {
let url = "https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9";
complete(e) {
if (!e.confirm) {
return;
}
let url = "https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html#heed";
common_vendor.index.setClipboardData({
data: url,
showToast: false,
......@@ -68,7 +70,8 @@ const _sfc_main = {
});
console.log("你暂未开通uni-push。不支持此功能。详情:https://uniapp.dcloud.net.cn/uniCloud/uni-ai-chat.html#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9");
},
success: () => {
success: (e) => {
console.log("success", e);
this.changeStream.check = () => {
};
}
......@@ -106,7 +109,7 @@ const _sfc_main = {
},
async send() {
let messages = [];
let msgs = [...this.msgList];
let msgs = JSON.parse(JSON.stringify(this.msgList));
let findIndex = [...msgs].reverse().findIndex((item) => item.summarize);
if (findIndex != -1) {
let aiSummaryIndex = msgs.length - findIndex - 1;
......
......@@ -34,7 +34,6 @@ page,
.page,
.container {
background-color: #efefef;
flex: 1;
height: 100vh;
flex-direction: column;
align-items: center;
......@@ -136,6 +135,13 @@ page,
user-select: text;
cursor: text;
}
.content {
display: inline;
}
.content rich-text {
max-width: 550rpx;
overflow: auto;
}
.reverse {
flex-direction: row-reverse;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册