@liujitcn/kratos-taro-app-system 0.0.84 → 0.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.84",
10
+ "version": "0.0.85",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist",
@@ -39,8 +39,8 @@
39
39
  "@tarojs/components": "4.2.1",
40
40
  "@tarojs/taro": "4.2.1",
41
41
  "react": "18.3.1",
42
- "@liujitcn/kratos-taro-app-core": "^0.0.84",
43
- "@liujitcn/kratos-taro-app-ui": "^0.0.84"
42
+ "@liujitcn/kratos-taro-app-core": "^0.0.85",
43
+ "@liujitcn/kratos-taro-app-ui": "^0.0.85"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "pnpm run build:entries && pnpm pack --pack-destination ../../../dist/npm",
@@ -11,24 +11,13 @@ page {
11
11
  }
12
12
 
13
13
  .my-content {
14
- padding: calc(env(safe-area-inset-top) + 24px) 32px calc(40px + env(safe-area-inset-bottom));
15
- }
16
-
17
- .my-viewport--weapp .my-content {
18
- /* k-top 在小程序端自带 44PX 状态栏高度的导航带,页面不再额外让出顶部空间 */
19
- padding-top: 0;
14
+ padding: 0 20px calc(40px + env(safe-area-inset-bottom));
20
15
  }
21
16
 
22
17
  .my-stack {
23
18
  display: flex;
24
19
  flex-direction: column;
25
20
  gap: 24px;
26
- margin-top: 16px;
27
- }
28
-
29
- .my-gear {
30
- width: 34px;
31
- height: 34px;
32
21
  }
33
22
 
34
23
  /* k-pfx 仅定义 flex 排布,卡片内边距交由页面控制 */
@@ -1,9 +1,9 @@
1
- import type { CSSProperties, ReactNode } from 'react'
1
+ import type { ReactNode } from 'react'
2
2
  import { Image, ScrollView, View } from '@tarojs/components'
3
3
  import defaultAvatar from '@liujitcn/kratos-taro-app-core/static/images/avatar.png'
