
chat-example.
npm init -y
npm i @tencentcloud/chat-uikit-uniapp unplugin-vue2-script-setup
mkdir -p ./TUIKit && rsync -av --exclude={'node_modules','package.json','excluded-list.txt'} ./node_modules/@tencentcloud/chat-uikit-uniapp/ ./TUIKit
mkdir -p ./TUIKit/tui-customer-service-plugin && rsync -av ./node_modules/@tencentcloud/tui-customer-service-plugin/ ./TUIKit/tui-customer-service-plugin
npm i @tencentcloud/chat-uikit-uniapp unplugin-vue2-script-setup
xcopy .\\node_modules\\@tencentcloud\\chat-uikit-uniapp .\\TUIKit /i /e /exclude:.\\node_modules\\@tencentcloud\\chat-uikit-uniapp\\excluded-list.txt
xcopy .\\node_modules\\@tencentcloud\\tui-customer-service-plugin .\\TUIKit\\tui-customer-service-plugin /i /e

const ScriptSetup = require('unplugin-vue2-script-setup/webpack').default;module.exports = {parallel: false,configureWebpack: {plugins: [ScriptSetup({/* options */}),],},chainWebpack(config) {// disable type check and let `vue-tsc` handles itconfig.plugins.delete('fork-ts-checker');},};
manifest.json file{"mp-weixin": {"appid": "","optimization": {"subPackages": true}},"h5": {"optimization": {"treeShaking": {"enable": false}}}}
Vue.use(VueCompositionAPI) , to prevent inability to use environment variables such as isPC.// Introduce the main package dependencyimport TencentCloudChat from "@tencentcloud/chat";import TUICore from "@tencentcloud/tui-core";import App from './App';// #ifndef VUE3import Vue from 'vue';import './uni.promisify.adaptor';import VueCompositionAPI from "@vue/composition-api";Vue.use(VueCompositionAPI);Vue.config.productionTip = false;App.mpType = 'app';const app = new Vue({...App,});app.$mount();// #endif// #ifdef VUE3import { createSSRApp } from 'vue';export function createApp() {const app = createSSRApp(App);return {app,};}// #endif
{"pages": [{"path": "pages/index/index" // Your project's homepage}],"subPackages": [{"root": "TUIKit","pages": [{"path": "components/TUIConversation/index","style": {"navigationBarTitleText": "Tencent Cloud IM"}},{"path": "components/TUIChat/index","style": {"navigationBarTitleText": "Tencent Cloud IM"}},// To integrate the chat component, this path must be configured: video playback{"path": "components/TUIChat/video-play","style": {"navigationBarTitleText": "Tencent Cloud IM"}},{"path": "components/TUIChat/web-view","style": {"navigationBarTitleText": "Tencent Cloud IM"}},{"path": "components/TUIContact/index","style": {"navigationBarTitleText": "Tencent Cloud IM"}},{"path": "components/TUIGroup/index","style": {"navigationBarTitleText": "Tencent Cloud IM"}}]}],"preloadRule": {"TUIKit/components/TUIConversation/index": {"network": "all","packages": ["TUIKit"]}},"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "uni-app","navigationBarBackgroundColor": "#F8F8F8","backgroundColor": "#F8F8F8"}}
<script lang="ts">// #ifdef APP-PLUS || H5import { TUIChatKit, genTestUserSig } from "./TUIKit";import { vueVersion } from "./TUIKit/adapter-vue";import { TUILogin } from "@tencentcloud/tui-core";// #endif// Mandatory informationconst config = {userID: "test-user1", // User IDSDKAppID: 0, // Your SDKAppIDsecretKey: "", // Your secretKey};uni.$chat_userID = config.userID;uni.$chat_SDKAppID = config.SDKAppID;uni.$chat_secretKey = config.secretKey;// #ifdef APP-PLUS || H5uni.$chat_userSig = genTestUserSig(config).userSig;// Initialization of TUIChatKitTUIChatKit.init();// #endifexport default {onLaunch: function () {// #ifdef APP-PLUS || H5// TUICore loginTUILogin.login({SDKAppID: uni.$chat_SDKAppID,userID: uni.$chat_userID,// A UserSig is a cipher for users to sign in to Instant Messaging - it is essentially the ciphertext resulting from encrypting information such as UserID.// This method is only suitable for running demos locally and debugging features. For more details, please refer to https://www.tencentcloud.com/document/product/269/32688?from_cn_redirect=1userSig: uni.$chat_userSig,// Should you require to transmit imagery, audio, video, files, and other forms of multimedia messages, please set `Setting` as `true`useUploadPlugin: true,// Local audit can identify and handle unsuitable and unsafe content to effectively ensure a pleasant product experience and business security// This feature is an added service, please refer to: https://www.tencentcloud.com/document/product/269/79139?from_cn_redirect=1// If you've purchased the content review service, please enable this feature by setting it to `true`useProfanityFilterPlugin: false,framework: `vue${vueVersion}` // Current development framework in use: vue2 / vue3});// #endif},onShow: function() {console.log('App Show')},onHide: function() {console.log('App Hide')}};</script><style>/*Common CSS for each page*/uni-page-body,html,body,page {width: 100% !important;height: 100% !important;overflow: hidden;}</style>
import { TUIChatKit, genTestUserSig } from "../../index.ts";import { vueVersion, onMounted } from "../../adapter-vue";import { TUILogin } from "@tencentcloud/tui-core";// Initialization of TUIChatKitTUIChatKit.init();uni.$chat_userSig = genTestUserSig({userID: uni.$chat_userID,SDKAppID: uni.$chat_SDKAppID,secretKey: uni.$chat_secretKey}).userSig;// loginTUILogin.login({SDKAppID: uni.$chat_SDKAppID,userID: uni.$chat_userID,// UserSig is the cipher for users to sign in to Instant Messaging, essentially being the ciphertext obtained from encrypting information such as UserID.// This method is only suitable for running Demo locally and debugging functions. For details, please refer to https://www.tencentcloud.com/document/product/269/32688?from_cn_redirect=1userSig: uni.$chat_userSig,// Should you require to send image, voice, video, file and other rich media messages, please set `Setting` to `true`useUploadPlugin: true,// Local review can successfully identify and handle inappropriate and unsafe content, thereby ensuring the safety and enhancing the user experience of your products// This functionality is a value-added service, please refer to: https://www.tencentcloud.com/document/product/269/79139?from_cn_redirect=1// If you have purchased the content review service, to activate this feature please set it to `true`useProfanityFilterPlugin: false,framework: `vue${vueVersion}` // Current development uses framework vue2 / vue3}).then(() => {uni.showToast({title: "login success"});});
// #ifdef MP-WEIXINimport "./subPackage-init.ts";// #endif

<template><div class="index"><p class="index-button" @click="openConversation">Open TUIKit Conversation</p><p class="index-button" @click="openContact">Open TUIKit Contacts</p></div></template><script>export default {methods: {// Open the TUIKit session listopenConversation() {uni.navigateTo({url: "/TUIKit/components/TUIConversation/index",});},// Accessing TUIKit ContactsopenContact() {uni.navigateTo({url: "/TUIKit/components/TUIContact/index",});},},};</script><style lang="scss" scoped>.index {height: 100%;display: flex;flex-direction: column;align-items: center;&-button {width: 180px;padding: 10px 40px;color: #fff;background-color: #006eff;font-size: 16px;margin-top: 65px;border-radius: 30px;text-align: center;}}</style>
config object's SDKAppID, secretKey, and userID. The SDKAppID and secretKey can be accessed through the Instant Messaging Console, and the userID can be accessed when creating an account in the Instant Messaging Console.// Mandatory informationconst config = {userID: "test-user1", // Login User IDSDKAppID: 0, // Your SDKAppIDsecretKey: "", // Your secretKey};
test-user1.

unpackage/dist/dev/mp-weixin under the project root directory using the WeChat Developer Tool.

피드백