Skip to content

Latest commit

 

History

History
90 lines (76 loc) · 2.37 KB

README_en.md

File metadata and controls

90 lines (76 loc) · 2.37 KB

DC-Electron

🇨🇳 中文 | 🇬🇧English

This scaffold is built based on VueCli4, vue-cli-plugin-electronic-builder and @dvgis/dc-sdk, which is used to quickly build 3D desktop applications.

Start

yarn run serve
yarn run electron:serve

Package

yarn run build
yarn run electron:build

Configuration

const dvgis = './node_modules/@dvgis'
module.exports = {
  // Other configuration
  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
        })
      }
    }
  }
}

Global variable Config

gets the value assigned by the corresponding configuration file

desktop: .dc-conf/config.json in the current user directory

Web side: the project directory public/config/config json

demo

pic