yx-web-sdk 0.0.4

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.
Files changed (100) hide show
  1. package/README.md +424 -0
  2. package/dist/AntdIcon-B0sjNvGu.mjs +307 -0
  3. package/dist/CloseOutlined-DDb89ei3.mjs +37 -0
  4. package/dist/_plugin-vue_export-helper-1tPrXgE0.mjs +10 -0
  5. package/dist/ait-person-popover/index.d.ts +3 -0
  6. package/dist/ait-person-popover/index.js +5 -0
  7. package/dist/ait-person-popover/index.vue.d.ts +39 -0
  8. package/dist/chat-card/index.d.ts +3 -0
  9. package/dist/chat-card/index.js +5 -0
  10. package/dist/chat-card/index.vue.d.ts +25 -0
  11. package/dist/chat-content/index.d.ts +3 -0
  12. package/dist/chat-content/index.js +5 -0
  13. package/dist/chat-content/index.vue.d.ts +51 -0
  14. package/dist/chat-page/index.d.ts +3 -0
  15. package/dist/chat-page/index.js +5 -0
  16. package/dist/chat-page/index.vue.d.ts +6 -0
  17. package/dist/chat-room/index.d.ts +3 -0
  18. package/dist/chat-room/index.js +5 -0
  19. package/dist/chat-room/index.vue.d.ts +9 -0
  20. package/dist/common-avatar/index.d.ts +3 -0
  21. package/dist/common-avatar/index.js +5 -0
  22. package/dist/common-avatar/index.vue.d.ts +17 -0
  23. package/dist/components/ait-person-popover/index.d.ts +3 -0
  24. package/dist/components/ait-person-popover/index.vue.d.ts +39 -0
  25. package/dist/components/chat-card/index.d.ts +3 -0
  26. package/dist/components/chat-card/index.vue.d.ts +25 -0
  27. package/dist/components/chat-content/composables/ait-person.d.ts +86 -0
  28. package/dist/components/chat-content/index.d.ts +3 -0
  29. package/dist/components/chat-content/index.vue.d.ts +51 -0
  30. package/dist/components/chat-page/index.d.ts +3 -0
  31. package/dist/components/chat-page/index.vue.d.ts +6 -0
  32. package/dist/components/chat-room/index.d.ts +3 -0
  33. package/dist/components/chat-room/index.vue.d.ts +9 -0
  34. package/dist/components/common-avatar/index.d.ts +3 -0
  35. package/dist/components/common-avatar/index.vue.d.ts +17 -0
  36. package/dist/components/icon-font/index.d.ts +47 -0
  37. package/dist/components/index-entry/index.d.ts +2 -0
  38. package/dist/components/index-entry/index.vue.d.ts +25 -0
  39. package/dist/components/index.d.ts +12 -0
  40. package/dist/components/list.d.ts +2 -0
  41. package/dist/components/members-sidebar/index.d.ts +3 -0
  42. package/dist/components/members-sidebar/index.vue.d.ts +4 -0
  43. package/dist/components/notice-box/index.d.ts +3 -0
  44. package/dist/components/notice-box/index.vue.d.ts +13 -0
  45. package/dist/components/server-channel-sidebar/index.d.ts +3 -0
  46. package/dist/components/server-channel-sidebar/index.vue.d.ts +18 -0
  47. package/dist/global.css +39 -0
  48. package/dist/icon-font/index.d.ts +47 -0
  49. package/dist/icon-font/index.js +7 -0
  50. package/dist/index/style.css +199 -0
  51. package/dist/index/style2.css +175 -0
  52. package/dist/index/style3.css +36 -0
  53. package/dist/index/style4.css +168 -0
  54. package/dist/index/style5.css +147 -0
  55. package/dist/index/style6.css +43 -0
  56. package/dist/index/style7.css +491 -0
  57. package/dist/index/style8.css +19 -0
  58. package/dist/index-3sSWCzxu.mjs +225 -0
  59. package/dist/index-4m4OVlx8.mjs +611 -0
  60. package/dist/index-CFI0URc5.mjs +135 -0
  61. package/dist/index-Dg8Q3cli.mjs +1092 -0
  62. package/dist/index-entry/index.d.ts +2 -0
  63. package/dist/index-entry/index.js +271 -0
  64. package/dist/index-entry/index.vue.d.ts +25 -0
  65. package/dist/index-entry/style.css +51 -0
  66. package/dist/index.d.ts +8 -0
  67. package/dist/index.vue_vue_type_script_setup_true_lang-DkMXpHkt.mjs +158 -0
  68. package/dist/index.vue_vue_type_style_index_0_lang-CfLKcYM9.mjs +102 -0
  69. package/dist/index.vue_vue_type_style_index_0_lang-CibeOmhP.mjs +407 -0
  70. package/dist/index.vue_vue_type_style_index_0_lang-CmfE8EVU.mjs +288 -0
  71. package/dist/index.vue_vue_type_style_index_0_lang-XiDTgYoZ.mjs +1012 -0
  72. package/dist/index.vue_vue_type_style_index_0_lang-Y-vyKHWz.mjs +36985 -0
  73. package/dist/members-sidebar/index.d.ts +3 -0
  74. package/dist/members-sidebar/index.js +5 -0
  75. package/dist/members-sidebar/index.vue.d.ts +4 -0
  76. package/dist/notice-box/index.d.ts +3 -0
  77. package/dist/notice-box/index.js +5 -0
  78. package/dist/notice-box/index.vue.d.ts +13 -0
  79. package/dist/plugin/index.d.ts +22 -0
  80. package/dist/resolver/index.d.ts +22 -0
  81. package/dist/resolver/index.es.js +36 -0
  82. package/dist/resolver/index.umd.js +40 -0
  83. package/dist/server-channel-sidebar/index.d.ts +3 -0
  84. package/dist/server-channel-sidebar/index.js +5 -0
  85. package/dist/server-channel-sidebar/index.vue.d.ts +18 -0
  86. package/dist/stores/channel.d.ts +114 -0
  87. package/dist/stores/global.d.ts +15 -0
  88. package/dist/stores/index.d.ts +7 -0
  89. package/dist/stores/qchat.d.ts +397 -0
  90. package/dist/stores/sdk.d.ts +48 -0
  91. package/dist/stores/server.d.ts +58 -0
  92. package/dist/stores/user.d.ts +9 -0
  93. package/dist/style.css +1359 -0
  94. package/dist/types/missing.d.ts +14 -0
  95. package/dist/utils/events.d.ts +7 -0
  96. package/dist/utils/index.d.ts +26 -0
  97. package/dist/utils/storage.d.ts +15 -0
  98. package/dist/yx-web-sdk.es.js +41593 -0
  99. package/dist/yx-web-sdk.umd.js +41590 -0
  100. package/package.json +191 -0
