提交 64ea76e3 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

......@@ -7681,7 +7681,7 @@ var serviceContext = (function () {
return webview
}
function initWebview (webview, routeOptions) {
function initWebview (webview, routeOptions, url = '') {
// 首页或非 nvue 页面
if (webview.id === '1' || !routeOptions.meta.isNVue) {
const webviewStyle = parseWebviewStyle(
......@@ -7689,6 +7689,17 @@ var serviceContext = (function () {
'',
routeOptions
);
if (url) {
const part = url.split('?');
webviewStyle.debugRefresh = {
isTab: routeOptions.meta.isTabBar,
arguments: JSON.stringify({
path: part[0].substr(1),
query: part[1] || ''
})
};
}
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] updateWebview`, webviewStyle);
}
......@@ -7881,7 +7892,8 @@ var serviceContext = (function () {
/**
* 首页需要主动registerPage,二级页面路由跳转时registerPage
*/
function registerPage ({
function registerPage ({
url,
path,
query,
openType,
......@@ -7920,7 +7932,7 @@ var serviceContext = (function () {
console.log(`[uni-app] registerPage`, path, webview.id);
}
initWebview(webview, routeOptions);
initWebview(webview, routeOptions, url);
const route = path.slice(1);
......@@ -7986,6 +7998,7 @@ var serviceContext = (function () {
}
function _navigateTo ({
url,
path,
query,
animationType,
......@@ -7998,6 +8011,7 @@ var serviceContext = (function () {
showWebview(
registerPage({
url,
path,
query,
openType: 'navigate'
......@@ -8020,18 +8034,19 @@ var serviceContext = (function () {
animationDuration
}, callbackId) {
const urls = url.split('?');
const path = urls[0];
const routeStyles = __uniRoutes.find(route => route.path === path).window;
const globalStyle = __uniConfig.window;
if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW;
}
if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION;
const path = urls[0];
const routeStyles = __uniRoutes.find(route => route.path === path).window;
const globalStyle = __uniConfig.window;
if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW;
}
if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION;
}
const query = parseQuery(urls[1] || '');
navigate(path, function () {
_navigateTo({
url,
path,
query,
animationType,
......@@ -8041,6 +8056,7 @@ var serviceContext = (function () {
}
function _reLaunch ({
url,
path,
query
}, callbackId) {
......@@ -8054,6 +8070,7 @@ var serviceContext = (function () {
showWebview(
registerPage({
url,
path,
query,
openType: 'reLaunch'
......@@ -8082,6 +8099,7 @@ var serviceContext = (function () {
const query = parseQuery(urls[1] || '');
navigate(path, function () {
_reLaunch({
url,
path,
query
}, callbackId);
......@@ -8089,6 +8107,7 @@ var serviceContext = (function () {
}
function _redirectTo ({
url,
path,
query
}, callbackId) {
......@@ -8099,6 +8118,7 @@ var serviceContext = (function () {
showWebview(
registerPage({
url,
path,
query,
openType: 'redirect'
......@@ -8123,6 +8143,7 @@ var serviceContext = (function () {
const query = parseQuery(urls[1] || '');
navigate(path, function () {
_redirectTo({
url,
path,
query
}, callbackId);
......@@ -8130,6 +8151,7 @@ var serviceContext = (function () {
}
function _switchTab ({
url,
path,
from
}, callbackId) {
......@@ -8180,6 +8202,7 @@ var serviceContext = (function () {
tabBarPage.$getAppWebview().show('none');
} else {
return showWebview(registerPage({
url,
path,
query: {},
openType: 'switchTab'
......@@ -8205,6 +8228,7 @@ var serviceContext = (function () {
const path = url.split('?')[0];
navigate(path, function () {
_switchTab({
url,
path,
from
}, callbackId);
......@@ -9451,10 +9475,12 @@ var serviceContext = (function () {
];
var tempCanvas;
function getTempCanvas () {
function getTempCanvas (width = 0, height = 0) {
if (!tempCanvas) {
tempCanvas = document.createElement('canvas');
}
tempCanvas.width = width;
tempCanvas.height = height;
return tempCanvas
}
......@@ -11771,7 +11797,7 @@ var serviceContext = (function () {
const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo';
process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`);
return uni[navigateType]({
url: entryPagePath,
url: entryPagePath + (__uniConfig.entryPageQuery || ''),
openType: 'appLaunch'
})
}
......@@ -12003,28 +12029,39 @@ var serviceContext = (function () {
});
}
function initHotReload () {
const reloadUrl = weex.config.reloadUrl;
if (!reloadUrl) {
function initEntryPage () {
const argsJsonStr = plus.runtime.arguments;
if (!argsJsonStr) {
return
}
if (reloadUrl === __uniConfig.entryPagePath) {
let entryPagePath;
let entryPageQuery;
try {
const args = JSON.parse(argsJsonStr);
entryPagePath = args.path || args.pathName;
entryPageQuery = (args.query ? ('?' + args.query) : '');
} catch (e) {}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return
}
const reloadPath = '/' + reloadUrl;
const routeOptions = __uniRoutes.find(route => route.path === reloadPath);
const entryRoute = '/' + entryPagePath;
const routeOptions = __uniRoutes.find(route => route.path === entryRoute);
if (!routeOptions) {
return
}
if (routeOptions.meta.isNVue) { // 暂不处理 nvue
return
}
if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath;
}
__uniConfig.entryPagePath = reloadUrl;
__uniConfig.entryPagePath = entryPagePath;
__uniConfig.entryPageQuery = entryPageQuery;
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] reloadUrl(${reloadUrl})`);
console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`);
}
}
......@@ -12046,7 +12083,7 @@ var serviceContext = (function () {
getCurrentPages: getCurrentPages$1
});
initHotReload();
initEntryPage();
initTabBar();
......
......@@ -39,7 +39,7 @@ module.exports = function migrate(input, out, options = {}) {
)
) {
options.silent !== true && console.log(`copy: ${dest}`)
fs.copySync(src, dest)
src !== dest && fs.copySync(src, dest)
}
} else {
options.silent !== true && console.log(`write: ${path.resolve(out, asset.path)}`)
......
......@@ -89,13 +89,6 @@ const v3 = {
loader: path.resolve(__dirname,
'../../packages/webpack-uni-app-loader/view/script')
})
// view 层 renderjs
// rules.push({
// resourceQuery: [/lang=renderjs/, /blockType=renderjs/],
// use: [{
// loader: path.resolve(__dirname, '../../packages/webpack-uni-app-loader/view/renderjs')
// }]
// })
}
scriptLoaders.push({
loader: path.resolve(__dirname,
......
......@@ -28,6 +28,7 @@ module.exports = function modifyVueLoader (webpackConfig, compilerOptions, api)
.use('vue-loader')
.loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vue-loader'))
.tap(options => Object.assign(options, {
isH5: process.env.UNI_PLATFORM === 'h5',
compiler: getPlatformCompiler(),
compilerOptions: Object.assign({
isUnaryTag,
......@@ -35,11 +36,11 @@ module.exports = function modifyVueLoader (webpackConfig, compilerOptions, api)
}, compilerOptions)
}, cacheConfig))
.end()
// .use('uniapp-custom-block-loader')
// .loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader'))
// .options({
// compiler: getPlatformCompiler()
// })
// .use('uniapp-custom-block-loader')
// .loader(require.resolve('@dcloudio/vue-cli-plugin-uni/packages/webpack-custom-block-loader'))
// .options({
// compiler: getPlatformCompiler()
// })
// h5 框架需要使用 scoped 样式,其他平台编译时识别是否 nvue 文件且注入 flex 相关样式
if (process.env.UNI_PLATFORM === 'h5') {
......
const {
getPlatformFilterTag,
normalizeNodeModules
normalizeNodeModules,
jsPreprocessOptions
} = require('@dcloudio/uni-cli-shared/lib/platform')
const preprocessor = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-preprocess-loader/preprocess')
const FILTER_TAG = getPlatformFilterTag()
function preprocessBlock(block) {
if (block.content) {
block.content = preprocessor.preprocess(block.content, jsPreprocessOptions.context, {
type: jsPreprocessOptions.type
}).trim()
}
return block
}
module.exports = function parseCustomBlocks(descriptor, options) {
if (!descriptor.template || !FILTER_TAG || options.isAppNVue) {
......@@ -23,7 +35,7 @@ module.exports = function parseCustomBlocks(descriptor, options) {
block.attrs.lang === FILTER_TAG
)
) {
modules[block.attrs.module] = block
modules[block.attrs.module] = preprocessBlock(block)
return true
}
if ( // renderjs
......@@ -33,7 +45,7 @@ module.exports = function parseCustomBlocks(descriptor, options) {
block.attrs.lang === 'renderjs'
)
) {
descriptor.renderjs = block
descriptor.renderjs = preprocessBlock(block)
modules[block.attrs.module] = Object.assign({}, block, {
content: ''
})
......
......@@ -142,7 +142,7 @@ module.exports = function (source) {
}
let renderjsImport = `var renderjs`
if(options.isAppView && descriptor.renderjs){
if((options.isAppView || options.isH5) && descriptor.renderjs){
const src = descriptor.renderjs.src || resourcePath
const attrsQuery = attrsToQuery(descriptor.renderjs.attrs, 'js')
const query = `?vue&type=renderjs${attrsQuery}${inheritQuery}`
......
......@@ -33,8 +33,10 @@ function parseEntryPagePath (appJson, manifestJson) {
try {
const args = JSON.parse(argsJsonStr)
const pathName = args.path || args.pathName
const entryPageQuery = (args.query ? ('?' + args.query) : '')
if (pathName && appJson.pages[0] !== pathName) {
appJson.entryPagePath = pathName
appJson.entryPageQuery = entryPageQuery
if (!isTabBarPage(pathName, getTabBarPages(appJson))) {
appJson.realEntryPagePath = appJson.pages[0]
}
......@@ -83,7 +85,7 @@ module.exports = function (appJson, manifestJson, {
if (appJson.page[appJson.entryPagePath].nvue) { // 首页是 nvue
manifestJson.launch_path = '' // 首页地址为空
manifestJson.plus.launchwebview.uniNView = {
path: appJson.entryPagePath
path: appJson.entryPagePath + '.js' + (appJson.entryPageQuery || '')
}
if (manifestJson.plus.tabBar) {
manifestJson.plus.tabBar.child = ['lauchwebview']
......@@ -100,4 +102,4 @@ module.exports = function (appJson, manifestJson, {
manifest.content = JSON.stringify(manifest.content)
delete appJson.nvue
return [manifest, definePages(appJson), appConfigService(appJson)]
}
}
import {
parseQuery
} from 'uni-shared'
} from 'uni-shared'
import {
ANI_SHOW,
ANI_DURATION
......@@ -25,6 +25,7 @@ import {
} from '../../framework/navigator'
function _navigateTo ({
url,
path,
query,
animationType,
......@@ -37,6 +38,7 @@ function _navigateTo ({
showWebview(
registerPage({
url,
path,
query,
openType: 'navigate'
......@@ -59,22 +61,23 @@ export function navigateTo ({
animationDuration
}, callbackId) {
const urls = url.split('?')
const path = urls[0]
const routeStyles = __uniRoutes.find(route => route.path === path).window
const globalStyle = __uniConfig.window
if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW
}
if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION
const path = urls[0]
const routeStyles = __uniRoutes.find(route => route.path === path).window
const globalStyle = __uniConfig.window
if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW
}
if (!animationDuration) {
animationDuration = routeStyles.animationDuration || globalStyle.animationDuration || ANI_DURATION
}
const query = parseQuery(urls[1] || '')
navigate(path, function () {
_navigateTo({
url,
path,
query,
animationType,
animationDuration
}, callbackId)
}, openType === 'appLaunch')
}
}
......@@ -22,6 +22,7 @@ import {
} from '../../framework/navigator'
function _reLaunch ({
url,
path,
query
}, callbackId) {
......@@ -35,6 +36,7 @@ function _reLaunch ({
showWebview(
registerPage({
url,
path,
query,
openType: 'reLaunch'
......@@ -63,6 +65,7 @@ export function reLaunch ({
const query = parseQuery(urls[1] || '')
navigate(path, function () {
_reLaunch({
url,
path,
query
}, callbackId)
......
......@@ -20,6 +20,7 @@ import {
} from '../../framework/navigator'
function _redirectTo ({
url,
path,
query
}, callbackId) {
......@@ -30,6 +31,7 @@ function _redirectTo ({
showWebview(
registerPage({
url,
path,
query,
openType: 'redirect'
......@@ -54,6 +56,7 @@ export function redirectTo ({
const query = parseQuery(urls[1] || '')
navigate(path, function () {
_redirectTo({
url,
path,
query
}, callbackId)
......
......@@ -23,6 +23,7 @@ import {
import tabBar from '../../framework/tab-bar'
function _switchTab ({
url,
path,
from
}, callbackId) {
......@@ -73,6 +74,7 @@ function _switchTab ({
tabBarPage.$getAppWebview().show('none')
} else {
return showWebview(registerPage({
url,
path,
query: {},
openType: 'switchTab'
......@@ -98,8 +100,9 @@ export function switchTab ({
const path = url.split('?')[0]
navigate(path, function () {
_switchTab({
url,
path,
from
}, callbackId)
}, openType === 'appLaunch')
}
}
......@@ -140,28 +140,39 @@ function initTabBar () {
})
}
function initHotReload () {
const reloadUrl = weex.config.reloadUrl
if (!reloadUrl) {
function initEntryPage () {
const argsJsonStr = plus.runtime.arguments
if (!argsJsonStr) {
return
}
if (reloadUrl === __uniConfig.entryPagePath) {
let entryPagePath
let entryPageQuery
try {
const args = JSON.parse(argsJsonStr)
entryPagePath = args.path || args.pathName
entryPageQuery = (args.query ? ('?' + args.query) : '')
} catch (e) {}
if (!entryPagePath || entryPagePath === __uniConfig.entryPagePath) {
return
}
const reloadPath = '/' + reloadUrl
const routeOptions = __uniRoutes.find(route => route.path === reloadPath)
const entryRoute = '/' + entryPagePath
const routeOptions = __uniRoutes.find(route => route.path === entryRoute)
if (!routeOptions) {
return
}
if (routeOptions.meta.isNVue) { // 暂不处理 nvue
return
}
if (!routeOptions.meta.isTabBar) {
__uniConfig.realEntryPagePath = __uniConfig.realEntryPagePath || __uniConfig.entryPagePath
}
__uniConfig.entryPagePath = reloadUrl
__uniConfig.entryPagePath = entryPagePath
__uniConfig.entryPageQuery = entryPageQuery
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] reloadUrl(${reloadUrl})`)
console.log(`[uni-app] entryPagePath(${entryPagePath + entryPageQuery})`)
}
}
......@@ -183,7 +194,7 @@ export function registerApp (appVm) {
getCurrentPages
})
initHotReload()
initEntryPage()
initTabBar()
......
......@@ -24,7 +24,8 @@ export function getCurrentPages (returnAll) {
/**
* 首页需要主动registerPage,二级页面路由跳转时registerPage
*/
export function registerPage ({
export function registerPage ({
url,
path,
query,
openType,
......@@ -63,7 +64,7 @@ export function registerPage ({
console.log(`[uni-app] registerPage`, path, webview.id)
}
initWebview(webview, routeOptions)
initWebview(webview, routeOptions, url)
const route = path.slice(1)
......
......@@ -38,7 +38,7 @@ export default function onWebviewReady (data, pageId) {
const navigateType = routeOptions.meta.isTabBar ? 'switchTab' : 'navigateTo'
process.env.NODE_ENV !== 'production' && perf(`${entryPagePath} navigateTo`)
return uni[navigateType]({
url: entryPagePath,
url: entryPagePath + (__uniConfig.entryPageQuery || ''),
openType: 'appLaunch'
})
}
......
......@@ -63,7 +63,7 @@ export function createWebview (path, routeOptions) {
return webview
}
export function initWebview (webview, routeOptions) {
export function initWebview (webview, routeOptions, url = '') {
// 首页或非 nvue 页面
if (webview.id === '1' || !routeOptions.meta.isNVue) {
const webviewStyle = parseWebviewStyle(
......@@ -71,6 +71,17 @@ export function initWebview (webview, routeOptions) {
'',
routeOptions
)
if (url) {
const part = url.split('?')
webviewStyle.debugRefresh = {
isTab: routeOptions.meta.isTabBar,
arguments: JSON.stringify({
path: part[0].substr(1),
query: part[1] || ''
})
}
}
if (process.env.NODE_ENV !== 'production') {
console.log(`[uni-app] updateWebview`, webviewStyle)
}
......
......@@ -49,7 +49,7 @@
class="uni-video-control-button"
@click.stop="trigger"
/>
<div class="uni-video-current-time">{{ currentTime|getTime }}</div>
<div class="uni-video-current-time">{{ currentTime|time }}</div>
<div
ref="progress"
class="uni-video-progress-container"
......@@ -67,7 +67,7 @@
</div>
</div>
</div>
<div class="uni-video-duration">{{ (duration||durationTime)|getTime }}</div>
<div class="uni-video-duration">{{ (duration||durationTime)|time }}</div>
</div>
<div
v-if="danmuBtn"
......@@ -94,7 +94,7 @@
<div
class="uni-video-cover-play-button"
@click.stop="play" />
<p class="uni-video-cover-duration">{{ (duration||durationTime)|getTime }}</p>
<p class="uni-video-cover-duration">{{ (duration||durationTime)|time }}</p>
</div>
<div
:class="{'uni-video-toast-volume':gestureType==='volume'}"
......@@ -129,7 +129,7 @@
<div
:class="{'uni-video-toast-progress':gestureType=='progress'}"
class="uni-video-toast">
<div class="uni-video-toast-title">{{ currentTimeNew|getTime }} / {{ durationTime|getTime }}</div>
<div class="uni-video-toast-title">{{ currentTimeNew|time }} / {{ durationTime|time }}</div>
</div>
</div>
<div
......@@ -162,10 +162,11 @@ const GestureType = {
export default {
name: 'Video',
filters: {
getTime (time) {
let h = Math.floor(time / 3600)
let m = Math.floor(time % 3600 / 60)
let s = Math.floor(time % 3600 % 60)
time (val) {
val = val > 0 && val < Infinity ? val : 0
let h = Math.floor(val / 3600)
let m = Math.floor(val % 3600 / 60)
let s = Math.floor(val % 3600 % 60)
h = (h < 10 ? '0' : '') + h
m = (m < 10 ? '0' : '') + m
s = (s < 10 ? '0' : '') + s
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册