4
4
  import {
5
5
  formatSrc,
6
- getMpCapsuleRightGap,
6
+ KratosNavBar,
7
7
  navigateAppRoute,
8
8
  navigateToLogin,
9
9
  useI18n,
@@ -28,15 +28,6 @@ export default function KratosMyPage({ children }: KratosMyPageProps) {
28
28
  const ensureAuthenticated = useUserStore((state) => state.ensureAuthenticated)
29
29
  const aiEnabled = useSettingStore((state) => state.aiEnabled)
30
30
  const avatarText = (profile?.nick_name || 'U').slice(0, 1)
31
- /** MP-WEIXIN 原生胶囊按钮右侧避让宽度,写入 --mp-capsule-gap 供 .k-top 预留空间。 */
32
- const capsuleGap = getMpCapsuleRightGap()
33
- const topNavStyle = { '--mp-capsule-gap': `${capsuleGap}px` } as CSSProperties
34
- /** 设计稿齿轮线稿,随主题取色的 data URI,替代 CSS 手绘图标。 */
35
- const gearIcon = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
36
- `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="${
37
- themeStore.theme === 'light' ? '#102232' : '#e9f4f6'
38
- }" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.6 1.6 0 0 0 .3 1.8 2 2 0 1 1-2.8 2.8 1.6 1.6 0 0 0-2.7 1.1 2 2 0 1 1-4 0 1.6 1.6 0 0 0-2.6-1.1 2 2 0 1 1-2.8-2.8A1.6 1.6 0 0 0 3 13.9a2 2 0 1 1 0-4 1.6 1.6 0 0 0 1.5-2.7 2 2 0 1 1 2.8-2.8A1.6 1.6 0 0 0 10 4.6a2 2 0 1 1 4 0 1.6 1.6 0 0 0 2.7.6 2 2 0 1 1 2.8 2.8 1.6 1.6 0 0 0-.1 2.6a2.2 2.2 0 1 1 0 4.4Z"/></svg>`,
39
- )}`
40
31
  /** 个人卡账号行:登录展示账号,未登录提示去登录。 */
41
32
  const accountText =
42
33
  isLoggedIn && profile ? profile.user_name || profile.nick_name || '' : t('system.profile.login_prompt')
@@ -54,17 +45,16 @@ export default function KratosMyPage({ children }: KratosMyPageProps) {
54
45
  <ScrollView
55
46
  enableBackToTop
56
47
  scrollY
57
- className={`my-viewport${process.env.TARO_ENV === 'weapp' ? ' my-viewport--weapp' : ''} ${
48
+ className={`my-viewport ${
58
49
  themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'
59
50
  }`}
60
51
  >
61
52
  <View className='my-content'>
62
- <View className='k-top' style={topNavStyle}>
63
- <View className='k-top__title'>{t('core.navigation.my')}</View>
64
- <View className='k-ic' onClick={() => openAuthenticatedPage('app/settings')}>
65
- <Image className='my-gear' src={gearIcon} mode='aspectFit' />
66
- </View>
67
- </View>
53
+ <KratosNavBar
54
+ title={t('core.navigation.my')}
55
+ variant='tab'
56
+ action={{ icon: 'settings', label: t('system.settings.title'), onClick: () => openAuthenticatedPage('app/settings') }}
57
+ />
68
58
 
69
59
  <View className='my-stack'>
70
60
  <View
@@ -1,16 +1,15 @@
1
1
  import { ScrollView, Text, View } from '@tarojs/components'
2
- import Taro, { getCurrentPages, useLoad } from '@tarojs/taro'
2
+ import Taro, { useLoad } from '@tarojs/taro'
3
3
  import { useEffect, useMemo, useRef, useState } from 'react'
4
4
  import {
5
5
  formatSrc,
6
6
  getCurrentLocale,
7
- navigateAppRoute,
7
+ KratosNavBar,
8
8
  t,
9
9
  uploadFile,
10
10
  useI18n,
11
11
  useThemeStore,
12
12
  } from '@liujitcn/kratos-taro-app-core'
13
- import { UniIcon } from '@liujitcn/kratos-taro-app-ui'
14
13
  import { isAuthExpiredError } from '@liujitcn/kratos-taro-app-core/utils/http'
15
14
  import { defAiMessageService, StreamAiMessageByChunkedRequest } from '../../../api/base/v1/ai_message'
16
15
  import { defAiSessionService } from '../../../api/base/v1/ai_session'
@@ -67,12 +66,10 @@ const PENDING_MESSAGE_ID = 'pending'
67
66
  const MAX_ATTACHMENT_COUNT = 6
68
67
  const STARTER_PROMPT_PAGE_SIZE = 4
69
68
 
70
- /** AI 助手页面。 */
69
+ /** AiPage 展示 AI 助手对话与会话历史。 */
71
70
  export default function AiPage() {
72
71
  const { locale } = useI18n()
73
72
  const themeStore = useThemeStore()
74
- /** 导航图标随主题取色,UniIcon 的 color 属性不接受 CSS 变量。 */
75
- const navIconColor = themeStore.theme === 'light' ? '#102232' : '#e9f4f6'
76
73
  const windowInfo = Taro.getWindowInfo() as ReturnType<typeof Taro.getWindowInfo> & {
77
74
  safeAreaInsets?: { top?: number; bottom?: number }
78
75
  }
@@ -658,14 +655,6 @@ export default function AiPage() {
658
655
  }
659
656
  }
660
657
 
661
- const navigateBack = () => {
662
- if (getCurrentPages().length > 1) {
663
- void Taro.navigateBack()
664
- return
665
- }
666
- navigateAppRoute('app/home')
667
- }
668
-
669
658
  const handleSend = async () => {
670
659
  if (isSubmitDisabled) return
671
660
  const text = inputText.trim() || t('system.ai.attachment_answer')
@@ -724,16 +713,11 @@ export default function AiPage() {
724
713
  <View
725
714
  className={`ai-page ${themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'}`}
726
715
  >
727
- <View className={`ai-navbar k-page-nav ${process.env.TARO_ENV === 'weapp' ? 'k-page-nav--weapp' : ''}`}>
728
- <View className='k-page-nav__back' aria-label={t('common.action.back')} onClick={navigateBack} />
729
- <View className='k-page-nav__title'>{t('system.ai.chat_title')}</View>
730
- <View
731
- className='k-page-nav__side k-ic'
732
- aria-label={t('system.ai.history')}
733
- onClick={() => setShowSessionDrawer((open) => !open)}
734
- >
735
- <UniIcon type='bars' size={22} color={navIconColor} />
736
- </View>
716
+ <View className='ai-navbar'>
717
+ <KratosNavBar
718
+ title={t('system.ai.chat_title')}
719
+ action={{ icon: 'history', label: t('system.ai.history'), onClick: () => setShowSessionDrawer((open) => !open) }}
720
+ />
737
721
  </View>
738
722
  <ScrollView
739
723
  className='ai-body'
@@ -1,7 +1,7 @@
1
- import Taro, { useLoad } from '@tarojs/taro'
1
+ import { useLoad } from '@tarojs/taro'
2
2
  import { Button, RichText, Text, View } from '@tarojs/components'
3
3
  import { useState } from 'react'
4
- import { homeTabPage, navigateAppView, t, useThemeStore } from '@liujitcn/kratos-taro-app-core'
4
+ import { KratosNavBar, navigateAppView, t, useThemeStore } from '@liujitcn/kratos-taro-app-core'
5
5
  import { UniIcon } from '@liujitcn/kratos-taro-app-ui'
6
6
  import { defNotificationService } from '../../../api/base/v1/notification'
7
7
  import type { Notification } from '../../../rpc/base/v1/notification'
@@ -9,7 +9,7 @@ import { MessageActionType, MessageContentFormat } from '../../../rpc/base/v1/no
9
9
  import { resolveMessageCategoryIcon } from './icons'
10
10
  import './message.scss'
11
11
 
12
- /** Taro 站内信详情页面。 */
12
+ /** MessageDetailPage 展示站内信详情与通知操作。 */
13
13
  export default function MessageDetailPage() {
14
14
  const themeStore = useThemeStore()
15
15
  const [detail, setDetail] = useState<Notification>()
@@ -55,20 +55,11 @@ export default function MessageDetailPage() {
55
55
  navigateAppView(detail.action_target, params)
56
56
  }
57
57
 
58
- /** 返回消息列表,页面栈为空时回到首页。 */
59
- function onBack() {
60
- void Taro.navigateBack({ fail: () => void Taro.reLaunch({ url: homeTabPage }) })
61
- }
62
-
63
58
  return (
64
59
  <View
65
60
  className={`detail-page ${themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'}`}
66
61
  >
67
- <View className={`k-page-nav ${process.env.TARO_ENV === 'weapp' ? 'k-page-nav--weapp' : ''}`}>
68
- <View className='k-page-nav__back' aria-label={t('common.action.back')} onClick={onBack} />
69
- <View className='k-page-nav__title'>{t('system.notification.title')}</View>
70
- <View className='k-page-nav__side' aria-hidden />
71
- </View>
62
+ <KratosNavBar title={t('system.notification.title')} />
72
63
  {detail ? (
73
64
  <>
74
65
  <Text className='detail-title'>{detail.title}</Text>
@@ -1,9 +1,8 @@
1
- import type { CSSProperties } from 'react'
2
1
  import { useDidShow } from '@tarojs/taro'
3
2
  import { Button, Text, View } from '@tarojs/components'
4
3
  import { useRef, useState } from 'react'
5
4
  import {
6
- getMpCapsuleRightGap,
5
+ KratosNavBar,
7
6
  KratosEmpty,
8
7
  navigateAppView,
9
8
  t,
@@ -17,12 +16,9 @@ import { refreshNotificationSummary } from '../../../notification'
17
16
  import { resolveMessageCategoryIcon } from './icons'
18
17
  import './message.scss'
19
18
 
20
- /** Taro 站内信收件箱页面。 */
19
+ /** MessageInboxPage 展示站内信收件箱,并提供全部已读操作。 */
21
20
  export default function MessageInboxPage() {
22
21
  const themeStore = useThemeStore()
23
- /** MP-WEIXIN 原生胶囊按钮右侧避让宽度,写入 --mp-capsule-gap 供 .k-top 预留空间。 */
24
- const capsuleGap = getMpCapsuleRightGap()
25
- const topNavStyle = { '--mp-capsule-gap': `${capsuleGap}px` } as CSSProperties
26
22
  const [items, setItems] = useState<Notification[]>([])
27
23
  const [cursorId, setCursorId] = useState(0)
28
24
  const [loading, setLoading] = useState(false)
@@ -176,20 +172,13 @@ export default function MessageInboxPage() {
176
172
  themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'
177
173
  }`}
178
174
  >
179
- <View className='k-top message-header' style={topNavStyle}>
180
- <View className='message-header__title'>
181
- <Text className='message-header__text'>{t('system.notification.title')}</Text>
182
- {unreadTotal > 0 && <View className='message-unread-dot' aria-hidden='true' />}
183
- </View>
184
- {selectedView !== NotificationView.NOTIFICATION_VIEW_ARCHIVED && unreadTotal > 0 && (
185
- <View
186
- className='k-ch k-ch--pri'
187
- onClick={() => void markAllRead().catch(() => undefined)}
188
- >
189
- {t('system.notification.mark_all_read')}
190
- </View>
191
- )}
192
- </View>
175
+ <KratosNavBar
176
+ title={t('system.notification.title')}
177
+ variant='tab'
178
+ action={selectedView !== NotificationView.NOTIFICATION_VIEW_ARCHIVED && unreadTotal > 0
179
+ ? { display: 'text', label: t('system.notification.mark_all_read'), onClick: () => void markAllRead().catch(() => undefined) }
180
+ : undefined}
181
+ />
193
182
  <View className='k-chips'>
194
183
  <View
195
184
  className={`k-ch${categoryId === undefined ? ' k-ch--pri' : ''}`}
@@ -1,49 +1,11 @@
1
1
  .message-page {
2
2
  box-sizing: border-box;
3
3
  min-height: 100vh;
4
- padding: 16px 24px calc(200px + env(safe-area-inset-bottom));
4
+ padding: 0 20px calc(200px + env(safe-area-inset-bottom));
5
5
  background: var(--kratos-bg-gradient);
6
6
  color: var(--kratos-color-text);
7
7
  }
8
8
 
9
- .message-header {
10
- /* 标题绝对居中后头部不再依赖流内内容撑高,保证标题行与筛选行留出间距 */
11
- min-height: 76px;
12
- padding: 20px 4px 24px;
13
- }
14
-
15
- /* 标题排版与 k-page-nav__title/k-top__title 同规格,绝对居中后文字与红点同行排布 */
16
- .message-header__title {
17
- position: absolute;
18
- left: 50%;
19
- display: flex;
20
- align-items: center;
21
- min-width: 0;
22
- max-width: calc(100% - 190px);
23
- overflow: hidden;
24
- font-size: 16PX;
25
- font-weight: 700;
26
- color: var(--kratos-color-text);
27
- transform: translateX(-50%);
28
- white-space: nowrap;
29
- }
30
-
31
- .message-header__text {
32
- min-width: 0;
33
- overflow: hidden;
34
- text-overflow: ellipsis;
35
- }
36
-
37
- .message-unread-dot {
38
- flex-shrink: 0;
39
- width: 12px;
40
- height: 12px;
41
- margin-left: 12px;
42
- border-radius: 50%;
43
- background: var(--kratos-color-danger);
44
- box-shadow: 0 0 16px var(--kratos-color-danger);
45
- }
46
-
47
9
  .message-tabs {
48
10
  display: flex;
49
11
  margin-top: 4px;
@@ -79,7 +41,7 @@
79
41
  .detail-page {
80
42
  box-sizing: border-box;
81
43
  min-height: 100vh;
82
- padding: 24px 30px calc(96px + env(safe-area-inset-bottom));
44
+ padding: 0 30px calc(96px + env(safe-area-inset-bottom));
83
45
  background: var(--kratos-bg-gradient);
84
46
  color: var(--kratos-color-text);
85
47
  }
@@ -4,7 +4,7 @@
4
4
  color: var(--kratos-color-text);
5
5
  }
6
6
 
7
- /* k-page-nav 自带安全区顶部内边距,这里只补水平与底部 */
7
+ /* 导航组件统一处理顶部空间,页面只维护内容的水平与底部留白。 */
8
8
  .profile-content {
9
9
  padding: 0 32px calc(40px + env(safe-area-inset-bottom));
10
10
  }
@@ -18,6 +18,7 @@ import type { BaseDictForm_DictItem } from '@liujitcn/kratos-taro-app-core/rpc/s
18
18
  import type { UserProfileForm } from '@liujitcn/kratos-taro-app-core/rpc/system/app/v1/auth'
19
19
  import { BaseUserIDType } from '@liujitcn/kratos-taro-app-core/rpc/system/common/v1/common'
20
20
  import {
21
+ KratosNavBar,
21
22
  formatSrc,
22
23
  navigateToLogin,
23
24
  uploadFile,
@@ -31,7 +32,7 @@ const IMG_MAX_SIZE = 1024 * 1024
31
32
  const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
32
33
  const ID_CODE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9-]{0,63}$/
33
34
 
34
- /** 用户个人资料编辑页。 */
35
+ /** ProfilePage 展示并编辑用户个人资料。 */
35
36
  export default function ProfilePage() {
36
37
  const { t } = useI18n()
37
38
  const themeStore = useThemeStore()
@@ -153,15 +154,7 @@ export default function ProfilePage() {
153
154
  className={`profile-viewport ${themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'}`}
154
155
  >
155
156
  <View className='profile-content'>
156
- <View className={`k-page-nav ${process.env.TARO_ENV === 'weapp' ? 'k-page-nav--weapp' : ''}`}>
157
- <View
158
- className='k-page-nav__back'
159
- aria-label={t('common.action.back')}
160
- onClick={() => void Taro.navigateBack()}
161
- />
162
- <View className='k-page-nav__title'>{t('system.profile.title')}</View>
163
- <View className='k-page-nav__side' aria-hidden />
164
- </View>
157
+ <KratosNavBar title={t('system.profile.title')} />
165
158
 
166
159
  <View className='k-glass k-glass--lit k-pfx profile-id' onClick={() => void onAvatarChange()}>
167
160
  <View className='profile-id__main'>
@@ -9,14 +9,14 @@ import {
9
9
  useThemeStore,
10
10
  useUserStore,
11
11
  type ThemeMode,
12
- homeTabPage,
12
+ KratosNavBar,
13
13
  } from '@liujitcn/kratos-taro-app-core'
14
14
  import { defMfaService } from '@liujitcn/kratos-taro-app-core/api/base/v1/mfa'
15
15
  import { isAuthExpiredError } from '@liujitcn/kratos-taro-app-core/utils/http'
16
16
  import PasswordVerifyDialog from './components/PasswordVerifyDialog'
17
17
  import './settings.scss'
18
18
 
19
- /** 应用设置页。 */
19
+ /** SettingsPage 展示应用设置与账号安全操作。 */
20
20
  export default function SettingsPage() {
21
21
  const { locale, setLocale, t } = useI18n()
22
22
  const themeStore = useThemeStore()
@@ -140,13 +140,7 @@ export default function SettingsPage() {
140
140
  void loadMfaStatus()
141
141
  })
142
142
 
143
- /** 返回个人中心,页面栈不可返回时回到首页。 */
144
- const onBack = () => {
145
- void Taro.navigateBack({
146
- fail: () => void Taro.reLaunch({ url: homeTabPage }),
147
- })
148
- }
149
-
143
+ /** onLogout 确认后退出当前账号并返回来源页面。 */
150
144
  const onLogout = async () => {
151
145
  if (logoutLoading) return
152
146
  const result = await Taro.showModal({
@@ -175,12 +169,7 @@ export default function SettingsPage() {
175
169
  themeStore.theme === 'light' ? 'theme-light' : 'theme-dark'
176
170
  }`}
177
171
  >
178
- <View className={`k-page-nav ${process.env.TARO_ENV === 'weapp' ? 'k-page-nav--weapp' : ''}`}>
179
- <View className='k-page-nav__back' aria-label={t('common.action.back')} onClick={onBack}>
180
- </View>
181
- <View className='k-page-nav__title'>{t('system.settings.title')}</View>
182
- <View className='k-page-nav__side' aria-hidden />
183
- </View>
172
+ <KratosNavBar title={t('system.settings.title')} />
184
173
 
185
174
  <View className='settings-content'>
186
175
  <View className='k-set-cat'>{t('system.settings.section_appearance')}</View>