提交 0bc263c0 编写于 作者: DCloud_JSON's avatar DCloud_JSON

1.0.0

上级 4db900f8
## 1.0.0(2023-04-24)
1.0.0
{ {
"id": "uni-ai-chat",
"name": "uni-ai-chat", "name": "uni-ai-chat",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "云端一体uni-ai示例项目",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"repository": { "repository": {},
"type": "git", "keywords": [
"url": "https://oauth2:kgLJqNu7Nq7_-ADr9AsC@gitcode.net/dcloud/uni-ai-chat.git" "uni-ai-chat"
}, ],
"keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"highlight.js": "^11.7.0", "highlight.js": "^11.7.0",
"markdown-it": "^13.0.1" "markdown-it": "^13.0.1"
} },
"displayName": "uni-ai-chat"
} }
\ No newline at end of file
<template> <template>
<view class="page"> <view class="page">
<view class="container"> <view class="container">
<view v-if="isWidescreen" class="header">uni-im-chat</view> <view v-if="isWidescreen" class="header">uni-ai-chat</view>
<text class="noData" v-if="msgList.length === 0">没有对话记录</text> <text class="noData" v-if="msgList.length === 0">没有对话记录</text>
<scroll-view :scroll-into-view="scrollIntoView" scroll-y="true" class="msg-list" :enable-flex="true"> <scroll-view :scroll-into-view="scrollIntoView" scroll-y="true" class="msg-list" :enable-flex="true">
<view v-for="(msg,index) in msgList" class="msg-item" :key="index"> <view v-for="(msg,index) in msgList" class="msg-item" :key="index">
......
"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const common_vendor = require("./common/vendor.js");
if (!Math) {
"./pages/chat/chat.js";
}
const _sfc_main = {
onLaunch: function() {
console.log("App Launch");
let version = common_vendor.index.getSystemInfoSync().uniRuntimeVersion;
function toNum(a) {
const c = a.toString().split(".");
const num_place = ["", "0", "00", "000", "0000"], r = num_place.reverse();
for (let i = 0; i < c.length; i++) {
const len = c[i].length;
c[i] = r[len] + c[i];
}
return c.join("");
}
if (toNum(version) < toNum("3.8.0")) {
common_vendor.index.showModal({
content: "本示例的HBuilderX版本不得低于3.8.0,请升级",
showCancel: false
});
}
},
onShow: function() {
console.log("App Show");
},
onHide: function() {
console.log("App Hide");
}
};
const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "/Users/dcloud_linju/Desktop/appCode/uni-ai-chat/App.vue"]]);
function createApp() {
const app = common_vendor.createSSRApp(App);
return {
app
};
}
createApp().app.mount("#app");
exports.createApp = createApp;
{
"pages": [
"pages/chat/chat"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"usingComponents": {}
}
\ No newline at end of file
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
/*每个页面公共css */page{--status-bar-height:25px;--top-window-height:0px;--window-top:0px;--window-bottom:0px;--window-left:0px;--window-right:0px;--window-magin:0px}[data-c-h="true"]{display: none !important;}
\ No newline at end of file
此差异已折叠。
"use strict";
const components_uniAiMsg_htmlParser = require("./html-parser.js");
const common_vendor = require("../../common/vendor.js");
const md = new common_vendor.MarkdownIt({
html: true,
highlight: function(str, lang) {
if (lang && common_vendor.HighlightJS.getLanguage(lang)) {
try {
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" style="padding: 5px 8px;margin: 5px 0;overflow: auto;"><code>' + md.utils.escapeHtml(str) + "</code></pre>";
}
});
const _sfc_main = {
name: "msg",
data() {
return {
left: "-100px",
top: "-100px"
};
},
mounted() {
},
props: {
md: {
type: String,
default() {
return "";
}
},
showCursor: {
type: [Boolean, Number],
default() {
return false;
}
}
},
computed: {
html() {
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({
a: $options.nodes && $options.nodes.length
}, $options.nodes && $options.nodes.length ? {
b: $options.nodes
} : {}, {
c: $props.showCursor ? 1 : ""
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/dcloud_linju/Desktop/appCode/uni-ai-chat/components/uni-ai-msg/uni-ai-msg.vue"]]);
wx.createComponent(Component);
{
"component": true,
"usingComponents": {}
}
\ 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
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
pre code.hljs{display:block;overflow-x:auto;padding:1em}
code.hljs{padding:3px 5px}
/*!
Theme: Agate
Author: (c) Taufik Nurrohman <hi@taufik-nurrohman.com>
Maintainer: @taufik-nurrohman
Updated: 2021-04-24
#333
#62c8f3
#7bd694
#888
#a2fca2
#ade5fc
#b8d8a2
#c6b4f0
#d36363
#fc9b9b
#fcc28c
#ffa
#fff
*/
.hljs{background:#333;color:#fff}
.hljs-doctag,.hljs-meta-keyword,.hljs-name,.hljs-strong{font-weight:700}
.hljs-code,.hljs-emphasis{font-style:italic}
.hljs-section,.hljs-tag{color:#62c8f3}
.hljs-selector-class,.hljs-selector-id,.hljs-template-variable,.hljs-variable{color:#ade5fc}
.hljs-meta-string,.hljs-string{color:#a2fca2}
.hljs-attr,.hljs-quote,.hljs-selector-attr{color:#7bd694}
.hljs-tag .hljs-attr{color:inherit}
.hljs-attribute,.hljs-title,.hljs-type{color:#ffa}
.hljs-number,.hljs-symbol{color:#d36363}
.hljs-bullet,.hljs-template-tag{color:#b8d8a2}
.hljs-built_in,.hljs-keyword,.hljs-literal,.hljs-selector-tag{color:#fcc28c}
.hljs-code,.hljs-comment,.hljs-formula{color:#888}
.hljs-link,.hljs-regexp,.hljs-selector-pseudo{color:#c6b4f0}
.hljs-meta{color:#fc9b9b}
.hljs-deletion{background:#fc9b9b;color:#333}
.hljs-addition{background:#a2fca2;color:#333}
.hljs-subst{color:#fff}
.hljs a{color:inherit}
.hljs a:focus,.hljs a:hover{color:inherit;text-decoration:underline}
.hljs mark{background:#555;color:inherit}
pre code.hljs{display:block;overflow-x:auto;padding:1em}
code.hljs{padding:3px 5px}
/*!
Theme: a11y-dark
Author: @ericwbailey
Maintainer: @ericwbailey
Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css
*/
.hljs{background:#2b2b2b;color:#f8f8f2}
.hljs-comment,.hljs-quote{color:#d4d0ab}
.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}
.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}
.hljs-attribute{color:gold}
.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}
.hljs-section,.hljs-title{color:#00e0e0}
.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}
.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}}
.rich-text-box pre.hljs {
padding: 5px 8px;
margin: 5px 0;
overflow: auto;
}
.cursor {
display: none;
}
.show-cursor .cursor {
display: inline-block;
color: blue;
font-weight: bold;
animation: blinking 1s infinite;
}
@keyframes blinking {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
\ No newline at end of file
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
scrollIntoView: "",
msgList: [],
content: "",
sseIndex: 0,
stream: false,
isWidescreen: false
};
},
computed: {
inputBoxDisabled() {
if (this.sseIndex !== 0) {
return true;
}
let length = this.msgList.length;
if (length) {
return !this.msgList[length - 1].isAi;
} else {
return false;
}
},
placeholderText() {
if (this.inputBoxDisabled) {
return "uni-ai正在回复中";
} else {
return "请输入要发给uni-ai的内容";
}
}
},
watch: {
msgList: {
handler(msgList) {
common_vendor.index.setStorageSync("uni-ai-msg", msgList);
},
deep: true
}
},
async mounted() {
this.msgList = common_vendor.index.getStorageSync("uni-ai-msg") || [];
this.showLastMsg();
this.changeStream.check = async () => {
common_vendor.index.getPushClientId({
fail: () => {
this.stream = false;
common_vendor.index.showModal({
content: "应用暂未开通uni-push。不支持此功能",
confirmText: "查看详情",
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,
success() {
common_vendor.index.showToast({
title: "已复制文档链接,请到浏览器粘贴浏览",
icon: "none",
duration: 5e3
});
}
});
}
});
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: (e) => {
console.log("success", e);
this.changeStream.check = () => {
};
}
});
};
},
methods: {
// updateLastMsg(){
// },
changeStream(e) {
this.changeStream.check();
this.stream = e.detail.value;
},
retriesSendMsg() {
this.send();
},
beforeSendMsg() {
if (!this.content) {
return common_vendor.index.showToast({
title: "内容不能为空",
icon: "none"
});
}
this.msgList.push({
isAi: false,
content: this.content,
state: 0,
create_time: Date.now()
});
this.showLastMsg();
this.$nextTick(() => {
this.content = "";
});
this.send();
},
async send() {
let messages = [];
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;
msgs[aiSummaryIndex].content = msgs[aiSummaryIndex].summarize;
msgs = msgs.splice(aiSummaryIndex, msgs.length - 1);
} else {
msgs = msgs.splice(-10);
}
messages = msgs.map((item) => {
let role = "user";
if (item.isAi) {
role = item.summarize ? "system" : "assistant";
}
return {
content: item.content,
role
};
});
console.log("send to ai messages:", messages);
let SSEChannel = false;
if (this.stream) {
SSEChannel = new common_vendor.Ds.SSEChannel();
SSEChannel.on("message", (message) => {
if (this.sseIndex === 0) {
this.msgList.push({
isAi: true,
content: message,
create_time: Date.now()
});
this.showLastMsg();
} else {
let length = this.msgList.length, lastMsg = this.msgList[length - 1];
lastMsg.content += "\n" + message;
this.msgList.splice(length - 1, 1, lastMsg);
this.showLastMsg();
}
this.sseIndex++;
});
SSEChannel.on("end", (e) => {
if (e && e.summarize) {
let length = this.msgList.length, lastMsg = this.msgList[length - 1];
lastMsg.summarize = e.summarize;
this.msgList.splice(length - 1, 1, lastMsg);
}
this.sseIndex = 0;
this.showLastMsg();
});
await SSEChannel.open();
}
const uniAiChat = common_vendor.Ds.importObject("uni-ai-chat", {
customUI: true
});
uniAiChat.send({
messages,
SSEChannel
}).then((res) => {
let index = this.msgList.length - 1;
let lastItem = this.msgList[index];
lastItem.state = 100;
this.msgList.splice(index, 1, lastItem);
if (!SSEChannel) {
this.msgList.push({
isAi: true,
content: res.reply,
summarize: res.summarize,
create_time: Date.now()
});
this.showLastMsg();
}
}).catch((e) => {
console.log(e);
let index = this.msgList.length - 1;
let lastItem = this.msgList[index];
lastItem.state = -100;
this.msgList.splice(index, 1, lastItem);
common_vendor.index.showModal({
content: JSON.stringify(e.message),
showCancel: false
});
});
},
showLastMsg() {
this.$nextTick(() => {
this.scrollIntoView = "last-msg-item";
this.$nextTick(() => {
this.scrollIntoView = "";
});
});
},
msgStateIcon(msg) {
switch (msg.state) {
case 0:
return "spinner-cycle";
case -100:
return "refresh-filled";
case -200:
return "info-filled";
default:
return false;
}
},
clear() {
common_vendor.index.showModal({
title: "确认要清空聊天记录?",
content: "本操作不可撤销",
complete: (e) => {
if (e.confirm) {
this.msgList = [];
}
}
});
},
toStreamMD() {
let url = "https://uniapp.dcloud.net.cn/uniCloud/uni-ai.html#chat-completion-stream";
common_vendor.index.setClipboardData({
data: url,
showToast: false,
success() {
common_vendor.index.showToast({
title: "已复制文档链接,请到浏览器粘贴浏览",
icon: "none",
duration: 5e3
});
}
});
}
}
};
if (!Array) {
const _easycom_uni_dateformat2 = common_vendor.resolveComponent("uni-dateformat");
const _easycom_uni_ai_msg2 = common_vendor.resolveComponent("uni-ai-msg");
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
(_easycom_uni_dateformat2 + _easycom_uni_ai_msg2 + _easycom_uni_icons2)();
}
const _easycom_uni_dateformat = () => "../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.js";
const _easycom_uni_ai_msg = () => "../../components/uni-ai-msg/uni-ai-msg.js";
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
(_easycom_uni_dateformat + _easycom_uni_ai_msg + _easycom_uni_icons)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.isWidescreen
}, $data.isWidescreen ? {} : {}, {
b: $data.msgList.length === 0
}, $data.msgList.length === 0 ? {} : {}, {
c: common_vendor.f($data.msgList, (msg, index, i0) => {
return common_vendor.e({
a: "70e1a550-0-" + i0,
b: common_vendor.p({
date: msg.create_time,
format: "MM/dd hh:mm:ss"
}),
c: msg.isAi ? "../../static/uni-ai.png" : "../../static/avatar.png",
d: "70e1a550-1-" + i0,
e: common_vendor.p({
md: msg.content,
["show-cursor"]: index == $data.msgList.length - 1 && msg.isAi && $data.sseIndex
}),
f: index == $data.msgList.length - 1 && !msg.isAi && msg.state != 100 && $options.msgStateIcon(msg)
}, index == $data.msgList.length - 1 && !msg.isAi && msg.state != 100 && $options.msgStateIcon(msg) ? {
g: common_vendor.o(($event) => msg.state == -100 ? $options.retriesSendMsg() : "", index),
h: "70e1a550-2-" + i0,
i: common_vendor.p({
color: msg.state === 0 ? "#999" : "#d22",
type: $options.msgStateIcon(msg)
})
} : {}, {
j: !msg.isAi ? 1 : "",
k: index
});
}),
d: $data.scrollIntoView,
e: $data.isWidescreen
}, $data.isWidescreen ? {
f: common_vendor.o((...args) => $options.clear && $options.clear(...args)),
g: common_assets._imports_0,
h: common_vendor.o($options.toStreamMD),
i: common_vendor.p({
type: "help"
}),
j: $data.stream,
k: common_vendor.o((...args) => $options.changeStream && $options.changeStream(...args))
} : {}, {
l: !$data.isWidescreen
}, !$data.isWidescreen ? {
m: common_vendor.o($options.clear),
n: common_vendor.p({
type: "trash",
size: "24",
color: "#888"
})
} : {}, {
o: !$data.isWidescreen,
p: $options.inputBoxDisabled,
q: $options.placeholderText,
r: -1,
s: $data.content,
t: common_vendor.o(($event) => $data.content = $event.detail.value),
v: $data.isWidescreen
}, $data.isWidescreen ? {} : {}, {
w: common_vendor.o((...args) => $options.beforeSendMsg && $options.beforeSendMsg(...args)),
x: $options.inputBoxDisabled || !$data.content,
y: !$data.isWidescreen
}, !$data.isWidescreen ? {
z: common_vendor.o($options.toStreamMD),
A: common_vendor.p({
type: "help"
}),
B: $data.stream,
C: common_vendor.o((...args) => $options.changeStream && $options.changeStream(...args))
} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/dcloud_linju/Desktop/appCode/uni-ai-chat/pages/chat/chat.vue"]]);
wx.createPage(MiniProgramPage);
{
"navigationBarTitleText": "uni-ai-chat",
"enablePullDownRefresh": false,
"usingComponents": {
"uni-dateformat": "../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat",
"uni-ai-msg": "../../components/uni-ai-msg/uni-ai-msg",
"uni-icons": "../../uni_modules/uni-icons/components/uni-icons/uni-icons"
}
}
\ No newline at end of file
<view class="page"><view class="container"><view wx:if="{{a}}" class="header">uni-im-chat</view><text wx:if="{{b}}" class="noData">没有对话记录</text><scroll-view scroll-into-view="{{d}}" scroll-y="true" class="msg-list" enable-flex="{{true}}"><view wx:for="{{c}}" wx:for-item="msg" wx:key="k" class="msg-item"><view class="create_time-box"><uni-dateformat wx:if="{{msg.b}}" class="create_time" u-i="{{msg.a}}" bind:__l="__l" u-p="{{msg.b}}"></uni-dateformat></view><view class="{{[msg.j && 'reverse']}}"><view class="userInfo"><image class="avatar" src="{{msg.c}}" mode="widthFix"></image></view><view class="content"><uni-ai-msg wx:if="{{msg.e}}" u-i="{{msg.d}}" bind:__l="__l" u-p="{{msg.e}}"></uni-ai-msg></view><uni-icons wx:if="{{msg.f}}" bindclick="{{msg.g}}" class="msgStateIcon" u-i="{{msg.h}}" bind:__l="__l" u-p="{{msg.i}}"></uni-icons></view></view><view id="last-msg-item"></view></scroll-view><view class="foot-box"><view wx:if="{{e}}" class="menu"><view class="trash menu-item"><image bindtap="{{f}}" src="{{g}}" mode="heightFix"></image></view><view class="set-stream menu-item"><view class="title"><text>流式响应</text><uni-icons wx:if="{{i}}" bindclick="{{h}}" class="help" u-i="70e1a550-3" bind:__l="__l" u-p="{{i}}"></uni-icons><text>:</text></view><switch checked="{{j}}" bindchange="{{k}}"/></view></view><view class="foot-box-content"><view wx:if="{{l}}" class="trash"><uni-icons wx:if="{{n}}" bindclick="{{m}}" u-i="70e1a550-4" bind:__l="__l" u-p="{{n}}"></uni-icons></view><view class="textarea-box"><block wx:if="{{r0}}"><textarea class="textarea" auto-height="{{o}}" disabled="{{p}}" placeholder="{{q}}" maxlength="{{r}}" placeholder-class="input-placeholder" value="{{s}}" bindinput="{{t}}"></textarea></block></view><view class="send-btn-box"><text wx:if="{{v}}" class="send-btn-tip">↵ 发送 / shift + ↵ 换行</text><button bindtap="{{w}}" disabled="{{x}}" class="send" type="primary">发送</button></view></view></view><view wx:if="{{y}}" id="set-stream"><view class="title"><text>流式响应</text><uni-icons wx:if="{{A}}" bindclick="{{z}}" class="help" u-i="70e1a550-5" bind:__l="__l" u-p="{{A}}"></uni-icons><text>:</text></view><switch checked="{{B}}" bindchange="{{C}}"/></view></view></view>
\ No newline at end of file
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
view,
textarea,
button,
.page {
display: flex;
box-sizing: border-box;
}
page,
.page,
.container {
background-color: #efefef;
height: 100vh;
flex-direction: column;
align-items: center;
justify-content: center;
}
.container {
background-color: #FAFAFA;
}
.foot-box {
width: 750rpx;
display: flex;
flex-direction: column;
padding: 10px 0px;
background-color: #FFF;
}
.foot-box-content {
justify-content: space-around;
}
.textarea-box {
padding: 8px 10px;
background-color: #f9f9f9;
border-radius: 5px;
}
.textarea-box .textarea {
max-height: 100px;
font-size: 14px;
overflow: auto;
width: 450rpx;
}
.input-placeholder {
color: #bbb;
}
.trash,
.send {
width: 50px;
height: 30px;
justify-content: center;
align-items: center;
flex-shrink: 0;
}
.trash {
width: 30rpx;
margin-left: 10rpx;
}
.send {
color: #FFF;
border-radius: 4px;
display: flex;
margin: 0;
padding: 0;
font-size: 14px;
margin-right: 20rpx;
}
.send::after {
display: none;
}
.msg-list {
flex: 1;
height: 1px;
width: 750rpx;
}
.userInfo {
flex-direction: column;
}
.msg-item {
position: relative;
width: 750rpx;
flex-direction: column;
padding: 0 15px;
padding-bottom: 15px;
}
.msgStateIcon {
position: relative;
top: 5px;
right: 5px;
align-self: center;
}
.avatar {
width: 40px;
border-radius: 2px;
}
.create_time {
font-size: 12px;
padding: 5px;
padding-top: 0;
color: #aaa;
justify-content: center;
width: 750rpx;
display: flex;
}
.content {
max-width: 550rpx;
background-color: #FFF;
border-radius: 5px;
padding: 12px 10px;
margin-left: 10px;
word-break: break-all;
-webkit-user-select: text;
user-select: text;
cursor: text;
}
.content {
display: inline;
}
.content rich-text {
max-width: 550rpx;
overflow: auto;
}
.reverse {
flex-direction: row-reverse;
}
.reverse .content {
margin-left: 0;
margin-right: 10px;
}
.reverse-align {
align-items: flex-end;
}
.noData {
margin-top: 15px;
text-align: center;
width: 750rpx;
color: #aaa;
font-size: 12px;
justify-content: center;
}
#set-stream {
z-index: 999;
padding: 0 5px;
justify-content: center;
align-items: center;
position: fixed;
bottom: 50px;
right: 0;
}
#set-stream .title {
font-size: 12px;
position: relative;
left: 10rpx;
}
#set-stream switch {
transform: scale(0.5);
}
\ No newline at end of file
{
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"compileType": "miniprogram",
"libVersion": "2.31.0",
"appid": "wx81dbb061d2258234",
"projectname": "uni-ai-chat",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
\ No newline at end of file
"use strict";
const uni_modules_uniDateformat_components_uniDateformat_dateFormat = require("./date-format.js");
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "uniDateformat",
props: {
date: {
type: [Object, String, Number],
default() {
return "-";
}
},
locale: {
type: String,
default: "zh"
},
threshold: {
type: Array,
default() {
return [0, 0];
}
},
format: {
type: String,
default: "yyyy/MM/dd hh:mm:ss"
},
// refreshRate使用不当可能导致性能问题,谨慎使用
refreshRate: {
type: [Number, String],
default: 0
}
},
data() {
return {
refreshMark: 0
};
},
computed: {
dateShow() {
this.refreshMark;
return uni_modules_uniDateformat_components_uniDateformat_dateFormat.friendlyDate(this.date, {
locale: this.locale,
threshold: this.threshold,
format: this.format
});
}
},
watch: {
refreshRate: {
handler() {
this.setAutoRefresh();
},
immediate: true
}
},
methods: {
refresh() {
this.refreshMark++;
},
setAutoRefresh() {
clearInterval(this.refreshInterval);
if (this.refreshRate) {
this.refreshInterval = setInterval(() => {
this.refresh();
}, parseInt(this.refreshRate));
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($options.dateShow)
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/dcloud_linju/Desktop/appCode/uni-ai-chat/uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.vue"]]);
wx.createComponent(Component);
"use strict";
const uni_modules_uniIcons_components_uniIcons_icons = require("./icons.js");
const common_vendor = require("../../../../common/vendor.js");
const getVal = (val) => {
const reg = /^[0-9]*$/g;
return typeof val === "number" || reg.test(val) ? val + "px" : val;
};
const _sfc_main = {
name: "UniIcons",
emits: ["click"],
props: {
type: {
type: String,
default: ""
},
color: {
type: String,
default: "#333333"
},
size: {
type: [Number, String],
default: 16
},
customPrefix: {
type: String,
default: ""
}
},
data() {
return {
icons: uni_modules_uniIcons_components_uniIcons_icons.icons.glyphs
};
},
computed: {
unicode() {
let code = this.icons.find((v) => v.font_class === this.type);
if (code) {
return unescape(`%u${code.unicode}`);
}
return "";
},
iconSize() {
return getVal(this.size);
}
},
methods: {
_onClick() {
this.$emit("click");
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $props.color,
b: $options.iconSize,
c: common_vendor.n("uniui-" + $props.type),
d: common_vendor.n($props.customPrefix),
e: common_vendor.n($props.customPrefix ? $props.type : ""),
f: common_vendor.o((...args) => $options._onClick && $options._onClick(...args))
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/dcloud_linju/Desktop/appCode/uni-ai-chat/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
wx.createComponent(Component);
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<text style="{{'color:' + a + ';' + ('font-size:' + b)}}" class="{{['uni-icons', c, d, e]}}" bindtap="{{f}}"></text>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册