Skip to content

Commit fc3db15

Browse files
committed
同步代码
1 parent 96143d3 commit fc3db15

File tree

4 files changed

+101
-13
lines changed

4 files changed

+101
-13
lines changed

src/components/mars-ui/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
2+
## mars-ui介绍
3+
4+
## 依赖库
5+
- [Ant Design Vue](https://next.antdv.com/components/overview-cn/):UI 控件库
6+
- [IconPark](https://iconpark.oceanengine.com/official):UI 图标库
7+
8+
9+
## 将mars-ui集成到自己的项目中
10+
11+
> 前提条件:需要 2 个项目的技术栈基本是一致的,比如`vue3+ts+ant-design-vue`
12+
13+
14+
### 流程概览:
15+
16+
需要拷贝的目录和文件:
17+
18+
- `/src/components/mars-ui` 拷贝到 `/src/components/mars-ui`
19+
20+
需要修改自己项目的文件:
21+
22+
- `package.json`
23+
- `vite.config.ts``vue.config.js`
24+
- `src/main.js`
25+
- 需要加地图的`vue文件`
26+
27+
![image](http://mars3d.cn/dev/img/guide/project-vue-hebing.jpg)
28+
29+
### 1. 拷贝src/components/mars-ui文件夹
30+
### 2. 在main.ts文件中进行集成
31+
```json
32+
33+
import "./components/mars-ui/common";
34+
import MarsUIInstall from "./components/mars-ui";
35+
36+
37+
MarsUIInstall(app);
38+
```
39+
### 3. 安装相关依赖
40+
```json
41+
"dependencies": {
42+
"@icon-park/svg": "^1.4.2",
43+
"@turf/turf": "^6.5.0",
44+
"ant-design-vue": "^4.0.7",
45+
"consola": "^3.2.3",
46+
"echarts": "^5.4.3",
47+
"mars3d": "~3.6.0",
48+
"mars3d-cesium": "~1.111.0",
49+
"nprogress": "^0.2.0",
50+
"vite-plugin-style-import": "^2.0.0",
51+
"vue": "^3.2.27",
52+
"vue-color-kit": "^1.0.6"
53+
},
54+
```
55+
56+
### 4. 配置vite文件
57+
```json
58+
export default defineConfig({
59+
css: {
60+
preprocessorOptions: {
61+
less: {
62+
javascriptEnabled: true,
63+
additionalData: `@import "${path.resolve(
64+
__dirname,
65+
"src/components/mars-ui/base.less"
66+
)}";`,
67+
},
68+
},
69+
},
70+
plugins: [
71+
vue(),
72+
mars3dPlugin(),
73+
createStyleImportPlugin({
74+
resolves: [AndDesignVueResolve()],
75+
libs: [
76+
{
77+
libraryName: "ant-design-vue",
78+
esModule: true,
79+
resolveStyle: (name) => {
80+
if (name === "auto-complete") {
81+
return `ant-design-vue/es/${name}/index`;
82+
}
83+
return `ant-design-vue/es/${name}/style/index`;
84+
},
85+
},
86+
],
87+
}),
88+
],
89+
});
90+
```
91+
92+
### 5. 使用
93+
参考实例,使用对应的标签
94+
95+
基础项目已经基本保证不会影响外部样式,此处要处理的是您项目中的全局样式对 mars3d 相关组件的影响。修改相关 CSS 保证基础项目功能 UI 正常即可。
96+

src/misc/env.d.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/// <reference types="vite/client" />
2+
/// <reference types="vite-svg-loader" />
3+
24
/**
35
* 统一定义ts模块类型
46
* @copyright 火星科技 mars3d.cn
@@ -29,16 +31,7 @@ declare module "mapv" {
2931
}
3032

3133
declare module "kml-geojson" {
32-
export const toKml: (geojson:any, options:any) => any
33-
export const toGeoJSON: (doc:any) => any
34+
export const toKml: (geojson: any, options: any) => any
35+
export const toGeoJSON: (doc: any) => any
3436
}
3537

36-
// declare module "*.svg" {
37-
// const svg: any
38-
// export default svg
39-
// }
40-
41-
// declare module "*.png" {
42-
// const png: string
43-
// export default png
44-
// }

src/widgets/basic/query-poi/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const pagination = {
153153
}
154154
155155
function clickVoid(e) {
156-
if (e.target.dataset?.event !== "prevent") {
156+
if (e.target.dataset?.event !== "prevent" && e.target.tagName !== "INPUT") {
157157
e.preventDefault()
158158
}
159159
}

vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { defineConfig, loadEnv } from "vite" // 帮手函数,这样不用 jsdo
44
import vue from "@vitejs/plugin-vue"
55
import eslintPlugin from "vite-plugin-eslint"
66
import { mars3dPlugin } from "vite-plugin-mars3d"
7-
87
import { createStyleImportPlugin, AndDesignVueResolve } from "vite-plugin-style-import"
98

109
export default ({ mode }: ConfigEnv) => {

0 commit comments

Comments
 (0)