Skip to content

refactor: UI界面,数据层重构、分包迁移与反馈 v2 对齐#232

Open
159357254680 wants to merge 18 commits into
mainfrom
zhy
Open

refactor: UI界面,数据层重构、分包迁移与反馈 v2 对齐#232
159357254680 wants to merge 18 commits into
mainfrom
zhy

Conversation

@159357254680

Copy link
Copy Markdown
Collaborator

概述

本 PR 对木犀课栈小程序前端做了系统性重构,核心不是单点修 bug,而是把「请求 → 状态 → 页面」三层理顺,同时做分包瘦身和反馈 v2 对齐,为发版做准备。

一、请求层

改了什么:

  • src/common/api/ 整体迁移为 src/common/request/
  • 统一 HTTP 客户端(get/post/upload 等),API 按业务域拆到 request/api/*
  • 补齐拦截器、token 管理、错误类型、全局错误管道

思路:

  • 页面和 store 不应各自处理请求细节,统一走一个客户端
  • 响应解包、401 刷新、toast/登出等行为集中管理,避免散落各处
  • 主站 token 和反馈/飞书等资源 token 分域处理,互不干扰
  • API 一接口一文件,方便维护和按域查阅

关键修复:

  • 401 刷新后响应结构与正常请求一致
  • 上传请求 401 走 uploadFile 重试,不走普通 request
  • 普通 4xx 不再误触发登出

二、数据层

改了什么:

  • 引入 Zustand 作为统一状态管理,页面不再直接调 API
  • 先经历 store 目录整理,中间短暂引入 actions/ 层,最终删除,编排下沉到各页 model/
  • 新增 evaluations 实体仓,课评数据有单一来源
  • publisher 统一管发布者资料缓存

思路:

  • 全局 store 只管「实体数据」(课评、用户、发布者等)
  • 页面 model 管「页面编排」(加载顺序、分页、乐观更新、跨 store 同步)
  • 页面组件只负责渲染,降低页面复杂度,也方便分包后复用

关键修复:

  • 广场评论数与详情页回复保持同步
  • 问答页用户资料改为批量拉取,解决 N+1

三、分包

改了什么:

  • 主包保留 Tab 和高频页(广场、班级、搜索、消息等)
  • 低频页拆入三个分包:profilefeedbackcourse
  • 新增 ROUTES 常量统一管理跳转路径

思路:

  • 按业务域拆,而不是按文件大小硬拆
  • 主包只留冷启动必用页面,控制首屏体积
  • 路径集中管理,避免分包后跳转遗漏

四、组件与页面体验

改了什么:

  • 评论相关组件重组(CommentCardReplySectionReviewDiscussion 等)
  • 搜索框 SearchInput 布局修复
  • 部分组件目录规范化(LineChartStarRatingVirtualList 等)
  • 访客模式、门禁页 GateScreen 支持匿名浏览

思路:

  • 评论是高频交互,组件职责拆清楚:卡片展示 / 回复区 / 讨论树
  • UI 问题优先用布局层面解决,少靠页面各自打补丁
  • 未登录用户能看的内容明确边界,不和鉴权逻辑搅在一起

五、反馈模块

改了什么:

  • 反馈 API 升到 v2
  • 历史列表、FAQ 请求参数与 Apifox 文档对齐
  • 状态字段兼容 v2 和旧版

思路:

  • 反馈是独立服务,走独立 baseUrltokenConfig,不混主站鉴权
  • 参数问题(如缺 limit_size=0)在 request + model 层一次性修正

六、工程化

改了什么:

  • Taro 及相关依赖统一到 4.0.6
  • CI 合并为单一 workflow(lint + build 并行)
  • README 更新,反映新目录和数据层约定
  • 清理 myrepo.bundlegraphify-out、调试 console.log

思路:

  • 先让构建和依赖版本稳定,再谈更严格的类型检查
  • 仓库只留源码,不进大文件和生成缓存

审查重点

  • 分包后页面路径是否全部更新
  • src/common/api/ 引用是否已切到 src/common/request/
  • 反馈 v2 后端环境是否就绪
  • yarn.lock 变更后依赖安装是否正常

159357254680 and others added 18 commits February 6, 2026 14:37
…iene

Move API access into domain stores with load strategies, migrate pages off direct request calls, sync plaza comment counts after replies, and remove myrepo.bundle from version control.

Co-authored-by: Cursor <cursoragent@cursor.com>
Unify @tarojs packages on 4.0.6, upgrade babel-preset-taro from 3.x, match @typescript-eslint plugin/parser versions, and add babel peers required by the Taro 4 preset.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace duplicate workflows with parallel lint and weapp build jobs, add yarn immutable install, concurrency cancellation, manual dispatch, and dist artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
…mains

Move low-frequency pages under src/subpackages/*, shrink the main package to tab and core flows, centralize routes in constants/routes.ts, remove deprecated shareGrades and useGradeStore, and fix feedback history VirtualList for subpackage builds.

Co-authored-by: Cursor <cursoragent@cursor.com>
…om answerId

Unwrap token-refresh retry responses like normal 200s, stop forcing switchTab on app launch when already authenticated, and load questionInfo from notification answerId via getAnswerDetail.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve rules-of-hooks violations, apply prettier/eslint --fix across the codebase, and document subpackage layout and CI in README.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add sassOptions.silenceDeprecations for @import deprecation noise, and stop BottomInput height flicker when long-pressing to reply by removing autoHeight and focusing before inserting the mention.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fix missing hook dependencies in main, ReplySection, FeedCard, Modal, and evaluationHistory; use stable store selectors and getState() for course actions; rename chart to LineChart with useCallback for chart redraw.

Co-authored-by: Cursor <cursoragent@cursor.com>
Allow guest browsing without blocking requests on missing tokens; normalize component folders (VirtualList, StarRating, ShowStar, SearchLabel); fix evaluateInfo comment pagination and timestamps; tune BottomInput @mention behavior; drop broken sass-loader webpack patch and unused OpenAPI artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
- mark tokenConfig (feedback/Feishu) 401s as resource scope so authHandler skips global logout
- non-401/403 4xx now throw ClientError instead of AuthError
- retry uploads via uploadFile after token refresh
- whitelist Taro.request fields to avoid leaking custom config into native API
- read tokens via getStorageSync to silence getStorage:fail noise
- reset custom tab-bar highlight via getCurrentPages after re-login
- gate guard fails closed when status check errors

Co-authored-by: Cursor <cursoragent@cursor.com>
- add copyToClipboard util; reuse in guide Contact/Source and feedback main
- use stable keys in myclass, feedback detail images, and guide Source
- move profile Header navigation into a one-shot useEffect guard
- read SearchInput value from e.detail.value with fallback
- remove dead useMyClasses.refresh

Co-authored-by: Cursor <cursoragent@cursor.com>
…updates

- unify comment/answer UI shapes via DiscussionComment supertype (any → typed)
- move loading/toast UI out of comment store actions into call sites
- sink optimistic reply/answer logic into evaluate & question store actions,
  adding failure rollback (fixes question answer not rolled back on error)
- memoize CommentCard and pass stable feed callbacks to cut re-renders
- replace dead scrollTop state with an explicit forceRender trigger
- drop empty onSearchToggle handlers; make the prop optional

Co-authored-by: Cursor <cursoragent@cursor.com>
Converges reply data into evaluate store, moves classInfo/research/history
orchestration into store actions, and extracts like UX into useLikeAction
to eliminate duplicate state, list flicker, and page-side setState.

Co-authored-by: Cursor <cursoragent@cursor.com>
…in flows.

Split monolithic useXxxStore files into domain folders, bucket detail sessions by entity id, and move bus navigation, feed loading, and publisher enrichment into actions so pages orchestrate through a single entry point.

Co-authored-by: Cursor <cursoragent@cursor.com>
- 建立 evaluations、evaluationHistory 等实体仓,首页/班级/课评详情由 pages 与 subpackages model 驱动
- 删除 actions/ 及旧 store 加载链路,评论/通知/发布逻辑迁入对应 model
- 修复评课评论区楼中楼分页与展示(弱化回复条数、暂关 @ 展示)
- 修复反馈历史布局/时间格式化及详情进度条仅高亮当前阶段
- 调整 VirtualList 触底加载与课评历史网络优先策略

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant