Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function dealWithPage(evt, window, value) {
const type = evt.type
let url = evt.url
if (value === 'webview') {
// 补全 url
url = mp.$$adapter.tool.completeURL(url, window.location.origin)
const options = {url: `/pages/webview/index?url=${encodeURIComponent(url)}`}
if (type === 'jump') wx.redirectTo(options)
else if (type === 'open') wx.navigateTo(options)
} else if (value === 'error') {
console.error(`page not found: ${evt.url}`)
} else if (value !== 'none') {
const targeturl = `${window.location.origin}/redirect?url=${encodeURIComponent(url)}`
const options = {url: `/pages/${value}/index?type=${type}&targeturl=${encodeURIComponent(targeturl)}`}
if (window.$$miniprogram.isTabBarPage(`/pages/${value}/index`)) wx.switchTab(options)
else if (type === 'jump') wx.redirectTo(options)
else if (type === 'open') wx.navigateTo(options)
}
}
const mp = require('miniprogram-render')
const _ = require('./tool')
const component = require('./component')
const {
Event,
} = mp.$$adapter
const {
WX_COMP_NAME_MAP,
NOT_SUPPORT,
} = _
module.exports = {
/**
* 初始化
*/
init(data) {
const domNode = this.domNode
const tagName = domNode.tagName
if (tagName === 'WX-COMPONENT') {
// 无可替换 html 标签
data.wxCompName = domNode.$$behavior
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
// 处理跳转受限制页面的情况
if (config.redirect && config.redirect.accessDenied) {
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
// 写入 page 的方法
if (typeof this.getTabBar === 'function') this.window.getTabBar = this.getTabBar.bind(this)
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
// 处理跳转受限制页面的情况
if (config.redirect && config.redirect.accessDenied) {
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
// 写入 page 的方法
if (typeof this.getTabBar === 'function') this.window.getTabBar = this.getTabBar.bind(this)
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
// 处理跳转受限制页面的情况
if (config.redirect && config.redirect.accessDenied) {
onLoad(query) {
const pageName = mp.$$adapter.tool.getPageName(this.route)
const pageConfig = this.pageConfig = config.pages[pageName] || {}
if (pageConfig.loadingText) {
wx.showLoading({
title: pageConfig.loadingText,
mask: true,
})
}
const mpRes = mp.createPage(this.route, config)
this.pageId = mpRes.pageId
this.window = mpRes.window
this.document = mpRes.document
this.query = query
init(this.window, this.document)
// 处理跳转页面不存在的情况
if (config.redirect && config.redirect.notFound) {
this.window.addEventListener('pagenotfound', evt => {
dealWithPage(evt, mpRes.window, config.redirect.notFound)
})
}
// 处理跳转受限制页面的情况
if (config.redirect && config.redirect.accessDenied) {
const mp = require('miniprogram-render')
const _ = require('./util/tool')
const initHandle = require('./util/init-handle')
const component = require('./util/component')
const {
cache,
EventTarget,
tool,
} = mp.$$adapter
const {
NOT_SUPPORT,
} = _
const {
wxCompNameMap,
} = component
// dom 子树作为自定义组件渲染的层级数
const MAX_DOM_SUB_TREE_LEVEL = 10
let DOM_SUB_TREE_LEVEL = 10
Component({
properties: {
inCover: {
type: Boolean,
value: false,
const mp = require('miniprogram-render')
const _ = require('./util/tool')
const initHandle = require('./util/init-handle')
const {
cache,
EventTarget,
tool,
} = mp.$$adapter
const {
WX_COMP_NAME_MAP,
NOT_SUPPORT,
} = _
// dom 子树作为自定义组件渲染的层级数
const MAX_DOM_SUB_TREE_LEVEL = 10
let DOM_SUB_TREE_LEVEL = 10
Component({
properties: {
inCover: {
type: Boolean,
value: false,
},
},