@@ -0,0 +1,2 @@
1
+ import IndexEntry from '../components/index-entry/index.vue';
2
+ export default IndexEntry;
@@ -0,0 +1,271 @@
1
+ import { defineComponent, computed, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, unref, withCtx, createTextVNode, Fragment, createElementVNode, createBlock, createCommentVNode } from "vue";
2
+ import { useRouter } from "vue-router";
3
+ import { Spin, Result, Button, Empty, message } from "ant-design-vue";
4
+ import { u as useImSdkStore, a as useServerStore, b as useChannelStore, c as useUserStore, d as useGlobalStore } from "../index.vue_vue_type_style_index_0_lang-Y-vyKHWz.mjs";
5
+ import { _ as _sfc_main$1 } from "../index.vue_vue_type_style_index_0_lang-CmfE8EVU.mjs";
6
+ import { S as ServerChannelSidebar } from "../index-4m4OVlx8.mjs";
7
+ import { M as MembersSidebar } from "../index-3sSWCzxu.mjs";
8
+ import { _ as _export_sfc } from "../_plugin-vue_export-helper-1tPrXgE0.mjs";
9
+ const _hoisted_1 = { class: "qchat-container" };
10
+ const _hoisted_2 = {
11
+ key: 0,
12
+ class: "loading-wrap"
13
+ };
14
+ const _hoisted_3 = {
15
+ key: 1,
16
+ class: "error-wrap"
17
+ };
18
+ const _hoisted_4 = { class: "chat-main" };
19
+ const _hoisted_5 = {
20
+ key: 1,
21
+ class: "no-channel"
22
+ };
23
+ const _sfc_main = /* @__PURE__ */ defineComponent({
24
+ ...{
25
+ name: "IndexEntry"
26
+ },
27
+ __name: "index",
28
+ props: {
29
+ credentials: {},
30
+ autoInit: { type: Boolean },
31
+ serverId: {},
32
+ request: { type: Function }
33
+ },
34
+ emits: ["ready", "error", "message"],
35
+ setup(__props, { expose: __expose, emit: __emit }) {
36
+ const props = __props;
37
+ const emit = __emit;
38
+ const router = useRouter();
39
+ const imSdkStore = useImSdkStore();
40
+ const serverStore = useServerStore();
41
+ const channelStore = useChannelStore();
42
+ const userStore = useUserStore();
43
+ const globalStore = useGlobalStore();
44
+ const sdkInitializing = computed(() => imSdkStore.sdkInitializing);
45
+ const sdkError = computed(() => imSdkStore.sdkError);
46
+ const isReady = computed(() => imSdkStore.isReady);
47
+ const serverList = computed(() => serverStore.serverList);
48
+ const curServer = computed(() => serverStore.curServer);
49
+ const channelList = computed(() => channelStore.channelList);
50
+ const currentChannel = computed(() => channelStore.currentChannel);
51
+ const userProfile = computed(() => userStore.userProfile);
52
+ const handleInit = async () => {
53
+ if (!props.credentials) {
54
+ message.error("连接超时,关闭页面");
55
+ setTimeout(() => {
56
+ window.close();
57
+ }, 1e3);
58
+ return;
59
+ }
60
+ const success = await imSdkStore.init(props.credentials);
61
+ if (success) {
62
+ await initData();
63
+ setupEventListeners();
64
+ globalStore.login();
65
+ emit("ready");
66
+ } else {
67
+ emit("error", imSdkStore.sdkError);
68
+ }
69
+ };
70
+ const handleRetry = () => {
71
+ imSdkStore.resetError();
72
+ handleInit();
73
+ };
74
+ const initData = async () => {
75
+ try {
76
+ userStore.setUserProfile({
77
+ account: imSdkStore.currentAccount,
78
+ nick: imSdkStore.currentAccount
79
+ });
80
+ await serverStore.getSeverList({ timestamp: 0 });
81
+ if (serverList.value.length > 0) {
82
+ let targetServer = serverList.value[0];
83
+ if (props.serverId) {
84
+ const serverIdStr = String(props.serverId);
85
+ const foundServer = serverList.value.find((s) => String(s.serverId) === serverIdStr);
86
+ console.log("[initData] 查找服务器:", serverIdStr, "找到:", foundServer == null ? void 0 : foundServer.serverId);
87
+ if (foundServer) {
88
+ targetServer = foundServer;
89
+ }
90
+ }
91
+ console.log("[initData] 选中服务器:", targetServer.serverId, targetServer.name);
92
+ await handleSelectServer(targetServer);
93
+ }
94
+ } catch (error) {
95
+ console.error("初始化数据失败:", error);
96
+ }
97
+ };
98
+ const setupEventListeners = () => {
99
+ const qchat = window.qchat;
100
+ if (!qchat) return;
101
+ qchat.on("message", (msg) => {
102
+ var _a;
103
+ console.log("[QChat] 收到消息:", msg);
104
+ if (msg.channelId === ((_a = currentChannel.value) == null ? void 0 : _a.channelId)) {
105
+ channelStore.addCurChannelMsgs({ data: [msg], isUnShift: false });
106
+ }
107
+ emit("message", msg);
108
+ });
109
+ qchat.on("unreadInfo", (info) => {
110
+ console.log("[QChat] 未读信息更新:", info);
111
+ channelStore.setUnReadNum(info);
112
+ });
113
+ qchat.on("systemNotification", (notification) => {
114
+ console.log("[QChat] 系统通知:", notification);
115
+ handleSystemNotification(notification);
116
+ });
117
+ qchat.on("disconnect", () => {
118
+ console.log("[QChat] 连接断开");
119
+ message.warning("连接已断开,正在重连...");
120
+ });
121
+ qchat.on("reconnect", () => {
122
+ console.log("[QChat] 重新连接成功");
123
+ message.success("重新连接成功");
124
+ });
125
+ };
126
+ const handleSystemNotification = (notification) => {
127
+ var _a, _b;
128
+ const { type, serverId, fromNick, fromAccount } = notification;
129
+ switch (type) {
130
+ case "serverMemberJoin":
131
+ message.info(`${fromNick || fromAccount} 加入了服务器`);
132
+ break;
133
+ case "serverMemberLeave":
134
+ message.info(`${fromNick || fromAccount} 离开了服务器`);
135
+ break;
136
+ case "channelCreate":
137
+ if (serverId && serverId === ((_a = curServer.value) == null ? void 0 : _a.serverId)) {
138
+ channelStore.getChannelsByPage({ serverId, timetag: 0, limit: 20 });
139
+ }
140
+ break;
141
+ case "channelDelete":
142
+ if (serverId && serverId === ((_b = curServer.value) == null ? void 0 : _b.serverId)) {
143
+ channelStore.getChannelsByPage({ serverId, timetag: 0, limit: 20 });
144
+ }
145
+ break;
146
+ default:
147
+ console.log("[QChat] 未处理的系统通知类型:", type);
148
+ }
149
+ };
150
+ const handleSelectServer = async (server) => {
151
+ serverStore.setCurServer(server);
152
+ try {
153
+ const memberRes = await serverStore.getSeverMember({
154
+ accids: [{ accid: imSdkStore.currentAccount, serverId: server.serverId }]
155
+ });
156
+ if (memberRes && memberRes.length > 0) {
157
+ const memberInfo = memberRes[0];
158
+ userStore.setUserProfile({
159
+ ...memberInfo,
160
+ account: memberInfo.accid
161
+ });
162
+ }
163
+ } catch (error) {
164
+ console.error("获取服务器成员信息失败:", error);
165
+ }
166
+ await channelStore.getChannelsByPage({ serverId: server.serverId, timetag: 0, limit: 20 });
167
+ if (channelList.value.length > 0) {
168
+ const query = router.currentRoute.value.query;
169
+ if (query.channel_id && channelList.value.find((channel) => channel.channelId === query.channel_id)) {
170
+ await handleSelectChannel(channelList.value.find((channel) => channel.channelId === query.channel_id));
171
+ } else {
172
+ await handleSelectChannel(channelList.value[0]);
173
+ }
174
+ } else {
175
+ channelStore.setCurChannel(null);
176
+ channelStore.clearCurChannelMsgs();
177
+ }
178
+ };
179
+ const handleSelectChannel = async (channel) => {
180
+ var _a;
181
+ channelStore.setCurChannel(channel);
182
+ channelStore.resetChannelUnReadCount();
183
+ channelStore.clearCurChannelMsgs();
184
+ try {
185
+ const msgs = await channelStore.getChannelHistoryMsgs({ limit: 100 });
186
+ channelStore.setCurChannelMsgs(msgs);
187
+ } catch (error) {
188
+ console.error("加载消息失败:", error);
189
+ }
190
+ channelStore.getMembersByPage({
191
+ serverId: ((_a = serverStore.curServer) == null ? void 0 : _a.serverId) || "",
192
+ channelId: channel.channelId || "",
193
+ timetag: 0,
194
+ limit: 100
195
+ }).then((res) => {
196
+ console.log("res", res);
197
+ channelStore.setChannelMembers(res);
198
+ serverStore.setSeverMembers(res);
199
+ });
200
+ };
201
+ onMounted(() => {
202
+ if (props.autoInit && props.credentials) {
203
+ handleInit();
204
+ }
205
+ });
206
+ onUnmounted(() => {
207
+ const qchat = window.qchat;
208
+ if (qchat) {
209
+ qchat.off("message");
210
+ qchat.off("unreadInfo");
211
+ qchat.off("systemNotification");
212
+ qchat.off("disconnect");
213
+ qchat.off("reconnect");
214
+ }
215
+ });
216
+ __expose({
217
+ init: handleInit,
218
+ destroy: imSdkStore.destroy
219
+ });
220
+ return (_ctx, _cache) => {
221
+ return openBlock(), createElementBlock("div", _hoisted_1, [
222
+ sdkInitializing.value ? (openBlock(), createElementBlock("div", _hoisted_2, [
223
+ createVNode(unref(Spin), {
224
+ size: "large",
225
+ tip: "正在连接云信服务..."
226
+ })
227
+ ])) : sdkError.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
228
+ createVNode(unref(Result), {
229
+ status: "error",
230
+ title: "连接失败",
231
+ "sub-title": sdkError.value
232
+ }, {
233
+ extra: withCtx(() => [
234
+ createVNode(unref(Button), {
235
+ type: "primary",
236
+ onClick: handleRetry
237
+ }, {
238
+ default: withCtx(() => [..._cache[0] || (_cache[0] = [
239
+ createTextVNode("重新连接", -1)
240
+ ])]),
241
+ _: 1
242
+ })
243
+ ]),
244
+ _: 1
245
+ }, 8, ["sub-title"])
246
+ ])) : isReady.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
247
+ createVNode(ServerChannelSidebar, {
248
+ request: props.request,
249
+ onSelectServer: handleSelectServer,
250
+ onSelectChannel: handleSelectChannel
251
+ }, null, 8, ["request"]),
252
+ createElementVNode("div", _hoisted_4, [
253
+ currentChannel.value ? (openBlock(), createBlock(_sfc_main$1, {
254
+ key: 0,
255
+ "current-channel": currentChannel.value,
256
+ "my-accid": unref(imSdkStore).currentAccount,
257
+ "my-avatar": userProfile.value.avatar || ""
258
+ }, null, 8, ["current-channel", "my-accid", "my-avatar"])) : (openBlock(), createElementBlock("div", _hoisted_5, [
259
+ createVNode(unref(Empty), { description: "请选择一个频道开始聊天" })
260
+ ]))
261
+ ]),
262
+ currentChannel.value ? (openBlock(), createBlock(MembersSidebar, { key: 0 })) : createCommentVNode("", true)
263
+ ], 64)) : createCommentVNode("", true)
264
+ ]);
265
+ };
266
+ }
267
+ });
268
+ const IndexEntry = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-9c960781"]]);
269
+ export {
270
+ IndexEntry as default
271
+ };
@@ -0,0 +1,25 @@
1
+ import type { QChatMessage } from 'nim-web-sdk-ng/dist/v1/QCHAT_BROWSER_SDK/QChatMsgServiceInterface';
2
+ import type { IMCredentials } from '../../stores/sdk';
3
+ type __VLS_Props = {
4
+ credentials: IMCredentials;
5
+ autoInit?: boolean;
6
+ serverId?: string;
7
+ request: (options: {
8
+ url: string;
9
+ method: string;
10
+ data?: any;
11
+ }) => Promise<any>;
12
+ };
13
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {
14
+ init: () => Promise<void>;
15
+ destroy: () => Promise<void>;
16
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
+ message: (msg: QChatMessage) => any;
18
+ error: (error: string) => any;
19
+ ready: () => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
21
+ onMessage?: ((msg: QChatMessage) => any) | undefined;
22
+ onError?: ((error: string) => any) | undefined;
23
+ onReady?: (() => any) | undefined;
24
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
+ export default _default;
@@ -0,0 +1,51 @@
1
+ .qchat-container[data-v-9c960781] {
2
+ display: flex;
3
+ height: 100%;
4
+ width: 100%;
5
+ color: var(--theme-text);
6
+ font-family: "Whitney", "Helvetica Neue", Helvetica, Arial, sans-serif;
7
+ }
8
+ .loading-wrap[data-v-9c960781],
9
+ .error-wrap[data-v-9c960781],
10
+ .init-wrap[data-v-9c960781] {
11
+ display: flex;
12
+ align-items: center;
13
+ justify-content: center;
14
+ width: 100%;
15
+ height: 100%;
16
+ }
17
+ .loading-wrap[data-v-9c960781] .ant-spin-text,
18
+ .error-wrap[data-v-9c960781] .ant-spin-text,
19
+ .init-wrap[data-v-9c960781] .ant-spin-text {
20
+ color: #dcddde;
21
+ }
22
+ .loading-wrap[data-v-9c960781] .ant-result-title,
23
+ .loading-wrap[data-v-9c960781] .ant-result-subtitle,
24
+ .error-wrap[data-v-9c960781] .ant-result-title,
25
+ .error-wrap[data-v-9c960781] .ant-result-subtitle,
26
+ .init-wrap[data-v-9c960781] .ant-result-title,
27
+ .init-wrap[data-v-9c960781] .ant-result-subtitle {
28
+ color: #dcddde;
29
+ }
30
+ .loading-wrap[data-v-9c960781] .ant-empty-description,
31
+ .error-wrap[data-v-9c960781] .ant-empty-description,
32
+ .init-wrap[data-v-9c960781] .ant-empty-description {
33
+ color: #72767d;
34
+ }
35
+ .chat-main[data-v-9c960781] {
36
+ flex: 1;
37
+ display: flex;
38
+ flex-direction: column;
39
+ background-color: var(--theme-global-bg);
40
+ overflow: hidden;
41
+ min-width: 300px;
42
+ }
43
+ .chat-main .no-channel[data-v-9c960781] {
44
+ display: flex;
45
+ align-items: center;
46
+ justify-content: center;
47
+ height: 100%;
48
+ }
49
+ .chat-main .no-channel[data-v-9c960781] .ant-empty-description {
50
+ color: #72767d;
51
+ }
@@ -0,0 +1,8 @@
1
+ import './styles/global.scss';
2
+ import type { App } from 'vue';
3
+ export { YxWebSDKResolver } from './resolver/index';
4
+ declare const _default: {
5
+ name: string;
6
+ install(app: App): void;
7
+ };
8
+ export default _default;
@@ -0,0 +1,158 @@
1
+ import { defineComponent, ref, computed, watch, openBlock, createBlock, createElementBlock } from "vue";
2
+ import { _ as _sfc_main$1 } from "./index.vue_vue_type_style_index_0_lang-XiDTgYoZ.mjs";
3
+ import { b as useChannelStore, a as useServerStore, c as useUserStore } from "./index.vue_vue_type_style_index_0_lang-Y-vyKHWz.mjs";
4
+ const _hoisted_1 = { key: 1 };
5
+ const HISTORY_LIMIT = 100;
6
+ const _sfc_main = /* @__PURE__ */ defineComponent({
7
+ ...{
8
+ name: "ChatRoom"
9
+ },
10
+ __name: "index",
11
+ props: {
12
+ myAccid: { default: "" },
13
+ myAvatar: { default: "" }
14
+ },
15
+ setup(__props) {
16
+ const channelStore = useChannelStore();
17
+ const serverStore = useServerStore();
18
+ const userStore = useUserStore();
19
+ const props = __props;
20
+ const imgUploading = ref(false);
21
+ const fileUploading = ref(false);
22
+ const isNoMore = ref(false);
23
+ const sendDisabled = ref(false);
24
+ const hasCurrentChannel = ref(false);
25
+ const channelName = computed(() => {
26
+ var _a;
27
+ return (_a = channelStore.currentChannel) == null ? void 0 : _a.name;
28
+ });
29
+ const topic = computed(() => {
30
+ var _a;
31
+ return (_a = channelStore.currentChannel) == null ? void 0 : _a.topic;
32
+ });
33
+ const msgs = computed(() => channelStore.currentChannelMsgs);
34
+ watch(
35
+ () => channelStore.currentChannel,
36
+ async (currentChannel) => {
37
+ sendDisabled.value = false;
38
+ if (currentChannel) {
39
+ hasCurrentChannel.value = true;
40
+ const msgs2 = await channelStore.getChannelHistoryMsgs({
41
+ limit: HISTORY_LIMIT
42
+ });
43
+ channelStore.setCurChannelMsgs(msgs2);
44
+ if (msgs2.length < HISTORY_LIMIT) {
45
+ isNoMore.value = true;
46
+ } else {
47
+ isNoMore.value = false;
48
+ }
49
+ } else {
50
+ hasCurrentChannel.value = false;
51
+ }
52
+ },
53
+ { immediate: true }
54
+ );
55
+ const sendMessage = (type, file, option) => {
56
+ if (type === "textMsg") {
57
+ channelStore.sendTextMsg({ body: file, ext: option == null ? void 0 : option.ext, mentionAccids: option == null ? void 0 : option.mentionAccids });
58
+ return;
59
+ }
60
+ if (type === "SendImg") {
61
+ imgUploading.value = true;
62
+ channelStore.sendImageMsg({
63
+ file,
64
+ onUploadStart: () => {
65
+ imgUploading.value = true;
66
+ },
67
+ onUploadDone: () => {
68
+ imgUploading.value = false;
69
+ }
70
+ });
71
+ return;
72
+ }
73
+ if (type === "SendFile") {
74
+ fileUploading.value = true;
75
+ channelStore.sendFileMsg({
76
+ file,
77
+ onUploadStart: () => {
78
+ fileUploading.value = true;
79
+ },
80
+ onUploadDone: () => {
81
+ fileUploading.value = false;
82
+ }
83
+ });
84
+ return;
85
+ }
86
+ };
87
+ const checkSendAuth = (type, file, option) => {
88
+ var _a, _b, _c;
89
+ sendDisabled.value = false;
90
+ if (((_a = serverStore.curServer) == null ? void 0 : _a.owner) === userStore.userProfile.account) {
91
+ sendDisabled.value = false;
92
+ sendMessage(type, file, option);
93
+ } else {
94
+ serverStore.checkPermissionMessage({
95
+ serverId: ((_b = serverStore.curServer) == null ? void 0 : _b.serverId) || "",
96
+ channelId: ((_c = channelStore.currentChannel) == null ? void 0 : _c.channelId) || "",
97
+ auth: "sendMsg"
98
+ }).then((resp) => {
99
+ if (resp) {
100
+ sendDisabled.value = false;
101
+ sendMessage(type, file, option);
102
+ }
103
+ });
104
+ }
105
+ };
106
+ const handleSendText = (text, option) => {
107
+ checkSendAuth("textMsg", text, option);
108
+ };
109
+ const handleSendImg = (file) => {
110
+ checkSendAuth("SendImg", file);
111
+ };
112
+ const handleSendFile = (file) => {
113
+ checkSendAuth("SendFile", file);
114
+ };
115
+ const handleResendText = (res) => {
116
+ channelStore.resendTextMsg(res);
117
+ };
118
+ const handleResendImg = (res) => {
119
+ channelStore.resendImageMsg(res);
120
+ };
121
+ const handleResendFile = (res) => {
122
+ channelStore.resendFileMsg(res);
123
+ };
124
+ const onLoadMore = async (lastTime) => {
125
+ const msgs2 = await channelStore.loadMoreHistoryMsgs({
126
+ limit: HISTORY_LIMIT,
127
+ lastTime
128
+ });
129
+ if (msgs2.length < HISTORY_LIMIT) {
130
+ isNoMore.value = true;
131
+ }
132
+ };
133
+ return (_ctx, _cache) => {
134
+ return hasCurrentChannel.value ? (openBlock(), createBlock(_sfc_main$1, {
135
+ key: 0,
136
+ msgs: msgs.value,
137
+ "channel-name": channelName.value,
138
+ "my-accid": props.myAccid,
139
+ "my-avatar": props.myAvatar,
140
+ topic: topic.value,
141
+ "is-no-more": isNoMore.value,
142
+ "img-uploading": imgUploading.value,
143
+ "file-uploading": fileUploading.value,
144
+ "send-disabled": sendDisabled.value,
145
+ "on-load-more": onLoadMore,
146
+ onSendText: handleSendText,
147
+ onSendFile: handleSendFile,
148
+ onSendImg: handleSendImg,
149
+ onResendText: handleResendText,
150
+ onResendImg: handleResendImg,
151
+ onResendFile: handleResendFile
152
+ }, null, 8, ["msgs", "channel-name", "my-accid", "my-avatar", "topic", "is-no-more", "img-uploading", "file-uploading", "send-disabled"])) : (openBlock(), createElementBlock("div", _hoisted_1, "当前服务器下没有频道~"));
153
+ };
154
+ }
155
+ });
156
+ export {
157
+ _sfc_main as _
158
+ };
@@ -0,0 +1,102 @@
1
+ import { defineComponent, ref, computed, onMounted, watch, onUnmounted, openBlock, createElementBlock, createElementVNode, createVNode, unref, createTextVNode, normalizeStyle, normalizeClass, toDisplayString, createCommentVNode } from "vue";
2
+ import { I as IconFont } from "./index-Dg8Q3cli.mjs";
3
+ const _hoisted_1 = { class: "yx-channel-notice" };
4
+ const _hoisted_2 = { class: "yx-channel-notice-icon" };
5
+ const _hoisted_3 = { class: "yx-channel-notice-text-item" };
6
+ const _hoisted_4 = {
7
+ key: 0,
8
+ class: "yx-channel-notice-text-item"
9
+ };
10
+ const _sfc_main = /* @__PURE__ */ defineComponent({
11
+ ...{
12
+ name: "NoticeBox"
13
+ },
14
+ __name: "index",
15
+ props: {
16
+ content: {},
17
+ scrollSpeed: { default: 40 },
18
+ scrollDelayMs: { default: 3e3 }
19
+ },
20
+ setup(__props) {
21
+ const props = __props;
22
+ const textWrapRef = ref(null);
23
+ const shouldScroll = ref(false);
24
+ const scrollStarted = ref(false);
25
+ let scrollStartTimer = null;
26
+ const scrollDuration = ref(0);
27
+ const scrollStyle = computed(
28
+ () => scrollStarted.value && scrollDuration.value > 0 ? { "--yx-notice-duration": `${scrollDuration.value}s` } : void 0
29
+ );
30
+ function checkOverflow() {
31
+ const el = textWrapRef.value;
32
+ if (!el) return;
33
+ const inner = el.querySelector(".yx-channel-notice-text-inner");
34
+ if (!inner) return;
35
+ const overflow = inner.scrollWidth > el.clientWidth;
36
+ shouldScroll.value = overflow;
37
+ scrollStarted.value = false;
38
+ if (scrollStartTimer) {
39
+ clearTimeout(scrollStartTimer);
40
+ scrollStartTimer = null;
41
+ }
42
+ if (overflow) {
43
+ const distance = inner.scrollWidth * 0.5;
44
+ scrollDuration.value = distance / props.scrollSpeed;
45
+ scrollStartTimer = setTimeout(() => {
46
+ scrollStarted.value = true;
47
+ scrollStartTimer = null;
48
+ }, props.scrollDelayMs);
49
+ } else {
50
+ scrollDuration.value = 0;
51
+ }
52
+ }
53
+ onMounted(() => {
54
+ checkOverflow();
55
+ });
56
+ watch(
57
+ () => [props.content, props.scrollSpeed, props.scrollDelayMs],
58
+ () => {
59
+ shouldScroll.value = false;
60
+ scrollStarted.value = false;
61
+ scrollDuration.value = 0;
62
+ if (scrollStartTimer) {
63
+ clearTimeout(scrollStartTimer);
64
+ scrollStartTimer = null;
65
+ }
66
+ requestAnimationFrame(() => {
67
+ requestAnimationFrame(checkOverflow);
68
+ });
69
+ }
70
+ );
71
+ onUnmounted(() => {
72
+ if (scrollStartTimer) clearTimeout(scrollStartTimer);
73
+ });
74
+ return (_ctx, _cache) => {
75
+ return openBlock(), createElementBlock("div", _hoisted_1, [
76
+ createElementVNode("div", _hoisted_2, [
77
+ createVNode(unref(IconFont), {
78
+ type: "gt-plane-releases-blue",
79
+ size: 20
80
+ })
81
+ ]),
82
+ _cache[0] || (_cache[0] = createTextVNode(" 📌 公告: ", -1)),
83
+ createElementVNode("div", {
84
+ ref_key: "textWrapRef",
85
+ ref: textWrapRef,
86
+ class: "yx-channel-notice-text"
87
+ }, [
88
+ createElementVNode("div", {
89
+ class: normalizeClass(["yx-channel-notice-text-inner", { "yx-channel-notice-text--scroll": scrollStarted.value }]),
90
+ style: normalizeStyle(scrollStyle.value)
91
+ }, [
92
+ createElementVNode("span", _hoisted_3, toDisplayString(__props.content), 1),
93
+ shouldScroll.value ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.content), 1)) : createCommentVNode("", true)
94
+ ], 6)
95
+ ], 512)
96
+ ]);
97
+ };
98
+ }
99
+ });
100
+ export {
101
+ _sfc_main as _
102
+ };