pinia-store
Skill0 starsChanged 19 days agoMITView on GitHub
Pinia 状态管理规范(setup store 写法、持久化到 uni storage、storeToRefs、模块划分)。新建或修改 stores/ 时使用。
In this repository11 other files it gives its agents.
- release-checklistSkill
- uniapp-cross-platformSkill
- uniapp-loginSkill
- uniapp-paymentSkill
- uniapp-performanceSkill
- uniapp-permissionsSkill
- uniapp-project-structureSkill
- uniapp-requestSkill
- uniapp-subpackagesSkill
- uniapp-ui-libsSkill
- vue3-compositionSkill
The file
Files
Pinia 规范
// stores/user.ts
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
export const useUserStore = defineStore('user', () => {
const token = ref(uni.getStorageSync('token') || '')
const refreshToken = ref(uni.getStorageSync('refreshToken') || '')
const info = ref<UserInfo | null>(null)
const isLogin = computed(() => !!token.value)
function setToken(t: { token: string; refreshToken?: string }) {
token.value = t.token; uni.setStorageSync('token', t.token)
if (t.refreshToken) { refreshToken.value = t.refreshToken; uni.setStorageSync('refreshToken', t.refreshToken) }
}
function logout() { token.value = ''; refreshToken.value = ''; info.value = null; uni.removeStorageSync('token'); uni.removeStorageSync('refreshToken') }
return { token, refreshToken, info, isLogin, setToken, logout }
})- 统一用 setup store;一个领域一个 store(user / cart / app),不要做一个巨型全局 store。
- 组件中解构用
storeToRefs(store),方法直接从 store 取。 - 持久化:小数据手动写
uni.setStorageSync,或用pinia-plugin-persistedstate并把 storage 配置为{ getItem: uni.getStorageSync, setItem: uni.setStorageSync }(不要用 localStorage)。 - uni-app Vue3 中在
main.ts的createSSRApp里app.use(createPinia())。 - store 里不要直接操作页面跳转/UI,交给调用方(logout 除外可通过事件)。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

