📱 refactor(web): remove legacy isMobile util and migrate to useIsMobile hook
BREAKING CHANGE: helpers/utils.js no longer exports `isMobile()`. Any external code that relied on this function must switch to the `useIsMobile` React hook. Summary ------- 1. Deleted the obsolete `isMobile()` function from helpers/utils.js. 2. Introduced `MOBILE_BREAKPOINT` constant and `matchMedia`-based detection for non-React contexts. 3. Reworked toast positioning logic in utils.js to rely on `matchMedia`. 4. Updated render.js: • Removed isMobile import. • Added MOBILE_BREAKPOINT detection in `truncateText`. 5. Migrated every page/component to the `useIsMobile` hook: • Layout: HeaderBar, PageLayout, SiderBar • Pages: Home, Detail, Playground, User (Add/Edit), Token, Channel, Redemption, Ratio Sync • Components: ChannelsTable, ChannelSelectorModal, ConflictConfirmModal 6. Purged all remaining `isMobile()` calls and legacy imports. 7. Added missing `const isMobile = useIsMobile()` declarations where required. Benefits -------- • Unifies mobile detection with a React-friendly hook. • Eliminates duplicated logic and improves maintainability. • Keeps non-React helpers lightweight by using `matchMedia` directly.
This commit is contained in:
@@ -14,6 +14,22 @@
|
||||
}
|
||||
|
||||
/* ==================== 全局基础样式 ==================== */
|
||||
/* 侧边栏宽度相关的 CSS 变量,配合 .sidebar-collapsed 类和媒体查询实现响应式布局 */
|
||||
:root {
|
||||
--sidebar-width: 180px;
|
||||
/* 展开时宽度 */
|
||||
--sidebar-width-collapsed: 60px; /* 折叠后宽度,显示图标栏 */
|
||||
/* 折叠后宽度 */
|
||||
--sidebar-current-width: var(--sidebar-width);
|
||||
}
|
||||
|
||||
/* 当 body 上存在 .sidebar-collapsed 类时,使用折叠宽度 */
|
||||
body.sidebar-collapsed {
|
||||
--sidebar-current-width: var(--sidebar-width-collapsed);
|
||||
}
|
||||
|
||||
/* 移除了在移动端强制设为 0 的限制,改由 React 控制是否渲染侧边栏以实现显示/隐藏 */
|
||||
|
||||
body {
|
||||
font-family: Lato, 'Helvetica Neue', Arial, Helvetica, 'Microsoft YaHei', sans-serif;
|
||||
color: var(--semi-color-text-0);
|
||||
|
||||
Reference in New Issue
Block a user