npm package: @mapgis/webclient-vue3-cesium
Description: MapGIS WebClient Vue3 Cesium by Vue3 + TS
Latest version: 17.8.0

# MapGIS WebClient Vue3 Cesium

## 特性

- 开箱即用的高质量 Vue 3组件
- 丰富的文档和示例

## 安装

```
# npm
npm install ant-design-vue@^4.2.6
npm install @mapgis/cesium
npm install @mapgis/webclient-common
npm install @mapgis/webclient-cesium-plugin
npm install @mapgis/webclient-vue3-ui
npm install @mapgis/webclient-vue3-common
npm install @mapgis/webclient-vue3-cesium

# yarn
yarn add ant-design-vue@^4.2.6
yarn add @mapgis/cesium
yarn add @mapgis/webclient-common
yarn add @mapgis/webclient-cesium-plugin
yarn add @mapgis/webclient-vue3-ui
yarn add @mapgis/webclient-vue3-common
yarn add @mapgis/webclient-vue3-cesium

# pnpm
pnpm add ant-design-vue@^4.2.6
pnpm add @mapgis/cesium
pnpm add @mapgis/webclient-common
pnpm add @mapgis/webclient-cesium-plugin
pnpm add @mapgis/webclient-vue3-ui
pnpm add @mapgis/webclient-vue3-common
pnpm add @mapgis/webclient-vue3-cesium
```

## 用法

在 main.ts 中写入以下内容：

### 完整引入

```js
import { createApp } from 'vue'
import App from './App.vue'

import '@mapgis/webclient-common'
import * as Cesium from '@mapgis/cesium'
globalThis.Cesium = Cesium
import '@mapgis/webclient-cesium-plugin'

import Antd from 'ant-design-vue'
import MapGISUIComponents from '@mapgis/webclient-vue3-ui'
import MapGISCommonComponents from '@mapgis/webclient-vue3-common'
import MapGISCesiumComponents from '@mapgis/webclient-vue3-cesium'

import 'ant-design-vue/dist/reset.css'
import '@mapgis/cesium/Build/Cesium/Widgets/widgets.css'
import '@mapgis/webclient-vue3-ui/dist/index.css'
import '@mapgis/webclient-vue3-common/dist/index.css'
import '@mapgis/webclient-vue3-cesium/dist/index.css'

createApp(App).use(Antd).use(MapGISUIComponents).use(MapGISCommonComponents).use(MapGISCesiumComponents).mount('#app')
```

### 按需导入

默认支持基于 ES modules 的 tree shaking，直接引入 import { WebScene } from '@mapgis/webclient-vue3-cesium'; 就会有按需加载的效果

```vue
<template>
  <a-config-provider>
    <mapgis-theme-provider>
      <WebScene>
        <SceneSetting
          style="
            position: absolute;
            left: 12px;
            top: 12px;
            z-index: 1000;
            background: rgba(255, 255, 255, 0.5);
            padding: 12px;
          "
        >
        </SceneSetting>
      </WebScene>
    </mapgis-theme-provider>
  </a-config-provider>
</template>

<script setup lang="ts">
import { WebScene, SceneSetting } from '@mapgis/webclient-vue3-cesium'
import '@mapgis/webclient-vue3-cesium/dist/theme/scene.css'
import '@mapgis/webclient-vue3-cesium/dist/theme/scene-setting.css'
</script>
```

## 导入资源

通过webpack、vite等工具实现资源的拷贝，以vite为例：

> 需要先安装vite-plugin-static-copy

配置`vite.config.js`

```js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

import { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
  define: {
    CESIUM_BASE_URL: JSON.stringify('./cesiumStatic'),
    MAPGIS_BASE_URL: JSON.stringify('./')
  },
  plugins: [
    vue(),
    viteStaticCopy({
      targets: [
        {
          src: 'node_modules/@mapgis/cesium/Build/Cesium/*',
          dest: 'cesiumStatic'
        },
        {
          src: 'node_modules/@mapgis/webclient-cesium-plugin/dist/webclient-cesium-plugin-resource/*',
          dest: 'webclient-cesium-plugin-resource'
        },
        {
          src: 'node_modules/@mapgis/webclient-common/dist/webclient-common-resource/*',
          dest: 'webclient-common-resource'
        }
      ]
    })
  ]
})
```