Uniapp Standard Skill logo

Uniapp Standard Skill

Community
jiushiwon
uniapp-standard-skill

uniapp 微信小程序开发通用规范 skill。覆盖红线规则、目录结构、接口封装、性能优化、状态管理、路由规范、组件通信、埋点等

Overview

Publisherjiushiwon
Repositorywg-skills
Skill nameuniapp-standard-skill
Stars
123
Forks
38
Bundled files
15
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 15 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jiushiwon on GitHub. Read the source before you install it.

Installation

Install the Uniapp Standard Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/frontend/uniapp/uniapp-standard-skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/frontend/uniapp/uniapp-standard-skill .claude/skills/uniapp-standard-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Uniapp Standard Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Uniapp Standard Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Uniapp Standard Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

uniapp 开发通用规范 Skill

Overview

本 skill 提供 uniapp 微信小程序项目的通用开发规范,不包含业务逻辑,只涵盖技术框架层面的最佳实践。

技术栈:uni-app + Vue3 + TypeScript + Pinia + SCSS

配套技能:

When to Use

  • "uniapp 开发规范"
  • "小程序规范"
  • "接口怎么写"
  • "uniapp 项目结构怎么组织"
  • "状态管理"
  • "路由规范"
  • "性能优化"

快速索引

规范主题位置说明
红线规则#一-核心红线规则20 条强制规范
目录结构#二-目录结构规范通用项目结构
接口规范#三-接口规范通用请求封装架构
性能规范#四-性能优化规范渲染、加载、内存
常用命令#五-常用命令开发、构建命令
项目模板#六-项目模板配置模板文件

一、核心红线规则

违反以下任意规则即视为不符合规范

编号规则说明
R01禁止嵌套 v-for单个页面 v-for 层数 ≤ 1
R02data 只存视图数据过滤接口原始数据
R03优先使用 uni.xxx禁止私有 API
R04DOM 节点数限制详见性能规范
R05长列表必须分页懒加载 + 分页
R06setData 数据量限制详见性能规范
R07禁止 eval/new Function危险方法
R08禁止硬编码配置项放 config 目录
R09请求防抖节流同一接口 1 秒内禁止重复
R10失败必须弹提示所有失败场景必须向用户暴露错误
R11AI 生成后必须 lintnpm run lint
R12提交前必须 lint通过后才能提交
R13commit 必须用中文禁止纯英文
R14commit 长度限制subject ≤ 50 字
R15SCSS 必须用 Token详见 uniapp-style-skill
R16Mock 放 mocks/禁止写在 API 文件或页面中
R17请求只传业务路径传 /user/info 不传 /api/v1/user/info,prefix 从 @/config 导入
R18屏幕适配走规范详见 uniapp-style-skill
R19鸿蒙降级规范详见 uniapp-style-skill
R20认证服务收口详见 uniapp-auth-skill

二、目录结构规范

2.1 通用项目结构

uniapp-project/
├── src/
│   ├── api/                      # 接口封装(不含具体业务模块)
│   │   ├── _mocks_/             # Mock 数据字典
│   │   ├── request.ts            # 统一请求封装
│   │   └── index.ts             # 导出入口
│   ├── components/               # 公共组件
│   │   ├── common/              # 通用组件
│   │   │   ├── Button/          # 按钮组件
│   │   │   ├── Card/           # 卡片组件
│   │   │   └── Loading/         # 加载组件
│   │   └── index.ts             # 组件导出(easycom 模式下可选)
│   ├── pages/                   # 业务页面
│   ├── stores/                  # Pinia 状态管理
│   │   ├── index.ts            # store 入口
│   │   └── user.ts             # 示例用户状态(需替换)
│   ├── services/                 # 业务服务层
│   │   ├── auth.service.ts     # 认证服务(详见 uniapp-auth-skill)
│   │   └── index.ts           # 服务导出
│   ├── utils/                   # 工具函数
│   │   ├── auth.ts             # 鉴权工具(详见 uniapp-auth-skill)
│   │   ├── toast.ts           # 提示工具
│   │   ├── storage.ts          # 存储工具
│   │   ├── platform.ts         # 平台判断
│   │   └── index.ts           # 工具导出
│   ├── config/                  # 应用配置
│   │   ├── env.config.ts       # 环境配置
│   │   ├── api.config.ts       # API 配置
│   │   └── index.ts           # 配置导出
│   ├── constants/              # 常量
│   │   ├── storage.ts         # 存储 Key
│   │   ├── enums.ts          # 枚举
│   │   └── index.ts          # 常量导出
│   ├── types/                  # TypeScript 类型
│   │   └── index.d.ts        # 全局类型
│   ├── styles/                 # SCSS 样式系统(详见 uniapp-style-skill)
│   │   ├── config/           # 主题配置
│   │   │   └── _theme-config.scss  # 唯一人工配置
│   │   ├── tokens/           # Token 定义
│   │   │   ├── _primitive.scss     # 基础色板
│   │   │   └── _semantic.scss     # 语义变量
│   │   ├── _functions.scss   # SCSS 函数
│   │   ├── _mixins.scss     # 混入
│   │   └── variables.scss   # 统一出口
│   ├── composables/           # 组合式函数
│   ├── App.vue               # 根组件
│   ├── main.ts               # 入口
│   └── pages.json           # 页面路由
├── static/                   # 静态资源
├── package.json
├── vite.config.ts
└── tsconfig.json

