@tencentcloud/ai-desk-customer-wechat
Version:
AI Desk customer UIKit for wechat mini program
131 lines (130 loc) • 4.86 kB
JavaScript
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const aiDeskCustomerUniapp_adapterVue = require("../../../adapter-vue.js");
const common_assets = require("../../../../common/assets.js");
const aiDeskCustomerUniapp_utils_env = require("../../../utils/env.js");
const aiDeskCustomerUniapp_components_CustomerServiceChat_utils_sendMessage = require("../utils/sendMessage.js");
require("../emoji-config/index.js");
if (!Math) {
(MessageQuote + MessageInputEditor + Icon)();
}
const MessageInputEditor = () => "./message-input-editor-uniapp.js";
const MessageQuote = () => "./message-input-quote/index.js";
const Icon = () => "../../common/Icon.js";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "index-uniapp",
props: {
placeholder: { default: "" },
isMuted: { type: Boolean, default: true },
muteText: { default: "" },
enableInput: { type: Boolean, default: true },
enableTyping: { type: Boolean, default: true },
replyOrReference: { default: () => ({}) },
inputToolbarDisplayType: { default: "none" }
},
emits: ["changeToolbarDisplayType", "sendMessage"],
setup(__props, { expose: __expose, emit: __emit }) {
const { ref, watch, onMounted, onUnmounted } = aiDeskCustomerUniapp_adapterVue.vue;
const emits = __emit;
const props = __props;
const editor = ref();
const currentConversation = ref();
const displayType = ref("editor");
onMounted(() => {
common_vendor.Jt.watch(common_vendor.o$1.CONV, {
currentConversation: onCurrentConversationUpdated
});
common_vendor.Jt.watch(common_vendor.o$1.CHAT, {
quoteMessage: onQuoteMessageUpdated
});
});
onUnmounted(() => {
common_vendor.Jt.unwatch(common_vendor.o$1.CONV, {
currentConversation: onCurrentConversationUpdated
});
common_vendor.Jt.unwatch(common_vendor.o$1.CHAT, {
quoteMessage: onQuoteMessageUpdated
});
});
watch(
() => props.inputToolbarDisplayType,
(newVal) => {
if (newVal !== "none") {
changeDisplayType("editor");
}
}
);
function changeDisplayType(display) {
displayType.value = display;
if (display === "audio") {
emits("changeToolbarDisplayType", "none");
}
}
function changeToolbarDisplayType(displayType2) {
emits("changeToolbarDisplayType", displayType2);
}
const onTyping = (inputContentEmpty, inputBlur) => {
aiDeskCustomerUniapp_components_CustomerServiceChat_utils_sendMessage.sendTyping(inputContentEmpty, inputBlur);
};
const onFocus = () => {
if (aiDeskCustomerUniapp_utils_env.isH5) {
emits("changeToolbarDisplayType", "none");
}
};
const insertEmoji = (emoji) => {
var _a, _b;
((_a = editor == null ? void 0 : editor.value) == null ? void 0 : _a.addEmoji) && ((_b = editor == null ? void 0 : editor.value) == null ? void 0 : _b.addEmoji(emoji));
};
const reEdit = (content) => {
var _a, _b;
(_a = editor == null ? void 0 : editor.value) == null ? void 0 : _a.resetEditor();
(_b = editor == null ? void 0 : editor.value) == null ? void 0 : _b.setEditorContent(content);
};
function onCurrentConversationUpdated(conversation) {
currentConversation.value = conversation;
}
function onQuoteMessageUpdated(options) {
if ((options == null ? void 0 : options.message) && (options == null ? void 0 : options.type) === "quote") {
changeDisplayType("editor");
}
}
__expose({
insertEmoji,
reEdit
});
return (_ctx, _cache) => {
return {
a: common_vendor.p({
displayType: common_vendor.unref(displayType)
}),
b: common_vendor.sr(editor, "fd8973ed-1", {
"k": "editor"
}),
c: common_vendor.unref(displayType) === "editor",
d: common_vendor.o(onTyping),
e: common_vendor.o(onFocus),
f: common_vendor.p({
placeholder: props.placeholder,
isMuted: props.isMuted,
muteText: props.muteText,
enableInput: props.enableInput,
enableTyping: props.enableTyping
}),
g: common_vendor.o(($event) => changeToolbarDisplayType("emojiPicker")),
h: common_vendor.p({
file: common_vendor.unref(common_assets.faceIcon),
size: "23px",
hotAreaSize: "3px"
}),
i: common_vendor.o(($event) => changeToolbarDisplayType("tools")),
j: common_vendor.p({
file: common_vendor.unref(common_assets.moreIcon),
size: "23px",
hotAreaSize: "3px"
})
};
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fd8973ed"]]);
wx.createComponent(Component);