提交 765912d4 编写于 作者: fxy060608's avatar fxy060608

wip(app): uni-app-plus

上级 01931e93
uni-button { uni-view {
position: relative;
display: block; display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
line-height: 2.55555556;
border-radius: 5px;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
color: #000000;
background-color: #f8f8f8;
cursor: pointer;
} }
uni-view[hidden] {
uni-button[hidden] { display: none;
display: none !important;
}
uni-button:after {
content: ' ';
width: 200%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border: 1px solid rgba(0, 0, 0, 0.2);
transform: scale(0.5);
transform-origin: 0 0;
box-sizing: border-box;
border-radius: 10px;
}
uni-button[native] {
padding-left: 0;
padding-right: 0;
}
uni-button[native] .uni-button-cover-view-wrapper {
border: inherit;
border-color: inherit;
border-radius: inherit;
background-color: inherit;
}
uni-button[native] .uni-button-cover-view-inner {
padding-left: 14px;
padding-right: 14px;
}
uni-button uni-cover-view {
line-height: inherit;
white-space: inherit;
}
uni-button[type='default'] {
color: #000000;
background-color: #f8f8f8;
}
uni-button[type='primary'] {
color: #ffffff;
background-color: #007aff;
}
uni-button[type='warn'] {
color: #ffffff;
background-color: #e64340;
}
uni-button[disabled] {
color: rgba(255, 255, 255, 0.6);
cursor: not-allowed;
}
uni-button[disabled][type='default'],
uni-button[disabled]:not([type]) {
color: rgba(0, 0, 0, 0.3);
background-color: #f7f7f7;
}
uni-button[disabled][type='primary'] {
background-color: rgba(0, 122, 255, 0.6);
}
uni-button[disabled][type='warn'] {
background-color: #ec8b89;
}
uni-button[type='primary'][plain] {
color: #007aff;
border: 1px solid #007aff;
background-color: transparent;
}
uni-button[type='primary'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='primary'][plain]:after {
border-width: 0;
}
uni-button[type='default'][plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[type='default'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='default'][plain]:after {
border-width: 0;
}
uni-button[plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[plain]:after {
border-width: 0;
}
uni-button[plain][native] .uni-button-cover-view-inner {
padding: 0;
}
uni-button[type='warn'][plain] {
color: #e64340;
border: 1px solid #e64340;
background-color: transparent;
}
uni-button[type='warn'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='warn'][plain]:after {
border-width: 0;
}
uni-button[size='mini'] {
display: inline-block;
line-height: 2.3;
font-size: 13px;
padding: 0 1.34em;
}
uni-button[size='mini'][native] {
padding: 0;
}
uni-button[size='mini'][native] .uni-button-cover-view-inner {
padding: 0 1.34em;
}
uni-button[loading]:not([disabled]) {
cursor: progress;
}
uni-button[loading]:before {
content: ' ';
display: inline-block;
width: 18px;
height: 18px;
vertical-align: middle;
animation: uni-loading 1s steps(12, end) infinite;
background-size: 100%;
}
uni-button[loading][type='primary'] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
uni-button[loading][type='primary'][plain] {
color: #007aff;
background-color: transparent;
}
uni-button[loading][type='default'] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
uni-button[loading][type='default'][plain] {
color: #353535;
background-color: transparent;
}
uni-button[loading][type='warn'] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
uni-button[loading][type='warn'][plain] {
color: #e64340;
background-color: transparent;
}
uni-button[loading][native]:before {
content: none;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type='primary'] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
.button-hover[type='primary'][plain] {
color: rgba(26, 173, 25, 0.6);
border-color: rgba(26, 173, 25, 0.6);
background-color: transparent;
}
.button-hover[type='default'] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[type='default'][plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type='warn'] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
.button-hover[type='warn'][plain] {
color: rgba(230, 67, 64, 0.6);
border-color: rgba(230, 67, 64, 0.6);
background-color: transparent;
} }
...@@ -5614,6 +5614,7 @@ var serviceContext = (function (vue) { ...@@ -5614,6 +5614,7 @@ var serviceContext = (function (vue) {
}); });
} }
const VD_SYNC = 'vdSync';
const ON_WEBVIEW_READY = 'onWebviewReady'; const ON_WEBVIEW_READY = 'onWebviewReady';
function initNVue(webviewStyle, routeMeta, path) { function initNVue(webviewStyle, routeMeta, path) {
...@@ -6490,7 +6491,6 @@ var serviceContext = (function (vue) { ...@@ -6490,7 +6491,6 @@ var serviceContext = (function (vue) {
}, delay); }, delay);
} }
const BRIDGE_NODE_SYNC = 'nodeSync';
const ACTION_TYPE_PAGE_CREATE = 1; const ACTION_TYPE_PAGE_CREATE = 1;
const ACTION_TYPE_PAGE_CREATED = 2; const ACTION_TYPE_PAGE_CREATED = 2;
const ACTION_TYPE_CREATE = 3; const ACTION_TYPE_CREATE = 3;
...@@ -6498,7 +6498,8 @@ var serviceContext = (function (vue) { ...@@ -6498,7 +6498,8 @@ var serviceContext = (function (vue) {
const ACTION_TYPE_REMOVE = 5; const ACTION_TYPE_REMOVE = 5;
const ACTION_TYPE_SET_ATTRIBUTE = 6; const ACTION_TYPE_SET_ATTRIBUTE = 6;
const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; const ACTION_TYPE_REMOVE_ATTRIBUTE = 7;
const ACTION_TYPE_SET_TEXT = 8; const ACTION_TYPE_SET_TEXT = 8;
class UniPageNode extends UniNode { class UniPageNode extends UniNode {
constructor(pageId, options, setup = false) { constructor(pageId, options, setup = false) {
super(NODE_TYPE_PAGE, '#page', null); super(NODE_TYPE_PAGE, '#page', null);
...@@ -6509,6 +6510,7 @@ var serviceContext = (function (vue) { ...@@ -6509,6 +6510,7 @@ var serviceContext = (function (vue) {
this.pageNode = this; this.pageNode = this;
this.createAction = [ACTION_TYPE_PAGE_CREATE, options]; this.createAction = [ACTION_TYPE_PAGE_CREATE, options];
this.createdAction = [ACTION_TYPE_PAGE_CREATED]; this.createdAction = [ACTION_TYPE_PAGE_CREATED];
this._update = this.update.bind(this);
setup && this.setup(); setup && this.setup();
} }
onCreate(thisNode, nodeName) { onCreate(thisNode, nodeName) {
...@@ -6548,6 +6550,10 @@ var serviceContext = (function (vue) { ...@@ -6548,6 +6550,10 @@ var serviceContext = (function (vue) {
} }
push(action) { push(action) {
this.updateActions.push(action); this.updateActions.push(action);
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('PageNode', 'push', action));
}
vue.queuePostFlushCb(this._update);
} }
restore() { restore() {
this.push(this.createAction); this.push(this.createAction);
...@@ -6557,20 +6563,23 @@ var serviceContext = (function (vue) { ...@@ -6557,20 +6563,23 @@ var serviceContext = (function (vue) {
setup() { setup() {
this.send([this.createAction]); this.send([this.createAction]);
} }
mounted() { // mounted() {
const { updateActions, createdAction } = this; // const { updateActions, createdAction } = this
updateActions.unshift(createdAction); // updateActions.unshift(createdAction)
this.update(); // this.update()
} // }
update() { update() {
const { updateActions } = this; const { updateActions } = this;
if ((process.env.NODE_ENV !== 'production')) {
console.log(formatLog('PageNode', 'update', updateActions.length));
}
if (updateActions.length) { if (updateActions.length) {
this.send(updateActions); this.send(updateActions);
updateActions.length = 0; updateActions.length = 0;
} }
} }
send(action) { send(action) {
UniServiceJSBridge.publishHandler(BRIDGE_NODE_SYNC, action, this.pageId); UniServiceJSBridge.publishHandler(VD_SYNC, action, this.pageId);
} }
} }
function pushCreateAction(pageNode, nodeId, nodeName) { function pushCreateAction(pageNode, nodeId, nodeName) {
...@@ -6730,6 +6739,7 @@ var serviceContext = (function (vue) { ...@@ -6730,6 +6739,7 @@ var serviceContext = (function (vue) {
function initPageOptions({ meta }) { function initPageOptions({ meta }) {
const statusbarHeight = getStatusbarHeight(); const statusbarHeight = getStatusbarHeight();
return { return {
route: meta.route,
version: 1, version: 1,
locale: '', locale: '',
disableScroll: meta.disableScroll === true, disableScroll: meta.disableScroll === true,
......
export const ACTION_TYPE_PAGE_CREATE = 1
export const ACTION_TYPE_PAGE_CREATED = 2
export const ACTION_TYPE_CREATE = 3
export const ACTION_TYPE_INSERT = 4
export const ACTION_TYPE_REMOVE = 5
export const ACTION_TYPE_SET_ATTRIBUTE = 6
export const ACTION_TYPE_REMOVE_ATTRIBUTE = 7
export const ACTION_TYPE_SET_TEXT = 8
export interface PageNodeOptions {
route: string
version: number
locale: string
disableScroll: boolean
onPageScroll: boolean
onPageReachBottom: boolean
onReachBottomDistance: number
statusbarHeight: number
windowTop: number
windowBottom: number
}
export interface PageCreateData extends PageNodeOptions {}
export type PageCreateAction = [typeof ACTION_TYPE_PAGE_CREATE, PageCreateData]
export type PageCreatedAction = [typeof ACTION_TYPE_PAGE_CREATED]
export type CreateAction = [
typeof ACTION_TYPE_CREATE,
number, // nodeId
string | number //nodeName
]
export type InsertAction = [
typeof ACTION_TYPE_INSERT,
number, // nodeId
number, // parentNodeId
number, // index
Record<string, any> // Element JSON
]
export type RemoveAction = [
typeof ACTION_TYPE_REMOVE,
number, // nodeId
number // parentNodeId
]
export type SetAttributeAction = [
typeof ACTION_TYPE_SET_ATTRIBUTE,
number, // nodeId
string, // attribute name
unknown // attribute value
]
export type RemoveAttributeAction = [
typeof ACTION_TYPE_REMOVE_ATTRIBUTE,
number, // nodeId
string // attribute name
]
export type SetTextAction = [
typeof ACTION_TYPE_SET_TEXT,
number, // nodeId
string // text content
]
export type PageUpdateAction =
| CreateAction
| InsertAction
| RemoveAction
| SetAttributeAction
| RemoveAttributeAction
| SetTextAction
export type PageAction = PageCreateAction | PageCreatedAction | PageUpdateAction
export const VD_SYNC = 'vdSync'
export const ON_WEBVIEW_READY = 'onWebviewReady' export const ON_WEBVIEW_READY = 'onWebviewReady'
import { queuePostFlushCb } from 'vue'
import { import {
UniNode, UniNode,
NODE_TYPE_PAGE, NODE_TYPE_PAGE,
UniBaseNode, UniBaseNode,
IUniPageNode, IUniPageNode,
formatLog,
} from '@dcloudio/uni-shared' } from '@dcloudio/uni-shared'
import {
const BRIDGE_NODE_SYNC = 'nodeSync' PageCreateAction,
PageCreatedAction,
const ACTION_TYPE_PAGE_CREATE = 1 PageAction,
const ACTION_TYPE_PAGE_CREATED = 2 PageNodeOptions,
export const ACTION_TYPE_CREATE = 3 ACTION_TYPE_CREATE,
export const ACTION_TYPE_INSERT = 4 ACTION_TYPE_INSERT,
export const ACTION_TYPE_REMOVE = 5 ACTION_TYPE_REMOVE,
export const ACTION_TYPE_SET_ATTRIBUTE = 6 ACTION_TYPE_SET_ATTRIBUTE,
export const ACTION_TYPE_REMOVE_ATTRIBUTE = 7 ACTION_TYPE_REMOVE_ATTRIBUTE,
export const ACTION_TYPE_SET_TEXT = 8 ACTION_TYPE_SET_TEXT,
ACTION_TYPE_PAGE_CREATE,
export interface PageNodeOptions { ACTION_TYPE_PAGE_CREATED,
version: number } from '../../../PageAction'
locale: string import { VD_SYNC } from '../../../constants'
disableScroll: boolean
onPageScroll: boolean
onPageReachBottom: boolean
onReachBottomDistance: number
statusbarHeight: number
windowTop: number
windowBottom: number
}
interface PageCreateData extends PageNodeOptions {}
type PageCreateAction = [typeof ACTION_TYPE_PAGE_CREATE, PageCreateData]
type PageCreatedAction = [typeof ACTION_TYPE_PAGE_CREATED]
export type CreateAction = [
typeof ACTION_TYPE_CREATE,
number, // nodeId
string | number //nodeName
]
export type InsertAction = [
typeof ACTION_TYPE_INSERT,
number, // nodeId
number, // parentNodeId
number, // index
Record<string, any> // Element JSON
]
export type RemoveAction = [
typeof ACTION_TYPE_REMOVE,
number, // nodeId
number // parentNodeId
]
export type SetAttributeAction = [
typeof ACTION_TYPE_SET_ATTRIBUTE,
number, // nodeId
string, // attribute name
unknown // attribute value
]
export type RemoveAttributeAction = [
typeof ACTION_TYPE_REMOVE_ATTRIBUTE,
number, // nodeId
string // attribute name
]
export type SetTextAction = [
typeof ACTION_TYPE_SET_TEXT,
number, // nodeId
string // text content
]
type PageUpdateAction =
| CreateAction
| InsertAction
| RemoveAction
| SetAttributeAction
| RemoveAttributeAction
| SetTextAction
export type PageAction = PageCreateAction | PageCreatedAction | PageUpdateAction
export default class UniPageNode extends UniNode implements IUniPageNode { export default class UniPageNode extends UniNode implements IUniPageNode {
pageId: number pageId: number
...@@ -87,6 +28,9 @@ export default class UniPageNode extends UniNode implements IUniPageNode { ...@@ -87,6 +28,9 @@ export default class UniPageNode extends UniNode implements IUniPageNode {
private createAction: PageCreateAction private createAction: PageCreateAction
private createdAction: PageCreatedAction private createdAction: PageCreatedAction
public updateActions: PageAction[] = [] public updateActions: PageAction[] = []
private _update: () => void
constructor( constructor(
pageId: number, pageId: number,
options: PageNodeOptions, options: PageNodeOptions,
...@@ -100,6 +44,8 @@ export default class UniPageNode extends UniNode implements IUniPageNode { ...@@ -100,6 +44,8 @@ export default class UniPageNode extends UniNode implements IUniPageNode {
this.createAction = [ACTION_TYPE_PAGE_CREATE, options] this.createAction = [ACTION_TYPE_PAGE_CREATE, options]
this.createdAction = [ACTION_TYPE_PAGE_CREATED] this.createdAction = [ACTION_TYPE_PAGE_CREATED]
this._update = this.update.bind(this)
setup && this.setup() setup && this.setup()
} }
onCreate(thisNode: UniNode, nodeName: string | number) { onCreate(thisNode: UniNode, nodeName: string | number) {
...@@ -139,6 +85,10 @@ export default class UniPageNode extends UniNode implements IUniPageNode { ...@@ -139,6 +85,10 @@ export default class UniPageNode extends UniNode implements IUniPageNode {
} }
push(action: PageAction) { push(action: PageAction) {
this.updateActions.push(action) this.updateActions.push(action)
if (__DEV__) {
console.log(formatLog('PageNode', 'push', action))
}
queuePostFlushCb(this._update)
} }
restore() { restore() {
this.push(this.createAction) this.push(this.createAction)
...@@ -148,20 +98,23 @@ export default class UniPageNode extends UniNode implements IUniPageNode { ...@@ -148,20 +98,23 @@ export default class UniPageNode extends UniNode implements IUniPageNode {
setup() { setup() {
this.send([this.createAction]) this.send([this.createAction])
} }
mounted() { // mounted() {
const { updateActions, createdAction } = this // const { updateActions, createdAction } = this
updateActions.unshift(createdAction) // updateActions.unshift(createdAction)
this.update() // this.update()
} // }
update() { update() {
const { updateActions } = this const { updateActions } = this
if (__DEV__) {
console.log(formatLog('PageNode', 'update', updateActions.length))
}
if (updateActions.length) { if (updateActions.length) {
this.send(updateActions) this.send(updateActions)
updateActions.length = 0 updateActions.length = 0
} }
} }
send(action: PageAction[]) { send(action: PageAction[]) {
UniServiceJSBridge.publishHandler(BRIDGE_NODE_SYNC, action, this.pageId) UniServiceJSBridge.publishHandler(VD_SYNC, action, this.pageId)
} }
} }
......
import { once } from '@dcloudio/uni-shared' import { once } from '@dcloudio/uni-shared'
import { createApp, defineComponent } from 'vue' import { createApp, defineComponent } from 'vue'
import { createPageNode, PageNodeOptions } from '../dom/Page' import { createPageNode } from '../dom/Page'
import { setupPage } from './setup' import { setupPage } from './setup'
import __vuePlugin from '../plugin' import __vuePlugin from '../plugin'
import { PageNodeOptions } from '../../../PageAction'
export type VueComponent = ReturnType<typeof defineComponent> export type VueComponent = ReturnType<typeof defineComponent>
......
import { ComponentPublicInstance } from 'vue'
import { hasOwn } from '@vue/shared' import { hasOwn } from '@vue/shared'
import { import {
formatLog, formatLog,
NAVBAR_HEIGHT, NAVBAR_HEIGHT,
ON_REACH_BOTTOM_DISTANCE, ON_REACH_BOTTOM_DISTANCE,
} from '@dcloudio/uni-shared' } from '@dcloudio/uni-shared'
import { initPageInternalInstance } from '@dcloudio/uni-core'
import { initEntry } from '../app/initEntry' import { initEntry } from '../app/initEntry'
import { initRouteOptions } from './routeOptions' import { initRouteOptions } from './routeOptions'
import { createWebview, initWebview } from '../webview' import { createWebview, initWebview } from '../webview'
import { createPage } from './define' import { createPage } from './define'
import { PageNodeOptions } from '../dom/Page' import { PageNodeOptions } from '../../../PageAction'
import { getStatusbarHeight } from '../../../helpers/statusBar' import { getStatusbarHeight } from '../../../helpers/statusBar'
import tabBar from '../app/tabBar' import tabBar from '../app/tabBar'
import { addCurrentPage } from './getCurrentPages' import { addCurrentPage } from './getCurrentPages'
import { initPageInternalInstance } from '@dcloudio/uni-core'
import { ComponentPublicInstance } from 'vue'
export type OpenType = export type OpenType =
| 'navigateTo' | 'navigateTo'
...@@ -92,6 +93,7 @@ export function registerPage({ ...@@ -92,6 +93,7 @@ export function registerPage({
function initPageOptions({ meta }: UniApp.UniRoute): PageNodeOptions { function initPageOptions({ meta }: UniApp.UniRoute): PageNodeOptions {
const statusbarHeight = getStatusbarHeight() const statusbarHeight = getStatusbarHeight()
return { return {
route: meta.route,
version: 1, version: 1,
locale: '', locale: '',
disableScroll: meta.disableScroll === true, disableScroll: meta.disableScroll === true,
......
import { ComponentInternalInstance } from 'vue'
import { extend } from '@vue/shared'
interface JsRuntime {
injectHook: (
type: string,
hook: Function,
target: ComponentInternalInstance | null,
prepend: boolean
) => Function | undefined
createApp: typeof createApp
}
export function defineRuntime(runtime: JsRuntime) {
// @ts-expect-error
extend(jsRuntime, runtime)
}
import { createApp, h } from 'vue' export * from './view'
import wrapper from 'vue3-webcomponent-wrapper'
import '@dcloudio/uni-components/style/button.css'
import {
// Audio,
Button,
// Canvas,
// Checkbox,
// CheckboxGroup,
// Editor,
// Form,
Icon,
Image,
// Input,
// Label,
// MovableArea,
// MovableView,
// Navigator,
// PickerView,
// PickerViewColumn,
// Progress,
// Radio,
// RadioGroup,
// ResizeSensor,
// RichText,
// ScrollView,
// Slider,
// Swiper,
// SwiperItem,
// Switch,
Text,
// Textarea,
View,
} from '@dcloudio/uni-components'
const { customElements } = window
customElements.define('v-uni-button', wrapper(Button, createApp, h))
customElements.define('v-uni-icon', wrapper(Icon, createApp, h))
customElements.define('v-uni-image', wrapper(Image, createApp, h))
customElements.define('v-uni-text', wrapper(Text, createApp, h))
customElements.define('v-uni-view', wrapper(View, createApp, h))
import '@dcloudio/uni-components/style/view.css'
export function View() {
return document.createElement('uni-view')
}
import { initSubscribeHandlers } from './subscriber'
export function initView() {
initSubscribeHandlers()
}
import { VD_SYNC } from '../../../constants'
import { onVdSync } from './vdom'
export function initSubscribeHandlers() {
const { subscribe } = UniViewJSBridge
subscribe(VD_SYNC, onVdSync)
}
import {
ACTION_TYPE_PAGE_CREATE,
ACTION_TYPE_PAGE_CREATED,
PageAction,
} from '../../../../PageAction'
import { onPageCreate } from './onPageCreate'
import { onPageCreated } from './onPageCreated'
export function onVdSync(actions: PageAction[]) {
actions.forEach((action) => {
switch (action[0]) {
case ACTION_TYPE_PAGE_CREATE:
return onPageCreate(action[1])
case ACTION_TYPE_PAGE_CREATED:
return onPageCreated()
}
})
}
import {
createScrollListener,
CreateScrollListenerOptions,
disableScrollListener,
updateCssVar,
} from '@dcloudio/uni-core'
import { formatLog } from '@dcloudio/uni-shared'
import { PageCreateData } from '../../../../PageAction'
export function onPageCreate({
route,
disableScroll,
onPageScroll,
onPageReachBottom,
onReachBottomDistance,
statusbarHeight,
windowTop,
windowBottom,
}: PageCreateData) {
const pageId = plus.webview.currentWebview().id!
;(window as any).__id__ = pageId
document.title = `${route}[${pageId}]`
initCssVar(statusbarHeight, windowTop, windowBottom)
if (disableScroll) {
document.addEventListener('touchmove', disableScrollListener)
} else if (onPageScroll || onPageReachBottom) {
initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance)
}
}
function initCssVar(
statusbarHeight: number,
windowTop: number,
windowBottom: number
) {
const cssVars = {
'--window-left': '0px',
'--window-right': '0px',
'--window-top': windowTop + 'px',
'--window-bottom': windowBottom + 'px',
'--status-bar-height': statusbarHeight + 'px',
}
if (__DEV__) {
console.log(formatLog('initCssVar', cssVars))
}
updateCssVar(cssVars)
}
function initPageScroll(
onPageScroll: boolean,
onPageReachBottom: boolean,
onReachBottomDistance: number
) {
const opts: CreateScrollListenerOptions = {}
if (onPageScroll) {
opts.onPageScroll = (scrollTop) => {
UniViewJSBridge.publishHandler('onPageScroll', { scrollTop })
}
}
if (onPageReachBottom) {
opts.onReachBottomDistance = onReachBottomDistance
opts.onReachBottom = () => UniViewJSBridge.publishHandler('onReachBottom')
}
// 避免监听太早,直接触发了 scroll
requestAnimationFrame(() =>
document.addEventListener('scroll', createScrollListener(opts))
)
}
import { ON_WEBVIEW_READY } from '../constants' import { ON_WEBVIEW_READY } from '../constants'
import { UniViewJSBridge } from './bridge' import { UniViewJSBridge } from './bridge'
import { initView } from './framework'
;(window as any).UniViewJSBridge = UniViewJSBridge ;(window as any).UniViewJSBridge = UniViewJSBridge
function onWebviewReady() { function onWebviewReady() {
initView()
UniViewJSBridge.publishHandler(ON_WEBVIEW_READY) UniViewJSBridge.publishHandler(ON_WEBVIEW_READY)
} }
if (typeof plus !== 'undefined') { if (typeof plus !== 'undefined') {
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"__VUE_OPTIONS_API__": "true", "__VUE_OPTIONS_API__": "true",
"__VUE_PROD_DEVTOOLS__": "false" "__VUE_PROD_DEVTOOLS__": "false"
}, },
"external": false "external": false,
"babel": true
}, },
{ {
"input": { "input": {
......
...@@ -737,7 +737,7 @@ var safeAreaInsets = { ...@@ -737,7 +737,7 @@ var safeAreaInsets = {
onChange, onChange,
offChange offChange
}; };
var D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out = safeAreaInsets; var out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => { const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]); }, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => { const onEventStop = /* @__PURE__ */ withModifiers(() => {
...@@ -749,10 +749,10 @@ function getWindowOffset() { ...@@ -749,10 +749,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left")); const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right")); const right = parseInt(style.getPropertyValue("--window-right"));
return { return {
top: top ? top + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top : 0, top: top ? top + out.top : 0,
bottom: bottom ? bottom + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom : 0, bottom: bottom ? bottom + out.bottom : 0,
left: left ? left + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left : 0, left: left ? left + out.left : 0,
right: right ? right + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right : 0 right: right ? right + out.right : 0
}; };
} }
function updateCssVar(cssVars) { function updateCssVar(cssVars) {
...@@ -13071,7 +13071,7 @@ function normalizePageMeta(pageMeta) { ...@@ -13071,7 +13071,7 @@ function normalizePageMeta(pageMeta) {
}, pageMeta.pullToRefresh)); }, pageMeta.pullToRefresh));
const { type, style } = navigationBar; const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") { if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += NAVBAR_HEIGHT + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top; pullToRefresh.offset += NAVBAR_HEIGHT + out.top;
} }
pageMeta.pullToRefresh = pullToRefresh; pageMeta.pullToRefresh = pullToRefresh;
} }
...@@ -15246,7 +15246,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15246,7 +15246,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth); const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight; let windowHeight = window.innerHeight;
const language = navigator.language; const language = navigator.language;
const statusBarHeight = D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top; const statusBarHeight = out.top;
let osname; let osname;
let osversion; let osversion;
let model; let model;
...@@ -15359,12 +15359,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15359,12 +15359,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`; const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase(); const platform = osname.toLocaleLowerCase();
const safeArea = { const safeArea = {
left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left, left: out.left,
right: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, right: windowWidth - out.right,
top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top, top: out.top,
bottom: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom, bottom: windowHeight - out.bottom,
width: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, width: windowWidth - out.left - out.right,
height: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom height: windowHeight - out.top - out.bottom
}; };
const { top: windowTop, bottom: windowBottom } = getWindowOffset(); const { top: windowTop, bottom: windowBottom } = getWindowOffset();
windowHeight -= windowTop; windowHeight -= windowTop;
...@@ -15384,10 +15384,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15384,10 +15384,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model, model,
safeArea, safeArea,
safeAreaInsets: { safeAreaInsets: {
top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top, top: out.top,
right: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right, right: out.right,
bottom: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom, bottom: out.bottom,
left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left left: out.left
} }
}; };
}); });
......
...@@ -17,17 +17,9 @@ export function initExtraPlugins(cliRoot: string, platform: UniApp.PLATFORM) { ...@@ -17,17 +17,9 @@ export function initExtraPlugins(cliRoot: string, platform: UniApp.PLATFORM) {
return initPlugins(resolvePlugins(cliRoot, platform)) return initPlugins(resolvePlugins(cliRoot, platform))
} }
function initPlugin(plugin: PluginConfig): Plugin | void { function initPlugin({ id, config: { main } }: PluginConfig): Plugin | void {
const configFile = path.join( const plugin = require(path.join(id, main || '/lib/uni.plugin.js'))
plugin.id, return plugin.default || plugin
plugin.config.main || '/lib/uni.plugin.js'
)
try {
const plugin = require(configFile)
return plugin.default || plugin
} catch (e) {
console.warn(`${configFile} not found`)
}
} }
function initPlugins(plugins: PluginConfig[]): Plugin[] { function initPlugins(plugins: PluginConfig[]): Plugin[] {
......
...@@ -6,6 +6,7 @@ import json from '@rollup/plugin-json' ...@@ -6,6 +6,7 @@ import json from '@rollup/plugin-json'
import alias from '@rollup/plugin-alias' import alias from '@rollup/plugin-alias'
import nodeResolve from '@rollup/plugin-node-resolve' import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs' import commonjs from '@rollup/plugin-commonjs'
import { getBabelOutputPlugin } from '@rollup/plugin-babel'
if (!process.env.TARGET) { if (!process.env.TARGET) {
throw new Error('TARGET package must be specified via --environment flag.') throw new Error('TARGET package must be specified via --environment flag.')
...@@ -111,20 +112,27 @@ function createConfig(entryFile, output, buildOption) { ...@@ -111,20 +112,27 @@ function createConfig(entryFile, output, buildOption) {
...Object.keys(pkg.peerDependencies || {}), ...Object.keys(pkg.peerDependencies || {}),
...(buildOption.external || []), ...(buildOption.external || []),
] ]
const plugins = [
createAliasPlugin(buildOption),
nodeResolve(),
commonjs(),
json({
namedExports: false,
}),
tsPlugin,
createReplacePlugin(buildOption, output.format),
]
if (buildOption.babel) {
plugins.push(
getBabelOutputPlugin({
presets: [['@babel/preset-env', { targets: ['iOS 9'] }]],
})
)
}
return { return {
input: resolve(entryFile), input: resolve(entryFile),
external, external,
plugins: [ plugins,
createAliasPlugin(buildOption),
nodeResolve(),
commonjs(),
json({
namedExports: false,
}),
tsPlugin,
createReplacePlugin(buildOption, output.format),
],
output, output,
onwarn: (msg, warn) => { onwarn: (msg, warn) => {
// if (!/Circular/.test(msg)) { // if (!/Circular/.test(msg)) {
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册