Tangsengdaodao IM Client

repository·main·Indexed 41 days ago

https://github.com/tangsengdaodao/tangsengdaodaoweb

A high-aesthetic enterprise Instant Messaging (IM) client powered by Wukong IM. Supports Web, Mac, Windows, and Linux platforms. Includes documentation for local development using node v22.12.0 and yarn 1.22.19, Electron desktop packaging for multiple architectures (x64 and arm64), and IPC communication for system-level actions like screenshot capture and native notifications.

Tokens
53.7K
Snippets
188
Records
231
Agent score
51%

What's inside Tangsengdaodao

  1. Build architecture-specific macOS DMG files

    main

    TangSengDaoDao uses separate DMG files for Intel (x64) and Apple Silicon (arm64) architectures instead of universal binaries. This prevents native module conflicts (e.g., with electron-screenshots) and optimizes performance. Use the following commands to trigger builds via yarn:

    # Build both x64 and arm64 DMG files
    yarn build-ele:mac-both
    
    # Build only Intel (x64) DMG
    yarn build-ele:mac-x64
    
    # Build only Apple Silicon (arm64) DMG
    yarn build-ele:mac-arm64
  2. Build macOS applications for specific architectures

    main

    TangSengDaoDao uses a native architecture-specific build system for macOS to ensure optimal performance and compatibility with native modules (like electron-screenshots). Instead of universal binaries or cross-compilation, the project builds separate binaries for Intel (x64) and Apple Silicon (arm64) using matching hardware runners.

    Architecture Mapping

    ArchitectureTarget RunnerBuild CommandOutput File
    Intel (x64)macos-13yarn build-ele:mac-x64*-x64.dmg
    Apple Silicon (arm64)macos-14yarn build-ele:mac-arm64*-arm64.dmg
    # Build for the current architecture (recommended for local dev)
    yarn test:arch-builds
    
    # Build specifically for Intel
    yarn build-ele:mac-x64
    
    # Build specifically for Apple Silicon
    yarn build-ele:mac-arm64
  3. Verify macOS architecture builds

    main

    To ensure both architectures are built correctly and to verify the binary contents, use the following commands:

    1. Automated Test: Run the built-in test command to verify both builds.
    2. Manual Verification: Use the lipo tool to inspect the binary architecture inside the generated .app bundle.
    # Test and verify both architecture builds
    yarn test:arch-builds
    
    # Manual verification of the binary architecture
    lipo -info "dist-ele/TangSengDaoDao.app/Contents/MacOS/TangSengDaoDao"
  4. Run and build the Electron desktop version

    main

    The Electron version supports packaging for Mac, Windows, and Linux.

    Local Development

    1. Install dependencies: yarn install.
    2. Start Electron development: yarn dev-ele.

    Building and Packaging

    Important: You must run yarn build to compile the web assets before attempting to package the desktop applications.

    Note: Packaging commands must be executed within the apps/web directory.

    yarn install
    yarn dev-ele
    yarn build
  5. Package Electron apps for Mac, Windows, or Linux

    main

    After running yarn build to compile the web assets, you can package the desktop application for specific operating systems.

    Note: These commands must be executed inside the apps/web directory.

    # Package for Mac
    yarn build-ele:mac
    
    # Package for Windows
    yarn build-ele:win
    
    # Package for Linux
    yarn build-ele:linux
  6. Run the Web version of Tangsengdaodao

    main

    To run the web-based version of the Tangsengdaodao IM client for local development, follow these steps. It is recommended to use node v22.12.0 and yarn 1.22.19 for local development.

    1. Install dependencies: Use yarn install or yarn bootstrap.
    2. Start development server: Run yarn dev to begin local debugging.
    3. Build the project: Run yarn build to compile the web assets.
    4. Clean cache: Run yarn clean to clear cached files.
    yarn install
    yarn dev
    yarn build
    yarn clean
  7. Deploy the Web version with custom API URL

    main

    To deploy a web image with a specific API endpoint, you must first update the API configuration in the source code, then run the make command.

    1. Update API URL: Modify packages/tsdaodaoweb/src/index.tsx and set WKApp.apiClient.config.apiURL = "/api/v1/".
    2. Deploy: Run make deploy to publish the image.
    # 1. Edit packages/tsdaodaoweb/src/index.tsx
    # WKApp.apiClient.config.apiURL = "/api/v1/"
    
    # 2. Deploy
    make deploy
  8. Identify the correct macOS DMG for installation

    main

    When downloading TangSengDaoDao, you must choose the DMG that matches your Mac's processor architecture to ensure native performance.

    1. Check via Terminal

    Run the following command in your terminal:

    uname -m
    • x86_64: You have an Intel Mac. Download the *-x64.dmg file.
    • arm64: You have an Apple Silicon Mac (M1, M2, M3, etc.). Download the *-arm64.dmg file.

    2. Check via System Settings

    • Go to the Apple Menu $\rightarrow$ About This Mac.
    • Look at the Chip or Processor section:
      • Intel: Download x64 DMG.
      • Apple M1/M2/M3: Download arm64 DMG.
    # Check architecture
    uname -m
  9. Core components and services in @tsdaodao/base

    main

    The @tsdaodao/base package provides the foundational building blocks for the Tangsengdaodao web application. It includes core application logic, UI components, and service layers. Key areas include:

    • Application Core: WKApp (the main application instance) and BaseModule.
    • Services: APIClient for network requests, StorageService for local persistence, Provider for dependency injection/context, Route for navigation, and DataSource for data management.
    • UI Components: Layout components like WKLayout, navigation components like WKNavMainHeader, and specialized components like Search, ContextMenus, and ChatPage.
    • Messaging: Base message structures (MessageBase) and specialized message types (e.g., Image messages) and cell renderers (MessageCell).
    • Utilities: Helpers for file management (FileHelper), notifications (NotificationUtil), string conversion (t2s), and pinyin (pinYin).
  10. Define and manage application Endpoints

    main

    Endpoints are used to register handlers (methods) that can be invoked by a unique sid (service ID). You can group endpoints into category groups and control their execution order using sort. Use EndpointManager.shared to manage these handlers.

    import { EndpointManager } from '@tsdaodao/base';
    
    // Registering a single method
    EndpointManager.shared.setMethod('get_user_data', (param) => {
        return { name: 'John Doe', ...param };
    }, { category: 'user_service', sort: 1 });
    
    // Invoking a specific method by sid
    const result = EndpointManager.shared.invoke('get_user_data', { id: 123 });
  11. Render reply previews in TextCell

    main

    If a message contains a reply reference (message.content.reply), TextCell renders a reply preview block above the main content.

    • Visuals: Displays the avatar of the original sender, their name, and a conversationDigest of the replied content.
    • Interaction: Clicking the reply block triggers context.locateMessage(message.content.reply.messageSeq), allowing the user to jump to the original message.
  12. Register and retrieve UI sections

    main

    The SectionManager (accessed via WKApp.sectionManager) allows you to register and retrieve UI sections based on an EndpointCategory. This is used for modularizing parts of the interface like user info, channel settings, or channel management.

    • register: Defines a section by an ID and a function that returns a Section based on a RouteContext.
    • sections: Retrieves all registered sections for a specific category.
    import { WKApp, EndpointCategory } from "@tsdaodao/base";
    
    // Register a section for user info
    WKApp.sectionManager.register(
      EndpointCategory.userInfo,
      "my-custom-section",
      (context) => {
        return {
          title: "My Info",
          rows: [{ title: "Name", value: "John Doe" }]
        };
      }
    );
    
    // Later, retrieve sections for rendering
    const sections = WKApp.sectionManager.sections(EndpointCategory.userInfo, context);