Your description here.
1.在app.vue中引入user.js,其中这里给里面的函数传值,pinia存储,userStore.loginSuccess({...res,showToast:false});这里面的...是指展开res对象内容,然后后面又传了一个值,刚好就能代替掉了,这个showtoast就变成false了,然后组成了一个新的对象import{onLaunch,onShow,onHide} from "@dcloudio/uni-app" import { useUserStore } from "./stores/user"; const uniIdco =uniCloud.importObject('uni-id-co') const userStore =useUserStore() onLaunch(()=>{ console.log('APP Lanch') uni.login({ success:login=>{
1.把\chiken\uni_modules\uni-id-pages\common\store.js拷贝一份到我们创建的stores目录下并改名为user.js,然后改造成pinia使用的js改造完成后import{ref} from "vue" import{defineStore} from "pinia"; const uniIdCo = uniCloud.importObject("uni-id-co") const db = uniCloud.database(); const usersTable = db.collection('uni-id-users') export const useUserStore =defineStore("user",()=>{ let hostUserInfo = uni.getStorageSync('uni-id-pages-userInfo')||{} const userInfo =ref(hostUserInfo);
1.pinia是统一集中管理数据,任何一个页面都能调用pinia使用教程https://uniapp.dcloud.net.cn/tutorial/vue3-pinia.html一 在main.js中修改 import App from './App' import * as Pinia from 'pinia'; 加上这行 // #ifndef VUE3 import Vue from 'vue' import './uni.promisify.adaptor' Vue.config.productionTip = false App.mpType = 'app' const app = new Vue({ ...App }) app.$mount() // #endif // #ifdef VUE3 import { createSSRApp } from 'vue' export function createApp() { c
1.在uni-id目录下创建hooks,在hooks里面创建index.js(作用看https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#hooks)然后修改成这样填入里面,userRecord是返回到数据库插入的值,而这个钩子是在创建用户之前有效,Math.random().toString(36).substring(3,9);这个是后面加上随机值tostring(36)是转换为36进制的文本,substring是截取3到9个// 钩子函数示例 hooks/index.js function beforeRegister({ userRecord, clientInfo } = {}) { userRecord.username='游客'+(Math.random().toString(36).substring(3,9)); } return userRecord // 务必返回处理后的userRecord } module.exports = { beforeRegister }
1.删除config.json中所有注释,正则匹配 //.*2.修改config.json中的属性 "tokenSecret": "xxm123321@#", "requestAuthSecret": "xxm123321@#", 这俩个是传输加密方式 这个下面填上自己的id和token "mp-weixin": { "tokenExpiresIn": 259200, "tokenExpiresThreshold": 86400, "oauth": { "weixin": { "appid": "wxf841f15175075902", "appsecret": "1d5e138d551ca5d439f5a52e13e70fed"
ikrins