uview-plus 3.8.55 → 3.8.106
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 +2147 -1828
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +22 -2
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +44 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/u-button.vue +2 -5
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +8 -0
- package/components/u-calendar/props.js +43 -1
- package/components/u-calendar/u-calendar.vue +16 -0
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +1028 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +9 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-datetime-picker/u-datetime-picker.vue +53 -4
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +57 -32
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +11 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +103 -10
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-item/u-index-item.vue +1 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-index-list/u-index-list.vue +1 -1
- package/components/u-input/props.js +3 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -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-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +246 -214
- package/components/u-qrcode/qrcode.js +105 -97
- package/components/u-qrcode/u-qrcode.vue +242 -289
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-scroll-list/scrollWxs.wxs +1 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +71 -29
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -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 +9 -1
- package/components/u-swipe-action-item/swipeActionItem.js +1 -0
- package/components/u-swipe-action-item/u-swipe-action-item.vue +42 -4
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-switch/u-switch.vue +1 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar/u-tabbar.vue +2 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-tabbar-item/u-tabbar-item.vue +64 -21
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +327 -137
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs/u-tabs.vue +11 -8
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tabs-pro/u-tabs-pro.vue +212 -0
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-text/text.js +1 -1
- package/components/u-text/u-text.vue +18 -6
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +48 -41
- package/components/u-waterfall/u-waterfall.vue +162 -110
- package/index.js +65 -8
- package/libs/config/config.js +1 -1
- package/libs/config/props.js +180 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/index.js +66 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +18 -54
- 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 +10 -7
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +3 -3
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +38 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swipeActionItem.d.ts +13 -0
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tabs.d.ts +2 -1
- package/types/comps/text.d.ts +1 -1
- package/types/comps/tooltip.d.ts +36 -1
- package/types/func.d.ts +23 -0
- package/types/index.d.ts +1 -0
- /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import LineProgressDefaultProps from './lineProgress'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(LineProgressDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 激活部分的颜色
|
|
@@ -9,12 +12,12 @@ export const props = defineMixin({
|
|
|
9
12
|
},
|
|
10
13
|
inactiveColor: {
|
|
11
14
|
type: String,
|
|
12
|
-
default: () => defProps.lineProgress.
|
|
15
|
+
default: () => defProps.lineProgress.inactiveColor
|
|
13
16
|
},
|
|
14
17
|
// 进度百分比,数值
|
|
15
18
|
percentage: {
|
|
16
19
|
type: [String, Number],
|
|
17
|
-
default: () => defProps.lineProgress.
|
|
20
|
+
default: () => defProps.lineProgress.percentage
|
|
18
21
|
},
|
|
19
22
|
// 是否在进度条内部显示百分比的值
|
|
20
23
|
showText: {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import LinkDefaultProps from './link'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(LinkDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 文字颜色
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import ListDefaultProps from './list'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(ListDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 控制是否出现滚动条,仅nvue有效
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import ListItemDefaultProps from './listItem'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(ListItemDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 用于滚动到指定item
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import LoadingIconDefaultProps from './loadingIcon'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(LoadingIconDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 是否显示组件
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import LoadingPageDefaultProps from './loadingPage'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
3
4
|
|
|
5
|
+
const defProps = registerComponentProps(LoadingPageDefaultProps)
|
|
4
6
|
export const props = defineMixin({
|
|
5
7
|
props: {
|
|
6
8
|
// 提示内容
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import LoadmoreDefaultProps from './loadmore'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(LoadmoreDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 组件状态,loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="up-markdown" :class="theme">
|
|
3
|
-
<up-parse
|
|
3
|
+
<up-parse
|
|
4
|
+
:content="parsedContent"
|
|
5
|
+
:previewImg="previewImg"
|
|
6
|
+
:copyLink="copyLink"
|
|
7
|
+
:domain="domain"
|
|
8
|
+
@load="emitLoad"
|
|
9
|
+
@ready="emitReady"
|
|
10
|
+
@imgtap="emitImgtap"
|
|
11
|
+
@linktap="emitLinktap"
|
|
12
|
+
@play="emitPlay"
|
|
13
|
+
@error="emitError"
|
|
14
|
+
></up-parse>
|
|
4
15
|
</view>
|
|
5
16
|
</template>
|
|
6
17
|
|
|
7
18
|
<script>
|
|
8
|
-
import { marked } from './marked.esm.
|
|
19
|
+
import { marked } from './marked.esm.mjs';
|
|
9
20
|
|
|
10
21
|
export default {
|
|
11
22
|
name: 'up-markdown',
|
|
23
|
+
// #ifdef VUE3
|
|
24
|
+
emits: ['load', 'ready', 'imgtap', 'linktap', 'play', 'error'],
|
|
25
|
+
// #endif
|
|
12
26
|
props: {
|
|
13
27
|
// markdown内容
|
|
14
28
|
content: {
|
|
@@ -20,6 +34,16 @@ export default {
|
|
|
20
34
|
type: Boolean,
|
|
21
35
|
default: true
|
|
22
36
|
},
|
|
37
|
+
// 是否允许外部链接被点击时自动打开
|
|
38
|
+
copyLink: {
|
|
39
|
+
type: [Boolean, String],
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
// 主域名,用于 up-parse 处理相对链接
|
|
43
|
+
domain: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ''
|
|
46
|
+
},
|
|
23
47
|
// 是否显示代码块行号
|
|
24
48
|
showLineNumber: {
|
|
25
49
|
type: Boolean,
|
|
@@ -93,6 +117,24 @@ export default {
|
|
|
93
117
|
applyTheme(html) {
|
|
94
118
|
// 可以根据theme属性添加不同的样式类
|
|
95
119
|
return html;
|
|
120
|
+
},
|
|
121
|
+
emitLoad(event) {
|
|
122
|
+
this.$emit('load', event)
|
|
123
|
+
},
|
|
124
|
+
emitReady(event) {
|
|
125
|
+
this.$emit('ready', event)
|
|
126
|
+
},
|
|
127
|
+
emitImgtap(event) {
|
|
128
|
+
this.$emit('imgtap', event)
|
|
129
|
+
},
|
|
130
|
+
emitLinktap(event) {
|
|
131
|
+
this.$emit('linktap', event)
|
|
132
|
+
},
|
|
133
|
+
emitPlay(event) {
|
|
134
|
+
this.$emit('play', event)
|
|
135
|
+
},
|
|
136
|
+
emitError(event) {
|
|
137
|
+
this.$emit('error', event)
|
|
96
138
|
}
|
|
97
139
|
}
|
|
98
140
|
};
|
|
@@ -297,4 +339,4 @@ export default {
|
|
|
297
339
|
line-height: 1.6;
|
|
298
340
|
}
|
|
299
341
|
}
|
|
300
|
-
</style>
|
|
342
|
+
</style>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import ModalDefaultProps from './modal'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(ModalDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 是否展示modal
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import NavbarDefaultProps from './navbar'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(NavbarDefaultProps)
|
|
4
6
|
export const props = defineMixin({
|
|
5
7
|
props: {
|
|
6
8
|
// 是否开启顶部安全区适配
|
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
height: addUnit(getPx(height) + getWindowInfo().statusBarHeight,'px'),
|
|
8
8
|
}"
|
|
9
9
|
></view>
|
|
10
|
-
<view
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
<view
|
|
11
|
+
class="u-navbar__inner"
|
|
12
|
+
:class="[fixed && 'u-navbar--fixed']"
|
|
13
|
+
:style="[navbarInnerStyle]"
|
|
14
|
+
>
|
|
15
|
+
<u-status-bar v-if="safeAreaInsetTop"></u-status-bar>
|
|
15
16
|
<view
|
|
16
17
|
class="u-navbar__content"
|
|
17
18
|
:class="[border && 'u-border-bottom']"
|
|
18
19
|
:style="{
|
|
19
20
|
height: addUnit(height),
|
|
20
|
-
backgroundColor:
|
|
21
|
+
backgroundColor: 'transparent',
|
|
21
22
|
}"
|
|
22
23
|
>
|
|
23
24
|
<view
|
|
@@ -95,8 +96,8 @@
|
|
|
95
96
|
* @property {String} rightIcon 右边返回图标的名称,只能为uview-plus自带的图标
|
|
96
97
|
* @property {String} title 导航栏标题,如设置为空字符,将会隐藏标题占位区域
|
|
97
98
|
* @property {String} titleColor 文字颜色 (默认 '' )
|
|
98
|
-
* @property {String} bgColor
|
|
99
|
-
* @property {String} statusBarBgColor
|
|
99
|
+
* @property {String} bgColor 导航栏背景设置,支持颜色、渐变或背景图 (默认 '#ffffff' )
|
|
100
|
+
* @property {String} statusBarBgColor 状态栏背景颜色,保留兼容;导航栏内部统一使用 bgColor 作为整体背景
|
|
100
101
|
* @property {String | Number} titleWidth 导航栏标题的最大宽度,内容超出会以省略号隐藏 (默认 '400rpx' )
|
|
101
102
|
* @property {String | Number} height 导航栏高度(不包括状态栏高度在内,内部自动加上)(默认 '44px' )
|
|
102
103
|
* @property {String | Number} leftIconSize 左侧返回图标的大小(默认 20px )
|
|
@@ -129,6 +130,11 @@
|
|
|
129
130
|
},
|
|
130
131
|
navbarRightColor() {
|
|
131
132
|
return this.upThemeVar('--up-main-color', this.$u.color.mainColor)
|
|
133
|
+
},
|
|
134
|
+
navbarInnerStyle() {
|
|
135
|
+
const style = {}
|
|
136
|
+
style.background = this.navbarBgColor
|
|
137
|
+
return style
|
|
132
138
|
}
|
|
133
139
|
},
|
|
134
140
|
emits: ["leftClick", "rightClick"],
|
|
@@ -142,7 +148,7 @@
|
|
|
142
148
|
// 如果配置了autoBack,自动返回上一页
|
|
143
149
|
this.$emit('leftClick')
|
|
144
150
|
if (config.interceptor.navbarLeftClick != null) {
|
|
145
|
-
config.interceptor.navbarLeftClick()
|
|
151
|
+
config.interceptor.navbarLeftClick.call(this, this)
|
|
146
152
|
} else {
|
|
147
153
|
if(this.autoBack) {
|
|
148
154
|
uni.navigateBack()
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import NoNetworkDefaultProps from './noNetwork'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(NoNetworkDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 页面文字提示
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import NoticeBarDefaultProps from './noticeBar'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(NoticeBarDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 显示的内容,数组
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { defineMixin } from '../../libs/vue'
|
|
2
|
-
import
|
|
2
|
+
import NotifyDefaultProps from './notify'
|
|
3
|
+
import { registerComponentProps } from '../../libs/config/props.js'
|
|
4
|
+
|
|
5
|
+
const defProps = registerComponentProps(NotifyDefaultProps)
|
|
3
6
|
export const props = defineMixin({
|
|
4
7
|
props: {
|
|
5
8
|
// 到顶部的距离
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const LINE_BREAK_PATTERN = /\r\n|\r|\n/
|
|
2
|
+
|
|
3
|
+
function normalizeParagraphs(content) {
|
|
4
|
+
const values = Array.isArray(content) ? content : [content == null ? '' : content]
|
|
5
|
+
return values.reduce((paragraphs, value) => {
|
|
6
|
+
String(value == null ? '' : value)
|
|
7
|
+
.split(LINE_BREAK_PATTERN)
|
|
8
|
+
.forEach((text) => paragraphs.push(text))
|
|
9
|
+
return paragraphs
|
|
10
|
+
}, [])
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function normalizeContent(content) {
|
|
14
|
+
const sourceParagraphs = normalizeParagraphs(content)
|
|
15
|
+
const hasContent = sourceParagraphs.some((text) => text.length > 0)
|
|
16
|
+
if (!hasContent) {
|
|
17
|
+
return {
|
|
18
|
+
paragraphs: [],
|
|
19
|
+
text: '',
|
|
20
|
+
length: 0
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let offset = 0
|
|
25
|
+
const paragraphs = sourceParagraphs.map((text, index) => {
|
|
26
|
+
const startOffset = offset
|
|
27
|
+
const endOffset = startOffset + text.length
|
|
28
|
+
offset = endOffset + 1
|
|
29
|
+
return {
|
|
30
|
+
index,
|
|
31
|
+
text,
|
|
32
|
+
startOffset,
|
|
33
|
+
endOffset
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const text = paragraphs.map((paragraph) => paragraph.text).join('\n')
|
|
38
|
+
return {
|
|
39
|
+
paragraphs,
|
|
40
|
+
text,
|
|
41
|
+
length: text.length
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function normalizeProgress(progress, chapter) {
|
|
46
|
+
const normalizedContent = normalizeContent(chapter && chapter.content)
|
|
47
|
+
const contentLength = normalizedContent.length
|
|
48
|
+
const requestedOffset = Number(progress && progress.charOffset)
|
|
49
|
+
const charOffset = Math.min(
|
|
50
|
+
contentLength,
|
|
51
|
+
Math.max(0, Number.isFinite(requestedOffset) ? requestedOffset : 0)
|
|
52
|
+
)
|
|
53
|
+
const requestedPageIndex = Number(progress && progress.pageIndex)
|
|
54
|
+
const chapterIndex = Number(chapter && chapter.index)
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
chapterId: progress && progress.chapterId != null
|
|
58
|
+
? progress.chapterId
|
|
59
|
+
: chapter && chapter.id != null
|
|
60
|
+
? chapter.id
|
|
61
|
+
: '',
|
|
62
|
+
chapterIndex: Number.isFinite(chapterIndex)
|
|
63
|
+
? chapterIndex
|
|
64
|
+
: Number(progress && progress.chapterIndex) || 0,
|
|
65
|
+
pageIndex: Math.max(0, Number.isFinite(requestedPageIndex) ? requestedPageIndex : 0),
|
|
66
|
+
pageCount: Math.max(0, Number(progress && progress.pageCount) || 0),
|
|
67
|
+
charOffset,
|
|
68
|
+
chapterProgress: contentLength
|
|
69
|
+
? Math.min(1, Math.max(0, charOffset / contentLength))
|
|
70
|
+
: 0,
|
|
71
|
+
totalProgress: Math.min(1, Math.max(0, Number(progress && progress.totalProgress) || 0)),
|
|
72
|
+
scrollTop: Math.max(0, Number(progress && progress.scrollTop) || 0),
|
|
73
|
+
updatedAt: Number(progress && progress.updatedAt) || 0
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
normalizeContent,
|
|
79
|
+
normalizeProgress
|
|
80
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { measureTextWidth } from './measure-adapter'
|
|
2
|
+
|
|
3
|
+
const CJK_PATTERN = /[\u3400-\u9fff\u3040-\u30ff\uff00-\uffef]/
|
|
4
|
+
|
|
5
|
+
function createUnit(text, startOffset, endOffset) {
|
|
6
|
+
return {
|
|
7
|
+
text,
|
|
8
|
+
startOffset,
|
|
9
|
+
endOffset
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function tokenizeText(text) {
|
|
14
|
+
const units = []
|
|
15
|
+
let token = ''
|
|
16
|
+
let tokenStart = 0
|
|
17
|
+
let offset = 0
|
|
18
|
+
|
|
19
|
+
const flushToken = () => {
|
|
20
|
+
if (token) {
|
|
21
|
+
units.push(createUnit(token, tokenStart, offset))
|
|
22
|
+
token = ''
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Array.from(String(text)).forEach((character) => {
|
|
27
|
+
const startOffset = offset
|
|
28
|
+
offset += character.length
|
|
29
|
+
if (CJK_PATTERN.test(character) || /\s/.test(character)) {
|
|
30
|
+
flushToken()
|
|
31
|
+
units.push(createUnit(character, startOffset, offset))
|
|
32
|
+
tokenStart = offset
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
if (!token) tokenStart = startOffset
|
|
36
|
+
token += character
|
|
37
|
+
})
|
|
38
|
+
flushToken()
|
|
39
|
+
return units
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function splitUnit(unit) {
|
|
43
|
+
if (unit.text.length <= 1) return [unit]
|
|
44
|
+
const result = []
|
|
45
|
+
let offset = unit.startOffset
|
|
46
|
+
Array.from(unit.text).forEach((character) => {
|
|
47
|
+
const nextOffset = offset + character.length
|
|
48
|
+
result.push(createUnit(character, offset, nextOffset))
|
|
49
|
+
offset = nextOffset
|
|
50
|
+
})
|
|
51
|
+
return result
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function lineFromUnits(units) {
|
|
55
|
+
return {
|
|
56
|
+
text: units.map((unit) => unit.text).join(''),
|
|
57
|
+
startOffset: units[0].startOffset,
|
|
58
|
+
endOffset: units[units.length - 1].endOffset
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createLayoutKey({
|
|
63
|
+
chapterId = '',
|
|
64
|
+
settings = {},
|
|
65
|
+
width = 0,
|
|
66
|
+
height = 0
|
|
67
|
+
} = {}) {
|
|
68
|
+
return JSON.stringify({
|
|
69
|
+
chapterId,
|
|
70
|
+
width,
|
|
71
|
+
height,
|
|
72
|
+
fontSize: settings.fontSize,
|
|
73
|
+
lineHeight: settings.lineHeight,
|
|
74
|
+
paragraphSpacing: settings.paragraphSpacing,
|
|
75
|
+
contentWidth: settings.contentWidth,
|
|
76
|
+
fontFamily: settings.fontFamily,
|
|
77
|
+
fontWeight: settings.fontWeight
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function wrapText(text, width, measureText = measureTextWidth) {
|
|
82
|
+
const source = String(text == null ? '' : text)
|
|
83
|
+
if (!source) {
|
|
84
|
+
return [{
|
|
85
|
+
text: '',
|
|
86
|
+
startOffset: 0,
|
|
87
|
+
endOffset: 0
|
|
88
|
+
}]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const units = tokenizeText(source).reduce((result, unit) => {
|
|
92
|
+
const unitWidth = measureText(unit.text)
|
|
93
|
+
if (unitWidth > width && unit.text.length > 1) {
|
|
94
|
+
return result.concat(splitUnit(unit))
|
|
95
|
+
}
|
|
96
|
+
result.push(unit)
|
|
97
|
+
return result
|
|
98
|
+
}, [])
|
|
99
|
+
const lines = []
|
|
100
|
+
let currentUnits = []
|
|
101
|
+
|
|
102
|
+
units.forEach((unit) => {
|
|
103
|
+
const candidateUnits = currentUnits.concat(unit)
|
|
104
|
+
const candidateText = candidateUnits.map((item) => item.text).join('')
|
|
105
|
+
if (
|
|
106
|
+
currentUnits.length &&
|
|
107
|
+
measureText(candidateText) > width
|
|
108
|
+
) {
|
|
109
|
+
lines.push(lineFromUnits(currentUnits))
|
|
110
|
+
currentUnits = [unit]
|
|
111
|
+
} else {
|
|
112
|
+
currentUnits = candidateUnits
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
if (currentUnits.length) {
|
|
117
|
+
lines.push(lineFromUnits(currentUnits))
|
|
118
|
+
}
|
|
119
|
+
return lines
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function getLineHeight(layout) {
|
|
123
|
+
const fontSize = Number(layout.fontSize) || 18
|
|
124
|
+
const lineHeight = Number(layout.lineHeight)
|
|
125
|
+
if (!Number.isFinite(lineHeight)) return fontSize * 1.8
|
|
126
|
+
return lineHeight <= 4 ? fontSize * lineHeight : lineHeight
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function createPage(lines, index) {
|
|
130
|
+
if (!lines.length) return null
|
|
131
|
+
return {
|
|
132
|
+
index,
|
|
133
|
+
text: lines.map((line) => line.text).join('\n'),
|
|
134
|
+
lines,
|
|
135
|
+
startOffset: lines[0].startOffset,
|
|
136
|
+
endOffset: lines[lines.length - 1].endOffset
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function paginateParagraphs(paragraphs = [], layout = {}) {
|
|
141
|
+
const width = Math.max(1, Number(layout.width) || 320)
|
|
142
|
+
const height = Math.max(1, Number(layout.height) || 500)
|
|
143
|
+
const lineHeight = Math.max(1, getLineHeight(layout))
|
|
144
|
+
const paragraphSpacing = Math.max(0, Number(layout.paragraphSpacing) || 0)
|
|
145
|
+
const measureText = typeof layout.measureText === 'function'
|
|
146
|
+
? layout.measureText
|
|
147
|
+
: (text) => measureTextWidth(text, layout)
|
|
148
|
+
const pages = []
|
|
149
|
+
let lines = []
|
|
150
|
+
let usedHeight = 0
|
|
151
|
+
|
|
152
|
+
const flushPage = () => {
|
|
153
|
+
const page = createPage(lines, pages.length)
|
|
154
|
+
if (page) pages.push(page)
|
|
155
|
+
lines = []
|
|
156
|
+
usedHeight = 0
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
paragraphs.forEach((paragraph, paragraphIndex) => {
|
|
160
|
+
const normalizedParagraph = typeof paragraph === 'string'
|
|
161
|
+
? {
|
|
162
|
+
text: paragraph,
|
|
163
|
+
startOffset: 0,
|
|
164
|
+
endOffset: paragraph.length
|
|
165
|
+
}
|
|
166
|
+
: paragraph
|
|
167
|
+
const paragraphLines = wrapText(
|
|
168
|
+
normalizedParagraph && normalizedParagraph.text,
|
|
169
|
+
width,
|
|
170
|
+
measureText
|
|
171
|
+
).map((line) => ({
|
|
172
|
+
...line,
|
|
173
|
+
startOffset: line.startOffset + (normalizedParagraph.startOffset || 0),
|
|
174
|
+
endOffset: line.endOffset + (normalizedParagraph.startOffset || 0),
|
|
175
|
+
paragraphIndex
|
|
176
|
+
}))
|
|
177
|
+
|
|
178
|
+
if (paragraphIndex > 0 && lines.length && usedHeight + paragraphSpacing + lineHeight > height) {
|
|
179
|
+
flushPage()
|
|
180
|
+
} else if (paragraphIndex > 0 && lines.length) {
|
|
181
|
+
usedHeight += paragraphSpacing
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
paragraphLines.forEach((line) => {
|
|
185
|
+
if (lines.length && usedHeight + lineHeight > height) {
|
|
186
|
+
flushPage()
|
|
187
|
+
}
|
|
188
|
+
lines.push(line)
|
|
189
|
+
usedHeight += lineHeight
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
flushPage()
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
pages,
|
|
196
|
+
pageCount: pages.length,
|
|
197
|
+
charOffsetToPage: pages.map((page) => ({
|
|
198
|
+
pageIndex: page.index,
|
|
199
|
+
startOffset: page.startOffset,
|
|
200
|
+
endOffset: page.endOffset
|
|
201
|
+
}))
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export function resolveAnchor(pages = [], charOffset = 0) {
|
|
206
|
+
if (!pages.length) {
|
|
207
|
+
return {
|
|
208
|
+
pageIndex: 0,
|
|
209
|
+
localOffset: 0
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const offset = Math.max(0, Number(charOffset) || 0)
|
|
213
|
+
const page = pages.find((item) => offset <= item.endOffset) || pages[pages.length - 1]
|
|
214
|
+
return {
|
|
215
|
+
pageIndex: page.index,
|
|
216
|
+
localOffset: Math.max(0, Math.min(page.text.length, offset - page.startOffset))
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export default {
|
|
221
|
+
createLayoutKey,
|
|
222
|
+
wrapText,
|
|
223
|
+
paginateParagraphs,
|
|
224
|
+
resolveAnchor
|
|
225
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function toNumber(value, fallback) {
|
|
2
|
+
const number = Number.parseFloat(value)
|
|
3
|
+
return Number.isFinite(number) ? number : fallback
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function getFontSize(style = {}) {
|
|
7
|
+
return toNumber(style.fontSize, 18)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getCharacterWidth(character, fontSize) {
|
|
11
|
+
if (/[\u3400-\u9fff\u3040-\u30ff\uff00-\uffef]/.test(character)) {
|
|
12
|
+
return fontSize
|
|
13
|
+
}
|
|
14
|
+
if (/\s/.test(character)) {
|
|
15
|
+
return fontSize * 0.28
|
|
16
|
+
}
|
|
17
|
+
return fontSize * 0.56
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function normalizeMeasureResult(value) {
|
|
21
|
+
if (typeof value === 'number') return value
|
|
22
|
+
if (value && typeof value.width === 'number') return value.width
|
|
23
|
+
return 0
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function measureTextWidth(text, style = {}, measureText) {
|
|
27
|
+
if (typeof measureText === 'function') {
|
|
28
|
+
return normalizeMeasureResult(measureText(String(text), style))
|
|
29
|
+
}
|
|
30
|
+
const fontSize = getFontSize(style)
|
|
31
|
+
return Array.from(String(text)).reduce(
|
|
32
|
+
(width, character) => width + getCharacterWidth(character, fontSize),
|
|
33
|
+
0
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createMeasureText({ canvasContext, style = {}, measureText } = {}) {
|
|
38
|
+
if (typeof measureText === 'function') {
|
|
39
|
+
return (text) => measureTextWidth(text, style, measureText)
|
|
40
|
+
}
|
|
41
|
+
if (canvasContext && typeof canvasContext.measureText === 'function') {
|
|
42
|
+
const fontSize = getFontSize(style)
|
|
43
|
+
const fontWeight = style.fontWeight || 400
|
|
44
|
+
const fontFamily = style.fontFamily || 'sans-serif'
|
|
45
|
+
canvasContext.font = `${fontWeight} ${fontSize}px ${fontFamily}`
|
|
46
|
+
return (text) => normalizeMeasureResult(canvasContext.measureText(String(text)))
|
|
47
|
+
}
|
|
48
|
+
return (text) => measureTextWidth(text, style)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function measureContainer(selector, vm) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
if (typeof uni === 'undefined' || typeof uni.createSelectorQuery !== 'function') {
|
|
54
|
+
resolve(null)
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
const query = vm
|
|
58
|
+
? uni.createSelectorQuery().in(vm)
|
|
59
|
+
: uni.createSelectorQuery()
|
|
60
|
+
query.select(selector).boundingClientRect((rect) => resolve(rect || null)).exec()
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
normalizeMeasureResult,
|
|
66
|
+
measureTextWidth,
|
|
67
|
+
createMeasureText,
|
|
68
|
+
measureContainer
|
|
69
|
+
}
|