uni-app-patterns

uni-app-patterns is a cursor rule for Cursor from soaring-xiongkulu/easyaiot. It costs 476 tokens per session, scanned A, original, MIT.

A set of coding rules for uni-app, a framework for building applications that target web browsers, mini-programs, and mobile apps from one codebase. The rules cover page layout, components, routing, lifecycles, and platform-specific code.

In plain words
What is it for?
Use it when creating pages or components, defining routes, handling page and component lifecycles, and writing conditional code for H5, WeChat mini-programs, or apps.
Why use it?
It keeps project files and page behaviour consistent across supported platforms, where APIs and features may differ.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when creating pages or components, defining routes, handling page and component lifecycles, and writing conditional code for H5, WeChat mini-programs, or apps.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/soaring-xiongkulu/easyaiot/uni-app-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/soaring-xiongkulu/easyaiot

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for uni-app-patterns

README.md
[![agentmods](https://agentmods.dev/badge/rules/soaring-xiongkulu/easyaiot/uni-app-patterns/github.svg)](https://agentmods.dev/rules/soaring-xiongkulu/easyaiot/uni-app-patterns)
Your own site
<a href="https://agentmods.dev/rules/soaring-xiongkulu/easyaiot/uni-app-patterns"><img src="https://agentmods.dev/badge/rules/soaring-xiongkulu/easyaiot/uni-app-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for uni-app-patterns

Your own site · 80×15
<a href="https://agentmods.dev/rules/soaring-xiongkulu/easyaiot/uni-app-patterns"><img src="https://agentmods.dev/badge/rules/soaring-xiongkulu/easyaiot/uni-app-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 476 This file is loaded in full into every session.
When invoked 476 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00476 $0.00476
Opus 5 $0.00238 $0.00238
Sonnet 5 $0.00095 $0.00095
Haiku 4.5 $0.00048 $0.00048

Measured 10d ago against content hash 6aa764e70089, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

uni-app-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

APP/.cursor/rules/uni-app-patterns.mdc · 63 lines

What it actually says

uni-app 开发规范

页面开发

  • 页面文件放在 src/pages/ 目录下
  • 使用约定式路由,文件名即路由路径
  • 页面配置在仅需要在 宏definePage 中配置标题等内容即可,会自动生成到 pages.json

组件开发

  • 组件文件放在 src/components/ 或者 src/pages/xx/components/ 目录下
  • 使用 uni-app 内置组件和第三方组件库
  • 支持 wot-ui\uview-pro\uv-ui\sard-ui\uview-plus 等多种第三方组件库 和 z-paging 组件
  • 自定义组件遵循 uni-app 组件规范

平台适配

  • 使用条件编译处理平台差异
  • 支持 H5、小程序、APP 多平台
  • 注意各平台的 API 差异
  • 使用 uni.xxx API 替代原生 API

示例代码结构

<script setup lang="ts">
// #ifdef H5
import { h5Api } from '@/utils/h5'
// #endif

// #ifdef MP-WEIXIN
import { mpApi } from '@/utils/mp'
// #endif

const handleClick = () => {
  // #ifdef H5
  h5Api.showToast('H5 平台')
  // #endif
  
  // #ifdef MP-WEIXIN
  mpApi.showToast('微信小程序')
  // #endif
}
</script>

<template>
  <view class="page">
    <!-- uni-app 组件 -->
    <button @click="handleClick">点击</button>
    
    <!-- 条件渲染 -->
    <!-- #ifdef H5 -->
    <view>H5 特有内容</view>
    <!-- #endif -->
  </view>
</template>

生命周期

  • 使用 uni-app 页面生命周期
  • onLoad、onShow、onReady、onHide、onUnload
  • 组件生命周期遵循 Vue3 规范
  • 注意页面栈和导航管理

globs: src/pages/.vue,src/components/.vue

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 63 lines · 476 tokens per session scan A 6aa764e70089

Subscribe to this mod's changes

uni-app-patterns is a cursor rule published in the GitHub repository soaring-xiongkulu/easyaiot (712 stars, last pushed 5d ago), licensed MIT. It adds 476 tokens to every session, about $0.0024 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.