### Flutter Project Setup and Run Source: https://github.com/daodao97/chatmcp/blob/main/README_TR.md Commands to install Flutter dependencies and run the application on different platforms (Linux, macOS, Windows, Android). ```shell flutter pub get flutter run -d linux ``` ```shell flutter pub get flutter run -d macos ``` ```shell flutter pub get flutter run -d windows ``` ```shell flutter pub get flutter run -d "Pixel ..." ``` -------------------------------- ### Install and Verify Flutter Source: https://github.com/daodao97/chatmcp/blob/main/README.md Instructions to install Flutter and verify the installation by checking the Flutter version. ```bash flutter --version ``` -------------------------------- ### Install uv and Node.js/npm Source: https://github.com/daodao97/chatmcp/blob/main/README_TR.md Instructions for installing uv (for macOS) and Node.js/npm (for macOS and Linux) using package managers or direct download. ```shell brew install uv brew install node ``` ```shell curl -LsSf https://astral.sh/uv/install.sh | sh sudo apt update sudo apt install nodejs npm ``` -------------------------------- ### Install uv or npx Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Instructions for installing the 'uv' package manager via Homebrew or Node.js for 'npx'. These are prerequisites for running ChatMcp. ```bash # uv brew install uv # npx brew install node ``` -------------------------------- ### Development Setup Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Commands to set up the development environment for ChatMcp using Flutter. This includes fetching dependencies and running the application on macOS. ```bash flutter pub get flutter run -d macos ``` -------------------------------- ### Installation Rules for Application Bundle Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Defines installation rules to create a relocatable application bundle. This includes clearing the bundle directory, installing the executable, Flutter data, libraries, and native assets. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Android Signing Configuration Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Guides for configuring Android signing for release builds of ChatMcp. Includes commands to create a keystore, verify signing configuration, and build signed APKs or App Bundles. ```bash # Generate signing key ./scripts/create_keystore.sh # Verify signing configuration ./scripts/verify_signing.sh # Build signed APK flutter build apk --release # Build signed App Bundle (recommended for Google Play) flutter build appbundle --release ``` -------------------------------- ### Clone and Run ChatMcp Locally Source: https://github.com/daodao97/chatmcp/blob/main/README.md Steps to clone the ChatMcp repository, install dependencies, and run the application on macOS and Linux. ```bash # Clone the repository git clone https://github.com/daodao97/chatmcp.git cd chatmcp # Install dependencies flutter pub get # Run on macOS flutter run -d macos # Run on Linux (requires Flutter desktop support enabled) flutter run -d linux # Build release for Linux flutter build linux ``` -------------------------------- ### Install uvx or npx Source: https://github.com/daodao97/chatmcp/blob/main/README.md Instructions for installing the 'uvx' or 'npx' package managers required for Chatmcp usage on macOS and Linux systems. ```bash # uvx brew install uv ``` ```bash # npx brew install node ``` ```bash # uvx curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```bash # npx (using apt) sudo apt update sudo apt install nodejs npm ``` -------------------------------- ### Linux Dependencies Installation Source: https://github.com/daodao97/chatmcp/blob/main/README_TR.md Commands to install necessary packages for running ChatMcp AppImage/DEB on Ubuntu 22.04 and 24.04, including FUSE, GTK3, EGL/GL, X11, and SQLite. ```bash sudo apt install -y libfuse2 libgtk-3-0 libegl1-mesa libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 ``` ```bash sudo apt install -y libfuse2 libgtk-3-0 libegl1 libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 ``` -------------------------------- ### Installation Rules for Executable and Assets Source: https://github.com/daodao97/chatmcp/blob/main/windows/CMakeLists.txt Configures the installation process for the project, specifying destinations for the executable, Flutter ICU data, libraries, bundled plugins, and native assets. It ensures that all necessary files are copied to the correct locations for runtime execution. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library. This installation is conditional and only occurs for builds that are not of type 'Debug', ensuring optimized performance for release versions. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Project Setup and Configuration Source: https://github.com/daodao97/chatmcp/blob/main/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, project name, and executable name. It also configures build types and compiler flags for different build modes. ```cmake cmake_minimum_required(VERSION 3.14) project(chatmcp LANGUAGES CXX) set(BINARY_NAME "chatmcp") cmake_policy(VERSION 3.14...3.25) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Configures and installs the Flutter asset directory. It removes any existing directory and then installs the new one. This is a common pattern for managing application assets in CMake projects. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Add MCP Server to Market Source: https://github.com/daodao97/chatmcp/blob/main/README_TR.md Instructions on how to add a new MCP Server to the MCP Server Market by forking the repository and adding a new entry to the `mcp_server_market.json` file. This includes an example JSON structure for defining a new server with its command and arguments. ```json { "mcpServers": { "existing-mcp-servers": {}, "your-mcp-server": { "command": "uvx", "args": [ "--from", "git+https://github.com/username/your-mcp-server", "your-mcp-server" ] } } } ``` -------------------------------- ### SQLite3 DLL Installation Source: https://github.com/daodao97/chatmcp/blob/main/windows/CMakeLists.txt Finds the SQLite3 DLL and installs it to the application's runtime destination. It includes a message indicating the found path or a warning if the DLL is not found. ```cmake find_file(SQLITE3_DLL NAMES "sqlite3.dll" PATHS "${CMAKE_CURRENT_SOURCE_DIR}" DOC "Path to SQLite3 DLL" ) if(SQLITE3_DLL) install(FILES "${SQLITE3_DLL}" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) message(STATUS "Found SQLite3 DLL at: ${SQLITE3_DLL}") else() message(WARNING "sqlite3.dll not found. The application may not work correctly.") endif() ``` -------------------------------- ### Linux Runtime Dependencies Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Lists the necessary runtime dependencies for running ChatMcp on Ubuntu 22.04 and 24.04, including FUSE, GTK3, graphics libraries, and other utilities. Installation commands are provided for both versions. ```bash # Ubuntu 22.04: sudo apt install -y libfuse2 libgtk-3-0 libegl1-mesa libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 # Ubuntu 24.04: sudo apt install -y libfuse2 libgtk-3-0 libegl1 libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Sets the minimum CMake version and project name. It also defines the executable name and application identifier, crucial for Flutter integration and system registration. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "chatmcp") set(APPLICATION_ID "run.daodao.chatmcp") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### MCP Server Market Configuration Source: https://github.com/daodao97/chatmcp/blob/main/README.md Example JSON structure for adding a new MCP Server to the MCP Server Market. This involves forking the repository, adding server details, and submitting a Pull Request. ```json { "mcpServers": { "existing-mcp-servers": {}, "your-mcp-server": { "command": "uvx", "args": [ "--from", "git+https://github.com/username/your-mcp-server", "your-mcp-server" ] } } } ``` -------------------------------- ### Sandpack Initialization and Code Update Source: https://github.com/daodao97/chatmcp/blob/main/assets/sandbox/index.html This JavaScript code snippet demonstrates how to initialize a Sandpack preview by getting a reference to the iframe, setting up an onload handler, and sending a message to register the frame with the Sandpack environment. It also includes a function to update the code within the Sandpack preview by sending a 'compile' message with updated modules. ```javascript const iframe = document.getElementById('sp-preview-iframe'); iframe.onload = () => { iframe.contentWindow.postMessage({ "type": "register-frame", "origin": window.location.origin, "id": 113370 }, "https://1-20-9-sandpack.codesandbox.io/") } function updateCode(code) { code = decodeURIComponent(code) iframe.contentWindow.postMessage({ "$id": 113370, "codesandbox": true, "type": "compile", "version": 3, "modules": { "/App.js": { "code": code, "path": "/App.js" }, "/index.js": { "code": "import React, { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport \"./styles.css\";\n\nimport App from \"./App\";\n\nconst root = createRoot(document.getElementById(\"root\"));\nroot.render(\n\n \n\n);", "path": "/index.js" }, "/styles.css": { "code": "body{\nfont-family: sans-serif;\n-webkit-font-smoothing: auto;\n-moz-font-smoothing: auto;\n-moz-osx-font-smoothing: grayscale;\nfont-smoothing: auto;\ntext-rendering: optimizeLegibility;\nfont-smooth: always;\n-webkit-tap-highlight-color: transparent;\n-webkit-touch-callout: none;\n}\n\nh1 {\nfont-size: 1.5rem;\n}", "path": "/styles.css" }, "/public/index.html": { "code": "\n\n\n \n \n Document\n\n\n
\n\n", "path": "/public/index.html" }, "/package.json": { "code": "{\n \"name\": \"sandpack-project\",\n \"main\": \"/index.js\",\n \"dependencies\": {\n \"react\": \"^18.0.0\",\n \"react-dom\": \"^18.0.0\",\n \"react-scripts\": \"^4.0.0\"\n },\n \"devDependencies\": {}\n}", "path": "/package.json" } }, "externalResources": [], "hasFileResolver": false, "template": "create-react-app", "showOpenInCodeSandbox": false, "showErrorScreen": false, "showLoadingScreen": false, "skipEval": false, "clearConsoleDisabled": true, "logLevel": 30 }, "https://1-20-9-sandpack.codesandbox.io/") } ``` -------------------------------- ### CMake: Flutter Library Setup Source: https://github.com/daodao97/chatmcp/blob/main/linux/flutter/CMakeLists.txt Configures the Flutter library for Linux GTK builds. It finds necessary packages (GTK, GLIB, GIO), sets paths for the Flutter library and ICU data, and defines include directories and link libraries for the 'flutter' interface target. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # === Flutter Library === # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Web Version Development and Deployment Source: https://github.com/daodao97/chatmcp/blob/main/README_TR.md Instructions for local web development, building the web version, and deploying to GitHub Pages using Flutter. ```shell # Install dependencies flutter pub get # Run locally flutter run -d chrome # or with a specific port flutter run -d chrome --web-port 8080 ``` ```shell # Build production version flutter build web # Build with base href for subdirectories flutter build web --base-href /chatmcp/ ``` ```shell # 1. Build web version flutter build web --base-href /chatmcp/ # 2. Push build/web contents to gh-pages branch ``` -------------------------------- ### Deploy ChatMcp to GitHub Pages Source: https://github.com/daodao97/chatmcp/blob/main/README.md Steps to build the web version of ChatMcp and deploy it to GitHub Pages, including building with a base href and pushing to the gh-pages branch or using GitHub Actions. ```bash # 1. Build Web version flutter build web --base-href /chatmcp/ # 2. Push build/web directory contents to gh-pages branch # Or use GitHub Actions for automatic deployment ``` -------------------------------- ### Build ChatMcp Web Version Source: https://github.com/daodao97/chatmcp/blob/main/README.md Commands to build the production version of the ChatMcp web application, including options for specifying a base href for deployment to subdirectories. ```bash # Build production version flutter build web # Build with base path (for deploying to subdirectory) flutter build web --base-href /chatmcp/ ``` -------------------------------- ### Web Version Development and Deployment Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Instructions for developing and deploying the web version of ChatMcp using Flutter. Covers local development, building for production, and deploying to GitHub Pages. ```bash # Local Development: flutter pub get flutter run -d chrome # or specify port: flutter run -d chrome --web-port 8080 # Build Web Version: flutter build web # Build with base href (for subdirectories): flutter build web --base-href /chatmcp/ # Deploy to GitHub Pages: # 1. Build web version flutter build web --base-href /chatmcp/ # 2. Push build/web contents to gh-pages branch or use GitHub Actions. ``` -------------------------------- ### Add MCP Server to Market Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md This JSON structure defines how to add a new MCP server to the MCP server market. It includes the command to run and its arguments, specifying the source of the MCP server. ```json { "mcpServers": { "existing-mcp-servers": {}, "your-mcp-server": { "command": "uvx", "args": [ "--from", "git+https://github.com/username/your-mcp-server", "your-mcp-server" ] } } } ``` -------------------------------- ### Linux Runtime Requirements (Ubuntu 24.04) Source: https://github.com/daodao97/chatmcp/blob/main/README.md Lists the necessary runtime packages for running ChatMCP AppImage/DEB on Ubuntu 24.04, including FUSE, GTK 3, EGL, X11 utilities, and SQLite. ```bash sudo apt install -y libfuse2 libgtk-3-0 libegl1 libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 ``` -------------------------------- ### Linux Runtime Requirements (Ubuntu 22.04) Source: https://github.com/daodao97/chatmcp/blob/main/README.md Lists the necessary runtime packages for running ChatMCP AppImage/DEB on Ubuntu 22.04, including FUSE, GTK 3, EGL, X11 utilities, and SQLite. ```bash sudo apt install -y libfuse2 libgtk-3-0 libegl1-mesa libgles2 libgl1-mesa-dri libglx-mesa0 libx11-6 xdg-utils libsqlite3-0 ``` -------------------------------- ### Run ChatMcp Web Version Locally Source: https://github.com/daodao97/chatmcp/blob/main/README.md Commands to run the web version of ChatMcp locally using Chrome or other browsers, with options to specify a port or run as a web server. ```bash # Install dependencies flutter pub get # Run Web version locally flutter run -d chrome # Or specify port flutter run -d chrome --web-port 8080 # Or run as web-serer for other browsers. flutter run -d web-server ``` -------------------------------- ### Application Executable Definition Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Defines the main executable target, including source files from the application, generated plugin registrants, and applies standard build settings. ```cmake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### ToastUtils 方法说明 Source: https://github.com/daodao97/chatmcp/blob/main/lib/utils/README.md 详细说明了 ToastUtils 中各个方法的用途、颜色、默认持续时间和使用场景。 ```APIDOC ToastUtils: error(String message, {Duration? duration}) - 用途: 显示错误信息 - 颜色: 红色 (Colors.red.shade600) - 默认持续时间: 5 秒 - 使用场景: 操作失败、系统错误、验证失败等 warn(String message, {Duration? duration}) - 用途: 显示警告信息 - 颜色: 橙色 (Colors.orange.shade600) - 默认持续时间: 4 秒 - 使用场景: 网络问题、权限不足、配置问题等 info(String message, {Duration? duration}) - 用途: 显示一般信息 - 颜色: 蓝色 (Colors.blue.shade600) - 默认持续时间: 3 秒 - 使用场景: 状态更新、提示信息、进度通知等 success(String message, {Duration? duration}) - 用途: 显示成功信息 - 颜色: 绿色 (Colors.green.shade600) - 默认持续时间: 3 秒 - 使用场景: 操作成功、保存完成、连接成功等 custom({required String message, required Color color, Duration? duration, Alignment? align, TextStyle? textStyle}) - 用途: 显示自定义样式的 toast - 参数: 完全自定义所有样式属性 - 使用场景: 需要特殊样式的场合 ``` -------------------------------- ### Sandbox Preview CSS Source: https://github.com/daodao97/chatmcp/blob/main/assets/sandbox/index.html This CSS code defines styles for the sandbox preview environment. It includes reset styles for margin, padding, and box-sizing, styles for the main preview area to occupy the full viewport height, and styles for an error overlay to display error messages prominently. ```css /* 重置样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } /* 预览区布局 */ #root { height: 100vh; } /* 错误提示样式 */ .error-overlay { position: fixed; bottom: 20px; right: 20px; background: #ff5252; color: white; padding: 12px 20px; border-radius: 4px; font-family: monospace; max-width: 80vw; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); } .sp-preview-iframe { width: 100%; height: 100%; border: none; } ``` -------------------------------- ### Sandbox Preview CSS Source: https://github.com/daodao97/chatmcp/blob/main/index.html This CSS code defines styles for the sandbox preview environment, including reset styles, layout for the preview area, and styling for error messages. ```css /* 重置样式 */ * { margin: 0; padding: 0; box-sizing: border-box; } /* 预览区布局 */ #root { height: 100vh; } /* 错误提示样式 */ .error-overlay { position: fixed; bottom: 20px; right: 20px; background: #ff5252; color: white; padding: 12px 20px; border-radius: 4px; font-family: monospace; max-width: 80vw; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); } .sp-preview-iframe { width: 100%; height: 100%; border: none; } ``` -------------------------------- ### Sandbox Preview Iframe Handling Source: https://github.com/daodao97/chatmcp/blob/main/index.html This JavaScript code snippet handles the loading of an iframe for the sandbox preview. It registers the frame with the CodeSandbox service and provides a mechanism to update the code within the preview. ```javascript const iframe = document.getElementById('sp-preview-iframe'); iframe.onload = () => { iframe.contentWindow.postMessage({ "type": "register-frame", "origin": "http://localhost:8080", "id": 113370 }, "https://1-20-9-sandpack.codesandbox.io/") } ``` ```javascript function updateCode(code) { code = decodeURIComponent(code) iframe.contentWindow.postMessage({ "$id": 113370, "codesandbox": true, "type": "compile", "version": 3, "modules": { "/App.js": { "code": code, "path": "/App.js" }, "/index.js": { "code": "import React, { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport \"./styles.css\";\n\nimport App from \"./App\";\n\nconst root = createRoot(document.getElementById(\"root\"));\nroot.render(\n\n \n\n);", "path": "/index.js" }, "/styles.css": { "code": "body {\nfont-family: sans-serif;\n-webkit-font-smoothing: auto;\n-moz-font-smoothing: auto;\n-moz-osx-font-smoothing: grayscale;\nfont-smoothing: auto;\ntext-rendering: optimizeLegibility;\nfont-smooth: always;\n-webkit-tap-highlight-color: transparent;\n-webkit-touch-callout: none;\n}\n\nh1 {\nfont-size: 1.5rem;\n}", "path": "/styles.css" }, "/public/index.html": { "code": "\n\n\n \n \n Document\n\n\n
\n\n", "path": "/public/index.html" }, "/package.json": { "code": "{\n \"name\": \"sandpack-project\",\n \"main\": \"/index.js\",\n \"dependencies\": {\n \"react\": \"^18.0.0\",\n \"react-dom\": \"^18.0.0\",\n \"react-scripts\": \"^4.0.0\"\n },\n \"devDependencies\": {}\n}", "path": "/package.json" } }, "externalResources": [], "hasFileResolver": false, "template": "create-react-app", "showOpenInCodeSandbox": false, "showErrorScreen": false, "showLoadingScreen": false, "skipEval": false, "clearConsoleDisabled": true, "logLevel": 30 }, "https://1-20-9-sandpack.codesandbox.io/") } ``` -------------------------------- ### 验证 APK 签名 Source: https://github.com/daodao97/chatmcp/blob/main/docs/android-signing.md 使用 `keytool` 和 `jarsigner` 命令验证已构建的 APK 文件是否已正确签名,并检查签名信息。 ```bash # 查看 APK 签名信息 keytool -printcert -jarfile build/app/outputs/flutter-apk/app-release.apk # 验证 APK 签名 jarsigner -verify -verbose -certs build/app/outputs/flutter-apk/app-release.apk ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Includes the CMake script that manages the build rules for generated plugins, ensuring they are correctly compiled and linked. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### 生成签名密钥 Source: https://github.com/daodao97/chatmcp/blob/main/docs/android-signing.md 使用此脚本生成 Android 应用的签名密钥库。脚本会引导用户输入密钥库文件名、密钥别名、密码以及证书信息。 ```bash ./scripts/create_keystore.sh ``` -------------------------------- ### Page Number Convention and Offset Calculation Source: https://github.com/daodao97/chatmcp/blob/main/docs/pagination_config.md Explains the convention of using 1-based page numbers for user-facing calls and internal conversion to 0-based offsets for data fetching. This ensures consistency between user interaction and data layer requirements. ```dart // 用户调用 (1-based) final result = await repository.getChats(page: 1); // 第一页 // 内部转换 (0-based offset) final offset = (page - 1) * pageSize; // offset = 0 for first page ``` -------------------------------- ### Runtime Output Directory Configuration Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Configures the runtime output directory for the executable to a subdirectory, preventing direct execution of unbundled copies and ensuring correct resource loading. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### ToastUtils 使用示例 Source: https://github.com/daodao97/chatmcp/blob/main/lib/utils/README.md 展示了如何使用 ToastUtils 显示不同级别的消息通知,包括错误、警告、信息、成功以及自定义样式的 toast。 ```dart import '../utils/toast.dart'; // 错误级别 - 红色背景,持续 5 秒 ToastUtils.error('操作失败,请重试'); // 警告级别 - 橙色背景,持续 4 秒 ToastUtils.warn('网络连接不稳定'); // 信息级别 - 蓝色背景,持续 3 秒 ToastUtils.info('正在处理您的请求'); // 成功级别 - 绿色背景,持续 3 秒 ToastUtils.success('操作成功完成'); // 自定义样式 ToastUtils.custom( message: '自定义消息', color: Colors.purple, duration: Duration(seconds: 2), ); ``` -------------------------------- ### Pagination Configuration Constants Source: https://github.com/daodao97/chatmcp/blob/main/docs/pagination_config.md Defines constants for pagination, including default page size, search page size, maximum and minimum page sizes, and the scroll trigger distance for loading more data. ```dart class PaginationConfig { /// 默认页面大小 - 20条记录 static const int defaultPageSize = 20; /// 搜索结果页面大小 - 20条记录 static const int searchPageSize = 20; /// 最大页面大小 - 100条记录 static const int maxPageSize = 100; /// 最小页面大小 - 1条记录 static const int minPageSize = 1; /// 滚动触发加载的距离 - 100像素 static const double loadMoreTriggerDistance = 100.0; } ``` -------------------------------- ### Debug Log and Data Paths Source: https://github.com/daodao97/chatmcp/blob/main/README_ZH.md Provides the file paths for logs and application data for ChatMcp on macOS, Windows, and Linux. Includes commands to reset the application data. ```bash # macOS: # Logs & Data: ~/Library/Application Support/ChatMcp # Reset: rm -rf ~/Library/Application\ Support/ChatMcp # Windows: # Logs & Data: %APPDATA%\ChatMcp # Reset: rd /s /q "%APPDATA%\ChatMcp" # Linux: # Logs & Data: ~/.local/share/ChatMcp # Reset: rm -rf ~/.local/share/ChatMcp # Reset: rm -rf ~/.local/share/run.daodao.chatmcp ``` -------------------------------- ### Flutter Integration and Subdirectories Source: https://github.com/daodao97/chatmcp/blob/main/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory, integrating Flutter's build rules and the application's runner logic into the main project build. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) add_subdirectory("runner") include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Standard Build Settings Function Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Defines a CMake function to apply standard compilation settings, including C++17 standard, Wall/Werror flags, optimization, and NDEBUG definition for non-Debug builds. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Linking Libraries and Dependencies Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Links the application executable with the Flutter library and GTK+ using PkgConfig. It also adds a dependency on the Flutter assemble target. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Flutter Integration and Dependencies Source: https://github.com/daodao97/chatmcp/blob/main/linux/CMakeLists.txt Integrates the Flutter build system by adding the Flutter subdirectory and checking for GTK+ 3.0 using PkgConfig. It also defines the application ID as a preprocessor macro. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Customize Launch Screen using Xcode Source: https://github.com/daodao97/chatmcp/blob/main/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md Guidance on using Xcode to modify the launch screen assets. This involves opening the project's workspace and replacing images in the Asset Catalog. ```bash open ios/Runner.xcworkspace # In Xcode: # Select Runner/Assets.xcassets in the Project Navigator. # Drag and drop desired images into the Asset Catalog. ```