Skip to content

Commit 810e55c

Browse files
committed
feat: emoji, voice, pic, call, video, file, gift, transfer, red envelop for chatting
1 parent ed1aab7 commit 810e55c

10 files changed

Lines changed: 1843 additions & 112 deletions

File tree

‎apps/chat-demo/client/i18n/locales/en.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,21 @@ export const en = {
308308
authors: "Authors",
309309
contacts: "Contacts",
310310
addressBook: "Address book",
311+
signature: "Signature",
312+
phone: "Phone",
313+
remark: "Remark",
314+
tags: "Tags",
315+
addRemark: "Set a remark name",
316+
addTags: "Add tags",
317+
block: "Block",
318+
blocked: "Blocked",
319+
unblock: "Unblock",
320+
unblocked: "Unblocked",
321+
hideTheirFeed: "Hide their moments",
322+
hideMine: "Don't let them see my moments",
323+
moments: "Moments",
324+
momentsEmpty: "No moments yet",
325+
noChat: "No conversation with this contact yet",
311326
hosts: "Hosts",
312327
people: "People",
313328
subscribers: "subscribers",
@@ -485,6 +500,31 @@ export const en = {
485500
outOfStock: "Out of stock",
486501
send: "Send",
487502
composerHint: "Message…",
503+
im: {
504+
emoji: "Emoji",
505+
voice: "Voice",
506+
image: "Photo",
507+
camera: "Camera",
508+
file: "File",
509+
location: "Location",
510+
myLocation: "My location",
511+
noGeo: "Location unavailable",
512+
hongbao: "Red packet",
513+
hongbaoAmount: "Amount",
514+
hongbaoBless: "Best wishes",
515+
hongbaoSend: "Send packet",
516+
transfer: "Transfer",
517+
transferAmount: "Amount",
518+
transferNote: "Add a note",
519+
transferSend: "Transfer",
520+
transferDefault: "Transfer",
521+
voiceCall: "Voice call",
522+
videoCall: "Video call",
523+
hangup: "Hang up",
524+
holdTalk: "Hold to talk",
525+
releaseEnd: "Release to send",
526+
more: "More",
527+
},
488528
moreFrom: "More from this list",
489529
needLogin: "Log in first (top-right) to call the API",
490530
subscribed: "Subscribed",

‎apps/chat-demo/client/i18n/locales/zh-CN.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ export const zhCN: TranslationSchema = {
307307
authors: "作者",
308308
contacts: "联系人",
309309
addressBook: "通讯录",
310+
signature: "个性签名",
311+
phone: "电话",
312+
remark: "备注名",
313+
tags: "标签",
314+
addRemark: "设置备注名",
315+
addTags: "添加标签",
316+
block: "拉黑",
317+
blocked: "已拉黑",
318+
unblock: "取消拉黑",
319+
unblocked: "已取消拉黑",
320+
hideTheirFeed: "屏蔽 TA 的动态",
321+
hideMine: "不让 TA 看我的动态",
322+
moments: "最新动态",
323+
momentsEmpty: "暂无动态",
324+
noChat: "还没有和 TA 的会话",
310325
hosts: "主办方",
311326
people: "用户",
312327
subscribers: "位订阅者",
@@ -483,6 +498,31 @@ export const zhCN: TranslationSchema = {
483498
outOfStock: "缺货",
484499
send: "发送",
485500
composerHint: "发消息…",
501+
im: {
502+
emoji: "表情",
503+
voice: "语音",
504+
image: "图片",
505+
camera: "拍摄",
506+
file: "文件",
507+
location: "位置",
508+
myLocation: "我的位置",
509+
noGeo: "无法获取位置",
510+
hongbao: "红包",
511+
hongbaoAmount: "金额",
512+
hongbaoBless: "恭喜发财,大吉大利",
513+
hongbaoSend: "塞钱进红包",
514+
transfer: "转账",
515+
transferAmount: "金额",
516+
transferNote: "添加转账说明",
517+
transferSend: "转账",
518+
transferDefault: "微信转账",
519+
voiceCall: "语音通话",
520+
videoCall: "视频通话",
521+
hangup: "挂断",
522+
holdTalk: "按住 说话",
523+
releaseEnd: "松开 结束",
524+
more: "更多",
525+
},
486526
moreFrom: "本页其它内容",
487527
needLogin: "请先登录(右上角),才能调用接口",
488528
subscribed: "已订阅",

‎apps/chat-demo/client/layout-actions.ts‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,56 @@ function pickId(obj: Record<string, unknown>): string | number | null {
347347
return null;
348348
}
349349

350-
/** Parse a bound comment-list GET — any table shape, scored fields. */
350+
export type AuthorFeedItem = {
351+
id: string | number;
352+
cells: Record<string, unknown>;
353+
};
354+
355+
/** Latest posts by one author — table/field names come from comments. */
356+
export async function fetchAuthorFeed(opts: {
357+
base: string;
358+
table: string;
359+
authorField: string;
360+
authorId: string | number;
361+
dateField?: string | null;
362+
count?: number;
363+
}): Promise<AuthorFeedItem[]> {
364+
const item: Record<string, unknown> = {
365+
[opts.authorField]: opts.authorId,
366+
};
367+
if (opts.dateField) item["@order"] = `${opts.dateField}-`;
368+
const json = await fetchBoundGet(opts.base, {
369+
"[]": {
370+
[opts.table]: item,
371+
count: opts.count ?? 6,
372+
query: 2,
373+
},
374+
});
375+
if (!json) return [];
376+
const list = Array.isArray(json["[]"])
377+
? json["[]"]
378+
: Array.isArray(json.list)
379+
? json.list
380+
: [];
381+
const out: AuthorFeedItem[] = [];
382+
for (const raw of list) {
383+
const row = asRecord(raw);
384+
if (!row) continue;
385+
const rec =
386+
asRecord(row[opts.table]) ||
387+
firstNestedRecords(row)[0] ||
388+
row;
389+
const id = pickId(rec);
390+
if (id == null) continue;
391+
const cells: Record<string, unknown> = {};
392+
for (const [k, v] of Object.entries(rec)) {
393+
cells[`${opts.table}.${k}`] = v;
394+
}
395+
out.push({ id, cells });
396+
}
397+
return out;
398+
}
399+
351400
export function parseCommentsFromResponse(json: unknown): SocialComment[] {
352401
if (!json || typeof json !== "object") return [];
353402
const root = json as Record<string, unknown>;

‎apps/chat-demo/client/layout-category.ts‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,61 @@ export function inferAppScopeField(
197197
return pickField(table, comments, APP_SCOPE_TOKENS, extra);
198198
}
199199

200+
const AUTHOR_ID_TOKENS = [
201+
"userid",
202+
"authorid",
203+
"ownerid",
204+
"uid",
205+
"publisherid",
206+
"作者",
207+
];
208+
209+
const DATE_ORDER_TOKENS = [
210+
"date",
211+
"time",
212+
"created",
213+
"createtime",
214+
"createdat",
215+
"published",
216+
"publishtime",
217+
"updatetime",
218+
"时间",
219+
"日期",
220+
];
221+
222+
export function inferAuthorIdField(
223+
table: string,
224+
comments: SchemaComments | null | undefined,
225+
extra?: string[],
226+
): string | null {
227+
return pickField(table, comments, AUTHOR_ID_TOKENS, extra);
228+
}
229+
230+
export function inferDateOrderField(
231+
table: string,
232+
comments: SchemaComments | null | undefined,
233+
extra?: string[],
234+
): string | null {
235+
return pickField(table, comments, DATE_ORDER_TOKENS, extra);
236+
}
237+
238+
const PEER_ID_TOKENS = [
239+
"toid",
240+
"touserid",
241+
"receiverid",
242+
"targetid",
243+
"peerid",
244+
"对方",
245+
];
246+
247+
export function inferPeerIdField(
248+
table: string,
249+
comments: SchemaComments | null | undefined,
250+
extra?: string[],
251+
): string | null {
252+
return pickField(table, comments, PEER_ID_TOKENS, extra);
253+
}
254+
200255
function inferSortField(
201256
table: string,
202257
comments: SchemaComments | null | undefined,

0 commit comments

Comments
 (0)