You've already forked template-MP-ts
Compare commits
27 Commits
b62eadc8b2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1dad063be1 | ||
|
|
e690f53b09 | ||
|
|
7db5d23ab8 | ||
|
|
f1faa644fe | ||
|
|
638fd3fef4 | ||
|
|
484177ca92 | ||
|
|
e17c3f82c3 | ||
|
|
df5f525bda | ||
|
|
1139b2b78a | ||
|
|
bf579e2667 | ||
|
|
4894cfa90b | ||
|
|
bf18ed7ae9 | ||
|
|
9d21fc649f | ||
|
|
5e4f5e8a6e | ||
|
|
223e5c8de3 | ||
|
|
63dacdc470 | ||
|
|
af5f192e22 | ||
|
|
563f750801 | ||
|
|
3432b23ff1 | ||
|
|
99de26a28b | ||
| 053c1cf31f | |||
| 73448d9dc9 | |||
|
|
1e5fd58a65 | ||
|
|
13444d678b | ||
|
|
87d02d4c0a | ||
| 06892298a9 | |||
| 7daa417356 |
1
.env
1
.env
@@ -2,3 +2,4 @@ VITE_BASE_URL= #接口地址
|
|||||||
VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址
|
VITE_ASSETSURL=https://cdn.vrupup.com/s/1598/assets/ #资源地址
|
||||||
VITE_APPID=wx9cb717d8151d8486 #小程序APPID
|
VITE_APPID=wx9cb717d8151d8486 #小程序APPID
|
||||||
VITE_UNI_APPID=_UNI_8842336 #UNI-APPID
|
VITE_UNI_APPID=_UNI_8842336 #UNI-APPID
|
||||||
|
VITE_LIBVERSION=3.0.0 #微信小程序基础库
|
||||||
30
.iflow/agents/code-reviewer.md
Normal file
30
.iflow/agents/code-reviewer.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
agent-type: code-reviewer
|
||||||
|
name: code-reviewer
|
||||||
|
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
|
||||||
|
when-to-use: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
|
||||||
|
allowed-tools:
|
||||||
|
model: gpt-4
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: blue
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a senior code reviewer with deep expertise in configuration security and production reliability. Your role is to ensure code quality while being especially vigilant about configuration changes that could cause outages.
|
||||||
|
|
||||||
|
When invoked:
|
||||||
|
1. Run git diff to see recent changes
|
||||||
|
2. Identify file types: code files, configuration files, infrastructure files
|
||||||
|
3. Apply appropriate review strategies for each type
|
||||||
|
4. Begin review immediately with heightened scrutiny for configuration changes
|
||||||
|
|
||||||
|
## Configuration Change Review (CRITICAL FOCUS)
|
||||||
|
|
||||||
|
### Magic Number Detection
|
||||||
|
For ANY numeric value change in configuration files:
|
||||||
|
- **ALWAYS QUESTION**: Why this specific value? What's the justification?
|
||||||
|
- **REQUIRE EVIDENCE**: Has this been tested under production-like load?
|
||||||
|
- **CHECK BOUNDS**: Is this within recommended ranges for your system?
|
||||||
|
- **ASSESS IMPACT**: What happens if this limit is reached?
|
||||||
|
|
||||||
|
Focus on fixing the underlying issue, not just symptoms. Always prioritize preventing production outages.
|
||||||
36
.iflow/agents/debugger.md
Normal file
36
.iflow/agents/debugger.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
agent-type: debugger
|
||||||
|
name: debugger
|
||||||
|
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
|
||||||
|
when-to-use: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
|
||||||
|
allowed-tools:
|
||||||
|
model: gpt-4
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: red
|
||||||
|
---
|
||||||
|
|
||||||
|
You are an expert debugger specializing in root cause analysis.
|
||||||
|
|
||||||
|
When invoked:
|
||||||
|
1. Capture error message and stack trace
|
||||||
|
2. Identify reproduction steps
|
||||||
|
3. Isolate the failure location
|
||||||
|
4. Implement minimal fix
|
||||||
|
5. Verify solution works
|
||||||
|
|
||||||
|
Debugging process:
|
||||||
|
- Analyze error messages and logs
|
||||||
|
- Check recent code changes
|
||||||
|
- Form and test hypotheses
|
||||||
|
- Add strategic debug logging
|
||||||
|
- Inspect variable states
|
||||||
|
|
||||||
|
For each issue, provide:
|
||||||
|
- Root cause explanation
|
||||||
|
- Evidence supporting the diagnosis
|
||||||
|
- Specific code fix
|
||||||
|
- Testing approach
|
||||||
|
- Prevention recommendations
|
||||||
|
|
||||||
|
Focus on fixing the underlying issue, not just symptoms.
|
||||||
23
.iflow/agents/frontend-developer.md
Normal file
23
.iflow/agents/frontend-developer.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
agent-type: frontend-developer
|
||||||
|
name: frontend-developer
|
||||||
|
description: Build React components, implement responsive layouts, and handle client-side state management.
|
||||||
|
when-to-use: Build React components, implement responsive layouts, and handle client-side state management.
|
||||||
|
allowed-tools:
|
||||||
|
model: gpt-4
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: orange
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a frontend developer specializing in modern web development with React and TypeScript. Create responsive, accessible, and performant user interfaces.
|
||||||
|
|
||||||
|
Core skills:
|
||||||
|
- React components and hooks
|
||||||
|
- TypeScript for type safety
|
||||||
|
- Responsive CSS with Tailwind or styled-components
|
||||||
|
- State management (Redux, Zustand, Context API)
|
||||||
|
- Performance optimization
|
||||||
|
- Accessibility (WCAG compliance)
|
||||||
|
- Testing with React Testing Library
|
||||||
|
Implement modern patterns like server components, suspense, and progressive enhancement.
|
||||||
41
.iflow/agents/javascript-pro.md
Normal file
41
.iflow/agents/javascript-pro.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
agent-type: javascript-pro
|
||||||
|
name: javascript-pro
|
||||||
|
description: Master modern JavaScript with ES6+, async patterns, and Node.js APIs. Handles promises, event loops, and browser/Node compatibility. Use PROACTIVELY for JavaScript optimization, async debugging, or complex JS patterns.
|
||||||
|
when-to-use: Master modern JavaScript with ES6+, async patterns, and Node.js APIs. Handles promises, event loops, and browser/Node compatibility. Use PROACTIVELY for JavaScript optimization, async debugging, or complex JS patterns.
|
||||||
|
allowed-tools:
|
||||||
|
model: sonnet
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: orange
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a JavaScript expert specializing in modern JS and async programming.
|
||||||
|
|
||||||
|
## Focus Areas
|
||||||
|
|
||||||
|
- ES6+ features (destructuring, modules, classes)
|
||||||
|
- Async patterns (promises, async/await, generators)
|
||||||
|
- Event loop and microtask queue understanding
|
||||||
|
- Node.js APIs and performance optimization
|
||||||
|
- Browser APIs and cross-browser compatibility
|
||||||
|
- TypeScript migration and type safety
|
||||||
|
|
||||||
|
## Approach
|
||||||
|
|
||||||
|
1. Prefer async/await over promise chains
|
||||||
|
2. Use functional patterns where appropriate
|
||||||
|
3. Handle errors at appropriate boundaries
|
||||||
|
4. Avoid callback hell with modern patterns
|
||||||
|
5. Consider bundle size for browser code
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
- Modern JavaScript with proper error handling
|
||||||
|
- Async code with race condition prevention
|
||||||
|
- Module structure with clean exports
|
||||||
|
- Jest tests with async test patterns
|
||||||
|
- Performance profiling results
|
||||||
|
- Polyfill strategy for browser compatibility
|
||||||
|
|
||||||
|
Support both Node.js and browser environments. Include JSDoc comments.
|
||||||
38
.iflow/agents/test-automator.md
Normal file
38
.iflow/agents/test-automator.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
agent-type: test-automator
|
||||||
|
name: test-automator
|
||||||
|
description: Create comprehensive test suites with unit, integration, and e2e tests. Sets up CI pipelines, mocking strategies, and test data. Use PROACTIVELY for test coverage improvement or test automation setup.
|
||||||
|
when-to-use: Create comprehensive test suites with unit, integration, and e2e tests. Sets up CI pipelines, mocking strategies, and test data. Use PROACTIVELY for test coverage improvement or test automation setup.
|
||||||
|
allowed-tools:
|
||||||
|
model: sonnet
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: brown
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a test automation specialist focused on comprehensive testing strategies.
|
||||||
|
|
||||||
|
## Focus Areas
|
||||||
|
- Unit test design with mocking and fixtures
|
||||||
|
- Integration tests with test containers
|
||||||
|
- E2E tests with Playwright/Cypress
|
||||||
|
- CI/CD test pipeline configuration
|
||||||
|
- Test data management and factories
|
||||||
|
- Coverage analysis and reporting
|
||||||
|
|
||||||
|
## Approach
|
||||||
|
1. Test pyramid - many unit, fewer integration, minimal E2E
|
||||||
|
2. Arrange-Act-Assert pattern
|
||||||
|
3. Test behavior, not implementation
|
||||||
|
4. Deterministic tests - no flakiness
|
||||||
|
5. Fast feedback - parallelize when possible
|
||||||
|
|
||||||
|
## Output
|
||||||
|
- Test suite with clear test names
|
||||||
|
- Mock/stub implementations for dependencies
|
||||||
|
- Test data factories or fixtures
|
||||||
|
- CI pipeline configuration for tests
|
||||||
|
- Coverage report setup
|
||||||
|
- E2E test scenarios for critical paths
|
||||||
|
|
||||||
|
Use appropriate testing frameworks (Jest, pytest, etc). Include both happy and edge cases.
|
||||||
39
.iflow/agents/typescript-pro.md
Normal file
39
.iflow/agents/typescript-pro.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
agent-type: typescript-pro
|
||||||
|
name: typescript-pro
|
||||||
|
description: Master TypeScript with advanced types, generics, and strict type safety. Handles complex type systems, decorators, and enterprise-grade patterns. Use PROACTIVELY for TypeScript architecture, type inference optimization, or advanced typing patterns.
|
||||||
|
when-to-use: Master TypeScript with advanced types, generics, and strict type safety. Handles complex type systems, decorators, and enterprise-grade patterns. Use PROACTIVELY for TypeScript architecture, type inference optimization, or advanced typing patterns.
|
||||||
|
allowed-tools:
|
||||||
|
model: sonnet
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: yellow
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a TypeScript expert specializing in advanced typing and enterprise-grade development.
|
||||||
|
|
||||||
|
## Focus Areas
|
||||||
|
- Advanced type systems (generics, conditional types, mapped types)
|
||||||
|
- Strict TypeScript configuration and compiler options
|
||||||
|
- Type inference optimization and utility types
|
||||||
|
- Decorators and metadata programming
|
||||||
|
- Module systems and namespace organization
|
||||||
|
- Integration with modern frameworks (React, Node.js, Express)
|
||||||
|
|
||||||
|
## Approach
|
||||||
|
1. Leverage strict type checking with appropriate compiler flags
|
||||||
|
2. Use generics and utility types for maximum type safety
|
||||||
|
3. Prefer type inference over explicit annotations when clear
|
||||||
|
4. Design robust interfaces and abstract classes
|
||||||
|
5. Implement proper error boundaries with typed exceptions
|
||||||
|
6. Optimize build times with incremental compilation
|
||||||
|
|
||||||
|
## Output
|
||||||
|
- Strongly-typed TypeScript with comprehensive interfaces
|
||||||
|
- Generic functions and classes with proper constraints
|
||||||
|
- Custom utility types and advanced type manipulations
|
||||||
|
- Jest/Vitest tests with proper type assertions
|
||||||
|
- TSConfig optimization for project requirements
|
||||||
|
- Type declaration files (.d.ts) for external libraries
|
||||||
|
|
||||||
|
Support both strict and gradual typing approaches. Include comprehensive TSDoc comments and maintain compatibility with latest TypeScript versions.
|
||||||
41
.iflow/agents/ui-ux-designer.md
Normal file
41
.iflow/agents/ui-ux-designer.md
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
agent-type: ui-ux-designer
|
||||||
|
name: ui-ux-designer
|
||||||
|
description: Create interface designs, wireframes, and design systems. Masters user research, prototyping, and accessibility standards. Use PROACTIVELY for design systems, user flows, or interface optimization.
|
||||||
|
when-to-use: Create interface designs, wireframes, and design systems. Masters user research, prototyping, and accessibility standards. Use PROACTIVELY for design systems, user flows, or interface optimization.
|
||||||
|
allowed-tools:
|
||||||
|
model: sonnet
|
||||||
|
inherit-tools: true
|
||||||
|
inherit-mcps: true
|
||||||
|
color: purple
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a UI/UX designer specializing in user-centered design and interface systems.
|
||||||
|
|
||||||
|
## Focus Areas
|
||||||
|
|
||||||
|
- User research and persona development
|
||||||
|
- Wireframing and prototyping workflows
|
||||||
|
- Design system creation and maintenance
|
||||||
|
- Accessibility and inclusive design principles
|
||||||
|
- Information architecture and user flows
|
||||||
|
- Usability testing and iteration strategies
|
||||||
|
|
||||||
|
## Approach
|
||||||
|
|
||||||
|
1. User needs first - design with empathy and data
|
||||||
|
2. Progressive disclosure for complex interfaces
|
||||||
|
3. Consistent design patterns and components
|
||||||
|
4. Mobile-first responsive design thinking
|
||||||
|
5. Accessibility built-in from the start
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
- User journey maps and flow diagrams
|
||||||
|
- Low and high-fidelity wireframes
|
||||||
|
- Design system components and guidelines
|
||||||
|
- Prototype specifications for development
|
||||||
|
- Accessibility annotations and requirements
|
||||||
|
- Usability testing plans and metrics
|
||||||
|
|
||||||
|
Focus on solving user problems. Include design rationale and implementation notes.
|
||||||
11
.iflow/commands/cleanproject.toml
Normal file
11
.iflow/commands/cleanproject.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Command: cleanproject
|
||||||
|
# Description: Clean up development artifacts while preserving your working code
|
||||||
|
# Category: utility
|
||||||
|
# Version: 1
|
||||||
|
# Author: 10169
|
||||||
|
|
||||||
|
description = "Clean up development artifacts while preserving your working code"
|
||||||
|
|
||||||
|
prompt = """
|
||||||
|
I'll help clean up development artifacts while preserving your working code. I'll identify cleanup targets using native tools: Glob tool to find temporary and debug files, Grep tool to detect debug statements in code, Read tool to verify file contents before removal. Critical directories are automatically protected: .claude directory (commands and configurations), .git directory (version control), node_modules, vendor (dependency directories), Essential configuration files. When I find multiple items to clean, I'll create a todo list to process them systematically.
|
||||||
|
"""
|
||||||
11
.iflow/commands/commit.toml
Normal file
11
.iflow/commands/commit.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Command: commit
|
||||||
|
# Description: Analyze your changes and create a meaningful commit message
|
||||||
|
# Category: utility
|
||||||
|
# Version: 1
|
||||||
|
# Author: 10169
|
||||||
|
|
||||||
|
description = "分析您的更改并创建有意义的提交消息"
|
||||||
|
|
||||||
|
prompt = """
|
||||||
|
我会分析您的更改并创建一条有意义的提交消息并使用简单的git命令进行提交更改。我会分析更改,以确定修改了哪些文件、更改的性质(功能、修复、重构等)以及受影响的范围/组件。基于分析结果、以及遵循项目的IFLOW上下文中的提交规范,我会创建一条常规的中文提交消息,其中包含类型(新增|修复|文档|优化|其他)、主题(用现在时清晰描述)。
|
||||||
|
"""
|
||||||
11
.iflow/commands/docs.toml
Normal file
11
.iflow/commands/docs.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Command: docs
|
||||||
|
# Description: Smart documentation management and updates
|
||||||
|
# Category: documentation
|
||||||
|
# Version: 1
|
||||||
|
# Author: 10169
|
||||||
|
|
||||||
|
description = "智能文档管理和更新"
|
||||||
|
|
||||||
|
prompt = """
|
||||||
|
我将根据代码变更更新、整理和维护文档,帮助您智能地管理文档。我将同步文档与实现变更,识别过时的章节,提出改进建议,并确保文档之间的一致性。功能包括自动文档更新、交叉引用链接、版本跟踪和质量评估。
|
||||||
|
"""
|
||||||
@@ -1,16 +1,18 @@
|
|||||||
{
|
{
|
||||||
|
"language": "zh-CN",
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
"Framelink Figma MCP": {
|
"bing-cn-mcp": {
|
||||||
"description": "为AI编程工具提供Figma设计文件访问能力,支持获取设计数据和下载图像资源,帮助实现设计到代码的一键转换。",
|
"description": "MCP 服务器,提供中文必应搜索结果抓取和网页内容抓取功能,支持中文搜索",
|
||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["-y", "@iflow-mcp/figma-developer-mcp@0.5.0", "--stdio"],
|
"args": ["-y", "@iflow-mcp/bing-cn-mcp"],
|
||||||
"env": {
|
"env": {
|
||||||
"FIGMA_API_KEY": ""
|
"USER_AGENT": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"playwright": {
|
"chrome-devtools": {
|
||||||
|
"description": "Chrome浏览器自动化工具,支持页面操作、性能分析、网络监控等功能",
|
||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["@playwright/mcp@latest"]
|
"args": ["-y", "@iflow-mcp/chrome-devtools-mcp"]
|
||||||
},
|
},
|
||||||
"context7": {
|
"context7": {
|
||||||
"description": "为开发者提供最新技术文档和代码示例的智能检索服务,支持库搜索和文档获取功能",
|
"description": "为开发者提供最新技术文档和代码示例的智能检索服务,支持库搜索和文档获取功能",
|
||||||
@@ -22,15 +24,6 @@
|
|||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["-y", "@iflow-mcp/fetch@1.0.2"]
|
"args": ["-y", "@iflow-mcp/fetch@1.0.2"]
|
||||||
},
|
},
|
||||||
"server-puppeteer": {
|
|
||||||
"description": "基于Puppeteer的浏览器自动化工具,支持页面导航、截图、元素操作和JavaScript执行等功能",
|
|
||||||
"command": "npx",
|
|
||||||
"args": ["-y", "@iflow-mcp/server-puppeteer@0.6.2"],
|
|
||||||
"env": {
|
|
||||||
"PUPPETEER_LAUNCH_OPTIONS": "{\"executablePath\":\"C:\\Program Files\\Google\\Chrome\\Application\"}",
|
|
||||||
"ALLOW_DANGEROUS": "{\"executablePath\":\"C:\\Program Files\\Google\\Chrome\\Application\"}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"math-tools": {
|
"math-tools": {
|
||||||
"description": "提供34个数学运算工具,包含算术运算、统计计算、数据科学和表达式求值功能,支持高精度计算。",
|
"description": "提供34个数学运算工具,包含算术运算、统计计算、数据科学和表达式求值功能,支持高精度计算。",
|
||||||
"command": "npx",
|
"command": "npx",
|
||||||
@@ -54,10 +47,13 @@
|
|||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["-y", "@iflow-mcp/server-filesystem@0.6.2", "E:\\"]
|
"args": ["-y", "@iflow-mcp/server-filesystem@0.6.2", "E:\\"]
|
||||||
},
|
},
|
||||||
"mcp-server-code-runner": {
|
"Framelink Figma MCP": {
|
||||||
"description": "多语言代码执行器,支持35种编程语言的代码片段执行,包括JavaScript、Python、Go、Java等主流语言",
|
"description": "为AI编程工具提供Figma设计文件访问能力,支持获取设计数据和下载图像资源,帮助实现设计到代码的一键转换。",
|
||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["-y", "@iflow-mcp/mcp-server-code-runner"]
|
"args": ["-y", "@iflow-mcp/figma-developer-mcp@0.5.0", "--stdio"],
|
||||||
|
"env": {
|
||||||
|
"FIGMA_API_KEY": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"gitlab": {
|
"gitlab": {
|
||||||
"description": "提供GitLab项目管理、文件操作、Issue管理、合并请求等功能的MCP服务器工具集",
|
"description": "提供GitLab项目管理、文件操作、Issue管理、合并请求等功能的MCP服务器工具集",
|
||||||
|
|||||||
51
IFLOW.md
51
IFLOW.md
@@ -1,4 +1,4 @@
|
|||||||
# 项目概述
|
# 项目概述 - IFLOW 上下文
|
||||||
|
|
||||||
这是一个基于 UniApp + Vue3 + TypeScript 的微信小程序项目模板。它提供了一个基础的项目结构和一些常用的工具函数,方便快速开发微信小程序。
|
这是一个基于 UniApp + Vue3 + TypeScript 的微信小程序项目模板。它提供了一个基础的项目结构和一些常用的工具函数,方便快速开发微信小程序。
|
||||||
|
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
* **TypeScript**: JavaScript 的超集,提供类型检查和更好的开发体验。
|
* **TypeScript**: JavaScript 的超集,提供类型检查和更好的开发体验。
|
||||||
* **uView-Plus**: 基于 UniApp 的 UI 组件库。
|
* **uView-Plus**: 基于 UniApp 的 UI 组件库。
|
||||||
* **z-paging**: 一个用于处理分页加载的组件库。
|
* **z-paging**: 一个用于处理分页加载的组件库。
|
||||||
* **Vuex**: 状态管理库。
|
* **Vuex**: 状态管理库,用于统一管理应用状态(登录状态、用户信息等)。
|
||||||
|
* **luch-request**: 基于 Promise 的网络请求库。
|
||||||
|
|
||||||
## 目录结构
|
## 目录结构
|
||||||
|
|
||||||
@@ -25,14 +26,16 @@
|
|||||||
│ └── utils/ # 工具函数
|
│ └── utils/ # 工具函数
|
||||||
│ └── tool.ts # 常用工具函数
|
│ └── tool.ts # 常用工具函数
|
||||||
├── components/ # 公共组件
|
├── components/ # 公共组件
|
||||||
|
├── wxcomponents/ # 微信原生组件
|
||||||
├── lib/ # 第三方库
|
├── lib/ # 第三方库
|
||||||
│ └── luch-request/ # luch-request 网络请求库
|
│ └── luch-request/ # luch-request 网络请求库
|
||||||
├── pages/ # 主包页面
|
├── pages/ # 主包页面
|
||||||
│ └── index/ # 首页
|
│ └── index/ # 首页
|
||||||
│ └── index.vue # 首页页面
|
│ └── index.vue # 首页页面
|
||||||
├── subPages/ # 分包页面
|
├── subPages/ # 分包页面
|
||||||
|
├── static/ # 静态资源文件
|
||||||
|
│ └── assets/ # 静态图片资源
|
||||||
├── store/ # 状态管理
|
├── store/ # 状态管理
|
||||||
│ └── index.ts # Vuex store
|
|
||||||
├── uni_modules/ # uni-app 组件
|
├── uni_modules/ # uni-app 组件
|
||||||
│ └── z-paging/ # 分页组件库
|
│ └── z-paging/ # 分页组件库
|
||||||
├── uview-plus/ # uView-Plus 组件库
|
├── uview-plus/ # uView-Plus 组件库
|
||||||
@@ -83,21 +86,23 @@ npm install
|
|||||||
* 遵循函数式编程范式。
|
* 遵循函数式编程范式。
|
||||||
* 方法类函数应该使用 `function` 进行定义。
|
* 方法类函数应该使用 `function` 进行定义。
|
||||||
* 避免出现超过4个以上的 `ref`,超过4个则使用 `reactive`。
|
* 避免出现超过4个以上的 `ref`,超过4个则使用 `reactive`。
|
||||||
* 页面的生命周期按需进行导入,如(`import { onLoad } from '@dcloudio/uni-app'`)。
|
* 页面的生命周期需要通过 `@dcloudio/uni-app` 依赖进行按需导入,如(`import { onLoad } from '@dcloudio/uni-app'`)。
|
||||||
|
页面的加载、挂载生命周期不要使用 `onMounted` 应该使用 `onLoad`
|
||||||
* 全局变量都集中放置于代码顶部。
|
* 全局变量都集中放置于代码顶部。
|
||||||
* 变量名使用小驼峰命名法。
|
* 变量名使用小驼峰命名法。
|
||||||
* 常量名使用全大写。
|
* 常量名使用全大写。
|
||||||
* 状态类变量命名参考 `isLogin`、`isOpen`。
|
* 状态类变量命名参考 `isLogin`、`isOpen`。
|
||||||
* 事件类方法命名参考 `handleClick`、`onSelect`。
|
* 事件类方法命名参考 `handleClick`、`onSelect`。
|
||||||
* 变量都应该写有注释说明、类型说明。
|
* 变量都应该写有注释说明、类型说明。
|
||||||
* `Promise` 方法使用 `async` `await` 写法,并进行容错处理。
|
* 所有 `Promise` 类方法使用 `async` `await` 写法,避免出现 `.then` 嵌套,并进行容错、错误抛出处理。
|
||||||
|
* 在需要页面跳转、提示、加载、本地存储、或其他功能的时候,优先使用工具函数 `common/utils/tool.ts` 中存在的函数。
|
||||||
* 字符串拼接使用ES6的模板语法。
|
* 字符串拼接使用ES6的模板语法。
|
||||||
* TypeScript规范应遵循项目中已有的风格。
|
* TypeScript规范应遵循项目中已有的风格。
|
||||||
|
|
||||||
## 静态资源
|
## 静态资源
|
||||||
|
|
||||||
* 静态资源变量 `ASSETSURL` 已进行全局暴露,可以在 `<template></template>` 中直接使用。
|
* 静态资源变量 `ASSETSURL` 已进行全局暴露,可以在 `<template></template>` 中直接使用。
|
||||||
* 所有静态资源URL应该使用 `ASSETSURL` 进行拼接,如:`${ASSETSURL}simple.png`。
|
* 所有静态资源URL应该使用 `ASSETSURL` 进行拼接,使用方式为:`${ASSETSURL}simple.png`、`background-image: url($ASSETSURL + 'b23bbf0c4c8e59f88f8fd883cb5d6b27.png')`。
|
||||||
|
|
||||||
## 工具函数 (tool.ts)
|
## 工具函数 (tool.ts)
|
||||||
|
|
||||||
@@ -115,18 +120,48 @@ npm install
|
|||||||
* 包含请求和响应拦截器,用于处理通用逻辑(如错误提示、鉴权等)。
|
* 包含请求和响应拦截器,用于处理通用逻辑(如错误提示、鉴权等)。
|
||||||
* 各业务板块的接口都应存放在 `api/modules` 下,并将单个接口进行导出以便页面按需导入。
|
* 各业务板块的接口都应存放在 `api/modules` 下,并将单个接口进行导出以便页面按需导入。
|
||||||
|
|
||||||
|
## 状态管理 (Vuex)
|
||||||
|
|
||||||
|
* 项目集成了Vuex进行全局状态管理。
|
||||||
|
* 状态管理文件位于 `store/index.ts`。
|
||||||
|
* 使用 `useStore` 钩子在组件中访问状态。
|
||||||
|
|
||||||
## 组件
|
## 组件
|
||||||
|
|
||||||
* 项目集成了 `uView-Plus` 和 `z-paging` 两个组件库。
|
* 项目集成了 `uView-Plus` 和 `z-paging` 两个组件库。
|
||||||
|
* 所有 `uni_modules` 目录中的组件无需导入直接可以进行使用。
|
||||||
* `uView-Plus` 组件已通过 `easycom` 自动导入,可以直接使用,如:`<u-button>`、`<u-icon>`。
|
* `uView-Plus` 组件已通过 `easycom` 自动导入,可以直接使用,如:`<u-button>`、`<u-icon>`。
|
||||||
* 全局组件放在 `components/` 目录下。
|
* 全局组件放在 `components/` 目录下。
|
||||||
* 页面独立组件放在页面根目录下的 `components/`。
|
* 页面独立组件放在页面根目录下的 `components/`。
|
||||||
* 每个组件应该附带 `README.MD` 文档。
|
* 微信的原生组件放在页面根目录下的 `wxcomponents/`,并在使用了组件的对应页面路由配置中添加组件的引用属性 `"usingComponents": { "components": "/wxcomponents/components/components" }`。
|
||||||
* 组件编写应遵循项目中已有的风格。
|
* 组件编写应遵循项目中已有的风格。
|
||||||
|
|
||||||
|
## 分页功能
|
||||||
|
|
||||||
|
* 项目使用 `z-paging` 组件实现分页功能。
|
||||||
|
* 分页组件通过 `v-model` 绑定数据,并使用 `@query` 事件处理数据查询。
|
||||||
|
* 在页面中直接使用 `v-for` 循环渲染数据项,如:`<view class="item" v-for="item in dataList" :key="item.id">`。
|
||||||
|
* 通过 `paging.value?.reload()` 触发分页组件重新加载数据。
|
||||||
|
* 通过 `paging.value?.complete()` 通知分页组件数据加载完成。
|
||||||
|
|
||||||
## 页面
|
## 页面
|
||||||
|
|
||||||
* 页面配置在 `pages.json` 中管理。
|
* 页面配置在 `pages.json` 中管理。
|
||||||
* 主包页面放在 `pages/` 目录下,分包页面放在 `subPages/` 目录下。
|
* 主包页面放在 `pages/` 目录下,分包页面放在 `subPages/` 目录下,如果页面不属于一级页面且没有包含在 `pages.json` 中的 `tabbar`,则应该放置在分包目录下。
|
||||||
* 页面使用 Composition API (setup语法糖) 编写。
|
* 页面使用 Composition API (setup语法糖) 编写。
|
||||||
* 注释、结构规范应遵循项目中已有的风格。
|
* 注释、结构规范应遵循项目中已有的风格。
|
||||||
|
|
||||||
|
## 代码提交规范
|
||||||
|
|
||||||
|
* 提交信息应清晰描述变更内容,如 `修复 搜索功能空值检查` 或 `新增 删除按钮功能`。
|
||||||
|
* 对于功能性的新增或修改,使用 `新增` 前缀。
|
||||||
|
* 对于错误修复,使用 `修复` 前缀。
|
||||||
|
* 对于性能优化、代码重构(既不修复错误也不添加功能),使用 `优化` 前缀。
|
||||||
|
* 对于文档更新,使用 `文档` 前缀。
|
||||||
|
* 提交信息应使用中文。
|
||||||
|
|
||||||
|
## 其他
|
||||||
|
|
||||||
|
* 页面中的分享功能应该使用原生的微信分享功能,通过 `button` 或 `<u-button>` 组件的 `open-type="share"` 属性实现。
|
||||||
|
* 项目使用环境变量管理不同环境的配置,通过 `.env` 文件配置。
|
||||||
|
* Vite配置文件 `vite.config.js` 包含了自定义插件用于在编译时替换 `manifest.json` 中的 appid。
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// 定义内外边距,历遍1-40
|
// 定义内外边距,历遍1-100
|
||||||
@for $i from 0 through 40 {
|
@for $i from 0 through 100 {
|
||||||
// 只要双数和能被5除尽的数
|
// 只要双数和能被5除尽的数
|
||||||
@if $i % 2==0 or $i % 5==0 {
|
@if $i % 2==0 or $i % 5==0 {
|
||||||
// 得出:u-margin-30或者u-m-30
|
// 得出:u-margin-30或者u-m-30
|
||||||
|
|||||||
2
main.ts
2
main.ts
@@ -1,6 +1,7 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
import store from './store'
|
||||||
|
|
||||||
// 创建应用实例
|
// 创建应用实例
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
@@ -14,6 +15,7 @@ app.provide('ASSETSURL', ASSETSURL)
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import uView from './uview-plus/index'
|
import uView from './uview-plus/index'
|
||||||
app.use(uView)
|
app.use(uView)
|
||||||
|
app.use(store)
|
||||||
|
|
||||||
// 挂载应用
|
// 挂载应用
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
|||||||
43
pages.json
43
pages.json
@@ -1,22 +1,43 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index"
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "首页"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"globalStyle": {
|
"subPackages": [
|
||||||
"navigationBarTextStyle": "black",
|
{
|
||||||
"navigationBarTitleText": "uni-app",
|
"root": "subPages",
|
||||||
"navigationBarBackgroundColor": "#F8F8F8",
|
"pages": [
|
||||||
"backgroundColor": "#F8F8F8"
|
{
|
||||||
|
"path": "welcome/index"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tabBar": {
|
||||||
|
"color": "#c3c3c3",
|
||||||
|
"selectedColor": "#454c5c",
|
||||||
|
"backgroundColor": "#ffffff",
|
||||||
|
"borderStyle": "black",
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"pagePath": "pages/index/index",
|
||||||
|
"text": "首页",
|
||||||
|
"iconPath": "static/assets/icon_home.png",
|
||||||
|
"selectedIconPath": "static/assets/icon_home_selected.png"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"easycom": {
|
"easycom": {
|
||||||
"autoscan": true,
|
"autoscan": true,
|
||||||
"custom": {
|
"custom": {
|
||||||
"^u-(.*)": "@/uview-plus/components/u-$1/u-$1.vue"
|
"^u-([^-].*)": "@/uview-plus/components/u-$1/u-$1.vue"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"globalStyle": {
|
||||||
|
"navigationBarTextStyle": "black",
|
||||||
|
"navigationBarTitleText": "miniprogram",
|
||||||
|
"navigationBarBackgroundColor": "#F8F8F8",
|
||||||
|
"backgroundColor": "#F8F8F8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
static/assets/icon_home.png
Normal file
BIN
static/assets/icon_home.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
static/assets/icon_home_selected.png
Normal file
BIN
static/assets/icon_home_selected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
7
subPages/welcome/index.vue
Normal file
7
subPages/welcome/index.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div> </div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@@ -1,36 +1,50 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import uni from '@dcloudio/vite-plugin-uni'
|
import uni from '@dcloudio/vite-plugin-uni'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { readFileSync, writeFileSync } from 'fs'
|
import { readFileSync, writeFileSync, existsSync, unlinkSync } from 'fs'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
|
|
||||||
// 自定义插件:替换 manifest.json 中的 appid
|
// 自定义插件:替换 manifest.json 中的 appid
|
||||||
|
// 仅在通过HBuilder首次编译时执行,避免热重载时重复执行导致内存占用高
|
||||||
function replaceManifestAppid() {
|
function replaceManifestAppid() {
|
||||||
return {
|
return {
|
||||||
name: 'replace-manifest-appid',
|
name: 'replace-manifest-appid',
|
||||||
buildStart() {
|
buildStart() {
|
||||||
|
// 检查是否通过HBuilder编译
|
||||||
|
// 检查是否已经执行过插件
|
||||||
|
const manifestUpdatedFlag = resolve(__dirname, '.manifest-updated')
|
||||||
|
const isFirstCompile = !existsSync(manifestUpdatedFlag)
|
||||||
|
|
||||||
|
// 仅首次编译时执行
|
||||||
|
if (!isFirstCompile) {
|
||||||
|
console.log('跳过 manifest appid 更新(已执行过首次编译)')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取环境变量,明确指定路径为项目根目录
|
// 获取环境变量,明确指定路径为项目根目录
|
||||||
dotenv.config({ path: resolve(__dirname, '.env') })
|
dotenv.config({ path: resolve(__dirname, '.env') })
|
||||||
const appid = process.env.VITE_APPID
|
const appid = process.env.VITE_APPID
|
||||||
const uni_appId = process.env.VITE_UNI_APPID
|
const uni_appId = process.env.VITE_UNI_APPID
|
||||||
|
const libVersion = process.env.VITE_LIBVERSION || '3.0.0'
|
||||||
|
|
||||||
if (appid && uni_appId) {
|
if (appid && uni_appId) {
|
||||||
// 读取 manifest.json 文件
|
// 读取 manifest.json 文件
|
||||||
const manifestPath = resolve(__dirname, 'manifest.json')
|
const manifestPath = resolve(__dirname, 'manifest.json')
|
||||||
let manifestContent = readFileSync(manifestPath, 'utf-8')
|
let manifestContent = readFileSync(manifestPath, 'utf-8')
|
||||||
|
|
||||||
// 解析 JSON
|
// 解析 JSON
|
||||||
const manifest = JSON.parse(manifestContent)
|
const manifest = JSON.parse(manifestContent)
|
||||||
|
|
||||||
// 替换
|
// 替换
|
||||||
manifest.appid = uni_appId
|
manifest.appid = uni_appId
|
||||||
|
|
||||||
if (manifest['mp-weixin']) {
|
if (manifest['mp-weixin']) {
|
||||||
manifest['mp-weixin'].appid = appid
|
manifest['mp-weixin'].appid = appid
|
||||||
|
manifest['mp-weixin'].libVersion = libVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写回文件
|
// 写回文件
|
||||||
writeFileSync(manifestPath, JSON.stringify(manifest, null, 4))
|
writeFileSync(manifestPath, JSON.stringify(manifest, null, 4))
|
||||||
|
// 创建标记文件,表示已执行过插件
|
||||||
|
writeFileSync(manifestUpdatedFlag, 'Manifest updated by HBuilder first compile')
|
||||||
console.log(`Manifest appid 已更新为: ${uni_appId}`)
|
console.log(`Manifest appid 已更新为: ${uni_appId}`)
|
||||||
console.log(`Manifest mp-weixin appid 已更新为: ${appid}`)
|
console.log(`Manifest mp-weixin appid 已更新为: ${appid}`)
|
||||||
} else {
|
} else {
|
||||||
@@ -40,8 +54,22 @@ function replaceManifestAppid() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否通过HBuilder编译,决定是否启用插件
|
||||||
|
const manifestUpdatedFlag = resolve(__dirname, '.manifest-updated')
|
||||||
|
|
||||||
|
if (existsSync(manifestUpdatedFlag)) {
|
||||||
|
unlinkSync(manifestUpdatedFlag)
|
||||||
|
console.log('已清理 manifest 更新标记文件')
|
||||||
|
}
|
||||||
|
|
||||||
|
const plugins = manifestUpdatedFlag ? [replaceManifestAppid(), uni()] : [uni()]
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [replaceManifestAppid(), uni()],
|
plugins,
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': '/src',
|
||||||
|
},
|
||||||
|
},
|
||||||
build: {
|
build: {
|
||||||
minify: 'terser',
|
minify: 'terser',
|
||||||
terserOptions: {
|
terserOptions: {
|
||||||
|
|||||||
Reference in New Issue
Block a user