- 开启 useCompilerPlugins: ["typescript"],源码改为 app.ts / pages/**/*.ts / utils/*.ts - 引入 miniprogram-api-typings 与 tsconfig(strict),新增 npm run typecheck - 事件与页面数据补充类型,setData 改为整体对象赋值 - AGENTS.md 补充技术栈、类型校验与命名约束
20 lines
389 B
TypeScript
20 lines
389 B
TypeScript
// app.ts
|
|
App<IAppOption>({
|
|
onLaunch() {
|
|
// 展示本地存储能力
|
|
const logs: number[] = wx.getStorageSync('logs') || []
|
|
logs.unshift(Date.now())
|
|
wx.setStorageSync('logs', logs)
|
|
|
|
// 登录
|
|
wx.login({
|
|
success: (_res) => {
|
|
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
}
|
|
})
|
|
},
|
|
globalData: {
|
|
userInfo: null
|
|
}
|
|
})
|