提交 1d08c3c8 编写于 作者: fxy060608's avatar fxy060608

调整部分代码,方便支持optimize

上级 9063ea96
......@@ -28,7 +28,8 @@ module.exports = {
'uni-shared': resolve('src/shared'),
'uni-mixins': resolve('src/core/view/mixins'),
'uni-helpers': resolve('src/core/helpers'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM)
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-components': resolve('src/core/view/components')
}
},
module: {
......
......@@ -40,6 +40,7 @@ config.plugins = config.plugins.concat([
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}),
new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge')],
'UniServiceJSBridge': [resolve('src/core/service/bridge')]
})
......
......@@ -20,8 +20,8 @@ const {
} = require('uni-service')
global.uni = Object.assign(uni, require('uni-view').default)
global.wx = global.uni
global.wx = global.uni
global.getApp = getApp
global.getCurrentPages = getCurrentPages
......@@ -34,4 +34,6 @@ Vue.use(require('uni-view/plugins').default, {
routes: __uniRoutes
})
require('uni-view/components')
require('uni-core/vue')
require('uni-platform/components')
require('uni-components')
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
import Vue from 'vue'
// 使用白名单过滤(前期有一批自定义组件使用了 uni-)
import tags from 'uni-helpers/tags'
import baseMixin from 'uni-mixins/base'
// const uniRegex = /^uni-/i
// const htmlRegex = /^html:/i
// const svgRegex = /^svg:/i
const oldIsReservedTag = Vue.config.isReservedTag
Vue.config.isReservedTag = function (tag) {
return tags.indexOf(tag) !== -1 || oldIsReservedTag(tag)
}
// Vue.config.parsePlatformTagName = function(tag) {
// return tag.replace(htmlRegex, '').replace(svgRegex, '')
// }
Vue.config.ignoredElements = tags
const oldGetTagNamespace = Vue.config.getTagNamespace
const conflictTags = ['switch', 'image', 'text', 'view']
Vue.config.getTagNamespace = function (tag) {
if (~conflictTags.indexOf(tag)) { // svg 部分标签名称与 uni 标签冲突
return false
}
return oldGetTagNamespace(tag) || false
}
Vue.config.errorHandler = function (err, vm, info) {
console.error('errorHandler', err, vm, info)
}
const requireComponents = [
// frameworkComponents
/* eslint-disable no-undef */
require.context('../../../platforms/' + __PLATFORM__ + '/components', true, /index\.vue$/),
// baseComponents
require.context('./', true, /index\.vue$/),
require.context('../../../platforms/' + __PLATFORM__ + '/view/components', true, /index\.vue$/)
......@@ -54,9 +17,7 @@ requireComponents.forEach((components, index) => {
componentConfig.mixins = componentConfig.mixins ? [].concat(baseMixin, componentConfig.mixins) : [baseMixin]
if (index > 0) {
componentConfig.name = 'VUni' + componentConfig.name
}
componentConfig.name = 'VUni' + componentConfig.name
// 全局注册组件
Vue.component(componentConfig.name, componentConfig)
......
import Vue from 'vue'
// 使用白名单过滤(前期有一批自定义组件使用了 uni-)
import tags from 'uni-helpers/tags'
const oldIsReservedTag = Vue.config.isReservedTag
Vue.config.isReservedTag = function (tag) {
return tags.indexOf(tag) !== -1 || oldIsReservedTag(tag)
}
Vue.config.ignoredElements = tags
const oldGetTagNamespace = Vue.config.getTagNamespace
const conflictTags = ['switch', 'image', 'text', 'view']
Vue.config.getTagNamespace = function (tag) {
if (~conflictTags.indexOf(tag)) { // svg 部分标签名称与 uni 标签冲突
return false
}
return oldGetTagNamespace(tag) || false
}
Vue.config.errorHandler = function (err, vm, info) {
console.error('errorHandler', err, vm, info)
}
import Vue from 'vue'
import App from './app'
import Page from './page'
import AsyncError from './async-error'
import AsyncLoading from './async-loading'
import ChooseLocation from './system-routes/choose-location'
import OpenLocation from './system-routes/open-location'
import PreviewImage from './system-routes/preview-image'
Vue.component(App.name, App)
Vue.component(Page.name, Page)
Vue.component(AsyncError.name, AsyncError)
Vue.component(AsyncLoading.name, AsyncLoading)
Vue.component(ChooseLocation.name, ChooseLocation)
Vue.component(OpenLocation.name, OpenLocation)
Vue.component(PreviewImage.name, PreviewImage)
<template>
<div class="uni-system-choose-location">
<template>
<div class="uni-system-choose-location">
<system-header
:confirm="!!data"
@back="_back"
@confirm="_choose">选择位置</system-header>
<div class="map-content">
@confirm="_choose">选择位置</system-header>
<div class="map-content">
<iframe
:src="src"
allow="geolocation"
seamless
sandbox="allow-scripts allow-same-origin allow-forms"
frameborder="0"/>
</div>
</div>
</template>
<script>
export default {
frameborder="0" />
</div>
</div>
</template>
<script>
import SystemHeader from '../system-header'
export default {
name: 'SystemChooseLocation',
data () {
return {
src: '',
data: null
}
},
mounted () {
var key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS'
this.src = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp`
window.addEventListener('message', (event) => {
var loc = event.data
if (loc && loc.module === 'locationPicker') {
this.data = {
name: loc.poiname,
address: loc.poiaddress,
latitude: loc.latlng.lat,
longitude: loc.latlng.lng
}
}
}, false)
},
methods: {
_choose () {
if (this.data) {
UniViewJSBridge.publishHandler('onChooseLocation', this.data)
getApp().$router.back()
}
},
_back () {
UniViewJSBridge.publishHandler('onChooseLocation', null)
getApp().$router.back()
}
}
}
</script>
<style>
.uni-system-choose-location {
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f8f8f8;
}
.map-content {
position: absolute;
left: 0;
top: 44px;
width: 100%;
bottom: 0;
overflow: hidden;
}
.map-content > iframe {
width: 100%;
height: 100%;
}
components: {
SystemHeader
},
data () {
return {
src: '',
data: null
}
},
mounted () {
var key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS'
this.src = `https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=uniapp`
window.addEventListener('message', (event) => {
var loc = event.data
if (loc && loc.module === 'locationPicker') {
this.data = {
name: loc.poiname,
address: loc.poiaddress,
latitude: loc.latlng.lat,
longitude: loc.latlng.lng
}
}
}, false)
},
methods: {
_choose () {
if (this.data) {
UniViewJSBridge.publishHandler('onChooseLocation', this.data)
getApp().$router.back()
}
},
_back () {
UniViewJSBridge.publishHandler('onChooseLocation', null)
getApp().$router.back()
}
}
}
</script>
<style>
.uni-system-choose-location {
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f8f8f8;
}
.map-content {
position: absolute;
left: 0;
top: 44px;
width: 100%;
bottom: 0;
overflow: hidden;
}
.map-content>iframe {
width: 100%;
height: 100%;
}
</style>
<template>
<div class="uni-system-open-location">
<system-header @back="_back">位置</system-header>
<div class="map-content">
<template>
<div class="uni-system-open-location">
<system-header @back="_back">位置</system-header>
<div class="map-content">
<iframe
ref="map"
:src="src"
allow="geolocation"
sandbox="allow-scripts allow-same-origin allow-forms"
frameborder="0"
@load="_load"/>
<!-- 去这里 -->
frameborder="0"
@load="_load" />
<!-- 去这里 -->
<div
v-if="isPoimarkerSrc"
class="actTonav"
@click="_nav"/>
</div>
</div>
</template>
<script>
const key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS'
const referer = 'uniapp'
const poimarkerSrc = 'https://apis.map.qq.com/tools/poimarker'
export default {
name: 'SystemOpenLocation',
data () {
const {
latitude,
longitude,
scale,
name,
address
} = this.$route.params
return {
latitude,
longitude,
scale,
name,
address,
src: '',
isPoimarkerSrc: false
}
},
mounted () {
if (this.latitude && this.longitude) {
this.src = `${poimarkerSrc}?type=0&marker=coord:${this.latitude},${this.longitude};title:${this.name};addr:${this.address};&key=${key}&referer=${referer}`
}
},
methods: {
_back () {
if (this.$refs.map.src.indexOf(poimarkerSrc) !== 0) {
this.$refs.map.src = this.src
} else {
getApp().$router.back()
}
},
_load () {
if (this.$refs.map.src.indexOf(poimarkerSrc) === 0) {
this.isPoimarkerSrc = true
} else {
this.isPoimarkerSrc = false
}
},
_nav () {
var url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive&to=${encodeURIComponent(this.name)}&tocoord=${this.latitude},${this.longitude}&referer=${referer}`
this.$refs.map.src = url
}
}
}
</script>
<style>
.uni-system-open-location {
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f8f8f8;
}
.map-content {
position: absolute;
left: 0;
top: 44px;
width: 100%;
bottom: 0;
overflow: hidden;
}
.map-content > iframe {
width: 100%;
height: 100%;
border: none;
}
.actTonav {
position: absolute;
right: 16px;
bottom: 56px;
width: 60px;
height: 60px;
border-radius: 60px;
}
@click="_nav" />
</div>
</div>
</template>
<script>
import SystemHeader from '../system-header'
const key = 'WXTBZ-6WERU-ECCVS-BZJCK-LW5OJ-SIBOS'
const referer = 'uniapp'
const poimarkerSrc = 'https://apis.map.qq.com/tools/poimarker'
export default {
name: 'SystemOpenLocation',
components: {
SystemHeader
},
data () {
const {
latitude,
longitude,
scale,
name,
address
} = this.$route.params
return {
latitude,
longitude,
scale,
name,
address,
src: '',
isPoimarkerSrc: false
}
},
mounted () {
if (this.latitude && this.longitude) {
this.src =
`${poimarkerSrc}?type=0&marker=coord:${this.latitude},${this.longitude};title:${this.name};addr:${this.address};&key=${key}&referer=${referer}`
}
},
methods: {
_back () {
if (this.$refs.map.src.indexOf(poimarkerSrc) !== 0) {
this.$refs.map.src = this.src
} else {
getApp().$router.back()
}
},
_load () {
if (this.$refs.map.src.indexOf(poimarkerSrc) === 0) {
this.isPoimarkerSrc = true
} else {
this.isPoimarkerSrc = false
}
},
_nav () {
var url =
`https://apis.map.qq.com/uri/v1/routeplan?type=drive&to=${encodeURIComponent(this.name)}&tocoord=${this.latitude},${this.longitude}&referer=${referer}`
this.$refs.map.src = url
}
}
}
</script>
<style>
.uni-system-open-location {
display: block;
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f8f8f8;
}
.map-content {
position: absolute;
left: 0;
top: 44px;
width: 100%;
bottom: 0;
overflow: hidden;
}
.map-content>iframe {
width: 100%;
height: 100%;
border: none;
}
.actTonav {
position: absolute;
right: 16px;
bottom: 56px;
width: 60px;
height: 60px;
border-radius: 60px;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册