Преглед на файлове

add moudle name

tags/2.16.0
Caven Chen преди 3 години
родител
ревизия
e7d850f0d2
променени са 6 файла, в които са добавени 30 реда и са изтрити 39 реда
  1. 8
    10
      modules/namespace/index.js
  2. 7
    23
      packages/base/index.js
  3. 6
    3
      packages/chart/index.js
  4. 2
    1
      packages/core/index.js
  5. 5
    1
      packages/mapv/index.js
  6. 2
    1
      packages/s3m/index.js

+ 8
- 10
modules/namespace/index.js Целия файл

@@ -3,20 +3,18 @@
* @Date: 2021-03-15 18:36:48
*/

const getCesium = () => {
return DC.Namespace?.Cesium
}
const cahce = {}

const getMapv = () => {
return DC.Namespace?.mapv
export function setNamespace(name, lib) {
cahce[name] = lib
}

const getTurf = () => {
return DC.Namespace?.turf
export function getNamespace(name) {
return cahce[name]
}

export const Cesium = getCesium()
export const Cesium = getNamespace('Cesium')

export const mapv = getMapv()
export const mapv = getNamespace('mapv')

export const turf = getTurf()
export const turf = getNamespace('turf')

+ 7
- 23
packages/base/index.js Целия файл

@@ -2,9 +2,10 @@
* @Author: Caven
* @Date: 2021-03-12 16:45:45
*/

import { initMixin, initUse } from '@dc-modules/global-api'
import * as Cesium from 'cesium'
import * as turf from '@turf/turf'
import { initMixin, initUse } from '@dc-modules/global-api'
import { setNamespace } from '@dc-modules/namespace'

let DC = {
version: __VERSION__,
@@ -12,7 +13,7 @@ let DC = {
baseUrl: './libs/dc-sdk/resources/',
author: __AUTHOR__,
home_page: __HOME_PAGE__,
Namespace: {},
Namespace: { Cesium, turf },
Initialized: false
}

@@ -20,27 +21,10 @@ let DC = {
initMixin(DC)
initUse(DC)

// load Cesium
let cesiumLoaded = false
DC.init = callback => {
if (!cesiumLoaded) {
new Promise((resolve, reject) => {
let Cesium = require('cesium/Cesium')
resolve(Cesium)
})
.then(Cesium => {
// set Cesium to Namespace
DC.Namespace['Cesium'] = Cesium
cesiumLoaded = true
delete window['Cesium']
// set turf to Namespace
DC.Namespace['turf'] = turf
callback && callback()
})
.catch(e => {})
} else {
callback && callback()
}
setNamespace('Cesium', DC.Namespace.Cesium)
setNamespace('turf', DC.Namespace.turf)
callback && callback()
}

export default DC

+ 6
- 3
packages/chart/index.js Целия файл

@@ -3,7 +3,9 @@
* @Date: 2020-02-02 15:55:53
*/

const install = function(DC) {
const install = function(DC, echarts) {
echarts = echarts || global.echarts

if (!echarts) {
throw new Error('Chart: missing charts lib')
}
@@ -23,11 +25,12 @@ const install = function(DC) {
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.DC) {
install(window.DC)
if (typeof window !== 'undefined' && window.DC && window.echarts) {
install(window.DC, window.echarts)
}

export default {
name: 'dc-chart',
version: __VERSION__,
compile_time: __TIME__,
install

+ 2
- 1
packages/core/index.js Целия файл

@@ -4,7 +4,7 @@
*/

const install = function(DC) {
if (!DC) {
if (!DC || !DC.init) {
throw new Error('Missing DC Base Package')
}

@@ -49,6 +49,7 @@ if (typeof window !== 'undefined' && window.DC) {
}

export default {
name: 'dc-core',
version: __VERSION__,
compile_time: __TIME__,
install

+ 5
- 1
packages/mapv/index.js Целия файл

@@ -3,6 +3,8 @@
* @Date: 2021-03-12 16:45:45
*/

import { setNamespace } from '@dc-modules/namespace'

const install = function(DC) {
if (!DC || !DC.init) {
throw new Error('Mapv: Missing DC Base')
@@ -12,6 +14,7 @@ const install = function(DC) {
try {
require('mapv-lib/mapv.min.js')
DC.Namespace['mapv'] = window.mapv
setNamespace('mapv', window.mapv)
DC.mixin(require('./src/components.js').default)
DC.mixin({
MapvDataSet: window.mapv?.DataSet
@@ -27,10 +30,11 @@ const install = function(DC) {

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.DC) {
install(DC)
install(window.DC)
}

export default {
name: 'dc-mapv',
version: __VERSION__,
compile_time: __TIME__,
install

+ 2
- 1
packages/s3m/index.js Целия файл

@@ -20,10 +20,11 @@ const install = function(DC) {

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.DC) {
install(DC)
install(window.DC)
}

export default {
name: 'dc-s3m',
version: __VERSION__,
compile_time: __TIME__,
install

Loading…
Отказ
Запис