diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/components/mapWindow/mapWindow.vue b/src/components/mapWindow/mapWindow.vue new file mode 100644 index 0000000..9ced291 --- /dev/null +++ b/src/components/mapWindow/mapWindow.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/components/mapWindow/mapWindow.vue b/src/components/mapWindow/mapWindow.vue new file mode 100644 index 0000000..9ced291 --- /dev/null +++ b/src/components/mapWindow/mapWindow.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/router/modules/environment.js b/src/router/modules/environment.js index 75094ea..4e80abc 100644 --- a/src/router/modules/environment.js +++ b/src/router/modules/environment.js @@ -5,7 +5,7 @@ { path: '/', component: Layout, - redirect: 'dashboard', + redirect: '/overview', name: 'Dashboard', hidden: true, children: [{ diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/components/mapWindow/mapWindow.vue b/src/components/mapWindow/mapWindow.vue new file mode 100644 index 0000000..9ced291 --- /dev/null +++ b/src/components/mapWindow/mapWindow.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/router/modules/environment.js b/src/router/modules/environment.js index 75094ea..4e80abc 100644 --- a/src/router/modules/environment.js +++ b/src/router/modules/environment.js @@ -5,7 +5,7 @@ { path: '/', component: Layout, - redirect: 'dashboard', + redirect: '/overview', name: 'Dashboard', hidden: true, children: [{ diff --git a/src/views/overview/component/deviceLayer.vue b/src/views/overview/component/deviceLayer.vue new file mode 100644 index 0000000..1e41bcf --- /dev/null +++ b/src/views/overview/component/deviceLayer.vue @@ -0,0 +1,207 @@ + + + + + + diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/components/mapWindow/mapWindow.vue b/src/components/mapWindow/mapWindow.vue new file mode 100644 index 0000000..9ced291 --- /dev/null +++ b/src/components/mapWindow/mapWindow.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/router/modules/environment.js b/src/router/modules/environment.js index 75094ea..4e80abc 100644 --- a/src/router/modules/environment.js +++ b/src/router/modules/environment.js @@ -5,7 +5,7 @@ { path: '/', component: Layout, - redirect: 'dashboard', + redirect: '/overview', name: 'Dashboard', hidden: true, children: [{ diff --git a/src/views/overview/component/deviceLayer.vue b/src/views/overview/component/deviceLayer.vue new file mode 100644 index 0000000..1e41bcf --- /dev/null +++ b/src/views/overview/component/deviceLayer.vue @@ -0,0 +1,207 @@ + + + + + + diff --git a/src/views/overview/overview-old.vue b/src/views/overview/overview-old.vue new file mode 100644 index 0000000..dac2209 --- /dev/null +++ b/src/views/overview/overview-old.vue @@ -0,0 +1,299 @@ + + + diff --git a/src/assets/map/device-offline.png b/src/assets/map/device-offline.png new file mode 100644 index 0000000..57cb637 --- /dev/null +++ b/src/assets/map/device-offline.png Binary files differ diff --git a/src/assets/map/device-online.png b/src/assets/map/device-online.png new file mode 100644 index 0000000..89b4cf8 --- /dev/null +++ b/src/assets/map/device-online.png Binary files differ diff --git a/src/components/mapWindow/base/mixins/abstract.js b/src/components/mapWindow/base/mixins/abstract.js new file mode 100644 index 0000000..9cf6d52 --- /dev/null +++ b/src/components/mapWindow/base/mixins/abstract.js @@ -0,0 +1,13 @@ +class Mixin { + constructor({ component, props, events, extraProps, exceptProps }) { + this.render = function(h) { + return h(component, { + props: props.reduce((obj, key) => Object.assign(obj, { [key]: this[key] }), {}), + on: events.reduce((obj, key) => Object.assign(obj, { [key]: this.transmitEvent }), {}) + }) + } + this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))] + } +} + +export default prop => new Mixin(prop) diff --git a/src/components/mapWindow/base/mixins/common.js b/src/components/mapWindow/base/mixins/common.js new file mode 100644 index 0000000..2fd1a28 --- /dev/null +++ b/src/components/mapWindow/base/mixins/common.js @@ -0,0 +1,82 @@ +const types = { + map: { + unload: 'clearMap' + }, + control: { + unload: 'removeControl' + }, + layer: { + unload: 'removeLayer' + }, + features: { + unload: 'removeFeatures' + }, + listener: { + unload: 'removeListener' + } +} + +const getParent = $component => ($component.abstract || $component.$el === $component.$children[0].$el) ? getParent($component.$parent) : $component + +function destroyInstance () { + const { unload, renderByParent, $parent } = this + if (renderByParent) { + $parent.reload() + } + unload() +} + +class Mixin { + constructor (prop) { + this.methods = { + ready () { + const $parent = getParent(this.$parent) + const map = this.map = $parent.map + this.load() + this.$emit('ready', { + map + }) + }, + transmitEvent (e) { + this.$emit(e.type.replace(/^on/, ''), e) + }, + reload () { + this && this.$nextTick(() => { + this.unload() + this.$nextTick(this.load) + }) + }, + unload () { + const { map, originInstance } = this + try { + switch (prop.type) { + case 'search': + return originInstance.clearResults() + case 'autoComplete': + case 'lushu': + return originInstance.dispose() + case 'markerClusterer': + return originInstance.clearMarkers() + default: + map[types[prop.type].unload](originInstance) + } + } catch (e) {} + } + } + this.computed = { + renderByParent () { + return this.$parent.preventChildrenRender + } + } + this.mounted = function () { + console.log('common mounted') + const $parent = getParent(this.$parent) + const map = $parent.map + const { ready } = this + console.log(map) + map ? ready() : $parent.$on('onload', ready) + } + } +} + +export default type => new Mixin({ type }) diff --git a/src/components/mapWindow/leafletMap.vue b/src/components/mapWindow/leafletMap.vue new file mode 100644 index 0000000..21dcc81 --- /dev/null +++ b/src/components/mapWindow/leafletMap.vue @@ -0,0 +1,153 @@ + + + + + + + diff --git a/src/components/mapWindow/mapWindow.vue b/src/components/mapWindow/mapWindow.vue new file mode 100644 index 0000000..9ced291 --- /dev/null +++ b/src/components/mapWindow/mapWindow.vue @@ -0,0 +1,46 @@ + + + + + + diff --git a/src/router/modules/environment.js b/src/router/modules/environment.js index 75094ea..4e80abc 100644 --- a/src/router/modules/environment.js +++ b/src/router/modules/environment.js @@ -5,7 +5,7 @@ { path: '/', component: Layout, - redirect: 'dashboard', + redirect: '/overview', name: 'Dashboard', hidden: true, children: [{ diff --git a/src/views/overview/component/deviceLayer.vue b/src/views/overview/component/deviceLayer.vue new file mode 100644 index 0000000..1e41bcf --- /dev/null +++ b/src/views/overview/component/deviceLayer.vue @@ -0,0 +1,207 @@ + + + + + + diff --git a/src/views/overview/overview-old.vue b/src/views/overview/overview-old.vue new file mode 100644 index 0000000..dac2209 --- /dev/null +++ b/src/views/overview/overview-old.vue @@ -0,0 +1,299 @@ + + + diff --git a/src/views/overview/overview.vue b/src/views/overview/overview.vue index dac2209..4050e90 100644 --- a/src/views/overview/overview.vue +++ b/src/views/overview/overview.vue @@ -1,25 +1,21 @@