Skip to content
/ dc-electron Public template

基于VueCli4和DC-SDK的多端三维WebGis项目框架

Notifications You must be signed in to change notification settings

dvgis/dc-electron

Repository files navigation

DC-Electron

🇨🇳 中文 | 🇬🇧English

该脚手架基于 VueCli4 、 vue-cli-plugin-electron-builder 、 @dvgis/dc-sdk 搭建,用于快速构建 3D 桌面端应用。

启动

yarn run serve
yarn run electron:serve

打包

yarn run build
yarn run electron:build

配置说明

const dvgis = './node_modules/@dvgis'
module.exports = {
  // 其他配置
  chainWebpack: config => {
    config.resolve.alias.set('dvgis', path.resolve(__dirname, dvgis))
    config.plugin('copy').use(CopywebpackPlugin, [
      [
        {
          from: path.join(__dirname, 'public'),
          to: path.join(__dirname, 'dist'),
          ignore: ['index.html']
        },
        {
          from: path.join(dvgis, 'dc-sdk/dist/resources'),
          to: path.join(__dirname, 'dist', 'libs/dc-sdk/resources')
        }
      ]
    ])
  },
  pluginOptions: {
    electronBuilder: {
      chainWebpackMainProcess: config => {
        let outputDir = 'dist_electron/bundled'
        fs.removeSync(path.join(__dirname, outputDir, 'Assets'))
        fs.removeSync(path.join(__dirname, outputDir, 'Widgets'))
        fs.removeSync(path.join(__dirname, outputDir, 'Workers'))
        fs.removeSync(path.join(__dirname, outputDir, 'ThirdParty'))
        config.plugin('copy').use(CopywebpackPlugin, [
          [
            {
              from: path.join(__dirname, 'public'),
              to: path.join(__dirname, outputDir),
              ignore: ['index.html']
            },
            {
              from: path.join(dvgis, 'dc-sdk/dist/resources'),
              to: path.join(__dirname, outputDir, 'libs/dc-sdk/resources')
            }
          ]
        ])
      },
      chainWebpackRendererProcess: config => {
        config.plugin('define').tap(args => {
          const env = args[0]['process.env']
          for (let key in env) {
            args[0][`process.env.${key}`] = env[key]
          }
          delete args[0]['process.env']
          return args
        })
      }
    }
  }
}

全局变量 Config

获取对应配置文件赋予的值

桌面端: 当前用户目录下的 .dc-conf/config.json

Web 端: 项目目录下的 public/config/config.json

示例

pic