51mazi

repository·main·Indexed 19 days ago

https://github.com/xiaoshengxianjun/51mazi

A comprehensive desktop writing software for novel writers (v0.8.5) featuring a TipTap-based rich-text editor, bookshelf management with password protection, and world-building tools. It includes a Canvas-based map design tool, relationship graphs, organizational structures, and event timeline management. The software integrates DeepSeek and Tongyi Wanxiang APIs for AI-powered text polishing, story continuation, random naming, and the generation of book covers, character portraits, and scene illustrations.

Tokens
72.3K
Snippets
152
Records
251
Agent score
64%

What's inside 51mazi

  1. Overview of core functional modules

    main

    51mazi provides several specialized tools for novelists:

    1. Multi-Book Management System: Uses independent data directories for each book and supports custom main directories with a file-system-based synchronization mechanism.
    2. Rich Text Editor: A professional environment using TipTap with real-time word counts, typing speed statistics, and auto-save.
    3. Map Design Tool: A Canvas-based drawing tool featuring pencil, eraser, paint bucket, and text tools, with support for dragging in image resources and canvas scaling.
    4. Relationship Graph: A visualization tool using relation-graph-vue3 for managing character nodes, editing relationship lines (with types and descriptions), and generating thumbnail previews.
    5. Data Storage: Uses electron-store for local configuration and the file system for book content and chapter version history.
  2. Overview of the Map Design Tool

    main

    The Map Design Tool is a Canvas-based feature integrated into 51mazi to help authors visualize story settings and geography. It provides a suite of drawing and management tools to create custom maps directly within the writing software.

    Key Features:

    • Drawing Tools: Pencil, Eraser, Paint Bucket (Flood Fill), and Text tools.
    • Resource Management: Drag-and-drop support for preset image resources (e.g., mountains, cities, forests).
    • View Controls: Canvas zooming and view adjustments.
    • Workflow Support: Undo/redo functionality and automatic real-time saving.
  3. Overview of 51mazi Features

    main

    51mazi is a comprehensive novel writing software designed for both novice and experienced authors. It combines a professional rich-text editing environment with AI-assisted creative tools and organizational management systems.

    Key Capabilities

    • AI-Assisted Creation: Uses DeepSeek for naming, polishing, and story continuation, and Tongyi Wanxiang for generating book covers, character images, and scene images.
    • Security & Privacy: Features completely localized storage and dual-layer protection (Bookshelf password + individual Book password).
    • Intelligent Editor: Includes character highlighting, forbidden word detection, and paragraph dragging.
    • Creative Tools: Professional map design tool, relationship graph management, and a dictionary management system with a tree structure.
    • Content Management: Multi-book management system and a novel downloader that supports multi-source searching, adding to the bookshelf, or exporting as TXT.
    • Technical Stack: Built using Electron, Vue 3, TipTap, Element Plus, and Pinia.
  4. Overview of 51mazi Novel Writing Software

    main

    51mazi is a desktop-based, open-source, and free novel writing software designed to provide a complete creative pipeline. It integrates writing, world-building, and AI-assisted asset generation into a single workflow. Key features include:

    • Writing Tools: Professional editor with rich text support, auto-save, word count statistics, character highlighting, and multiple themes (including eye-protection modes).
    • AI Generation: One-click generation of novel covers and character portraits (vertical full-body illustrations) using AI.
    • World Building: Tools for managing character profiles (人物档案), relationship maps (关系图谱), map design (地图设计), and dictionary entries (词条字典).
    • Data Privacy: All data (books, characters, maps, etc.) is stored locally on your computer. It supports bookshelf passwords and individual book passwords for enhanced privacy.
    • Platform Support: Available for Windows and macOS via GitHub releases.
  5. Overview of 51mazi Creative Toolset

    main

    51mazi is a comprehensive novel writing suite that integrates all stages of the creative process from conception to final manuscript. It is designed for privacy-conscious authors, storing all data locally and supporting password protection for bookshelves and individual books.

    Integrated Creative Modules:

    • Planning: Outlines (大纲), Maps (地图), and Relationship Graphs (关系图谱).
    • World Building: Terminology Dictionaries (词条字典) and Character Profiles (人物档案).
    • AI-Assisted Tools: AI Naming (AI 起名), AI Cover Generation (AI 封面), and AI Character Image Generation (AI 人物图).
    • Data Security: Local storage, bookshelf protection, and individual book password support.
  6. Map Design tool feature summary

    main

    The Map Design tool in 51mazi provides a professional canvas-based environment for world-building.

    Core Capabilities:

    • Drawing Tools: Pencil, Eraser, and Paint Bucket.
    • Annotation: Text tool for labeling map locations.
    • Navigation: Zooming via mouse wheel or buttons.
    • History: Undo/Redo functionality for managing operation history.
    • Asset Management: Drag-and-drop support for preset image resources.
    • Persistence: Automatic saving of drawing content.
    • Cross-Platform: Optimized for both desktop (keyboard/mouse) and mobile (touch) interfaces.
  7. Summary of implemented editor features

    main

    The 51mazi editor implementation includes the following core capabilities:

    Basic Editing & Formatting

    • Text input, deletion, and selection
    • Bold, Italic, and alignment controls
    • Font family, font size, and line height settings

    User Experience & Data

    • Real-time Statistics: Word count and typing speed
    • Auto-save: Implemented via debouncing and local storage
    • Keyboard Shortcuts: Support for common operations
    • Theme Support: Multi-theme mode compatibility

    Technical Architecture

    • High performance based on ProseMirror
    • Extensible via custom extensions and plugins
    • Data security through error handling and auto-save mechanisms.
  8. Understand the 51mazi project architecture

    main

    51mazi is a desktop novel writing software built with Electron and Vue 3. The project follows a standard Electron structure separating the main process, preload scripts, and the renderer process:

    • src/main/: Electron main process.
    • src/preload/: Preload scripts.
    • src/renderer/: The Vue 3 application (Renderer process).
      • src/components/: UI components like EditorPanel.vue, MapDesign.vue, and RelationshipDesign.vue.
      • src/views/: Page views.
      • src/stores/: Pinia state management.
      • src/router/: Vue Router configuration.
      • src/utils/: Utility functions.
    • electron.vite.config.mjs: Vite configuration for Electron.
    51mazi/
    ├── src/
    │   ├── main/
    │   ├── preload/
    │   └── renderer/
    │       ├── src/
    │       │   ├── components/
    │       │   ├── views/
    │       │   ├── stores/
    │       │   ├── router/
    │       │   └── utils/
    │       └── assets/
    ├── package.json
    └── electron.vite.config.mjs
  9. Overview of the Map Design Tool architecture

    main

    The Map Design Tool in 51mazi is a professional-grade editor built using Vue 3 and the Native Canvas API. It uses a modular Composables architecture to separate concerns between canvas state, element management, history (undo/redo), and individual drawing tools. This design allows for high maintainability and easy extension of new drawing capabilities.

    // Core Tech Stack
    {
      "vue": "^3.5.13",           // Vue 3 Composition API
      "element-plus": "^2.10.1",  // UI Component Library
      "canvas": "Native Canvas API"  // Drawing Engine
    }
  10. How AI cover prompt construction works

    main

    To ensure the AI model attempts to include text on the cover, 51mazi uses a 'three-part' prompt concatenation strategy. The final prompt sent to the API is constructed as follows:

    1. Title Part (Required): 封面上必须清晰、醒目地显示书名《{bookName}》,书名需易于辨认。
    2. Author Part (Optional): If a pen name is provided: 封面上必须清晰显示作者笔名:{penName}。
    3. Style Part: If user input is provided: 风格与画面要求:{userPrompt}. If empty, it defaults to: 封面风格为小说封面,美观大气。

    Example Logic (from AICoverDrawer.vue):

    const titlePart = `封面上必须清晰、醒目地显示书名《${bookName}》,书名需易于辨认。`
    const authorPart = penName ? `封面上必须清晰显示作者笔名:${penName}。` : ''
    const stylePart = userPrompt ? `风格与画面要求:${userPrompt}` : '封面风格为小说封面,美观大气。'
    const fullPrompt = `${titlePart}${authorPart}${stylePart}`
    
    await generateAICover({ prompt: fullPrompt, size, bookName, negativePrompt })
  11. How the Flood Fill algorithm works in 51mazi

    main

    The Bucket Tool implements a Flood Fill algorithm using a stack-based approach rather than recursion. This prevents stack overflow errors when filling large areas and provides better performance and memory control.

    Algorithm Logic:

    1. Start at the clicked pixel and record its color.
    2. Check the four adjacent pixels (up, down, left, right).
    3. If an adjacent pixel matches the starting color, fill it with the target color.
    4. Add the new pixel to a stack and repeat until a boundary or a different color is encountered.

    To ensure $O(1)$ lookup efficiency and prevent infinite loops, a Set is used to track visited pixels using a string key format: `${x},${y}`.

    // Core algorithm flow (simplified)
    function floodFill(startX, startY, targetColor, fillColor, imageData) {
      const stack = [[startX, startY]]  // Use a stack instead of recursion
      const visited = new Set()         // Track visited pixels
      
      while (stack.length) {
        const [x, y] = stack.pop()
        
        // Boundary check and color matching
        if (isValid(x, y) && colorMatches(x, y, targetColor)) {
          fillPixel(x, y, fillColor)     // Fill pixel
          visited.add(`${x},${y}`)       // Mark as visited
          
          // Add adjacent pixels to stack
          stack.push([x+1, y], [x-1, y], [x, y+1], [x, y-1])
        }
      }
    }
  12. Architecture of the Novel Downloader

    main

    The novel downloading functionality in 51mazi follows a decoupled architecture designed for Electron:

    • Main Process: Responsible for the heavy lifting, including network requests, parsing, and content cleaning. It uses configuration-driven book sources to handle different websites.
    • Renderer Process: Responsible for the User Interface (search, results, progress bars). It sends commands to the main process via IPC and displays the results.
    • Preload Script: Acts as the bridge, exposing novel* APIs to the renderer and forwarding progress events.

    This separation avoids CORS issues and security risks associated with making network requests directly from the browser context.