uview-plus 3.8.86 → 3.8.108
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/changelog.md +173 -3
- package/components/u-action-sheet/u-action-sheet.vue +21 -2
- package/components/u-barcode/u-barcode.vue +0 -2
- package/components/u-button/u-button.vue +2 -5
- package/components/u-canvas/u-canvas.vue +430 -77
- package/components/u-cell/u-cell.vue +8 -0
- package/components/u-datetime-picker/u-datetime-picker.vue +53 -4
- package/components/u-dragsort/u-dragsort.vue +55 -31
- package/components/u-icon/u-icon.vue +12 -3
- package/components/u-icon/util.js +81 -10
- package/components/u-index-item/u-index-item.vue +1 -1
- package/components/u-index-list/u-index-list.vue +1 -1
- package/components/u-novel-reader/content-normalizer.js +80 -0
- package/components/u-novel-reader/layout-engine.js +225 -0
- package/components/u-novel-reader/measure-adapter.js +69 -0
- package/components/u-novel-reader/novelReader.js +35 -0
- package/components/u-novel-reader/persistence.js +144 -0
- package/components/u-novel-reader/props.js +100 -0
- package/components/u-novel-reader/reader-catalog.vue +234 -0
- package/components/u-novel-reader/reader-content.vue +226 -0
- package/components/u-novel-reader/reader-core.js +151 -0
- package/components/u-novel-reader/reader-settings.vue +325 -0
- package/components/u-novel-reader/reader-toolbar.vue +313 -0
- package/components/u-novel-reader/theme-vars.scss +49 -0
- package/components/u-novel-reader/u-novel-reader.vue +836 -0
- package/components/u-poster/u-poster.vue +272 -222
- package/components/u-qrcode/qrcode.js +56 -49
- package/components/u-qrcode/u-qrcode.vue +159 -88
- package/components/u-scroll-list/scrollWxs.wxs +1 -1
- package/components/u-slider/u-slider.vue +1 -1
- package/components/u-swipe-action-item/index.wxs +43 -25
- package/components/u-swipe-action-item/nvue.js +9 -0
- package/components/u-swipe-action-item/other.js +32 -21
- package/components/u-swipe-action-item/props.js +5 -0
- package/components/u-swipe-action-item/swipeActionItem.js +1 -0
- package/components/u-swipe-action-item/u-swipe-action-item.vue +28 -4
- package/components/u-switch/u-switch.vue +1 -1
- package/components/u-tabbar/u-tabbar.vue +2 -1
- package/components/u-tabbar-item/u-tabbar-item.vue +64 -21
- package/components/u-tabs/u-tabs.vue +11 -8
- package/components/u-tabs-pro/u-tabs-pro.vue +212 -0
- package/components/u-text/text.js +1 -1
- package/components/u-text/u-text.vue +18 -6
- package/components/u-upload/u-upload.vue +1 -1
- package/components/u-waterfall/u-waterfall.vue +118 -65
- package/libs/config/config.js +1 -1
- package/libs/config/props.js +1 -0
- package/libs/function/index.js +66 -0
- package/libs/mixin/mixin.js +4 -50
- package/libs/root/index.js +78 -5
- package/libs/root/page.js +7 -7
- package/libs/root/root.js +73 -3
- package/libs/util/app-nvue-webview-canvas.js +486 -0
- package/libs/util/gcanvas/bridge/bridge-weex.js +0 -2
- package/libs/util/gcanvas/index.js +3 -3
- package/package.json +2 -2
- package/types/comps/swipeActionItem.d.ts +13 -0
- package/types/comps/tabs.d.ts +2 -1
- package/types/comps/text.d.ts +1 -1
- package/types/func.d.ts +23 -0
- package/types/index.d.ts +1 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="up-novel-reader__settings" :style="settingsStyle">
|
|
3
|
+
<view class="up-novel-reader__settings-header">
|
|
4
|
+
<text class="up-novel-reader__settings-title">阅读设置</text>
|
|
5
|
+
<view
|
|
6
|
+
class="up-novel-reader__settings-close"
|
|
7
|
+
@tap="close"
|
|
8
|
+
>
|
|
9
|
+
<u-icon name="close" size="18" :color="textColor"></u-icon>
|
|
10
|
+
</view>
|
|
11
|
+
</view>
|
|
12
|
+
<slot v-if="$slots.default"></slot>
|
|
13
|
+
<scroll-view v-else class="up-novel-reader__settings-scroll" scroll-y>
|
|
14
|
+
<view class="up-novel-reader__settings-section">
|
|
15
|
+
<text class="up-novel-reader__settings-label">主题</text>
|
|
16
|
+
<view class="up-novel-reader__theme-list">
|
|
17
|
+
<view
|
|
18
|
+
v-for="theme in themes"
|
|
19
|
+
:key="theme.value"
|
|
20
|
+
class="up-novel-reader__theme-option"
|
|
21
|
+
:class="{ 'is-active': draftSettings.theme === theme.value }"
|
|
22
|
+
:style="themeOptionStyle(theme)"
|
|
23
|
+
@tap="setTheme(theme.value)"
|
|
24
|
+
>
|
|
25
|
+
<text>{{ theme.label }}</text>
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
<view class="up-novel-reader__settings-section">
|
|
30
|
+
<view class="up-novel-reader__settings-row">
|
|
31
|
+
<text class="up-novel-reader__settings-label">字号</text>
|
|
32
|
+
<text class="up-novel-reader__settings-value">{{ draftSettings.fontSize }}px</text>
|
|
33
|
+
</view>
|
|
34
|
+
<u-slider
|
|
35
|
+
v-model="draftSettings.fontSize"
|
|
36
|
+
min="12"
|
|
37
|
+
max="32"
|
|
38
|
+
step="1"
|
|
39
|
+
active-color="#2979ff"
|
|
40
|
+
@change="emitSettings"
|
|
41
|
+
></u-slider>
|
|
42
|
+
</view>
|
|
43
|
+
<view class="up-novel-reader__settings-section">
|
|
44
|
+
<view class="up-novel-reader__settings-row">
|
|
45
|
+
<text class="up-novel-reader__settings-label">行高</text>
|
|
46
|
+
<text class="up-novel-reader__settings-value">{{ Number(draftSettings.lineHeight).toFixed(1) }}</text>
|
|
47
|
+
</view>
|
|
48
|
+
<u-slider
|
|
49
|
+
v-model="draftSettings.lineHeight"
|
|
50
|
+
min="1.2"
|
|
51
|
+
max="2.6"
|
|
52
|
+
step="0.1"
|
|
53
|
+
active-color="#2979ff"
|
|
54
|
+
@change="emitSettings"
|
|
55
|
+
></u-slider>
|
|
56
|
+
</view>
|
|
57
|
+
<view class="up-novel-reader__settings-section">
|
|
58
|
+
<view class="up-novel-reader__settings-row">
|
|
59
|
+
<text class="up-novel-reader__settings-label">段距</text>
|
|
60
|
+
<text class="up-novel-reader__settings-value">{{ draftSettings.paragraphSpacing }}px</text>
|
|
61
|
+
</view>
|
|
62
|
+
<u-slider
|
|
63
|
+
v-model="draftSettings.paragraphSpacing"
|
|
64
|
+
min="0"
|
|
65
|
+
max="36"
|
|
66
|
+
step="2"
|
|
67
|
+
active-color="#2979ff"
|
|
68
|
+
@change="emitSettings"
|
|
69
|
+
></u-slider>
|
|
70
|
+
</view>
|
|
71
|
+
<view class="up-novel-reader__settings-section">
|
|
72
|
+
<view class="up-novel-reader__settings-row">
|
|
73
|
+
<text class="up-novel-reader__settings-label">正文宽度</text>
|
|
74
|
+
<text class="up-novel-reader__settings-value">{{ contentWidthPercent }}%</text>
|
|
75
|
+
</view>
|
|
76
|
+
<u-slider
|
|
77
|
+
v-model="contentWidthValue"
|
|
78
|
+
min="60"
|
|
79
|
+
max="100"
|
|
80
|
+
step="2"
|
|
81
|
+
active-color="#2979ff"
|
|
82
|
+
@change="emitContentWidth"
|
|
83
|
+
></u-slider>
|
|
84
|
+
</view>
|
|
85
|
+
<view class="up-novel-reader__settings-section up-novel-reader__settings-options">
|
|
86
|
+
<view class="up-novel-reader__settings-option" @tap="toggleWeight">
|
|
87
|
+
<view>
|
|
88
|
+
<text class="up-novel-reader__settings-label">粗体正文</text>
|
|
89
|
+
<text class="up-novel-reader__settings-hint">增强低亮度主题下的可读性</text>
|
|
90
|
+
</view>
|
|
91
|
+
<u-icon
|
|
92
|
+
:name="draftSettings.fontWeight >= 600 ? 'checkmark-circle-fill' : 'circle'"
|
|
93
|
+
size="22"
|
|
94
|
+
:color="draftSettings.fontWeight >= 600 ? '#2979ff' : mutedColor"
|
|
95
|
+
></u-icon>
|
|
96
|
+
</view>
|
|
97
|
+
<view class="up-novel-reader__settings-option" @tap="toggleAnimation">
|
|
98
|
+
<view>
|
|
99
|
+
<text class="up-novel-reader__settings-label">翻页动画</text>
|
|
100
|
+
<text class="up-novel-reader__settings-hint">关闭后立即切换页面</text>
|
|
101
|
+
</view>
|
|
102
|
+
<u-icon
|
|
103
|
+
:name="draftSettings.animation ? 'checkmark-circle-fill' : 'circle'"
|
|
104
|
+
size="22"
|
|
105
|
+
:color="draftSettings.animation ? '#2979ff' : mutedColor"
|
|
106
|
+
></u-icon>
|
|
107
|
+
</view>
|
|
108
|
+
</view>
|
|
109
|
+
<view class="up-novel-reader__settings-footer">
|
|
110
|
+
<view class="up-novel-reader__settings-done" @tap="close">完成</view>
|
|
111
|
+
</view>
|
|
112
|
+
</scroll-view>
|
|
113
|
+
</view>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script>
|
|
117
|
+
import { mergeReaderSettings } from './reader-core'
|
|
118
|
+
|
|
119
|
+
export default {
|
|
120
|
+
name: 'NovelReaderSettings',
|
|
121
|
+
props: {
|
|
122
|
+
settings: {
|
|
123
|
+
type: Object,
|
|
124
|
+
default: () => ({})
|
|
125
|
+
},
|
|
126
|
+
themeTokens: {
|
|
127
|
+
type: Object,
|
|
128
|
+
default: () => ({})
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
emits: ['update-settings', 'close'],
|
|
132
|
+
data() {
|
|
133
|
+
return {
|
|
134
|
+
draftSettings: mergeReaderSettings(this.settings),
|
|
135
|
+
themes: [
|
|
136
|
+
{ value: 'day', label: '日间', background: '#f7f8fa', text: '#303133' },
|
|
137
|
+
{ value: 'paper', label: '护眼', background: '#f3ead7', text: '#51483d' },
|
|
138
|
+
{ value: 'green', label: '豆沙', background: '#e7f1e4', text: '#3f5140' },
|
|
139
|
+
{ value: 'night', label: '夜间', background: '#202124', text: '#d6d7da' },
|
|
140
|
+
{ value: 'dark', label: '深色', background: '#111214', text: '#e5e7eb' }
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
computed: {
|
|
145
|
+
settingsStyle() {
|
|
146
|
+
return {
|
|
147
|
+
color: this.textColor,
|
|
148
|
+
backgroundColor: this.themeTokens.background || '#ffffff'
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
textColor() {
|
|
152
|
+
return this.themeTokens.text || '#303133'
|
|
153
|
+
},
|
|
154
|
+
mutedColor() {
|
|
155
|
+
return this.themeTokens.muted || '#909399'
|
|
156
|
+
},
|
|
157
|
+
contentWidthValue: {
|
|
158
|
+
get() {
|
|
159
|
+
const value = Number.parseFloat(this.draftSettings.contentWidth)
|
|
160
|
+
return Number.isFinite(value) ? value : 92
|
|
161
|
+
},
|
|
162
|
+
set(value) {
|
|
163
|
+
this.draftSettings.contentWidth = `${value}%`
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
contentWidthPercent() {
|
|
167
|
+
return Math.round(this.contentWidthValue)
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
watch: {
|
|
171
|
+
settings: {
|
|
172
|
+
handler(value) {
|
|
173
|
+
this.draftSettings = mergeReaderSettings(value)
|
|
174
|
+
},
|
|
175
|
+
deep: true
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
methods: {
|
|
179
|
+
themeOptionStyle(theme) {
|
|
180
|
+
return {
|
|
181
|
+
backgroundColor: theme.background,
|
|
182
|
+
color: theme.text
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
setTheme(theme) {
|
|
186
|
+
this.draftSettings.theme = theme
|
|
187
|
+
this.emitSettings()
|
|
188
|
+
},
|
|
189
|
+
toggleWeight() {
|
|
190
|
+
this.draftSettings.fontWeight = this.draftSettings.fontWeight >= 600 ? 400 : 600
|
|
191
|
+
this.emitSettings()
|
|
192
|
+
},
|
|
193
|
+
toggleAnimation() {
|
|
194
|
+
this.draftSettings.animation = !this.draftSettings.animation
|
|
195
|
+
this.emitSettings()
|
|
196
|
+
},
|
|
197
|
+
emitContentWidth() {
|
|
198
|
+
this.emitSettings()
|
|
199
|
+
},
|
|
200
|
+
emitSettings() {
|
|
201
|
+
this.draftSettings = mergeReaderSettings(this.draftSettings)
|
|
202
|
+
this.$emit('update-settings', { ...this.draftSettings })
|
|
203
|
+
},
|
|
204
|
+
close() {
|
|
205
|
+
this.$emit('close')
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<style lang="scss" scoped>
|
|
212
|
+
.up-novel-reader__settings {
|
|
213
|
+
width: 100%;
|
|
214
|
+
max-height: 78vh;
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.up-novel-reader__settings-header {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: row;
|
|
221
|
+
align-items: center;
|
|
222
|
+
justify-content: space-between;
|
|
223
|
+
padding: 18px 20px 12px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.up-novel-reader__settings-title {
|
|
227
|
+
font-size: 18px;
|
|
228
|
+
font-weight: 600;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.up-novel-reader__settings-close {
|
|
232
|
+
display: flex;
|
|
233
|
+
flex-direction: row;
|
|
234
|
+
align-items: center;
|
|
235
|
+
justify-content: center;
|
|
236
|
+
width: 34px;
|
|
237
|
+
height: 34px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.up-novel-reader__settings-scroll {
|
|
241
|
+
max-height: calc(78vh - 64px);
|
|
242
|
+
padding: 0 20px 24px;
|
|
243
|
+
box-sizing: border-box;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.up-novel-reader__settings-section {
|
|
247
|
+
padding: 14px 0;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.up-novel-reader__settings-row,
|
|
251
|
+
.up-novel-reader__settings-option {
|
|
252
|
+
display: flex;
|
|
253
|
+
flex-direction: row;
|
|
254
|
+
align-items: center;
|
|
255
|
+
justify-content: space-between;
|
|
256
|
+
gap: 12px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.up-novel-reader__settings-row {
|
|
260
|
+
min-height: 34px;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.up-novel-reader__settings-label {
|
|
264
|
+
font-size: 14px;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.up-novel-reader__settings-value {
|
|
268
|
+
color: var(--up-novel-reader-muted, #909399);
|
|
269
|
+
font-size: 13px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.up-novel-reader__settings-hint {
|
|
273
|
+
color: var(--up-novel-reader-muted, #909399);
|
|
274
|
+
font-size: 12px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.up-novel-reader__theme-list {
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-direction: row;
|
|
280
|
+
gap: 8px;
|
|
281
|
+
margin-top: 10px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.up-novel-reader__theme-option {
|
|
285
|
+
display: flex;
|
|
286
|
+
flex-direction: row;
|
|
287
|
+
align-items: center;
|
|
288
|
+
justify-content: center;
|
|
289
|
+
flex: 1;
|
|
290
|
+
height: 42px;
|
|
291
|
+
border: 1px solid transparent;
|
|
292
|
+
border-radius: 8px;
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.up-novel-reader__theme-option.is-active {
|
|
297
|
+
border-color: var(--up-novel-reader-active, #2979ff);
|
|
298
|
+
box-shadow: 0 0 0 2px rgba(41, 121, 255, 0.18);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.up-novel-reader__settings-option {
|
|
302
|
+
padding: 10px 0;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.up-novel-reader__settings-hint {
|
|
306
|
+
display: block;
|
|
307
|
+
margin-top: 3px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.up-novel-reader__settings-footer {
|
|
311
|
+
padding: 10px 0 18px;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.up-novel-reader__settings-done {
|
|
315
|
+
display: flex;
|
|
316
|
+
flex-direction: row;
|
|
317
|
+
align-items: center;
|
|
318
|
+
justify-content: center;
|
|
319
|
+
height: 42px;
|
|
320
|
+
border-radius: 8px;
|
|
321
|
+
color: #ffffff;
|
|
322
|
+
background-color: var(--up-novel-reader-active, #2979ff);
|
|
323
|
+
font-size: 14px;
|
|
324
|
+
}
|
|
325
|
+
</style>
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="up-novel-reader__toolbar"
|
|
4
|
+
:class="[
|
|
5
|
+
`up-novel-reader__toolbar--${position}`,
|
|
6
|
+
{ 'is-dark': isDark }
|
|
7
|
+
]"
|
|
8
|
+
:style="toolbarStyle"
|
|
9
|
+
@tap.stop="handleToggleControls"
|
|
10
|
+
>
|
|
11
|
+
<view v-if="position === 'top'" class="up-novel-reader__toolbar-row">
|
|
12
|
+
<view class="up-novel-reader__toolbar-group">
|
|
13
|
+
<view
|
|
14
|
+
v-if="showBack"
|
|
15
|
+
class="up-novel-reader__toolbar-button"
|
|
16
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
17
|
+
@tap.stop="handleBack"
|
|
18
|
+
>
|
|
19
|
+
<u-icon :name="backIcon" size="21" :color="textColor"></u-icon>
|
|
20
|
+
</view>
|
|
21
|
+
<text class="up-novel-reader__toolbar-title">{{ title || '小说阅读' }}</text>
|
|
22
|
+
</view>
|
|
23
|
+
<view class="up-novel-reader__toolbar-group">
|
|
24
|
+
<slot name="top"></slot>
|
|
25
|
+
<view
|
|
26
|
+
class="up-novel-reader__toolbar-button"
|
|
27
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
28
|
+
@tap.stop="handleToggleCatalog"
|
|
29
|
+
>
|
|
30
|
+
<u-icon name="list" size="20" :color="textColor"></u-icon>
|
|
31
|
+
</view>
|
|
32
|
+
<view
|
|
33
|
+
class="up-novel-reader__toolbar-button"
|
|
34
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
35
|
+
@tap.stop="handleToggleBookmark"
|
|
36
|
+
>
|
|
37
|
+
<u-icon
|
|
38
|
+
name="bookmark"
|
|
39
|
+
size="20"
|
|
40
|
+
:color="isBookmarked ? activeColor : textColor"
|
|
41
|
+
:bold="isBookmarked"
|
|
42
|
+
></u-icon>
|
|
43
|
+
</view>
|
|
44
|
+
<slot name="toolbar-extra"></slot>
|
|
45
|
+
<view
|
|
46
|
+
class="up-novel-reader__toolbar-button"
|
|
47
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
48
|
+
@tap.stop="handleToggleControls"
|
|
49
|
+
>
|
|
50
|
+
<u-icon name="close" size="19" :color="textColor"></u-icon>
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
</view>
|
|
54
|
+
<view v-else class="up-novel-reader__toolbar-row up-novel-reader__toolbar-row--bottom">
|
|
55
|
+
<view class="up-novel-reader__progress">
|
|
56
|
+
<text class="up-novel-reader__progress-label">{{ progressLabel }}</text>
|
|
57
|
+
<view class="up-novel-reader__progress-track">
|
|
58
|
+
<view class="up-novel-reader__progress-value" :style="{ width: `${progressPercent}%` }"></view>
|
|
59
|
+
</view>
|
|
60
|
+
</view>
|
|
61
|
+
<view class="up-novel-reader__toolbar-group">
|
|
62
|
+
<slot name="bottom"></slot>
|
|
63
|
+
<view
|
|
64
|
+
class="up-novel-reader__toolbar-button"
|
|
65
|
+
:class="{ 'is-disabled': previousDisabled }"
|
|
66
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
67
|
+
@tap.stop="handlePrevious"
|
|
68
|
+
>
|
|
69
|
+
<u-icon name="arrow-left" size="18" :color="previousDisabled ? disabledColor : textColor"></u-icon>
|
|
70
|
+
</view>
|
|
71
|
+
<view
|
|
72
|
+
class="up-novel-reader__toolbar-button"
|
|
73
|
+
:class="{ 'is-disabled': nextDisabled }"
|
|
74
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
75
|
+
@tap.stop="handleNext"
|
|
76
|
+
>
|
|
77
|
+
<u-icon name="arrow-right" size="18" :color="nextDisabled ? disabledColor : textColor"></u-icon>
|
|
78
|
+
</view>
|
|
79
|
+
<view
|
|
80
|
+
class="up-novel-reader__toolbar-button"
|
|
81
|
+
hover-class="up-novel-reader__toolbar-button--hover"
|
|
82
|
+
@tap.stop="handleToggleSettings"
|
|
83
|
+
>
|
|
84
|
+
<u-icon name="setting" size="20" :color="textColor"></u-icon>
|
|
85
|
+
</view>
|
|
86
|
+
</view>
|
|
87
|
+
</view>
|
|
88
|
+
</view>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<script>
|
|
92
|
+
export default {
|
|
93
|
+
name: 'NovelReaderToolbar',
|
|
94
|
+
props: {
|
|
95
|
+
position: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: 'top'
|
|
98
|
+
},
|
|
99
|
+
title: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: ''
|
|
102
|
+
},
|
|
103
|
+
showBack: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: true
|
|
106
|
+
},
|
|
107
|
+
backIcon: {
|
|
108
|
+
type: String,
|
|
109
|
+
default: 'arrow-left'
|
|
110
|
+
},
|
|
111
|
+
isBookmarked: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: false
|
|
114
|
+
},
|
|
115
|
+
progress: {
|
|
116
|
+
type: Object,
|
|
117
|
+
default: () => ({})
|
|
118
|
+
},
|
|
119
|
+
pageCount: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: 0
|
|
122
|
+
},
|
|
123
|
+
currentChapterIndex: {
|
|
124
|
+
type: Number,
|
|
125
|
+
default: -1
|
|
126
|
+
},
|
|
127
|
+
chapterCount: {
|
|
128
|
+
type: Number,
|
|
129
|
+
default: 0
|
|
130
|
+
},
|
|
131
|
+
hasPrevious: {
|
|
132
|
+
type: Boolean,
|
|
133
|
+
default: false
|
|
134
|
+
},
|
|
135
|
+
hasNext: {
|
|
136
|
+
type: Boolean,
|
|
137
|
+
default: false
|
|
138
|
+
},
|
|
139
|
+
themeTokens: {
|
|
140
|
+
type: Object,
|
|
141
|
+
default: () => ({})
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
emits: [
|
|
145
|
+
'back',
|
|
146
|
+
'toggle-catalog',
|
|
147
|
+
'toggle-settings',
|
|
148
|
+
'toggle-bookmark',
|
|
149
|
+
'previous',
|
|
150
|
+
'next',
|
|
151
|
+
'toggle-controls'
|
|
152
|
+
],
|
|
153
|
+
computed: {
|
|
154
|
+
isDark() {
|
|
155
|
+
return ['night', 'dark'].includes(this.themeTokens.theme)
|
|
156
|
+
},
|
|
157
|
+
textColor() {
|
|
158
|
+
return this.themeTokens.text || '#303133'
|
|
159
|
+
},
|
|
160
|
+
activeColor() {
|
|
161
|
+
return this.themeTokens.active || '#2979ff'
|
|
162
|
+
},
|
|
163
|
+
disabledColor() {
|
|
164
|
+
return this.themeTokens.disabled || '#c8c9cc'
|
|
165
|
+
},
|
|
166
|
+
toolbarStyle() {
|
|
167
|
+
return {
|
|
168
|
+
backgroundColor: this.themeTokens.toolbar || '#ffffff',
|
|
169
|
+
borderColor: this.themeTokens.border || 'rgba(48, 49, 51, 0.12)'
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
progressPercent() {
|
|
173
|
+
if (this.progress.chapterProgress != null) {
|
|
174
|
+
return Math.min(100, Math.max(0, Number(this.progress.chapterProgress) * 100 || 0))
|
|
175
|
+
}
|
|
176
|
+
if (this.pageCount > 0) {
|
|
177
|
+
return Math.min(100, Math.max(0, ((this.progress.pageIndex || 0) + 1) / this.pageCount * 100))
|
|
178
|
+
}
|
|
179
|
+
return 0
|
|
180
|
+
},
|
|
181
|
+
progressLabel() {
|
|
182
|
+
const current = this.currentChapterIndex >= 0 ? this.currentChapterIndex + 1 : 0
|
|
183
|
+
const chapterText = this.chapterCount ? `${current}/${this.chapterCount}` : '阅读进度'
|
|
184
|
+
const percentText = `${Math.round(this.progressPercent)}%`
|
|
185
|
+
return `${chapterText} · ${percentText}`
|
|
186
|
+
},
|
|
187
|
+
previousDisabled() {
|
|
188
|
+
return !this.hasPrevious
|
|
189
|
+
},
|
|
190
|
+
nextDisabled() {
|
|
191
|
+
return !this.hasNext
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
methods: {
|
|
195
|
+
handleBack() {
|
|
196
|
+
this.$emit('back')
|
|
197
|
+
},
|
|
198
|
+
handleToggleCatalog() {
|
|
199
|
+
this.$emit('toggle-catalog')
|
|
200
|
+
},
|
|
201
|
+
handleToggleSettings() {
|
|
202
|
+
this.$emit('toggle-settings')
|
|
203
|
+
},
|
|
204
|
+
handleToggleBookmark() {
|
|
205
|
+
this.$emit('toggle-bookmark')
|
|
206
|
+
},
|
|
207
|
+
handlePrevious() {
|
|
208
|
+
if (!this.previousDisabled) this.$emit('previous')
|
|
209
|
+
},
|
|
210
|
+
handleNext() {
|
|
211
|
+
if (!this.nextDisabled) this.$emit('next')
|
|
212
|
+
},
|
|
213
|
+
handleToggleControls() {
|
|
214
|
+
this.$emit('toggle-controls')
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
</script>
|
|
219
|
+
|
|
220
|
+
<style lang="scss" scoped>
|
|
221
|
+
.up-novel-reader__toolbar {
|
|
222
|
+
box-sizing: border-box;
|
|
223
|
+
width: 100%;
|
|
224
|
+
padding: 10px 14px;
|
|
225
|
+
border-bottom-width: 1px;
|
|
226
|
+
border-bottom-style: solid;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.up-novel-reader__toolbar--bottom {
|
|
230
|
+
border-top-width: 1px;
|
|
231
|
+
border-top-style: solid;
|
|
232
|
+
border-bottom: 0;
|
|
233
|
+
padding-top: 8px;
|
|
234
|
+
padding-bottom: 8px;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.up-novel-reader__toolbar-row {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: row;
|
|
240
|
+
align-items: center;
|
|
241
|
+
justify-content: space-between;
|
|
242
|
+
min-height: 36px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.up-novel-reader__toolbar-row--bottom {
|
|
246
|
+
gap: 12px;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.up-novel-reader__toolbar-group {
|
|
250
|
+
display: flex;
|
|
251
|
+
flex-direction: row;
|
|
252
|
+
align-items: center;
|
|
253
|
+
min-width: 0;
|
|
254
|
+
gap: 6px;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.up-novel-reader__toolbar-title {
|
|
258
|
+
max-width: 200px;
|
|
259
|
+
overflow: hidden;
|
|
260
|
+
color: inherit;
|
|
261
|
+
font-size: 16px;
|
|
262
|
+
font-weight: 600;
|
|
263
|
+
text-overflow: ellipsis;
|
|
264
|
+
white-space: nowrap;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.up-novel-reader__toolbar-button {
|
|
268
|
+
display: flex;
|
|
269
|
+
flex-direction: row;
|
|
270
|
+
align-items: center;
|
|
271
|
+
justify-content: center;
|
|
272
|
+
width: 36px;
|
|
273
|
+
height: 36px;
|
|
274
|
+
border-radius: 18px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.up-novel-reader__toolbar-button--hover {
|
|
278
|
+
opacity: 0.55;
|
|
279
|
+
background-color: rgba(127, 127, 127, 0.12);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.up-novel-reader__toolbar-button.is-disabled {
|
|
283
|
+
opacity: 0.5;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.up-novel-reader__progress {
|
|
287
|
+
flex: 1;
|
|
288
|
+
min-width: 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.up-novel-reader__progress-label {
|
|
292
|
+
display: block;
|
|
293
|
+
margin-bottom: 5px;
|
|
294
|
+
color: inherit;
|
|
295
|
+
font-size: 11px;
|
|
296
|
+
line-height: 16px;
|
|
297
|
+
opacity: 0.78;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.up-novel-reader__progress-track {
|
|
301
|
+
width: 100%;
|
|
302
|
+
height: 3px;
|
|
303
|
+
overflow: hidden;
|
|
304
|
+
border-radius: 3px;
|
|
305
|
+
background-color: rgba(127, 127, 127, 0.22);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.up-novel-reader__progress-value {
|
|
309
|
+
height: 100%;
|
|
310
|
+
border-radius: 3px;
|
|
311
|
+
background-color: var(--up-novel-reader-active, #2979ff);
|
|
312
|
+
}
|
|
313
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.up-novel-reader.theme-day {
|
|
2
|
+
--up-novel-reader-background: #f7f8fa;
|
|
3
|
+
--up-novel-reader-text: #303133;
|
|
4
|
+
--up-novel-reader-muted: #909399;
|
|
5
|
+
--up-novel-reader-toolbar: #ffffff;
|
|
6
|
+
--up-novel-reader-border: rgba(48, 49, 51, 0.12);
|
|
7
|
+
--up-novel-reader-active: #2979ff;
|
|
8
|
+
--up-novel-reader-disabled: #c8c9cc;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.up-novel-reader.theme-paper {
|
|
12
|
+
--up-novel-reader-background: #f3ead7;
|
|
13
|
+
--up-novel-reader-text: #51483d;
|
|
14
|
+
--up-novel-reader-muted: #8f806d;
|
|
15
|
+
--up-novel-reader-toolbar: #f7efdf;
|
|
16
|
+
--up-novel-reader-border: rgba(81, 72, 61, 0.16);
|
|
17
|
+
--up-novel-reader-active: #9b7653;
|
|
18
|
+
--up-novel-reader-disabled: #c7b9a3;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.up-novel-reader.theme-green {
|
|
22
|
+
--up-novel-reader-background: #e7f1e4;
|
|
23
|
+
--up-novel-reader-text: #3f5140;
|
|
24
|
+
--up-novel-reader-muted: #708371;
|
|
25
|
+
--up-novel-reader-toolbar: #eef6eb;
|
|
26
|
+
--up-novel-reader-border: rgba(63, 81, 64, 0.16);
|
|
27
|
+
--up-novel-reader-active: #4d8b55;
|
|
28
|
+
--up-novel-reader-disabled: #b6c7b4;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.up-novel-reader.theme-night {
|
|
32
|
+
--up-novel-reader-background: #202124;
|
|
33
|
+
--up-novel-reader-text: #d6d7da;
|
|
34
|
+
--up-novel-reader-muted: #9ca0a8;
|
|
35
|
+
--up-novel-reader-toolbar: #292b30;
|
|
36
|
+
--up-novel-reader-border: rgba(214, 215, 218, 0.16);
|
|
37
|
+
--up-novel-reader-active: #7da7ff;
|
|
38
|
+
--up-novel-reader-disabled: #62656d;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.up-novel-reader.theme-dark {
|
|
42
|
+
--up-novel-reader-background: #111214;
|
|
43
|
+
--up-novel-reader-text: #e5e7eb;
|
|
44
|
+
--up-novel-reader-muted: #9ca3af;
|
|
45
|
+
--up-novel-reader-toolbar: #1b1d21;
|
|
46
|
+
--up-novel-reader-border: rgba(229, 231, 235, 0.16);
|
|
47
|
+
--up-novel-reader-active: #8ab4ff;
|
|
48
|
+
--up-novel-reader-disabled: #5f6368;
|
|
49
|
+
}
|