diff --git a/app.js b/app.js index e71910e..438c558 100644 --- a/app.js +++ b/app.js @@ -2,39 +2,72 @@ import request from './utils/request'; App({ onLaunch() { - // Login + // Initialize login process immediately + this.loginPromise = new Promise((resolve, reject) => { + this._resolveLogin = resolve; + this._rejectLogin = reject; + }); + + this.doLogin(); + }, + + // Perform actual login + doLogin() { wx.login({ success: res => { - // Send res.code to backend to swap for openId, sessionKey, unionId if (res.code) { - request.get('/auth/miniLogin', { code: res.code }).then(data => { - // Response structure based on user input: { user: {...}, token: "...", expiresAt: ... } - // Note: request.js might return data.user directly if it unwraps 'data' - // But looking at previous request.js usage, it seems to return the 'data' field of the response. - // Let's handle both cases safely. - + request.get('/auth/miniLogin', { code: res.code }).then(async (data) => { const token = data.token; - const user = data.user; if (token && typeof token === 'string') { wx.setStorageSync('token', token); - if (user) { - wx.setStorageSync('userInfo', user); - this.globalData.userInfo = user; - } - console.log('Login successful, user info stored'); + console.log('Login successful'); + if (this._resolveLogin) this._resolveLogin(token); + + // Background Profile Update + request.get('/profile/detail').then(userDetail => { + if (userDetail) { + wx.setStorageSync('userInfo', userDetail); + this.globalData.userInfo = userDetail; + } + }).catch(e => { + console.error('Fetch profile detail failed on launch', e); + // Fallback + if (data.user) { + wx.setStorageSync('userInfo', data.user); + this.globalData.userInfo = data.user; + } + }); } else { - console.warn('Login response did not contain a valid token', data); + console.warn('Login response invalid', data); + if (this._rejectLogin) this._rejectLogin('No token'); } }).catch(err => { - console.error('Login failed', err); + console.error('Login API failed', err); + if (this._rejectLogin) this._rejectLogin(err); }); } else { console.error('wx.login failed: ' + res.errMsg); + if (this._rejectLogin) this._rejectLogin(res.errMsg); } + }, + fail: err => { + if (this._rejectLogin) this._rejectLogin(err); } }); }, + + // Method for other pages/utils to wait for login + ensureLogin() { + // If token exists, resolve immediately + const token = wx.getStorageSync('token'); + if (token) return Promise.resolve(token); + + // Return existing promise or create new if failed previously? + // For simplicity, return the launch promise. + // In robust apps, handle token expiration and re-login here. + return this.loginPromise; + }, globalData: { userInfo: null } diff --git a/app.json b/app.json index 7ab7c5e..f259092 100644 --- a/app.json +++ b/app.json @@ -9,9 +9,12 @@ "pages/profile/index", "pages/plant-detail/edit/index", "pages/plant-detail/index", + "pages/plant-detail/growth-record/index", "pages/wiki/detail/index", "pages/wiki/identify/index", - "pages/profile/identify-history/index" + "pages/profile/identify-history/index", + "pages/profile/badges/index", + "pages/profile/badges/level-detail/index" ], "window": { "backgroundTextStyle": "light", diff --git a/app.wxss b/app.wxss index e537fb9..fdf6d3c 100644 --- a/app.wxss +++ b/app.wxss @@ -1,4 +1,13 @@ /** app.wxss **/ +@font-face { + font-family: 't'; + src: url('https://tdesign.gtimg.com/icon/0.3.1/fonts/t.woff') format('woff'), + url('https://tdesign.gtimg.com/icon/0.3.1/fonts/t.ttf') format('truetype'); + font-weight: normal; + font-style: normal; + font-display: swap; +} + page { --primary: #558B2F; --primary-light: #9CCC65; diff --git a/assets/icons/arrow-left.svg b/assets/icons/arrow-left.svg deleted file mode 100644 index 53f0a73..0000000 --- a/assets/icons/arrow-left.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/book-open.svg b/assets/icons/book-open.svg deleted file mode 100644 index cb553f0..0000000 --- a/assets/icons/book-open.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/calendar.svg b/assets/icons/calendar.svg deleted file mode 100644 index 262d050..0000000 --- a/assets/icons/calendar.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/camera.svg b/assets/icons/camera.svg deleted file mode 100644 index 57331d8..0000000 --- a/assets/icons/camera.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/check.svg b/assets/icons/check.svg deleted file mode 100644 index deec4c4..0000000 --- a/assets/icons/check.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/chevron-right.svg b/assets/icons/chevron-right.svg deleted file mode 100644 index 5bad1fa..0000000 --- a/assets/icons/chevron-right.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/community.svg b/assets/icons/community.svg deleted file mode 100644 index 6c2eb68..0000000 --- a/assets/icons/community.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/community_active.svg b/assets/icons/community_active.svg deleted file mode 100644 index 5976231..0000000 --- a/assets/icons/community_active.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/crown.svg b/assets/icons/crown.svg deleted file mode 100644 index 14a7972..0000000 --- a/assets/icons/crown.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/droplets.svg b/assets/icons/droplets.svg deleted file mode 100644 index b1ebc7c..0000000 --- a/assets/icons/droplets.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/file-text.svg b/assets/icons/file-text.svg deleted file mode 100644 index 965243c..0000000 --- a/assets/icons/file-text.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/garden.svg b/assets/icons/garden.svg deleted file mode 100644 index a094935..0000000 --- a/assets/icons/garden.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/garden_active.svg b/assets/icons/garden_active.svg deleted file mode 100644 index 4b98367..0000000 --- a/assets/icons/garden_active.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/heart.svg b/assets/icons/heart.svg deleted file mode 100644 index fa1ae63..0000000 --- a/assets/icons/heart.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/help-circle.svg b/assets/icons/help-circle.svg deleted file mode 100644 index 224b9a3..0000000 --- a/assets/icons/help-circle.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/image.svg b/assets/icons/image.svg deleted file mode 100644 index 64f36bf..0000000 --- a/assets/icons/image.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/lock.svg b/assets/icons/lock.svg deleted file mode 100644 index ff64a3e..0000000 --- a/assets/icons/lock.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/medal.svg b/assets/icons/medal.svg deleted file mode 100644 index b5694bd..0000000 --- a/assets/icons/medal.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/profile.svg b/assets/icons/profile.svg deleted file mode 100644 index 50a32c7..0000000 --- a/assets/icons/profile.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/profile_active.svg b/assets/icons/profile_active.svg deleted file mode 100644 index 502193f..0000000 --- a/assets/icons/profile_active.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/scan-line.svg b/assets/icons/scan-line.svg deleted file mode 100644 index f727fc3..0000000 --- a/assets/icons/scan-line.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/scissors.svg b/assets/icons/scissors.svg deleted file mode 100644 index c4aac8b..0000000 --- a/assets/icons/scissors.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/search.svg b/assets/icons/search.svg deleted file mode 100644 index 34618e1..0000000 --- a/assets/icons/search.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/settings.svg b/assets/icons/settings.svg deleted file mode 100644 index e4e525a..0000000 --- a/assets/icons/settings.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/shield.svg b/assets/icons/shield.svg deleted file mode 100644 index 4781eaf..0000000 --- a/assets/icons/shield.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/shovel.svg b/assets/icons/shovel.svg deleted file mode 100644 index 78c8638..0000000 --- a/assets/icons/shovel.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/star.svg b/assets/icons/star.svg deleted file mode 100644 index 43fef57..0000000 --- a/assets/icons/star.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/tasks.svg b/assets/icons/tasks.svg deleted file mode 100644 index a752d48..0000000 --- a/assets/icons/tasks.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/tasks_active.svg b/assets/icons/tasks_active.svg deleted file mode 100644 index b3c4f6f..0000000 --- a/assets/icons/tasks_active.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/trophy.svg b/assets/icons/trophy.svg deleted file mode 100644 index 8f0c4f9..0000000 --- a/assets/icons/trophy.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/wiki.svg b/assets/icons/wiki.svg deleted file mode 100644 index 174e9fd..0000000 --- a/assets/icons/wiki.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/wiki_active.svg b/assets/icons/wiki_active.svg deleted file mode 100644 index 9d582eb..0000000 --- a/assets/icons/wiki_active.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/x.svg b/assets/icons/x.svg deleted file mode 100644 index 969bfad..0000000 --- a/assets/icons/x.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/assets/icons/zap.svg b/assets/icons/zap.svg deleted file mode 100644 index ab520fa..0000000 --- a/assets/icons/zap.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 736519e..eeb66d8 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -5,9 +5,9 @@ "requires": true, "packages": { "node_modules/tdesign-miniprogram": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/tdesign-miniprogram/-/tdesign-miniprogram-1.12.2.tgz", - "integrity": "sha512-ZpOdwonT26RRCK/FWbg9tR2lAJ54Hb4PAdyTWu8URWkbKOmSQhn0JCwCtWWRofKbyWCPsCn5NqljobaGh5VCMg==", + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/tdesign-miniprogram/-/tdesign-miniprogram-1.12.3.tgz", + "integrity": "sha512-F4nMv/ph3yyq9bO4RrJuB9x9VWyKIN6lV1HqFaV4AsR0cpDoBYtGYLPOFejvj0MYDSntSHLMVe1nm0fqsXUaUQ==", "license": "MIT" } } diff --git a/node_modules/tdesign-miniprogram/CHANGELOG.md b/node_modules/tdesign-miniprogram/CHANGELOG.md index 0ee2b63..aba5162 100644 --- a/node_modules/tdesign-miniprogram/CHANGELOG.md +++ b/node_modules/tdesign-miniprogram/CHANGELOG.md @@ -5,6 +5,21 @@ toc: false docClass: timeline --- +## 🌈 1.12.3 `2026-02-03` + +### 🚀 Features + +- `ActionSheet`: 为 `items` 子项的 `icon` 字段新增 `object` 类型,支持透传到 `TIcon` 组件 @anlyyao ([#4251](https://github.com/Tencent/tdesign-miniprogram/pull/4251)) +- `Button`: 新增 `activity-type`,`entrance-path` 和 `need-show-entrance` 属性 @anlyyao ([#4220](https://github.com/Tencent/tdesign-miniprogram/pull/4220)) +- `ChatActionbar`: 支持长按展示 @mimaoxiao ([#4071](https://github.com/Tencent/tdesign-miniprogram/pull/4071)) +- `Icon`: 新增 217 个与人工智能、文档、徽标和文件相关的图标 @uyarn ([#4207](https://github.com/Tencent/tdesign-miniprogram/pull/4207)) +- `Search`: 为 `change` 事件新增 `trigger` 参数,表示触发源 @anlyyao ([#4223](https://github.com/Tencent/tdesign-miniprogram/pull/4223)) + +### 🐞 Bug Fixes + +- `ChatContent`: 修复英文单词在换行时被截断的问题 @mimaoxiao ([#4226](https://github.com/Tencent/tdesign-miniprogram/pull/4226)) +- `Popup`: 修复 `duration` 参数无效的问题 @novlan1 ([#4201](https://github.com/Tencent/tdesign-miniprogram/pull/4201)) + ## 🌈 1.12.2 `2026-01-21` ### 🚀 Features diff --git a/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.d.ts b/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.d.ts index 8fc3991..d3c2b76 100644 --- a/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.d.ts +++ b/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.d.ts @@ -1,22 +1,7 @@ -/// -/// import { SuperComponent } from '../common/src/index'; export default class ActionSheet extends SuperComponent { static show: (options: import("./show").ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance; - behaviors: WechatMiniprogram.Behavior.BehaviorIdentifier<{ - distanceTop: number; - }, { - usingCustomNavbar: { - type: BooleanConstructor; - value: false; - }; - customNavbarHeight: { - type: NumberConstructor; - value: number; - }; - }, { - calculateCustomNavbarDistanceTop(): void; - }, WechatMiniprogram.Component.BehaviorOption>[]; + behaviors: string[]; externalClasses: string[]; properties: { align?: { diff --git a/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.wxml b/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.wxml index 6432ffd..ffd48ed 100644 --- a/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.wxml +++ b/node_modules/tdesign-miniprogram/miniprogram_dist/action-sheet/action-sheet.wxml @@ -1 +1 @@ -{{description}}