@liujitcn/kratos-uni-app-core 0.0.79 → 0.0.80

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.
@@ -1,12 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import { onLoad } from '@dcloudio/uni-app'
3
- import { useSettingStore } from '../../../stores'
3
+ import { useSettingStore, useThemeStore } from '../../../stores'
4
4
  import { ref } from 'vue'
5
5
  import { useI18n } from '../../../locales'
6
+ import { homeTabPage } from '../../../utils/navigation'
6
7
 
7
8
  const settingStore = useSettingStore()
9
+ const themeStore = useThemeStore()
8
10
  const { t } = useI18n()
9
11
  const content = ref('')
12
+ const pageTitle = ref(t('core.navigation.protocol'))
10
13
 
11
14
  const protocolClassMap: Record<string, string> = {
12
15
  h2: 'protocol-title',
@@ -49,6 +52,7 @@ const decorateProtocolContent = (html: string) => {
49
52
  const loadProtocol = async (type?: string) => {
50
53
  const isPrivacy = type === 'privacy'
51
54
  const title = isPrivacy ? t('core.protocol.privacy') : t('core.protocol.service')
55
+ pageTitle.value = title
52
56
  const key = isPrivacy ? 'privacyProtocol' : 'serviceProtocol'
53
57
 
54
58
  try {
@@ -58,7 +62,6 @@ const loadProtocol = async (type?: string) => {
58
62
  throw new Error(t('core.protocol.not_configured', { title }))
59
63
  }
60
64
 
61
- await uni.setNavigationBarTitle({ title })
62
65
  content.value = decorateProtocolContent(protocol)
63
66
  } catch (error) {
64
67
  await uni.showToast({
@@ -74,9 +77,19 @@ const loadProtocol = async (type?: string) => {
74
77
  onLoad((query) => {
75
78
  void loadProtocol(query?.type)
76
79
  })
80
+
81
+ /** 返回来源页,页面栈为空时回到首页。 */
82
+ const onBack = () => {
83
+ uni.navigateBack({ fail: () => uni.reLaunch({ url: homeTabPage }) })
84
+ }
77
85
  </script>
78
86
  <template>
79
- <view class="protocol-page">
87
+ <view class="protocol-page" :class="themeStore.themeClass">
88
+ <view class="k-page-nav">
89
+ <view class="k-page-nav__back" :aria-label="t('common.action.back')" @tap="onBack"></view>
90
+ <view class="k-page-nav__title">{{ pageTitle }}</view>
91
+ <view class="k-page-nav__side" aria-hidden="true"></view>
92
+ </view>
80
93
  <view class="protocol-card">
81
94
  <rich-text class="protocol-content" :nodes="content" />
82
95
  </view>
@@ -84,28 +97,25 @@ onLoad((query) => {
84
97
  </template>
85
98
 
86
99
  <style lang="scss">
87
- page {
88
- background-color: #f5f7f6;
89
- }
90
-
91
100
  .protocol-page {
92
101
  min-height: 100vh;
93
102
  padding: 24rpx;
94
103
  box-sizing: border-box;
104
+ background: var(--kratos-bg-gradient);
95
105
  }
96
106
 
97
107
  .protocol-card {
98
108
  overflow: hidden;
99
109
  padding: 40rpx 32rpx 56rpx;
100
- border: 1rpx solid #edf1ef;
110
+ border: 1rpx solid var(--kratos-color-border);
101
111
  border-radius: 24rpx;
102
- background-color: #fff;
103
- box-shadow: 0 8rpx 24rpx rgba(33, 54, 48, 0.05);
112
+ background-color: var(--kratos-color-surface);
113
+ box-shadow: var(--kratos-glow-soft);
104
114
  }
105
115
 
106
116
  .protocol-content {
107
117
  display: block;
108
- color: #53635d;
118
+ color: var(--kratos-color-text-muted);
109
119
  font-size: 28rpx;
110
120
  line-height: 1.85;
111
121
  word-break: break-word;
@@ -113,7 +123,7 @@ page {
113
123
 
114
124
  .protocol-content .protocol-title {
115
125
  margin: 0 0 28rpx;
116
- color: #1f2d29;
126
+ color: var(--kratos-color-text);
117
127
  font-size: 42rpx;
118
128
  font-weight: 700;
119
129
  line-height: 1.35;
@@ -122,8 +132,8 @@ page {
122
132
  .protocol-content .protocol-section-title {
123
133
  margin: 38rpx 0 14rpx;
124
134
  padding-left: 16rpx;
125
- border-left: 6rpx solid #27ba9b;
126
- color: #263a34;
135
+ border-left: 6rpx solid var(--kratos-color-primary);
136
+ color: var(--kratos-color-text);
127
137
  font-size: 31rpx;
128
138
  font-weight: 600;
129
139
  line-height: 1.45;
@@ -131,7 +141,7 @@ page {
131
141
 
132
142
  .protocol-content .protocol-paragraph {
133
143
  margin: 0 0 22rpx;
134
- color: #53635d;
144
+ color: var(--kratos-color-text-muted);
135
145
  font-size: 28rpx;
136
146
  line-height: 1.85;
137
147
  }
@@ -152,12 +162,12 @@ page {
152
162
  }
153
163
 
154
164
  .protocol-content .protocol-emphasis {
155
- color: #263a34;
165
+ color: var(--kratos-color-text);
156
166
  font-weight: 600;
157
167
  }
158
168
 
159
169
  .protocol-content .protocol-link {
160
- color: #16806d;
170
+ color: var(--kratos-color-primary);
161
171
  text-decoration: underline;
162
172
  }
163
173
 
@@ -171,8 +181,8 @@ page {
171
181
  .protocol-content .protocol-quote {
172
182
  margin: 24rpx 0;
173
183
  padding: 18rpx 22rpx;
174
- border-left: 6rpx solid #b8e8dc;
175
- color: #6c7b75;
176
- background-color: #f3fbf8;
184
+ border-left: 6rpx solid var(--kratos-color-primary-edge);
185
+ color: var(--kratos-color-text-muted);
186
+ background-color: var(--kratos-color-primary-soft);
177
187
  }
178
188
  </style>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="webview-container">
2
+ <view class="webview-container" :class="themeStore.themeClass">
3
3
  <!-- 小程序/APP 使用 web-view 组件 -->
4
4
  <!-- #ifdef MP-WEIXIN || MP-ALIPAY || APP-PLUS -->
5
5
  <web-view :src="url" @message="handleMessage"></web-view>
@@ -34,12 +34,14 @@
34
34
  import { computed, ref } from 'vue'
35
35
  import { onLoad } from '@dcloudio/uni-app'
36
36
  import { useI18n } from '../../../locales'
37
+ import { useThemeStore } from '../../../stores'
37
38
 
38
39
  const url = ref('')
39
40
  const isH5 = ref(false)
40
41
  const isIframeLoaded = ref(false)
41
42
  const isIframeTimedOut = ref(false)
42
43
  const { t } = useI18n()
44
+ const themeStore = useThemeStore()
43
45
 
44
46
  /** 只放行 http(s) 外链,其它协议按非法地址处理。 */
45
47
  const isAllowedUrl = (value: string) => /^https?:\/\//i.test(value)
@@ -117,19 +119,19 @@ const handleMessage = () => {}
117
119
  justify-content: center;
118
120
  padding: 48rpx;
119
121
  text-align: center;
120
- background-color: #fff;
122
+ background: var(--kratos-bg-gradient);
121
123
  }
122
124
 
123
125
  .webview-empty__title {
124
126
  font-size: 32rpx;
125
127
  font-weight: 600;
126
- color: #333;
128
+ color: var(--kratos-color-text);
127
129
  }
128
130
 
129
131
  .webview-empty__desc {
130
132
  margin-top: 16rpx;
131
133
  font-size: 26rpx;
132
- color: #888;
134
+ color: var(--kratos-color-text-muted);
133
135
  }
134
136
 
135
137
  .webview-open-button {
@@ -141,8 +143,12 @@ const handleMessage = () => {}
141
143
  height: 72rpx;
142
144
  line-height: 72rpx;
143
145
  border-radius: 72rpx;
144
- background-color: #27ba9b;
145
- color: #fff;
146
+ background: linear-gradient(
147
+ 135deg,
148
+ var(--kratos-color-primary-deep),
149
+ var(--kratos-color-primary)
150
+ );
151
+ color: var(--kratos-color-on-primary);
146
152
  font-size: 26rpx;
147
153
  }
148
154
  </style>