2.2 命名规范

  • 目录:全部小写,多单词用连字符 -
  • 禁止:大写、下划线 _、中文、模糊命名
  • 组件目录:目录即命名空间,如 Button/index.vue
  • 类型文件:以 .d.ts 结尾或放在 types/ 目录

三、接口规范

3.1 请求封装架构

typescript
// src/api/request.ts

/** 请求方法类型 */
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD';

/** 请求配置选项 */
interface RequestOptions {
  /** 接口相对路径 */
  url: string;
  /** 请求方法,默认 GET */
  method?: HttpMethod;
  /** 请求参数 */
  data?: Record<string, any>;
  /** 请求头 */
  header?: Record<string, string>;
  /** 超时时间(ms),默认 30000 */
  timeout?: number;
  /** 是否自动处理错误提示,默认 true */
  showErrorToast?: boolean;
  /** 是否需要 Token,默认 true */
  needAuth?: boolean;
  /** 鉴权头格式 */
  authMode?: 'customer-token' | 'bearer';
  /** 响应数据类型,默认 json */
  dataType?: string;
  /** 成功状态码,默认 200 */
  successCode?: number;
  /** 是否在响应结果中携带 _headers */
  withHeaders?: boolean;
  /** 接口路径前缀 */
  prefix?: string;
  /** 是否跳过防抖检查,默认 false */
  skipDebounce?: boolean;
  /** 是否跳过 401 统一处理 */
  skipAuthHandler?: boolean;
  /** 接口级 Mock 开关 */
  mock?: boolean;
}

/** 统一响应结构 */
interface ApiResponse<T = any> {
  code: number;
  message: string;
  data: T;
  _headers?: Record<string, string | string[]>;
}

/** 发送请求 */
export function request<T = any>(options: RequestOptions): Promise<ApiResponse<T>>;

/** GET 请求 */
export function get<T = any>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;

/** POST 请求 */
export function post<T = any>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;

/** PUT 请求 */
export function put<T = any>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;

/** DELETE 请求 */
export function del<T = any>(url: string, data?: Record<string, any>, options?: Omit<RequestOptions, 'url' | 'method' | 'data'>): Promise<ApiResponse<T>>;

3.2 请求拦截器

typescript
// src/api/request.ts - 请求拦截器

function requestInterceptor(options: RequestOptions): RequestOptions {
  const headers: Record<string, string> = {
    'Content-Type': 'application/json',
    'X-Tenant-Id': 'default',
    ...options.header,
  };

  // Token 注入(详见 uniapp-auth-skill)
  if (options.needAuth !== false) {
    const token = getToken();
    if (token) {
      if (options.authMode === 'bearer') {
        headers.Authorization = `Bearer ${token}`;
      } else {
        headers['Customer-Token'] = token;
      }
    }

    const customerContext = getCustomerContext();
    if (customerContext) {
      headers['X-Customer-Context'] = customerContext;
    }
  }

  return { ...options, header: headers };
}

3.3 响应拦截器

typescript
// src/api/request.ts - 响应拦截器
import { handleUnauthorized, handleForbidden } from '@/services/auth.service';
import { AUTH_FAILURE_CODES } from '@/config/api.config';

