tuikit-atomicx-vue3 4.4.0-beta.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-D1G-LitO.js → MessageInput.vue_vue_type_script_setup_true_lang-D9jiYNFu.js} +31 -31
- package/dist/chat/index.d.ts +35 -35
- package/dist/chat/server.js +15 -15
- package/dist/components/ContactList/ContactInfo/BlacklistInfo/BlacklistInfo.js +6 -6
- package/dist/components/ContactList/ContactInfo/ContactInfo.js +1 -1
- package/dist/components/ContactList/ContactInfo/FriendApplicationInfo/FriendApplicationInfo.js +1 -1
- package/dist/components/ContactList/ContactInfo/FriendInfo/FriendInfo.js +9 -9
- package/dist/components/ContactList/ContactInfo/GroupApplicationInfo/GroupApplicationInfo.js +1 -1
- package/dist/components/ContactList/ContactInfo/GroupInfo/GroupInfo.js +4 -4
- package/dist/components/ContactList/ContactInfo/SearchGroupInfo/SearchGroupInfo.js +8 -8
- package/dist/components/ContactList/ContactInfo/SearchUserInfo/SearchUserInfo.js +7 -7
- package/dist/components/ContactList/ContactList.js +7 -7
- package/dist/components/ContactList/ContactListItem/BlacklistItem/BlacklistItem.js +8 -8
- package/dist/components/ContactList/ContactListItem/FriendApplicationItem/FriendApplicationItem.js +5 -5
- package/dist/components/ContactList/ContactListItem/FriendItem/FriendItem.js +5 -5
- package/dist/components/ContactList/ContactListItem/GroupApplicationItem/GroupApplicationItem.js +1 -1
- package/dist/components/ContactList/ContactListItem/GroupItem/GroupItem.js +1 -1
- package/dist/components/ContactList/ContactSearch/ContactSearch.js +6 -6
- package/dist/components/ConversationList/ConversationCreate/ConversationCreate.js +9 -9
- package/dist/components/ConversationList/ConversationList.js +4 -4
- package/dist/components/ConversationList/ConversationList.vue.d.ts +10 -10
- package/dist/components/ConversationList/ConversationPreview/ConversationPreview.vue.d.ts +10 -10
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.js +20 -20
- package/dist/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue.d.ts +2 -2
- package/dist/components/ConversationList/ConversationPreview/index.js +1 -1
- package/dist/components/ConversationList/index.d.ts +30 -30
- package/dist/components/MessageInput/EmojiPicker/EmojiPicker.js +88 -84
- package/dist/components/MessageInput/MessageInput.js +1 -1
- package/dist/components/MessageInput/MessageInput.vue.d.ts +2 -2
- package/dist/components/MessageInput/TextEditor/EditorCore.d.ts +2 -1
- package/dist/components/MessageInput/TextEditor/EditorCore.js +23 -21
- package/dist/components/MessageInput/TextEditor/TextEditor.vue.d.ts +2 -2
- package/dist/components/MessageInput/TextEditor/index.js +32 -31
- package/dist/components/MessageInput/index.d.ts +6 -6
- package/dist/components/MessageInput/index.js +1 -1
- package/dist/components/MessageList/Message/AudioMessage/WaveForm.js +24 -34
- package/dist/components/MessageList/Message/CustomMessage/CallMessage/CallMessage.js +29 -28
- package/dist/components/MessageList/Message/Message.vue.d.ts +1 -1
- package/dist/components/MessageList/MessageList.js +8 -6
- package/dist/components/MessageList/index.d.ts +2 -2
- package/dist/hooks/useAudioControl.d.ts +3 -3
- package/dist/hooks/useAudioControl.js +32 -30
- package/dist/rtc/server.js +45 -40
- package/dist/states/LoginState.d.ts +23 -0
- package/dist/states/LoginState.js +34 -39
- package/dist/states/MessageInputState/MessageInputState.d.ts +41 -7
- package/dist/states/MessageInputState/MessageInputState.js +60 -59
- package/dist/states/MessageInputState/utils.d.ts +8 -1
- package/dist/states/MessageInputState/utils.js +30 -10
- package/dist/styles/index.css +1 -1
- package/dist/utils/call.js +1 -1
- package/package.json +2 -2
- package/src/chat/server.ts +0 -1
- package/src/components/ContactList/ContactInfo/BlacklistInfo/BlacklistInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/ContactInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/FriendApplicationInfo/FriendApplicationInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/FriendInfo/FriendInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/GroupApplicationInfo/GroupApplicationInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/GroupInfo/GroupInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/SearchGroupInfo/SearchGroupInfo.vue +1 -1
- package/src/components/ContactList/ContactInfo/SearchUserInfo/SearchUserInfo.vue +1 -1
- package/src/components/ContactList/ContactList.vue +1 -1
- package/src/components/ContactList/ContactListItem/BlacklistItem/BlacklistItem.vue +1 -1
- package/src/components/ContactList/ContactListItem/FriendApplicationItem/FriendApplicationItem.vue +1 -1
- package/src/components/ContactList/ContactListItem/FriendItem/FriendItem.vue +1 -1
- package/src/components/ContactList/ContactListItem/GroupApplicationItem/GroupApplicationItem.vue +1 -1
- package/src/components/ContactList/ContactListItem/GroupItem/GroupItem.vue +1 -1
- package/src/components/ContactList/ContactSearch/ContactSearch.vue +1 -1
- package/src/components/ConversationList/ConversationActions/ConversationActions.vue +1 -1
- package/src/components/ConversationList/ConversationCreate/ConversationCreate.vue +2 -2
- package/src/components/ConversationList/ConversationCreate/ConversationCreateButton/ConversationCreateButton.vue +1 -1
- package/src/components/ConversationList/ConversationCreate/ConversationCreateGroupDetail/ConversationCreateGroupDetail.vue +1 -1
- package/src/components/ConversationList/ConversationCreate/ConversationCreateUserSelectList/ConversationCreateUserSelectList.vue +1 -1
- package/src/components/ConversationList/ConversationCreate/ConversationGroupTypeInfo/ConversationGroupTypeInfo.vue +1 -1
- package/src/components/ConversationList/ConversationList.vue +2 -2
- package/src/components/ConversationList/ConversationListContent/ConversationListContent.vue +1 -1
- package/src/components/ConversationList/ConversationListHeader/ConversationListHeader.vue +1 -1
- package/src/components/ConversationList/ConversationPlaceHolder/ConversationPlaceHolder.vue +1 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreview.vue +1 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewAbstract.vue +1 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewTimestamp.vue +1 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewTitle.vue +1 -1
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewUI.vue +3 -3
- package/src/components/ConversationList/ConversationPreview/ConversationPreviewUnread.vue +1 -1
- package/src/components/ConversationList/ConversationSearch/ConversationSearch.vue +1 -1
- package/src/components/MessageInput/EmojiPicker/EmojiPicker.vue +7 -3
- package/src/components/MessageInput/MessageInput.module.scss +1 -0
- package/src/components/MessageInput/MessageInput.vue +1 -1
- package/src/components/MessageInput/TextEditor/EditorCore.ts +4 -2
- package/src/components/MessageInput/TextEditor/TextEditor.vue +3 -4
- package/src/components/MessageList/Message/AudioMessage/WaveForm.vue +20 -37
- package/src/components/MessageList/Message/CustomMessage/CallMessage/CallMessage.vue +1 -1
- package/src/components/MessageList/Message/Message.vue +1 -1
- package/src/components/MessageList/MessageList.vue +2 -0
- package/src/components/Search/Search.vue +1 -1
- package/src/components/Search/SearchAdvanced/DateRangePicker/DateRangePicker.vue +1 -1
- package/src/components/Search/SearchAdvanced/MessageAdvanced/MessageAdvanced.vue +1 -1
- package/src/components/Search/SearchAdvanced/SearchAdvanced.vue +1 -1
- package/src/components/Search/SearchAdvanced/SearchTab/SearchTab.vue +1 -1
- package/src/components/Search/SearchAdvanced/Slider/Slider.vue +1 -1
- package/src/components/Search/SearchAdvanced/UserAdvanced/UserAdvanced.vue +1 -1
- package/src/components/Search/SearchBar/SearchBar.vue +1 -1
- package/src/components/Search/SearchResults/EmptyResult/EmptyResult.vue +1 -1
- package/src/components/Search/SearchResults/Loading/Loading.vue +1 -1
- package/src/components/Search/SearchResults/SearchResults.vue +1 -1
- package/src/components/Search/SearchResults/SearchResultsItem/Conversation/Conversation.vue +1 -1
- package/src/components/Search/SearchResults/SearchResultsItem/Group/Group.vue +1 -1
- package/src/components/Search/SearchResults/SearchResultsItem/Message/Message.vue +1 -1
- package/src/components/Search/SearchResults/SearchResultsItem/SearchResultsItem.vue +1 -1
- package/src/components/Search/SearchResults/SearchResultsItem/User/User.vue +1 -1
- package/src/hooks/useAudioControl.ts +17 -4
- package/src/rtc/server.ts +4 -0
- package/src/utils/call.ts +2 -2
package/dist/rtc/server.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var s = (
|
|
4
|
-
import { ref as
|
|
5
|
-
import
|
|
6
|
-
import S, { TUIConstants as g, TUILogin as
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var T = (n, t, i) => t in n ? h(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
|
|
3
|
+
var s = (n, t, i) => T(n, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { ref as U } from "vue";
|
|
5
|
+
import m from "@tencentcloud/chat-uikit-engine";
|
|
6
|
+
import S, { TUIConstants as g, TUILogin as _ } from "@tencentcloud/tui-core";
|
|
7
|
+
import l from "@tencentcloud/tuiroom-engine-js";
|
|
8
|
+
import { dataReport as p } from "../report/dataReport.js";
|
|
9
|
+
import { MetricsKey as c } from "../report/MetricsKey.js";
|
|
10
|
+
import { useLoginState as N } from "../states/LoginState.js";
|
|
11
|
+
import { isMobile as C } from "../utils/env.js";
|
|
9
12
|
const e = class e {
|
|
10
13
|
constructor() {
|
|
11
14
|
s(this, "isReady", !1);
|
|
12
15
|
s(this, "isEngineLoggingIn", !1);
|
|
13
|
-
s(this, "isLogin",
|
|
16
|
+
s(this, "isLogin", U(!1));
|
|
14
17
|
s(this, "resolveList", []);
|
|
15
18
|
s(this, "rejectList", []);
|
|
16
19
|
this.init();
|
|
@@ -28,9 +31,9 @@ const e = class e {
|
|
|
28
31
|
/**
|
|
29
32
|
* @param { TUIInitParam } params
|
|
30
33
|
*/
|
|
31
|
-
onNotifyEvent(
|
|
32
|
-
if (
|
|
33
|
-
switch (
|
|
34
|
+
onNotifyEvent(t, i) {
|
|
35
|
+
if (t === g.TUILogin.EVENT.LOGIN_STATE_CHANGED)
|
|
36
|
+
switch (i) {
|
|
34
37
|
case g.TUILogin.EVENT_SUB_KEY.USER_LOGIN_SUCCESS:
|
|
35
38
|
this.login();
|
|
36
39
|
break;
|
|
@@ -41,52 +44,54 @@ const e = class e {
|
|
|
41
44
|
}
|
|
42
45
|
async login() {
|
|
43
46
|
const {
|
|
44
|
-
chat:
|
|
45
|
-
SDKAppID:
|
|
46
|
-
userID:
|
|
47
|
-
userSig:
|
|
48
|
-
} =
|
|
47
|
+
chat: t,
|
|
48
|
+
SDKAppID: i,
|
|
49
|
+
userID: E,
|
|
50
|
+
userSig: I
|
|
51
|
+
} = _.getContext();
|
|
49
52
|
if (this.isEngineLoggingIn)
|
|
50
|
-
return new Promise((
|
|
51
|
-
this.resolveList.push(
|
|
53
|
+
return new Promise((o, r) => {
|
|
54
|
+
this.resolveList.push(o), this.rejectList.push(r);
|
|
52
55
|
});
|
|
53
56
|
try {
|
|
54
|
-
this.isEngineLoggingIn = !0
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
this.isEngineLoggingIn = !0;
|
|
58
|
+
const o = C ? c.T_METRICS_STATE_API_LOGIN_MOBILE_COUNT : c.T_METRICS_STATE_API_LOGIN_COUNT;
|
|
59
|
+
p.reportCount(o), await m.login({
|
|
60
|
+
chat: t,
|
|
61
|
+
SDKAppID: i,
|
|
62
|
+
userID: E,
|
|
63
|
+
userSig: I
|
|
59
64
|
});
|
|
60
|
-
const
|
|
61
|
-
sdkAppId:
|
|
62
|
-
userId:
|
|
63
|
-
userSig:
|
|
64
|
-
tim:
|
|
65
|
+
const r = await l.login({
|
|
66
|
+
sdkAppId: i,
|
|
67
|
+
userId: E,
|
|
68
|
+
userSig: I,
|
|
69
|
+
tim: t
|
|
65
70
|
});
|
|
66
|
-
this.isLogin.value = !0, this.resolveList.forEach((
|
|
67
|
-
|
|
71
|
+
this.isLogin.value = !0, this.resolveList.forEach((u) => {
|
|
72
|
+
u();
|
|
68
73
|
}), this.rejectList = [], this.resolveList = [];
|
|
69
|
-
const { loginUserInfo:
|
|
70
|
-
return a.value || (
|
|
74
|
+
const { loginUserInfo: f } = N(), a = (await t.getUserProfile({ userIDList: [E] })).data[0];
|
|
75
|
+
return a.value || (f.value = {
|
|
71
76
|
userId: a.userID,
|
|
72
77
|
userName: a.nick,
|
|
73
78
|
avatarUrl: a.avatar,
|
|
74
79
|
customInfo: a.profileCustomField
|
|
75
|
-
}),
|
|
76
|
-
} catch (
|
|
80
|
+
}), r;
|
|
81
|
+
} catch (o) {
|
|
77
82
|
throw this.rejectList.forEach((r) => {
|
|
78
|
-
r(
|
|
79
|
-
}), this.rejectList = [], this.resolveList = [],
|
|
83
|
+
r(o);
|
|
84
|
+
}), this.rejectList = [], this.resolveList = [], o;
|
|
80
85
|
} finally {
|
|
81
86
|
this.isEngineLoggingIn = !1;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
logout() {
|
|
85
|
-
|
|
90
|
+
l.logout(), this.isLogin.value = !1, this.isEngineLoggingIn = !1;
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
93
|
s(e, "instance");
|
|
89
|
-
let
|
|
94
|
+
let L = e;
|
|
90
95
|
export {
|
|
91
|
-
|
|
96
|
+
L as default
|
|
92
97
|
};
|
|
@@ -3,6 +3,29 @@ import { LoginParams, LoginUserInfo, SetSelfInfoParams } from '../types/login';
|
|
|
3
3
|
declare function login(options: LoginParams): Promise<void>;
|
|
4
4
|
declare function setSelfInfo(options: SetSelfInfoParams): Promise<void>;
|
|
5
5
|
declare function logout(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* 用户登录状态管理 Hook
|
|
8
|
+
* @memberof module:LoginState
|
|
9
|
+
* @description 提供用户登录、登出、个人信息管理等功能
|
|
10
|
+
* @returns {Object} 返回登录状态管理对象
|
|
11
|
+
* @returns {Ref<LoginUserInfo | null>} returns.loginUserInfo - 当前登录用户信息
|
|
12
|
+
* @returns {Function} returns.login - 登录函数
|
|
13
|
+
* @returns {Function} returns.logout - 登出函数
|
|
14
|
+
* @returns {Function} returns.setSelfInfo - 设置个人信息函数
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const { loginUserInfo, login, logout, setSelfInfo } = useLoginState();
|
|
18
|
+
*
|
|
19
|
+
* // 登录
|
|
20
|
+
* await login({ userId: 'user123', userSig: 'sig', sdkAppId: 123456 });
|
|
21
|
+
*
|
|
22
|
+
* // 设置个人信息
|
|
23
|
+
* await setSelfInfo({ nick: '新昵称' });
|
|
24
|
+
*
|
|
25
|
+
* // 登出
|
|
26
|
+
* await logout();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
6
29
|
export declare function useLoginState(): {
|
|
7
30
|
loginUserInfo: import('vue').Ref<{
|
|
8
31
|
userId: string;
|
|
@@ -1,69 +1,64 @@
|
|
|
1
1
|
import { ref as c } from "vue";
|
|
2
|
-
import { TUILogin as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { isMobile as m } from "../utils/env.js";
|
|
7
|
-
const a = c(null), { getChatScene: I } = g();
|
|
8
|
-
async function S(r) {
|
|
2
|
+
import { TUILogin as u } from "@tencentcloud/tui-core";
|
|
3
|
+
import { useStatistical as i } from "../statistical/statistical.js";
|
|
4
|
+
const s = c(null), { getChatScene: f } = i();
|
|
5
|
+
async function g(r) {
|
|
9
6
|
if (!r.userId || !r.userSig || !r.sdkAppId)
|
|
10
7
|
throw new Error("[loginState login] params error");
|
|
11
|
-
const { userId: l, userSig:
|
|
8
|
+
const { userId: l, userSig: t, sdkAppId: n, ...e } = r, a = {
|
|
12
9
|
SDKAppID: n,
|
|
13
10
|
userID: l,
|
|
14
|
-
userSig:
|
|
11
|
+
userSig: t,
|
|
15
12
|
useUploadPlugin: !0,
|
|
16
|
-
scene:
|
|
17
|
-
...
|
|
13
|
+
scene: f(),
|
|
14
|
+
...e
|
|
18
15
|
};
|
|
19
16
|
try {
|
|
20
|
-
await
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} catch (t) {
|
|
24
|
-
throw console.error("[loginState login] error", t), t;
|
|
17
|
+
await u.login(a);
|
|
18
|
+
} catch (o) {
|
|
19
|
+
throw console.error("[loginState login] error", o), o;
|
|
25
20
|
}
|
|
26
21
|
}
|
|
27
|
-
async function
|
|
28
|
-
const l =
|
|
29
|
-
if (
|
|
22
|
+
async function m(r) {
|
|
23
|
+
const l = s.value || {}, { chat: t } = u.getContext();
|
|
24
|
+
if (t) {
|
|
30
25
|
const n = [];
|
|
31
|
-
r.customInfo && Object.keys(r.customInfo).forEach((
|
|
32
|
-
var
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
key:
|
|
36
|
-
value: (
|
|
26
|
+
r.customInfo && Object.keys(r.customInfo).forEach((e) => {
|
|
27
|
+
var o;
|
|
28
|
+
let a = e;
|
|
29
|
+
e.includes("Tag_Profile_Custom") || (a = `Tag_Profile_Custom_${e}`), n.push({
|
|
30
|
+
key: a,
|
|
31
|
+
value: (o = r.customInfo) == null ? void 0 : o[e]
|
|
37
32
|
});
|
|
38
33
|
});
|
|
39
34
|
try {
|
|
40
|
-
const
|
|
35
|
+
const e = await t.updateMyProfile({
|
|
41
36
|
nick: r.userName,
|
|
42
37
|
avatar: r.avatarUrl,
|
|
43
38
|
profileCustomField: n
|
|
44
39
|
});
|
|
45
|
-
return
|
|
40
|
+
return s.value = {
|
|
46
41
|
...l,
|
|
47
42
|
...r
|
|
48
|
-
},
|
|
49
|
-
} catch (
|
|
50
|
-
throw console.error("[loginState setSelfInfo] error",
|
|
43
|
+
}, e;
|
|
44
|
+
} catch (e) {
|
|
45
|
+
throw console.error("[loginState setSelfInfo] error", e), e;
|
|
51
46
|
}
|
|
52
47
|
} else
|
|
53
48
|
throw Error("[loginState setSelfInfo] not login");
|
|
54
49
|
}
|
|
55
|
-
async function
|
|
56
|
-
|
|
50
|
+
async function I() {
|
|
51
|
+
s.value = null, u.logout();
|
|
57
52
|
}
|
|
58
|
-
function
|
|
53
|
+
function p() {
|
|
59
54
|
return {
|
|
60
|
-
loginUserInfo:
|
|
61
|
-
login:
|
|
62
|
-
logout:
|
|
63
|
-
setSelfInfo:
|
|
55
|
+
loginUserInfo: s,
|
|
56
|
+
login: g,
|
|
57
|
+
logout: I,
|
|
58
|
+
setSelfInfo: m
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
61
|
export {
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
p as default,
|
|
63
|
+
p as useLoginState
|
|
69
64
|
};
|
|
@@ -3,13 +3,13 @@ import { MessageContentType, InputContent } from './type';
|
|
|
3
3
|
import { Editor } from '@tiptap/vue-3';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
6
|
+
* 消息输入状态管理
|
|
7
|
+
* @module MessageInputState
|
|
8
|
+
* @description 管理聊天消息输入相关的状态和操作,包括:
|
|
9
|
+
* - 原始输入值(文本或结构化内容)
|
|
10
|
+
* - 编辑器实例管理
|
|
11
|
+
* - 内容操作(插入、更新等)
|
|
12
|
+
* - 消息发送功能
|
|
13
13
|
*/
|
|
14
14
|
interface MessageInputState {
|
|
15
15
|
inputRawValue: Ref<string | InputContent[]>;
|
|
@@ -24,6 +24,40 @@ interface MessageInputAction {
|
|
|
24
24
|
blurEditor: () => void;
|
|
25
25
|
sendMessage: (msg?: string | InputContent[]) => void;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* 消息输入状态管理 Hook
|
|
29
|
+
* @memberof module:MessageInputState
|
|
30
|
+
* @description 提供消息输入相关的状态管理和操作功能,包括文本输入、编辑器控制、消息发送等
|
|
31
|
+
* @returns {MessageInputState & MessageInputAction} 返回消息输入状态管理对象
|
|
32
|
+
* @returns {Ref<string>} returns.inputRawValue - 输入框原始值
|
|
33
|
+
* @returns {Ref<boolean>} returns.isPeerTyping - 对方是否正在输入
|
|
34
|
+
* @returns {Function} returns.updateRawValue - 更新输入框原始值函数
|
|
35
|
+
* @returns {Function} returns.setEditorInstance - 设置编辑器实例函数
|
|
36
|
+
* @returns {Function} returns.setContent - 设置编辑器内容函数
|
|
37
|
+
* @returns {Function} returns.insertContent - 插入内容到编辑器函数
|
|
38
|
+
* @returns {Function} returns.focusEditor - 聚焦编辑器函数
|
|
39
|
+
* @returns {Function} returns.blurEditor - 失焦编辑器函数
|
|
40
|
+
* @returns {Function} returns.sendMessage - 发送消息函数
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const {
|
|
44
|
+
* inputRawValue,
|
|
45
|
+
* isPeerTyping,
|
|
46
|
+
* setContent,
|
|
47
|
+
* sendMessage,
|
|
48
|
+
* focusEditor
|
|
49
|
+
* } = useMessageInputState();
|
|
50
|
+
*
|
|
51
|
+
* // 设置编辑器内容
|
|
52
|
+
* setContent('Hello World');
|
|
53
|
+
*
|
|
54
|
+
* // 发送消息
|
|
55
|
+
* await sendMessage();
|
|
56
|
+
*
|
|
57
|
+
* // 聚焦编辑器
|
|
58
|
+
* focusEditor();
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
27
61
|
declare function useMessageInputState(): MessageInputState & MessageInputAction;
|
|
28
62
|
export { useMessageInputState, MessageContentType };
|
|
29
63
|
export type { InputContent };
|
|
@@ -1,111 +1,112 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { TUIStore as w, StoreName as
|
|
3
|
-
import { MessageContentType as
|
|
4
|
-
import { convertInputContentToEditorNode as p } from "./utils.js";
|
|
1
|
+
import { ref as l } from "vue";
|
|
2
|
+
import { TUIStore as w, StoreName as I, TUIChatService as r } from "@tencentcloud/chat-uikit-engine";
|
|
3
|
+
import { MessageContentType as a } from "./type.js";
|
|
4
|
+
import { trimInputContent as M, convertInputContentToEditorNode as p } from "./utils.js";
|
|
5
5
|
import { useMessageListState as v } from "../MessageListState/MessageListState.js";
|
|
6
6
|
import { transformTextWithEmojiNameToKey as f } from "../../utils/emoji.js";
|
|
7
|
-
const n =
|
|
7
|
+
const n = l(null), m = l(""), y = l(!1), E = (e) => {
|
|
8
8
|
if (typeof e != "string" && !Array.isArray(e)) {
|
|
9
9
|
console.warn("Invalid input type for updateRawValue");
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
typeof e == "string" ? m.value = e.trim() : m.value = (e == null ? void 0 : e.length) > 0 ? e : "",
|
|
13
|
-
|
|
12
|
+
typeof e == "string" ? m.value = e.trim() : m.value = (e == null ? void 0 : e.length) > 0 ? e : "", r.enterTypingState(), setTimeout(() => {
|
|
13
|
+
r.leaveTypingState();
|
|
14
14
|
}, 3e3);
|
|
15
|
-
}, I = (e) => {
|
|
16
|
-
n.value && n.value.destroy(), n.value = e;
|
|
17
15
|
}, C = (e) => {
|
|
16
|
+
n.value && n.value.destroy(), n.value = e;
|
|
17
|
+
}, S = (e) => {
|
|
18
18
|
if (n.value) {
|
|
19
19
|
if (typeof e == "string")
|
|
20
20
|
n.value.commands.setContent(e, !0);
|
|
21
21
|
else {
|
|
22
|
-
const
|
|
23
|
-
n.value.commands.setContent(
|
|
22
|
+
const i = e.map(p);
|
|
23
|
+
n.value.commands.setContent(i, !0);
|
|
24
24
|
}
|
|
25
25
|
n.value.commands.focus();
|
|
26
26
|
}
|
|
27
|
-
},
|
|
27
|
+
}, x = (e, i = !0) => {
|
|
28
28
|
if (n.value) {
|
|
29
29
|
if (typeof e == "string")
|
|
30
30
|
n.value.commands.insertContent(e);
|
|
31
31
|
else {
|
|
32
|
-
const
|
|
33
|
-
n.value.commands.insertContent(
|
|
32
|
+
const o = e.map(p);
|
|
33
|
+
n.value.commands.insertContent(o);
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
i && n.value.commands.focus();
|
|
36
36
|
}
|
|
37
|
-
},
|
|
37
|
+
}, h = () => {
|
|
38
38
|
var e;
|
|
39
39
|
(e = n.value) == null || e.commands.focus();
|
|
40
|
-
},
|
|
40
|
+
}, R = () => {
|
|
41
41
|
var e;
|
|
42
42
|
(e = n.value) == null || e.commands.blur();
|
|
43
|
-
},
|
|
44
|
-
const { enableReadReceipt:
|
|
45
|
-
needReadReceipt:
|
|
46
|
-
}
|
|
47
|
-
|
|
43
|
+
}, A = async (e) => {
|
|
44
|
+
const { enableReadReceipt: i } = v(), o = {
|
|
45
|
+
needReadReceipt: i.value || !1
|
|
46
|
+
};
|
|
47
|
+
let s = e ?? m.value;
|
|
48
|
+
if (typeof s == "string" ? s = s.trim() : s = M(s), !s)
|
|
48
49
|
return;
|
|
49
|
-
if (typeof
|
|
50
|
-
|
|
51
|
-
payload: { text: f(
|
|
52
|
-
...
|
|
50
|
+
if (typeof s == "string") {
|
|
51
|
+
r.sendTextMessage({
|
|
52
|
+
payload: { text: f(s) },
|
|
53
|
+
...o
|
|
53
54
|
});
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
payload: { text: f(
|
|
60
|
-
...
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
[
|
|
64
|
-
[
|
|
57
|
+
let c = "";
|
|
58
|
+
const u = async () => {
|
|
59
|
+
c && (await r.sendTextMessage({
|
|
60
|
+
payload: { text: f(c) },
|
|
61
|
+
...o
|
|
62
|
+
}), c = "");
|
|
63
|
+
}, d = {
|
|
64
|
+
[a.TEXT]: (t) => t,
|
|
65
|
+
[a.IMAGE]: async (t) => (await u(), await r.sendImageMessage({
|
|
65
66
|
payload: { file: t },
|
|
66
|
-
...
|
|
67
|
+
...o
|
|
67
68
|
}), ""),
|
|
68
|
-
[
|
|
69
|
+
[a.VIDEO]: async (t) => (await u(), await r.sendVideoMessage({
|
|
69
70
|
payload: { file: t },
|
|
70
|
-
...
|
|
71
|
+
...o
|
|
71
72
|
}), ""),
|
|
72
|
-
[
|
|
73
|
+
[a.FILE]: async (t) => (await u(), await r.sendFileMessage({
|
|
73
74
|
payload: { file: t },
|
|
74
|
-
...
|
|
75
|
+
...o
|
|
75
76
|
}), ""),
|
|
76
|
-
[
|
|
77
|
-
[
|
|
77
|
+
[a.MENTION]: async () => (await u(), console.warn("Mention feature not implemented yet"), ""),
|
|
78
|
+
[a.EMOJI]: (t) => t.key
|
|
78
79
|
};
|
|
79
|
-
for (const t of
|
|
80
|
-
if (!t.type || !
|
|
80
|
+
for (const t of s) {
|
|
81
|
+
if (!t.type || !d[t.type])
|
|
81
82
|
throw new Error(`Invalid message type: ${t.type}`);
|
|
82
|
-
const g =
|
|
83
|
-
[
|
|
83
|
+
const g = d[t.type], T = await g(t.content);
|
|
84
|
+
[a.TEXT, a.EMOJI].includes(t.type) && (c += T);
|
|
84
85
|
}
|
|
85
|
-
await
|
|
86
|
+
await u();
|
|
86
87
|
};
|
|
87
|
-
function
|
|
88
|
+
function J() {
|
|
88
89
|
return {
|
|
89
90
|
inputRawValue: m,
|
|
90
91
|
isPeerTyping: y,
|
|
91
92
|
updateRawValue: E,
|
|
92
|
-
setEditorInstance:
|
|
93
|
-
setContent:
|
|
94
|
-
insertContent:
|
|
95
|
-
focusEditor:
|
|
96
|
-
blurEditor:
|
|
97
|
-
sendMessage:
|
|
93
|
+
setEditorInstance: C,
|
|
94
|
+
setContent: S,
|
|
95
|
+
insertContent: x,
|
|
96
|
+
focusEditor: h,
|
|
97
|
+
blurEditor: R,
|
|
98
|
+
sendMessage: A
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
w.watch(
|
|
101
|
+
function N() {
|
|
102
|
+
w.watch(I.CHAT, {
|
|
102
103
|
typingStatus: (e) => {
|
|
103
104
|
y.value = e;
|
|
104
105
|
}
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
|
|
108
|
+
N();
|
|
108
109
|
export {
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
a as MessageContentType,
|
|
111
|
+
J as useMessageInputState
|
|
111
112
|
};
|
|
@@ -27,4 +27,11 @@ declare function convertInputContentToEditorNode(item: InputContent): {
|
|
|
27
27
|
};
|
|
28
28
|
text?: undefined;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Trims whitespace from the beginning and end of an InputContent array,
|
|
32
|
+
* while preserving internal whitespace and line breaks
|
|
33
|
+
* @param content - The input content array to trim
|
|
34
|
+
* @returns Trimmed input content array
|
|
35
|
+
*/
|
|
36
|
+
declare function trimInputContent(content: InputContent[]): InputContent[];
|
|
37
|
+
export { trimInputContent, convertInputContentToEditorNode, };
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { MessageContentType as
|
|
2
|
-
function
|
|
1
|
+
import { MessageContentType as r } from "./type.js";
|
|
2
|
+
function l(e) {
|
|
3
3
|
switch (e.type) {
|
|
4
|
-
case
|
|
4
|
+
case r.TEXT:
|
|
5
5
|
return {
|
|
6
6
|
type: "text",
|
|
7
7
|
text: e.content
|
|
8
8
|
};
|
|
9
|
-
case
|
|
10
|
-
const t = e.content,
|
|
9
|
+
case r.IMAGE: {
|
|
10
|
+
const t = e.content, s = URL.createObjectURL(t);
|
|
11
11
|
return {
|
|
12
|
-
type:
|
|
12
|
+
type: r.IMAGE,
|
|
13
13
|
attrs: {
|
|
14
|
-
src:
|
|
14
|
+
src: s,
|
|
15
15
|
alt: t == null ? void 0 : t.name,
|
|
16
16
|
fileData: t,
|
|
17
17
|
title: t == null ? void 0 : t.name
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
case
|
|
21
|
+
case r.EMOJI: {
|
|
22
22
|
const t = e.content;
|
|
23
23
|
return {
|
|
24
|
-
type:
|
|
24
|
+
type: r.EMOJI,
|
|
25
25
|
attrs: {
|
|
26
26
|
src: t.url,
|
|
27
27
|
alt: t.key,
|
|
@@ -36,6 +36,26 @@ function c(e) {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
+
function f(e) {
|
|
40
|
+
if (e.length === 0)
|
|
41
|
+
return [];
|
|
42
|
+
let t = -1, s = -1;
|
|
43
|
+
for (let n = 0; n < e.length; n++) {
|
|
44
|
+
const o = e[n];
|
|
45
|
+
(o.type !== r.TEXT || o.content.trim().length > 0) && (t === -1 && (t = n), s = n);
|
|
46
|
+
}
|
|
47
|
+
return t === -1 ? [] : e.slice(t, s + 1).map((n, o, p) => {
|
|
48
|
+
if (n.type === r.TEXT) {
|
|
49
|
+
let c = n.content;
|
|
50
|
+
return o === 0 && (c = c.trimStart()), o === p.length - 1 && (c = c.trimEnd()), {
|
|
51
|
+
...n,
|
|
52
|
+
content: c
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return n;
|
|
56
|
+
}).filter((n) => n.type === r.TEXT ? n.content.length > 0 : !0);
|
|
57
|
+
}
|
|
39
58
|
export {
|
|
40
|
-
|
|
59
|
+
l as convertInputContentToEditorNode,
|
|
60
|
+
f as trimInputContent
|
|
41
61
|
};
|