新分支:Vite+React19+TS+Tailwind v4 重新搭建,先跑通四级响应式布局壳
不再沿用旧 im_webapp 的技术栈(webpack + class组件 + 15000行全局CSS + 手搓History路由), 按业务重新选型:Vite/React Router/Zustand预留/TanStack Query/保留tinode-sdk真实依赖 (协议客户端本身没有重写的业务理由)。新代码放在 web/ 子目录,旧代码原样保留在仓库根目录, 两者共存到重写完成。 这一步先验证布局壳本身:NavRail(消息/通讯录/收藏/文件助手/通话记录/设置)+ 会话列表 + 主区域 + 详情栏,按设计稿的四档断点(<640/640-959/960-1279/≥1280)用真实浏览器宽度逐档验证 过——两列及以下"列表/主区域二选一+返回键"、三列"详情栏抽屉化"、四列"详情栏常驻"均已用 真实点击/返回验证正确,不是只看了截图。会话列表和聊天内容目前是占位数据,业务数据接入和 Tinode连接是下一步。 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
4e8f45d7d8
commit
8bcd9f3a5b
@@ -0,0 +1,40 @@
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Navigate, createBrowserRouter, RouterProvider } from 'react-router-dom';
|
||||
|
||||
import { AppShell } from '@/app/AppShell';
|
||||
import { SectionPlaceholder } from '@/app/SectionPlaceholder';
|
||||
import { ConversationView } from '@/features/messages/ConversationView';
|
||||
import { EmptyMain } from '@/features/messages/EmptyMain';
|
||||
import { MessagesLayout } from '@/features/messages/MessagesLayout';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
element: <AppShell />,
|
||||
children: [
|
||||
{ index: true, element: <Navigate to="/messages" replace /> },
|
||||
{
|
||||
path: 'messages',
|
||||
element: <MessagesLayout />,
|
||||
children: [
|
||||
{ index: true, element: <EmptyMain /> },
|
||||
{ path: ':topicId', element: <ConversationView /> },
|
||||
],
|
||||
},
|
||||
{ path: 'contacts', element: <SectionPlaceholder title="通讯录" /> },
|
||||
{ path: 'favorites', element: <SectionPlaceholder title="我的收藏" /> },
|
||||
{ path: 'files', element: <SectionPlaceholder title="文件助手" /> },
|
||||
{ path: 'calls', element: <SectionPlaceholder title="通话记录" /> },
|
||||
{ path: 'settings', element: <SectionPlaceholder title="设置" /> },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<RouterProvider router={router} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import { BottomTabBar } from './BottomTabBar';
|
||||
import { NavRail } from './NavRail';
|
||||
|
||||
/**
|
||||
* Top-level chrome: persistent icon rail (>=640px) or bottom tab bar (<640px), wrapping whichever
|
||||
* feature section is active. Each feature section owns its own list/main/detail responsive split
|
||||
* internally (see e.g. features/messages) -- this shell only decides "rail vs tabs", nothing about
|
||||
* columns within a section.
|
||||
*/
|
||||
export function AppShell() {
|
||||
return (
|
||||
<div className="flex h-dvh w-full overflow-hidden bg-surface-page">
|
||||
<div className="hidden sm:flex sm:h-full">
|
||||
<NavRail />
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-1 flex-col overflow-hidden">
|
||||
<div className="min-h-0 flex-1 overflow-hidden">
|
||||
<Outlet />
|
||||
</div>
|
||||
<div className="sm:hidden">
|
||||
<BottomTabBar />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
import { Icon } from './Icon';
|
||||
|
||||
const TABS = [
|
||||
{ to: '/messages', icon: 'chat_bubble', label: '消息' },
|
||||
{ to: '/contacts', icon: 'contacts', label: '通讯录' },
|
||||
{ to: '/settings', icon: 'person', label: '我的' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Replaces the old app's message-center-view.jsx-embedded 2-tab (消息/工作台) bar: this one is
|
||||
* top-level (visible regardless of which section is open, not just inside the message list) and
|
||||
* has 3 tabs per the new design, since 工作台 no longer exists.
|
||||
*/
|
||||
export function BottomTabBar() {
|
||||
return (
|
||||
<nav className="grid h-[82px] flex-none grid-cols-3 border-t border-border-panel bg-white pb-4.5">
|
||||
{TABS.map((tab) => (
|
||||
<NavLink
|
||||
key={tab.to}
|
||||
to={tab.to}
|
||||
className={({ isActive }) =>
|
||||
`flex flex-col items-center justify-center gap-0.5 text-[11px] no-underline ${
|
||||
isActive ? 'text-accent' : 'text-text-tertiary-3'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<Icon name={tab.icon} className="!text-2xl" />
|
||||
{tab.label}
|
||||
</NavLink>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
/** Thin wrapper around a Material Icons ligature glyph (font loaded in index.html). */
|
||||
export function Icon({ name, className = '' }: { name: string; className?: string }) {
|
||||
return <i className={`material-icons select-none ${className}`}>{name}</i>;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { NavLink } from 'react-router-dom';
|
||||
|
||||
import { Icon } from './Icon';
|
||||
|
||||
interface NavRailItem {
|
||||
to: string;
|
||||
icon: string;
|
||||
label: string;
|
||||
badge?: number;
|
||||
}
|
||||
|
||||
const TOP_ITEMS: NavRailItem[] = [
|
||||
{ to: '/messages', icon: 'chat_bubble', label: '消息' },
|
||||
{ to: '/contacts', icon: 'contacts', label: '通讯录' },
|
||||
{ to: '/favorites', icon: 'inventory_2', label: '收藏' },
|
||||
{ to: '/files', icon: 'folder', label: '文件助手' },
|
||||
];
|
||||
|
||||
const BOTTOM_ITEMS: NavRailItem[] = [
|
||||
{ to: '/calls', icon: 'phone', label: '通话记录' },
|
||||
{ to: '/settings', icon: 'settings', label: '设置' },
|
||||
];
|
||||
|
||||
function NavRailButton({ item }: { item: NavRailItem }) {
|
||||
return (
|
||||
<NavLink
|
||||
to={item.to}
|
||||
title={item.label}
|
||||
className={({ isActive }) =>
|
||||
`relative grid h-11 w-11 place-items-center rounded-[10px] no-underline ${
|
||||
isActive ? 'bg-accent-soft-bg text-accent' : 'text-icon-default'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<Icon name={item.icon} className="!text-2xl" />
|
||||
{item.badge ? (
|
||||
<b className="absolute top-1 right-0.5 grid h-4 min-w-4 place-items-center rounded-full bg-unread px-1 text-[10px] leading-none font-medium text-white">
|
||||
{item.badge}
|
||||
</b>
|
||||
) : null}
|
||||
</NavLink>
|
||||
);
|
||||
}
|
||||
|
||||
/** Persistent 64px icon rail, visible at >=640px (see App.tsx for the <640 bottom-tab fallback). */
|
||||
export function NavRail({ selfInitial = '我', unreadMessages = 0 }: { selfInitial?: string; unreadMessages?: number }) {
|
||||
return (
|
||||
<nav className="flex h-full w-16 flex-none flex-col items-center border-r border-border-panel bg-surface-rail py-3.5">
|
||||
<div className="mb-5 grid h-[38px] w-[38px] place-items-center rounded-[10px] bg-accent text-base font-medium text-white">
|
||||
{selfInitial}
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col items-center gap-1.5">
|
||||
{TOP_ITEMS.map((item) => (
|
||||
<NavRailButton key={item.to} item={item.to === '/messages' ? { ...item, badge: unreadMessages } : item} />
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-col items-center gap-1.5">
|
||||
{BOTTOM_ITEMS.map((item) => (
|
||||
<NavRailButton key={item.to} item={item} />
|
||||
))}
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function SectionPlaceholder({ title }: { title: string }) {
|
||||
return (
|
||||
<div className="flex h-full w-full items-center justify-center bg-surface-content text-sm text-text-tertiary-4">
|
||||
{title}(后续阶段实现)
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { Link, useOutletContext, useParams } from 'react-router-dom';
|
||||
|
||||
import { Icon } from '@/app/Icon';
|
||||
|
||||
interface OutletCtx {
|
||||
onToggleDetail: () => void;
|
||||
}
|
||||
|
||||
/** Placeholder chat surface -- real header/bubbles/composer land in Phase 1. */
|
||||
export function ConversationView() {
|
||||
const { topicId } = useParams();
|
||||
const { onToggleDetail } = useOutletContext<OutletCtx>();
|
||||
|
||||
return (
|
||||
<div className="flex h-full w-full flex-col bg-surface-chat">
|
||||
<header className="flex h-15 flex-none items-center justify-between border-b border-border-panel bg-white px-5">
|
||||
<div className="flex items-center gap-2">
|
||||
{/* Only the <960 tiers hide the list column, so only there do we need our own way back. */}
|
||||
<Link to="/messages" className="grid h-9.5 w-9.5 place-items-center text-text-heading md:hidden">
|
||||
<Icon name="arrow_back_ios_new" />
|
||||
</Link>
|
||||
<strong className="text-base font-semibold text-text-heading">{topicId}</strong>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onToggleDetail}
|
||||
className="grid h-9.5 w-9.5 place-items-center rounded-lg text-text-tertiary-1 md:bg-accent-soft-bg md:text-accent lg:bg-transparent lg:text-text-tertiary-1"
|
||||
>
|
||||
<Icon name="info" />
|
||||
</button>
|
||||
</header>
|
||||
<div className="flex flex-1 items-center justify-center text-sm text-text-tertiary-4">
|
||||
消息流占位(阶段1实现)
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Icon } from '@/app/Icon';
|
||||
|
||||
export function EmptyMain() {
|
||||
return (
|
||||
<div className="flex h-full w-full flex-col items-center justify-center gap-2 bg-surface-content text-text-tertiary-4">
|
||||
<Icon name="forum" className="!text-5xl" />
|
||||
<span className="text-sm">选择一个会话开始聊天</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Outlet, useParams } from 'react-router-dom';
|
||||
|
||||
import { Icon } from '@/app/Icon';
|
||||
|
||||
const PLACEHOLDER_CHATS = [
|
||||
{ id: 'grp1', name: '项目协作群', summary: '陈明远:@我 明天上午十点开项目会,请准时参加', time: '10:24', unread: 5 },
|
||||
{ id: 'p1', name: '接语彤', summary: '我:收到,我会提前准备材料。', time: '10:12', unread: 0 },
|
||||
{ id: 'grp2', name: '产品评审群', summary: '[图片]', time: '09:47', unread: 2 },
|
||||
];
|
||||
|
||||
function ChatListColumn() {
|
||||
const { topicId } = useParams();
|
||||
return (
|
||||
<aside className="flex h-full w-full flex-none flex-col border-r border-border-panel bg-white md:w-[300px] lg:w-80">
|
||||
<header className="flex h-15 flex-none items-center justify-between px-5">
|
||||
<h1 className="m-0 text-xl font-semibold text-text-heading">消息</h1>
|
||||
<Icon name="add_comment" className="text-text-heading" />
|
||||
</header>
|
||||
<div className="flex flex-1 flex-col overflow-y-auto">
|
||||
{PLACEHOLDER_CHATS.map((chat) => (
|
||||
<a
|
||||
key={chat.id}
|
||||
href={`/messages/${chat.id}`}
|
||||
className={`grid min-h-[68px] grid-cols-[44px_minmax(0,1fr)_auto] items-center gap-3 border-b border-list-item px-4 py-2.5 no-underline ${
|
||||
topicId === chat.id ? 'bg-accent-selected-bg' : 'bg-white'
|
||||
}`}
|
||||
>
|
||||
<span className="grid h-11 w-11 place-items-center rounded-lg bg-avatar-1 text-base font-medium text-white">
|
||||
{chat.name.slice(0, 1)}
|
||||
</span>
|
||||
<span className="flex min-w-0 flex-col gap-1">
|
||||
<strong className="truncate text-[15px] font-medium text-[#272b31]">{chat.name}</strong>
|
||||
<small className="truncate text-[13px] text-text-tertiary-2">{chat.summary}</small>
|
||||
</span>
|
||||
<span className="flex flex-none flex-col items-end justify-between gap-1.5">
|
||||
<time className="text-xs text-text-tertiary-3">{chat.time}</time>
|
||||
{chat.unread ? (
|
||||
<b className="grid h-[18px] min-w-[18px] place-items-center rounded-full bg-unread px-1.5 text-[11px] font-medium text-white">
|
||||
{chat.unread}
|
||||
</b>
|
||||
) : null}
|
||||
</span>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
function DetailColumn({ onClose }: { onClose?: () => void }) {
|
||||
return (
|
||||
<aside className="flex h-full w-full flex-none flex-col overflow-y-auto border-l border-border-panel bg-white md:w-[300px]">
|
||||
<header className="flex h-15 flex-none items-center justify-between border-b border-list-item px-5">
|
||||
<strong className="text-[15px] font-semibold">聊天设置</strong>
|
||||
{onClose ? (
|
||||
<button type="button" onClick={onClose} className="grid h-8 w-8 place-items-center text-text-tertiary-4">
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
) : null}
|
||||
</header>
|
||||
<div className="p-5 text-sm text-text-secondary">详情栏内容占位(阶段1实现)</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The 4-tier responsive split described in the design handoff:
|
||||
* - <640 and 640-959: list OR main, whichever the route implies (topicId present -> main; the
|
||||
* conversation header then needs its own back-to-list affordance, since NavRail alone doesn't
|
||||
* provide one at this tier -- see ConversationView).
|
||||
* - 960-1279: list + main together, detail as an overlay drawer toggled by the header's "i" icon.
|
||||
* - >=1280: list + main + detail all docked side by side.
|
||||
*/
|
||||
export function MessagesLayout() {
|
||||
const { topicId } = useParams();
|
||||
const [detailOpen, setDetailOpen] = useState(false);
|
||||
const showListOnNarrow = !topicId;
|
||||
|
||||
return (
|
||||
<div className="relative flex h-full w-full">
|
||||
<div className={`h-full w-full md:w-auto md:shrink-0 ${showListOnNarrow ? '' : 'hidden md:flex'}`}>
|
||||
<ChatListColumn />
|
||||
</div>
|
||||
<div className={`h-full min-w-0 flex-1 ${showListOnNarrow ? 'hidden md:block' : ''}`}>
|
||||
<Outlet context={{ onToggleDetail: () => setDetailOpen((v) => !v) }} />
|
||||
</div>
|
||||
<div className="hidden h-full lg:block">
|
||||
<DetailColumn />
|
||||
</div>
|
||||
{detailOpen ? (
|
||||
<div className="absolute inset-0 hidden md:block lg:hidden">
|
||||
<div className="absolute inset-0 bg-[#22262d]/25" onClick={() => setDetailOpen(false)} />
|
||||
<div className="absolute inset-y-0 right-0 shadow-[-8px_0_32px_rgba(0,0,0,0.12)]">
|
||||
<DetailColumn onClose={() => setDetailOpen(false)} />
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
/*
|
||||
* Design tokens ported 1:1 from docs/design_handoff_meetingim_web/README.md's "Design Tokens"
|
||||
* section. Values are exact hex/px from the design handoff, not semantic guesses -- keep them in
|
||||
* sync with that doc, not with whatever the previous im_webapp's css/base.css happened to use.
|
||||
*
|
||||
* Breakpoints are intentionally remapped onto Tailwind's own sm/md/lg so every component can just
|
||||
* use the standard `sm:`/`md:`/`lg:` prefixes (min-width, mobile-first) instead of inventing custom
|
||||
* variants: <640 base styles = single column mobile, sm: (>=640) = two column, md: (>=960) = three
|
||||
* column, lg: (>=1280) = four column docked detail panel.
|
||||
*/
|
||||
@theme {
|
||||
--breakpoint-sm: 640px;
|
||||
--breakpoint-md: 960px;
|
||||
--breakpoint-lg: 1280px;
|
||||
|
||||
--font-sans: Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
||||
|
||||
/* Primary / accent */
|
||||
--color-accent: #1677ff;
|
||||
--color-accent-soft-bg: #e3eefe;
|
||||
--color-accent-selected-bg: #e8f1fe;
|
||||
--color-focus-border: #4091ff;
|
||||
|
||||
--color-btn: #368bfa;
|
||||
--color-btn-hover: #1677e8;
|
||||
--color-btn-disabled: #b8d5fa;
|
||||
|
||||
/* Sent bubble */
|
||||
--color-bubble-mine: #b9eb8f;
|
||||
|
||||
/* Surfaces */
|
||||
--color-surface-chat: #eef1f4;
|
||||
--color-surface-content: #f6f7f9;
|
||||
--color-surface-page: #f7f9fc;
|
||||
--color-surface-rail: #f2f4f7;
|
||||
--color-surface-input: #f2f4f7;
|
||||
--color-surface-search: #f1f2f4;
|
||||
|
||||
/* Borders */
|
||||
--color-border-panel: #eceef1;
|
||||
--color-border-row: #f1f2f4;
|
||||
--color-border-list-item: #f4f5f7;
|
||||
|
||||
/* Text */
|
||||
--color-text-title: #14171c;
|
||||
--color-text-heading: #22262d;
|
||||
--color-text-body: #252931;
|
||||
--color-text-secondary: #656b74;
|
||||
--color-text-tertiary-1: #4a4f57;
|
||||
--color-text-tertiary-2: #969ca5;
|
||||
--color-text-tertiary-3: #9ca2aa;
|
||||
--color-text-tertiary-4: #8d949d;
|
||||
--color-text-placeholder-1: #b2b7bf;
|
||||
--color-text-placeholder-2: #a5abb4;
|
||||
|
||||
--color-icon-default: #555c65;
|
||||
--color-icon-arrow: #c2c7ce;
|
||||
|
||||
/* Status */
|
||||
--color-unread: #f34b46;
|
||||
--color-danger-text: #d94b4b;
|
||||
--color-danger-border: #cf3f3f;
|
||||
--color-danger-border-soft: #f3c4c4;
|
||||
--color-online: #1fb36a;
|
||||
--color-offline: #aeb4bd;
|
||||
|
||||
/* Orange (system messages / group owner / warning) */
|
||||
--color-warn: #ff951c;
|
||||
--color-warn-bg: #fff5e5;
|
||||
--color-announce: #f5a623;
|
||||
--color-announce-bg: #fff8e6;
|
||||
--color-announce-text: #6d4c41;
|
||||
|
||||
/* Green (file assistant / success) */
|
||||
--color-success: #16ae54;
|
||||
--color-success-bg: #eefaf3;
|
||||
|
||||
/* Alert strips */
|
||||
--color-error-strip-bg: #ffeef0;
|
||||
--color-error-strip-text: #b51c1c;
|
||||
--color-info-strip-bg: #e8f1fe;
|
||||
--color-info-strip-text: #1a4f9c;
|
||||
|
||||
/* Call surfaces (dark) */
|
||||
--color-call-bg-1: #1b2231;
|
||||
--color-call-bg-2: #1f2a3d;
|
||||
--color-call-bg-3: #3b4a63;
|
||||
|
||||
/* Avatar palette (deterministic per-contact hashing picks from this list) */
|
||||
--color-avatar-1: #3c8df6;
|
||||
--color-avatar-2: #7c5cf6;
|
||||
--color-avatar-3: #2bb673;
|
||||
--color-avatar-4: #f28c3b;
|
||||
--color-avatar-5: #e2537a;
|
||||
--color-avatar-6: #0097a8;
|
||||
--color-avatar-7: #8d6e63;
|
||||
--color-avatar-8: #5c6bc0;
|
||||
--color-avatar-9: #26a69a;
|
||||
--color-avatar-10: #ef6c00;
|
||||
--color-avatar-11: #9ca2aa;
|
||||
|
||||
/* Shadows */
|
||||
--shadow-card: 0 8px 32px rgba(35, 74, 125, 0.10);
|
||||
--shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.18);
|
||||
--shadow-menu: 0 12px 36px rgba(0, 0, 0, 0.16);
|
||||
--shadow-bubble: 0 1px 2px rgba(0, 0, 0, 0.06);
|
||||
--shadow-btn: 0 4px 12px rgba(54, 139, 250, 0.2);
|
||||
--shadow-focus-ring: 0 0 0 3px rgba(22, 119, 255, 0.1);
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--color-surface-page);
|
||||
color: var(--color-text-body);
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Ported from the previous im_webapp's src/config.js. These values encode real constraints that
|
||||
// must match the backend (server/*.go) -- they are not stylistic choices, so the numbers/strings
|
||||
// themselves carry over unchanged even though this is a from-scratch rewrite.
|
||||
|
||||
/** Version-independent product name (Firebase app name, youth-mode copy, etc.). */
|
||||
export const BASE_APP_NAME = 'MeetingIM';
|
||||
|
||||
/** Name used in the Tinode client's User-Agent string. */
|
||||
export const APP_NAME = `${BASE_APP_NAME}/${__APP_VERSION__}`;
|
||||
|
||||
/**
|
||||
* Tinode API key for the WS handshake ({hi} packet) and every REST call's X-MeetingIM-APIKey
|
||||
* header. Generated with https://github.com/tinode/chat/tree/master/keygen against this
|
||||
* deployment's own API_KEY_SALT -- the fallback below only works against a backend still using
|
||||
* the upstream sample salt, same caveat as the old app.
|
||||
*/
|
||||
export const API_KEY = import.meta.env.VITE_TINODE_API_KEY || 'AQEAAAABAAD_rAp4DJh05a1HAwFT3A6K';
|
||||
|
||||
export const KNOWN_HOSTS = { hosted: 'web.118im.com', local: 'localhost:6060' } as const;
|
||||
export const DEFAULT_HOST = KNOWN_HOSTS.hosted;
|
||||
|
||||
export const LOGGING_ENABLED = true;
|
||||
|
||||
/** Minimum time between two keypress notifications, ms. */
|
||||
export const KEYPRESS_DELAY = 3_000;
|
||||
/** Delay before sending a read notification, ms. */
|
||||
export const READ_DELAY = 1_500;
|
||||
|
||||
export const MIN_TAG_LENGTH = 2;
|
||||
export const MAX_TAG_LENGTH = 96;
|
||||
export const MAX_TAG_COUNT = 16;
|
||||
|
||||
export const DEFAULT_P2P_ACCESS_MODE = 'JRWPS';
|
||||
export const NEW_GRP_ACCESS_MODE = 'JRWPSAO';
|
||||
export const CHANNEL_ACCESS_MODE = 'JR';
|
||||
export const NO_ACCESS_MODE = 'N';
|
||||
|
||||
/** Design breakpoints, px. Four tiers per the new design handoff (was a single 640 cut before). */
|
||||
export const BREAKPOINTS = { sm: 640, md: 960, lg: 1280 } as const;
|
||||
|
||||
export const AVATAR_SIZE = 384;
|
||||
export const MAX_AVATAR_BYTES = 4096;
|
||||
export const BROKEN_IMAGE_SIZE = 32;
|
||||
export const NO_DIMENSIONS_VIDEO = 128;
|
||||
|
||||
export const MESSAGES_PAGE = 24;
|
||||
|
||||
export const MAX_INBAND_ATTACHMENT_SIZE = 262_144;
|
||||
export const MAX_EXTERN_ATTACHMENT_SIZE = 1 << 23;
|
||||
export const MAX_IMAGE_DIM = 1024;
|
||||
export const IMAGE_PREVIEW_DIM = 64;
|
||||
export const VIDEO_PREVIEW_DIM = 96;
|
||||
export const IMAGE_THUMBNAIL_DIM = 36;
|
||||
export const VIDEO_THUMBNAIL_WIDTH = 48;
|
||||
|
||||
export const MAX_ONLINE_IN_TOPIC = 4;
|
||||
export const MAX_TITLE_LENGTH = 60;
|
||||
export const MAX_TOPIC_DESCRIPTION_LENGTH = 360;
|
||||
export const MAX_PEER_TITLE_LENGTH = 24;
|
||||
|
||||
export const MESSAGE_PREVIEW_LENGTH = 80;
|
||||
export const QUOTED_REPLY_LENGTH = 30;
|
||||
export const FORWARDED_PREVIEW_LENGTH = 84;
|
||||
export const EDIT_PREVIEW_LENGTH = 48;
|
||||
|
||||
export const MIN_DURATION = 2_000;
|
||||
export const MAX_DURATION = 600_000;
|
||||
|
||||
export const IMMEDIATE_P2P_SUBSCRIPTION = false;
|
||||
|
||||
export const CLICKABLE_URL_SCHEMES = ['http', 'https', 'ftp', 'ftps'];
|
||||
|
||||
export const QRCODE_SIZE = 128;
|
||||
|
||||
export const WAKE_UP_TIMEOUT = 80_000;
|
||||
export const WAKE_UP_TICK = 1_000;
|
||||
|
||||
export const TOAST_DURATION = 3_000;
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* `tinode-sdk` ships as a plain UMD JS bundle with no bundled TypeScript types. This is a
|
||||
* deliberately partial ambient declaration covering only the surface this app actually calls --
|
||||
* grown incrementally as later phases touch more of the SDK, not an attempt at a full port of the
|
||||
* upstream JS. Method/property names and shapes below are verified against the installed
|
||||
* `node_modules/tinode-sdk/umd/tinode.dev.js` (v0.25.3), not guessed from the upstream docs, since
|
||||
* this project's own history has repeatedly found the two disagree (e.g. this deployment's REST
|
||||
* layer uses `X-MeetingIM-APIKey`, not the upstream `X-Tinode-APIKey`).
|
||||
*/
|
||||
declare module 'tinode-sdk' {
|
||||
export interface TinodeOptions {
|
||||
appName: string;
|
||||
host: string;
|
||||
apiKey: string;
|
||||
transport?: 'ws' | 'lp' | null;
|
||||
secure?: boolean;
|
||||
persist?: boolean;
|
||||
}
|
||||
|
||||
export type AuthLevel = 'anon' | 'auth' | 'root';
|
||||
|
||||
export class AccessMode {
|
||||
mode: string;
|
||||
given: string;
|
||||
want: string;
|
||||
isOwner(): boolean;
|
||||
isAdmin(): boolean;
|
||||
isSharer(): boolean;
|
||||
isWriter(): boolean;
|
||||
isReader(): boolean;
|
||||
isMuted(): boolean;
|
||||
isDeleter(): boolean;
|
||||
isJoiner(): boolean;
|
||||
isPresencer(): boolean;
|
||||
}
|
||||
|
||||
export interface TopicDescPublic {
|
||||
fn?: string;
|
||||
name?: string;
|
||||
photo?: { data?: string; type?: string; ref?: string };
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface TopicDescPrivate {
|
||||
comment?: string;
|
||||
pinned?: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/** A row from `MeTopic.contacts()` -- a live, mutable contact/subscription snapshot. */
|
||||
export interface Contact {
|
||||
topic: string;
|
||||
user?: string;
|
||||
updated?: Date;
|
||||
touched?: Date;
|
||||
online?: boolean;
|
||||
acs?: AccessMode;
|
||||
seq?: number;
|
||||
read?: number;
|
||||
recv?: number;
|
||||
unread?: number;
|
||||
public?: TopicDescPublic | null;
|
||||
private?: TopicDescPrivate | null;
|
||||
latestMessage?: () => StoredMessage | undefined;
|
||||
}
|
||||
|
||||
export interface StoredMessage {
|
||||
seq: number;
|
||||
from?: string;
|
||||
ts?: Date;
|
||||
content?: unknown;
|
||||
head?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export class Topic {
|
||||
name: string;
|
||||
subscribe(): Promise<unknown>;
|
||||
leave(unsub?: boolean): Promise<unknown>;
|
||||
getMeta(query: unknown): Promise<unknown>;
|
||||
publish(data: unknown, head?: Record<string, unknown>): Promise<unknown>;
|
||||
isSubscribed(): boolean;
|
||||
}
|
||||
|
||||
export class MeTopic extends Topic {
|
||||
contacts(callback: (contact: Contact) => void): void;
|
||||
pinnedTopicRank(topic: string): number;
|
||||
getMeta(query: unknown): Promise<unknown>;
|
||||
}
|
||||
|
||||
export class Tinode {
|
||||
constructor(options: TinodeOptions, onCompletion?: () => void);
|
||||
|
||||
_connection?: { sendText: (msg: string) => unknown; __tenantPatched?: boolean };
|
||||
|
||||
setHumanLanguage(locale: string): void;
|
||||
enableLogging(enabled: boolean, verbose?: boolean): void;
|
||||
|
||||
connect(host?: string): Promise<void>;
|
||||
disconnect(): void;
|
||||
isConnected(): boolean;
|
||||
isAuthenticated(): boolean;
|
||||
getAuthenticatedUserID(): string | undefined;
|
||||
|
||||
login(scheme: string, secret: string, cred?: unknown): Promise<{ ctrl: { code: number; params?: Record<string, unknown> } }>;
|
||||
loginToken(token: string, cred?: unknown): Promise<{ ctrl: { code: number } }>;
|
||||
getAuthToken(): { token: string; expires: Date } | null;
|
||||
|
||||
getMeTopic(): MeTopic;
|
||||
getTopic(topicName: string): Topic;
|
||||
|
||||
account(userId: string, scheme: string, secret: string, login: boolean, desc?: unknown): Promise<unknown>;
|
||||
|
||||
onConnect?: () => void;
|
||||
onDisconnect?: (err?: Error) => void;
|
||||
onLogin?: (code: number, text: string) => void;
|
||||
onNetworkProbe?: () => void;
|
||||
onAutoreconnectIteration?: (seconds: number, promise?: Promise<unknown>) => void;
|
||||
}
|
||||
|
||||
export const Drafty: {
|
||||
init(text: string): unknown;
|
||||
parse(text: string): unknown;
|
||||
toPlainText(content: unknown): string;
|
||||
preview(content: unknown, length: number, cutFirst?: boolean): unknown;
|
||||
videoCall(audioOnly: boolean): unknown;
|
||||
isValid(content: unknown): boolean;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export const TheCard: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
/** Injected by vite.config.ts's `define`, from package.json's version field. */
|
||||
declare const __APP_VERSION__: string;
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_TINODE_API_KEY?: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
Reference in New Issue
Block a user