function responseInterceptor<T>(res: any, options: RequestOptions): ApiResponse<T> {
  const { statusCode, data } = res;

  // 401/403 处理(详见 uniapp-auth-skill)
  if (statusCode === 401 || AUTH_FAILURE_CODES.includes(data?.code)) {
    if (!options.skipAuthHandler) {
      handleUnauthorized();
    }
    throw new Error('登录已过期');
  }

  if (statusCode === 403) {
    handleForbidden();
    throw new Error('权限不足');
  }

  // HTTP 状态码异常
  if (statusCode !== (options.successCode ?? 200)) {
    throw new Error(`请求失败: ${statusCode}`);
  }

  // 业务码异常
  if (data && typeof data.code === 'number' && data.code !== 0 && data.code !== 200) {
    throw new Error(data.message || '请求失败');
  }

  return data as ApiResponse<T>;
}

3.4 Mock 数据规范

typescript
// src/api/_mocks_/index.ts

export interface MockEntry<T = any> {
  code: number;
  message: string;
  data: T;
}

export const MOCK_MAP: Record<string, MockEntry> = {};

key 格式:METHOD:相对路径(不含 prefix)

3.5 API 配置

typescript
// src/config/api.config.ts

/** 多环境域名 */
const BASE_URL_MAP: Record<string, string> = {
  development: 'https://dev-api.example.com',
  test: 'https://test-api.example.com',
  production: 'https://api.example.com',
};

/** API 前缀 */
export const API_PREFIX = {
  DEFAULT: '/api/v1',
  // 业务前缀按需添加
} as const;

/** Mock 模式 */
export type MockMode = 'none' | 'auto' | 'force';
export const MOCK_MODE: MockMode = 'auto';

/** 防抖时间(ms) */
export const REQUEST_DEBOUNCE_MS = 1000;

/** 认证失败业务码(与 401 同等处理) */
export const AUTH_FAILURE_CODES = [2001, 2002] as const;

3.6 错误处理规范

  • 开发/体验版:Modal 展示完整错误详情
  • 正式版:按消息长度选择 Toast 或精简 Modal
  • 401:自动跳转登录页(详见 uniapp-auth-skill)
  • 403:弹权限不足(详见 uniapp-auth-skill)

四、性能优化规范

4.1 DOM 节点限制

场景最大节点数
页面总节点1000
列表项节点100
列表项数50

4.2 setData 限制

  • 数据量:单次不超过 100KB
  • 调用频率:每秒不超过 20 次
  • 优化:使用 diff 算法只更新变化部分

4.3 长列表规范

  • 必须使用懒加载
  • 必须分页(每页 ≤ 20 条)
  • 数量 > 1000 时考虑虚拟列表

4.4 图片优化

  • 使用懒加载组件
  • 合理设置尺寸(避免原图)
  • 考虑 CDN 缩略图

五、常用命令

命令用途
npm install安装依赖(先删除 node_modules)
npm run dev:mp-weixin微信小程序开发调试
npm run build:mp-weixin微信小程序打包
npm run lintESLint 代码检查

六、项目模板

6.1 模板文件

templates/
├── vite.config.ts        # Vite 配置模板
├── tsconfig.json         # TypeScript 配置模板
├── main.ts              # 应用入口模板(Pinia + SSR)
├── pages.json            # 页面路由配置模板(tabBar 需配套 static/tabbar/*.png 图标文件)
├── pages-sub.json       # 分包配置模板
├── package.json         # 依赖配置模板
├── .env.example         # 环境变量示例(复制为 .env 后修改)
└── env.d.ts             # 类型声明模板(放到 src/ 下使用)

6.2 使用方式

bash
# # 复制模板到新项目
cp -r templates/* /path/to/new-project/

References

本技能参考

  • references/api-architecture.md — 请求封装架构详解
  • references/performance.md — 性能优化详解
  • references/store-guide.md — 状态管理最佳实践
  • references/router-guide.md — 路由配置与跳转规范
  • references/analytics.md — 埋点规范
  • references/component-communication.md — 组件通信规范
  • references/storage-guide.md — 存储 Key 常量规范

配套技能

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Uniapp Standard Skill AI skill do?

uniapp 微信小程序开发通用规范 skill。覆盖红线规则、目录结构、接口封装、性能优化、状态管理、路由规范、组件通信、埋点等

Why use Uniapp Standard Skill on TypingMind?

Because you install it once and use it with any model. Uniapp Standard Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Uniapp Standard Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/frontend/uniapp/uniapp-standard-skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Uniapp Standard Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Uniapp Standard Skill?

As many as you like. As long as a model supports skills, you can use Uniapp Standard Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Uniapp Standard Skill AI skill free?

Yes. It is published on GitHub by jiushiwon under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