TDesign Vue Next Starter

repository·develop·Indexed 21 days ago

https://github.com/tencent/tdesign-vue-next-starter

A production-ready project scaffold for middle and back-end management systems based on TDesign, Vue 3, Vite, Pinia, and TypeScript. It includes built-in support for themes, dark mode, mock data, and pre-configured ESLint rules using @antfu/eslint-config. The starter provides a CLI tool, tdesign-starter-cli, for project initialization and includes a set of reusable components such as common-table, ProductCard, Result, and Thumbnail.

Tokens
23.2K
Snippets
74
Records
88
Agent score
76%

What's inside tdesign-vue-next-starter

  1. Overview of TDesign Vue Next Starter features

    develop

    TDesign Vue Next Starter is a project template built with Vue 3, Vite, Pinia, and TypeScript. It is designed to provide an out-of-the-box configuration for middle and background management systems.

    Key features include:

    • Pre-built pages and a complete directory structure.
    • Support for dark mode and custom theme colors.
    • Various space layouts.
    • Mock data schemes.
    • Code specification configurations.
  2. Build the project for production or testing

    develop

    Use the following commands to generate build artifacts for different environments:

    • Production: Use npm run build to create a build for the formal production environment.
    • Testing: Use npm run build:test to create a build for the testing environment.
    • Preview: Use npm run preview to locally preview the generated build artifacts.
    ## Build for production environment
    npm run build
    
    ## Build for testing environment
    npm run build:test
    
    ## Preview build artifacts
    npm run preview
  3. Develop and run the project locally

    develop

    Once your project is initialized, follow these steps to start development:

    1. Install dependencies: Run npm install to download the necessary packages.
    2. Start development server: Run npm run dev to launch the project in development mode.
    ## Install dependencies
    npm install
    
    ## Start project
    npm run dev
  4. Install tdesign-starter-cli and create a new project

    develop

    To start a new project using the TDesign Vue Next Starter, you must first install the global CLI tool, then use it to initialize your project repository.

    1. Install the CLI: Use npm to install the latest version of tdesign-starter-cli globally.
    2. Initialize Project: Run the td-starter init command to begin the project creation process.
    # 1. Install tdesign-starter-cli
    npm i tdesign-starter-cli@latest -g
    
    # 2. Create project
    td-starter init
  5. View Deployment Details and Project Lists

    develop

    The DetailDeploy page provides a dashboard for monitoring deployment trends and managing project lists. It features ECharts-based visualizations for deployment trends and warnings, and a TDesign table for managing project data.

    Key Features

    • Deployment Trend Monitoring: A real-time line chart (monitorContainer) that updates every 3 seconds.
    • Warning Data Visualization: A bar chart (dataContainer) that can be toggled between weekly and monthly views using a t-radio-group.
    • Project Management Table: A t-table displaying project names, administrators, and update times, with support for sorting and row operations (Manage and Delete).
    • Project Info Dialog: A t-dialog that displays detailed base information for a selected project.

    Data Integration

    • API: Uses getProjectList from @/api/detail to fetch project data.
    • State Management: Integrates with useSettingStore to retrieve chartColors and react to brandTheme changes via changeChartsTheme.
    • Localization: Uses the t function for all UI strings (e.g., pages.detailDeploy.projectList.title).
  6. How route modules are organized and loaded

    develop

    The project uses a module-based routing system where routes are automatically discovered and loaded from the ./src/router/modules/ directory. Routes are categorized into two types based on their file naming convention:

    1. Homepage Routes: Any file named homepage.ts within a module folder (e.g., ./modules/user/homepage.ts) is treated as a homepage-related route and exported via homepageRouterList.
    2. Fixed Routes: All other .ts files in the modules directory (excluding those named homepage.ts) are treated as standard fixed routes and exported via fixedRouterList.

    To add new routes, create a .ts file in a subdirectory of src/router/modules/ and export a RouteRecordRaw object or an array of RouteRecordRaw objects as the default export.

    // Example of a new module route: src/router/modules/settings/index.ts
    import type { RouteRecordRaw } from 'vue-router';
    
    const route: RouteRecordRaw = {
      path: '/settings',
      name: 'settings',
      component: () => import('@/pages/settings/index.vue'),
    };
    
    export default route;
  7. Manage notification lists in DetailSecondary component

    develop

    The DetailSecondary component provides a UI for viewing, filtering, and managing notification items using a tabbed interface. It integrates with the useNotificationStore to handle data state.

    Key Features

    • Tabbed Filtering: Users can switch between 'All' (msgData), 'Unread' (unreadMsg), and 'Read' (readMsg) notifications.
    • Read/Unread Toggle: Clicking a message or its action icon toggles the status property of the NotificationItem.
    • Deletion: Users can delete a specific notification, which triggers a confirmation dialog.

    Data Model

    The component operates on NotificationItem objects. Key properties used include:

    • id: Unique identifier for the message.
    • status: Boolean indicating if the message is unread.
    • type: The category of the notification.
    • content: The text content of the message.
    • quality: Used to determine the theme of the notification tag via NOTIFICATION_TYPES.
    • date: The timestamp/date string for the message.
  8. Manage Layout Settings via useSettingStore

    develop

    The layout's behavior is driven by the useSettingStore. You can control the layout type and sidebar visibility through this store:

    • setting.layout.value: Determines if the layout uses the 'side' mode or the default mode.
    • settingStore.showSidebar: A boolean that, when true, applies the t-layout--with-sider class to the main layout component.