Skip to content

Commit e1001d1

Browse files
committed
同步代码
1 parent 1656630 commit e1001d1

File tree

26 files changed

+878
-354
lines changed

26 files changed

+878
-354
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"intro.js": "^4.3.0",
5353
"localforage": "^1.10.0",
5454
"lodash-es": "^4.17.21",
55-
"mars3d": "^3.3.3",
56-
"mars3d-cesium": "^1.92.0",
55+
"mars3d": "^3.3.7",
56+
"mars3d-cesium": "^1.92.5",
5757
"mockjs": "^1.1.0",
5858
"nprogress": "^0.2.0",
5959
"path-to-regexp": "^6.2.0",

public/config/config.json

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"map3d": {
3-
"templateValues": {
4-
"dataServer": "//data.mars3d.cn",
5-
"gltfServerUrl": "//data.mars3d.cn/gltf"
6-
},
73
"scene": {
84
"center": { "lat": 31.686288, "lng": 117.229619, "alt": 11333.9, "heading": 359.2, "pitch": -39.5 },
95
"scene3DOnly": false,
@@ -60,6 +56,10 @@
6056
"template": "<div>经度:{lng}</div> <div>纬度:{lat}</div> <div class='hide1000'>横{crsx} 纵{crsy}</div> <div>海拔:{alt}米</div> <div class='hide700'>层级:{level}</div><div>方向:{heading}°</div> <div>俯仰角:{pitch}°</div><div class='hide700'>视高:{cameraHeight}米</div>"
6157
}
6258
},
59+
"templateValues": {
60+
"dataServer": "//data.mars3d.cn",
61+
"gltfServerUrl": "//data.mars3d.cn/gltf"
62+
},
6363
"terrain": {
6464
"url": "//data.mars3d.cn/terrain",
6565
"show": true
@@ -73,8 +73,8 @@
7373
"icon": "img/basemaps/tdt_img.png",
7474
"type": "group",
7575
"layers": [
76-
{ "name": "底图", "type": "tdt", "layer": "img_d", "key": ["789e558be762ff832392a0393fd8a4f1"] },
77-
{ "name": "注记", "type": "tdt", "layer": "img_z", "key": ["789e558be762ff832392a0393fd8a4f1"] }
76+
{ "name": "底图", "type": "tdt", "layer": "img_d" },
77+
{ "name": "注记", "type": "tdt", "layer": "img_z" }
7878
],
7979
"show": true
8080
},
@@ -84,8 +84,8 @@
8484
"icon": "img/basemaps/tdt_vec.png",
8585
"type": "group",
8686
"layers": [
87-
{ "name": "底图", "type": "tdt", "layer": "vec_d", "key": ["789e558be762ff832392a0393fd8a4f1"] },
88-
{ "name": "注记", "type": "tdt", "layer": "vec_z", "key": ["789e558be762ff832392a0393fd8a4f1"] }
87+
{ "name": "底图", "type": "tdt", "layer": "vec_d" },
88+
{ "name": "注记", "type": "tdt", "layer": "vec_z" }
8989
]
9090
},
9191
{
@@ -152,7 +152,6 @@
152152
"name": "微软影像",
153153
"icon": "img/basemaps/bingAerial.png",
154154
"type": "bing",
155-
"key": "AuKhM0WRkjhX8E4y1OM0TukYycaw_4Vh3eSfXONDf7OARls-WEB3K_Rfx89bWxof",
156155
"layer": "Aerial"
157156
},
158157
{
@@ -242,12 +241,10 @@
242241
{
243242
"pid": 50,
244243
"name": "行政区划界线",
245-
"type": "xyz",
246-
"url": "https://t{s}.tianditu.gov.cn/DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=789e558be762ff832392a0393fd8a4f1",
247-
"subdomains": "01234567",
244+
"type": "tdt",
245+
"url": "https://t{s}.tianditu.gov.cn/DataServer?T=ibo_w&x={x}&y={y}&l={z}",
248246
"maximumLevel": 10,
249-
"mapSplit": false,
250-
"show": true
247+
"mapSplit": false
251248
},
252249
{
253250
"pid": 50,
@@ -289,8 +286,6 @@
289286
"layers": "mars:hfjy",
290287
"crs": "EPSG:4326",
291288
"parameters": { "transparent": "true", "format": "image/png" },
292-
"highlight": { "clampToGround": true },
293-
"center": { "lat": 31.743214, "lng": 117.277097, "alt": 47197.7, "heading": 0.3, "pitch": -78.8 },
294289
"popup": "名称:{项目名称}<br />类型:{设施类型}<br />面积:{用地面积}亩<br />位置:{具体位置}",
295290
"mapSplit": false,
296291
"show": false,
@@ -924,7 +919,7 @@
924919
]
925920
}
926921
},
927-
"center":{"lat":31.504746,"lng":118.264278,"alt":580,"heading":29,"pitch":-49}
922+
"center": { "lat": 31.504746, "lng": 118.264278, "alt": 580, "heading": 29, "pitch": -49 }
928923
},
929924
{ "id": 2060, "pid": 20, "name": "BIM模型", "type": "group" },
930925
{

src/marsgis/components/mars-ui/base.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
// 表单元素
6464
.ant-form {
6565
color: rgba(255, 255, 255, 0.925);
66+
.ant-form-item-extra{
67+
color: @mars-basecolor;
68+
}
6669
}
6770
.ant-form-item {
6871
margin-bottom: 10px !important;

src/marsgis/components/mars-ui/function.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
}
218218

219219
.f-push-10-t {
220+
color: @mars-basecolor;
220221
margin-top: 10px !important;
221222
}
222223

src/marsgis/components/mars-ui/index.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构
1414
/* table elements 表格元素 */
1515
margin: 0;
1616
padding: 0;
17+
color: #fff;
1718
-moz-user-select: none; /*火狐*/
1819
-webkit-user-select: none; /*webkit浏览器*/
1920
-ms-user-select: none; /*IE10*/
@@ -31,6 +32,7 @@ body,
3132
html {
3233
background-color: @background-base;
3334
color: @mars-basecolor;
35+
font-size: 14px;
3436
overflow: hidden;
3537
* {
3638
scrollbar-base-color: #f4f7fc;

src/marsgis/components/mars-ui/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import MarsButton from "./mars-button/index.vue"
99
import MarsInput from "./mars-input/index.vue"
1010
import MarsTextarea from "./mars-textarea/index.vue"
1111
import MarsInputNumber from "./mars-input-number/index.vue"
12+
import MarsInputGroup from "./mars-input-group/index.vue"
1213
import MarsDatePicker from "./mars-date-picker/index.vue"
1314
import MarsRangePicker from "./mars-range-picker/index.vue"
1415
import MarsColorPicker from "./mars-color-picker"
@@ -18,6 +19,7 @@ import MarsDialog from "./mars-dialog/index.vue"
1819
import MarsSlider from "./mars-slider/index.vue"
1920
import MarsPannel from "./mars-pannel/index.vue"
2021
import MarsDropDown from "./mars-dropdown"
22+
import MarsGui from "./mars-gui/index.vue"
2123
import MarsMessage, { $message as marsMessage } from "./mars-message"
2224
import MarsAlert, { $alert as marsAlert } from "./mars-alert/"
2325
import MarsNotify, { $notify as marsNotify } from "./mars-notify"
@@ -74,6 +76,7 @@ const components = [
7476
MarsSelect,
7577
MarsButton,
7678
MarsInput,
79+
MarsInputGroup,
7780
MarsInputNumber,
7881
MarsDatePicker,
7982
MarsRangePicker,
@@ -85,7 +88,8 @@ const components = [
8588
MarsPannel,
8689
MarsTextarea,
8790
MarsSwitch,
88-
MarsSlider
91+
MarsSlider,
92+
MarsGui
8993
]
9094

9195
let marsUIConfig: Record<string, any>

src/marsgis/components/mars-ui/mars-alert/alert.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
.ant-modal-confirm-content {
1212
font-size: 14px;
1313
color: @mars-basecolor !important;
14+
user-select: text;
1415
}
1516
.ant-modal-confirm-btns {
1617
margin-top: 20px;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
export const components = {
2+
number: "mars-input-number",
3+
switch: "mars-switch",
4+
radio: "a-radio-group",
5+
checkbox: "a-checkbox-group",
6+
slider: "mars-slider",
7+
color: "mars-color-picker",
8+
select: "mars-select",
9+
textarea: "mars-textarea",
10+
input: "mars-input",
11+
inputGroup: "mars-input-group"
12+
}
13+
14+
export interface GuiItem {
15+
type: keyof typeof components
16+
field: string
17+
label: string
18+
extra?: any
19+
min?: number
20+
max?: number
21+
step?: number
22+
range?: boolean
23+
data?: any[]
24+
value?: string | boolean | number | any
25+
units?: string[]
26+
show?: boolean | ((data: any) => boolean)
27+
change?: (value: any, dataObj: any) => any
28+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<template>
2+
<a-form :label-col="labelCol" :wrapper-col="wrapperCol">
3+
<template v-for="(item, i) in renderOptions" :key="i">
4+
<a-form-item v-if="(item.show as any)(attrForm)" :label="item.label">
5+
<component
6+
:is="getComponent(item.type)"
7+
v-model:value="item.value"
8+
:min="item.min || item.min === 0 ? item.min : -Infinity"
9+
:max="item.max || item.max === 0 ? item.max : Infinity"
10+
:step="item.step || 0.1"
11+
:range="item.range || false"
12+
:options="item.data || []"
13+
:units="item.units"
14+
@change="itemChange(item)"
15+
>
16+
</component>
17+
<template v-if="item.extra" #extra>{{ item.extra(attrForm) }}</template>
18+
</a-form-item>
19+
</template>
20+
</a-form>
21+
</template>
22+
<script setup lang="ts">
23+
import { computed, ref, watchEffect } from "vue"
24+
import { components, GuiItem } from "./index"
25+
const props = defineProps<{
26+
options: GuiItem[]
27+
}>()
28+
29+
const emits = defineEmits(["change"])
30+
31+
const renderOptions = ref<GuiItem[]>([])
32+
33+
const attrForm = computed(() => {
34+
const modelValues: Record<string, any> = {}
35+
renderOptions.value.forEach((item) => {
36+
modelValues[item.field] = item.value
37+
})
38+
39+
return modelValues
40+
})
41+
42+
const labelCol = { span: 6 }
43+
const wrapperCol = { span: 18 }
44+
45+
watchEffect(() => {
46+
renderOptions.value = props.options.map((item) => mergeItemOption(item))
47+
})
48+
49+
defineExpose({
50+
// 删除指定 field 或 索引的 元素
51+
delete: (key: string | number) => {
52+
let index: number
53+
if (typeof key === "string") {
54+
renderOptions.value.forEach((item, i) => {
55+
if (item.field === key) {
56+
index = i
57+
}
58+
})
59+
}
60+
if (typeof key === "number" && key >= 0 && key < renderOptions.value.length) {
61+
index = key
62+
}
63+
if (index !== undefined) {
64+
renderOptions.value.splice(index, 1)
65+
}
66+
},
67+
// 在指定位置插入 一个 或 多个 元素
68+
insert(index: number, ...args: GuiItem[]) {
69+
args.forEach((item) => {
70+
renderOptions.value.splice(index, 0, mergeItemOption(item))
71+
})
72+
},
73+
updateField(field: string, value) {
74+
renderOptions.value.forEach((item) => {
75+
if (item.field === field) {
76+
item.value = value
77+
}
78+
})
79+
},
80+
updateExtra(field: string, value) {
81+
renderOptions.value.forEach((item) => {
82+
if (item.field === field) {
83+
item.extra = mergeExtra(value)
84+
}
85+
})
86+
},
87+
getValue(field: string) {
88+
const item = renderOptions.value.find((it) => {
89+
return it.field === field
90+
})
91+
if (item) {
92+
return item.value
93+
}
94+
throw new Error("field is not exist")
95+
},
96+
getValues() {
97+
return attrForm.value
98+
}
99+
})
100+
101+
function getComponent(type: keyof typeof components) {
102+
return components[type]
103+
}
104+
105+
function mergeItemOption(item) {
106+
// show字段转为function
107+
if (typeof item.show !== "function") {
108+
item.show = () => (item.show === undefined ? true : !!item.show)
109+
}
110+
111+
// extra 字段转为function
112+
item.extra = mergeExtra(item.extra)
113+
return item
114+
}
115+
116+
function mergeExtra(extra) {
117+
let extraNew = extra
118+
if (typeof extraNew !== "function" && extraNew) {
119+
extraNew = () => {
120+
if (typeof extra === "string") {
121+
let str = extra
122+
const paramsPattern = /[^{\}]+(?=})/g
123+
const extractParams = str.match(paramsPattern) || []
124+
extractParams.forEach((key) => {
125+
str = str.replace(new RegExp(`{${key}}`, "g"), attrForm.value[key])
126+
})
127+
return str
128+
} else {
129+
return extra
130+
}
131+
}
132+
}
133+
return extraNew
134+
}
135+
136+
function itemChange(item: GuiItem) {
137+
emits("change", attrForm.value)
138+
if (item.change) {
139+
item.change(item.value, attrForm.value)
140+
}
141+
}
142+
</script>
143+
<script lang="ts">
144+
export default {
145+
name: "mars-gui"
146+
}
147+
</script>
148+
149+
<style lang="less"></style>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<a-space>
3+
<template v-for="(item, i) in value" :key="i">
4+
<mars-input v-model:value="values[i]" @change="(v) => itemChange(v, i)" :suffix="props.units[i]" />
5+
</template>
6+
</a-space>
7+
</template>
8+
<script lang="ts" setup>
9+
import { watchEffect, ref } from "vue"
10+
const props = defineProps<{
11+
value: string[]
12+
units: string[]
13+
}>()
14+
15+
const values = ref([])
16+
17+
watchEffect(() => {
18+
values.value = props.value
19+
})
20+
21+
const emits = defineEmits(["update:value", "change"])
22+
23+
function itemChange(v, i) {
24+
emits("update:value", values)
25+
emits("change", values)
26+
}
27+
</script>
28+
<script lang="ts">
29+
export default {
30+
name: "mars-input-group"
31+
}
32+
</script>
33+
<style lang="less" scoped></style>

0 commit comments

Comments
 (0)