
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
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
subPackages and disable H5 treeShaking option in the source view of manifest.json file.// weixin miniProgram"mp-weixin" : {"appid" : "","optimization" : {"subPackages" : true}},// H5: close treeshaking to solve the problem of uni[methond]() is not a function"h5" : {"optimization" : {"treeShaking" : {"enable" : false}}},
manifest.json when packaging mini programs.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');},};
<script lang="ts">import { TUILogin } from '@tencentcloud/tui-core-lite';import { TUIChatEngine } from '@tencentcloud/chat-uikit-engine-lite';// #ifdef APP-PLUS || H5import { TUIChatKit } from './TUIKit';TUIChatKit.init();// #endiflet vueVersion = 2;// #ifdef VUE3vueVersion = 3;// #endif// Required information// You can get userSig from TencentCloud chat console for Testing TUIKit.// Deploy production environment please get it from your server.// View https://www.tencentcloud.com/document/product/269/32688?from_cn_redirect=1uni.$SDKAppID = 0; // Your SDKAppIDuni.$userID = ''; // Your userIDuni.$userSig = ''; // Your userSigexport default {onLaunch: function () {TUILogin.login({SDKAppID: uni.$SDKAppID,userID: uni.$userID,userSig: uni.$userSig,framework: `vue${vueVersion}` // framework used vue2 / vue3}).then(() => {TUIChatEngine.isReady();}).catch(() => {});}};</script><style>/* common css for page */uni-page-body,html,body,page {width: 100% !important;height: 100% !important;overflow: hidden;}</style>
{"pages": [{"path": "pages/index/index" // Your project homepage}],"subPackages": [{"root": "TUIKit","pages": [{"path": "components/TUIConversation/index","style": {"navigationBarTitleText": "Tencent Cloud IM"}},{"path": "components/TUIChat/index","style": {"navigationBarTitleText": "Tencent Cloud IM","app-plus": {"softinputMode": "adjustResize","titleNView": {"buttons": [{"type": "menu"}]}},"h5": {"titleNView": {"buttons": []}}}},// 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"}},{"path": "components/TUISearch/index","style": {"navigationBarTitleText": "Chat record"}}]}],"preloadRule": {"pages/index/index": {"network": "all","packages": ["TUIKit"]}},"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "uni-app","navigationBarBackgroundColor": "#F8F8F8","backgroundColor": "#F8F8F8"}}
isPC from being unavailable.// #ifndef VUE3import VueCompositionAPI from '@vue/composition-api';Vue.use(VueCompositionAPI);// #endif
<template><div><button @click="openConversationList">Open session list</button><button @click="openContact">Open contact person</button></div></template><script>export default {methods: {Open session listopenConversationList() {uni.navigateTo({ url: '/TUIKit/components/TUIConversation/index' });},Open contact personopenContact() {uni.navigateTo({ url: '/TUIKit/components/TUIContact/index' });},},};</script>
App.vue.uni.$SDKAppID = 0; // Your SDKAppIDuni.$userID = ''; // Your userIDuni.$userSig = ''; // Your userSig




unpackage/dist/dev/mp-weixin in the project root directory.
/TUIKit/debug folder in the project directory before release. During development, for convenience, the project provides a script to generate UserSig locally, stored in the TUIKit/debug folder. However, this is not secure as the secretKey in this method can be easily decompiled and reverse engineered. Once your key is leaked, attackers can steal your Tencent Cloud traffic. This method is only suitable for running the Demo locally and debugging features. Therefore, please delete the debug script before project release and use the backend to generate UserSig. For specific reasons and operation steps, refer to the documentation: Generate UserSig./TUIKit/debug folder under the project directory before release, use the backend to generate UserSig. For reason and operation steps, refer to the documentation: generate UserSig.unpackage/dist/build/mp-weixin folder of the project directory. Just open the folder using WeChat Developer Tools.Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback