1
|
1
|
<template>
|
2
|
|
- <collapse-item name="三维静态路径" :expanded="true">
|
3
|
|
- <setting-item-box>
|
4
|
|
- <setting-item name="路径">
|
|
2
|
+ <collapse-item name="三维配置" :expanded="true">
|
|
3
|
+ <setting-item-box name="文件上传" :alone="true">
|
|
4
|
+ <setting-item :name="fileSizeMsg">
|
|
5
|
+ <n-upload
|
|
6
|
+ :max="1"
|
|
7
|
+ :customRequest="customRequest"
|
|
8
|
+ :onBeforeUpload="beforeUploadHandle"
|
|
9
|
+ :default-file-list="defaultFileList"
|
|
10
|
+ >
|
|
11
|
+ <n-button> 上传文件</n-button>
|
|
12
|
+ </n-upload>
|
|
13
|
+ </setting-item>
|
|
14
|
+ </setting-item-box>
|
|
15
|
+ <setting-item-box name="静态路径">
|
|
16
|
+ <setting-item>
|
5
|
17
|
<n-select
|
6
|
18
|
@change="handlePathChange"
|
7
|
19
|
style="width: 12vw"
|
...
|
...
|
@@ -12,9 +24,7 @@ |
12
|
24
|
></n-select>
|
13
|
25
|
</setting-item>
|
14
|
26
|
</setting-item-box>
|
15
|
|
- </collapse-item>
|
16
|
|
- <collapse-item name="三维配置属性" :expanded="true">
|
17
|
|
- <setting-item-box>
|
|
27
|
+ <setting-item-box name="属性配置">
|
18
|
28
|
<setting-item name="场景色(需要这种格式HEX #000000,否则失效)">
|
19
|
29
|
<n-color-picker size="small" :show-alpha="false" v-model:value="optionData.backgroundColor"></n-color-picker>
|
20
|
30
|
</setting-item>
|
...
|
...
|
@@ -24,19 +34,6 @@ |
24
|
34
|
<SettingItem name="启用阻尼">
|
25
|
35
|
<n-switch v-model:value="optionData.enableDamping" size="small" />
|
26
|
36
|
</SettingItem>
|
27
|
|
- <!-- <SettingItem name="选择灯光">
|
28
|
|
- <setting-item name="灯光">
|
29
|
|
- <n-select
|
30
|
|
- @change="handleLightChange"
|
31
|
|
- v-model:value="selectLight"
|
32
|
|
- size="small"
|
33
|
|
- :options="lightList"
|
34
|
|
- ></n-select>
|
35
|
|
- </setting-item>
|
36
|
|
- <setting-item name="灯光颜色选择">
|
37
|
|
- <n-color-picker size="small" :show-alpha="false" v-model:value="lightColor"></n-color-picker>
|
38
|
|
- </setting-item>
|
39
|
|
- </SettingItem> -->
|
40
|
37
|
<SettingItem v-if="optionData.enableDamping" name="阻尼值">
|
41
|
38
|
<n-input-number v-model:value="optionData.dampingFactor" :min="0" :max="1" size="small"></n-input-number>
|
42
|
39
|
</SettingItem>
|
...
|
...
|
@@ -54,10 +51,13 @@ |
54
|
51
|
</template>
|
55
|
52
|
|
56
|
53
|
<script setup lang="ts">
|
57
|
|
-import { PropType, h, ref, watch } from 'vue'
|
|
54
|
+import { PropType, h, ref, nextTick } from 'vue'
|
58
|
55
|
import { option } from './config'
|
59
|
56
|
import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
|
60
|
|
-import { NEllipsis, NInputNumber, NSelect, NSpace, SelectOption } from 'naive-ui'
|
|
57
|
+import { NEllipsis, NInputNumber, NSelect, NSpace, SelectOption, NCard } from 'naive-ui'
|
|
58
|
+import { uploadFile } from '@/api/external/contentSave/content'
|
|
59
|
+import { downloadFile } from '@/api/external/common'
|
|
60
|
+import { UploadCustomRequestOptions } from 'naive-ui'
|
61
|
61
|
|
62
|
62
|
const props = defineProps({
|
63
|
63
|
optionData: {
|
...
|
...
|
@@ -66,6 +66,11 @@ const props = defineProps({ |
66
|
66
|
}
|
67
|
67
|
})
|
68
|
68
|
|
|
69
|
+const defaultFileList = ref([])
|
|
70
|
+
|
|
71
|
+//文件限制大小
|
|
72
|
+const fileSizeConst = ref(15)
|
|
73
|
+
|
69
|
74
|
const handleChange = (e: boolean) => {
|
70
|
75
|
if (e) props.optionData.dataset = ''
|
71
|
76
|
}
|
...
|
...
|
@@ -79,44 +84,6 @@ const encodinghList = [ |
79
|
84
|
{ label: 'sRGB ', value: 'sRGB ' }
|
80
|
85
|
]
|
81
|
86
|
|
82
|
|
-/**
|
83
|
|
-环境光(AmbientLight) | 方向光(DirectionalLight) | 点光(PointLight) | 半球光(HemisphereLight)
|
84
|
|
-暂且支持 环境光
|
85
|
|
- */
|
86
|
|
-const lightList = [
|
87
|
|
- {
|
88
|
|
- type: 'AmbientLight',
|
89
|
|
- value: 'AmbientLight',
|
90
|
|
- label: '环境光'
|
91
|
|
- }
|
92
|
|
-]
|
93
|
|
-
|
94
|
|
-const selectLight = ref('')
|
95
|
|
-
|
96
|
|
-const lightColor = ref('')
|
97
|
|
-
|
98
|
|
-const lightChange = (type: string, color: string) => {
|
99
|
|
- props.optionData.lights = [
|
100
|
|
- {
|
101
|
|
- type,
|
102
|
|
- color
|
103
|
|
- }
|
104
|
|
- ] as any
|
105
|
|
-}
|
106
|
|
-
|
107
|
|
-const handleLightChange = (e: string) => {
|
108
|
|
- selectLight.value = e
|
109
|
|
- lightChange(e, lightColor.value)
|
110
|
|
-}
|
111
|
|
-
|
112
|
|
-watch(
|
113
|
|
- () => lightColor.value,
|
114
|
|
- newValue => {
|
115
|
|
- lightChange(selectLight.value, newValue)
|
116
|
|
- }
|
117
|
|
-)
|
118
|
|
-
|
119
|
|
-//TODO:三维静态路径地址,无法通过import.meta.globEager来引入,要报错,待优化
|
120
|
87
|
const pathList = [
|
121
|
88
|
{
|
122
|
89
|
label: '猫模型',
|
...
|
...
|
@@ -167,4 +134,55 @@ const renderOption = (option: SelectOption) => { |
167
|
134
|
h(NEllipsis, null, () => option.label)
|
168
|
135
|
])
|
169
|
136
|
}
|
|
137
|
+
|
|
138
|
+const fileSizeMsg = ref(`文件需小于 ${fileSizeConst.value}M ,格式为${threeSupportFileFormat.join(',')}的文件`)
|
|
139
|
+
|
|
140
|
+const extname = (filename: string) => {
|
|
141
|
+ if (!filename || typeof filename != 'string') {
|
|
142
|
+ return false
|
|
143
|
+ }
|
|
144
|
+ let a = filename.split('').reverse().join('')
|
|
145
|
+ let b = a.substring(0, a.search(/\./)).split('').reverse().join('')
|
|
146
|
+ return b
|
|
147
|
+}
|
|
148
|
+
|
|
149
|
+// 上传图片前置处理
|
|
150
|
+// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
151
|
+//@ts-ignore
|
|
152
|
+const beforeUploadHandle = async ({ file }) => {
|
|
153
|
+ defaultFileList.value = []
|
|
154
|
+ const type = extname(file.file.name) as string
|
|
155
|
+ const size = file.file.size
|
|
156
|
+ if (size / (1024 * 1024) > fileSizeConst.value) {
|
|
157
|
+ window['$message'].warning(`文件超出 ${fileSizeConst.value}M限制,请重新上传!`)
|
|
158
|
+ return false
|
|
159
|
+ }
|
|
160
|
+ if (!threeSupportFileFormat.includes(type)) {
|
|
161
|
+ window['$message'].warning('文件格式不符合,请重新上传!')
|
|
162
|
+ return false
|
|
163
|
+ }
|
|
164
|
+ return true
|
|
165
|
+}
|
|
166
|
+
|
|
167
|
+// 自定义上传操作
|
|
168
|
+const customRequest = (options: UploadCustomRequestOptions) => {
|
|
169
|
+ const { file } = options
|
|
170
|
+ nextTick(async () => {
|
|
171
|
+ if (file.file) {
|
|
172
|
+ const formData = new FormData()
|
|
173
|
+ formData.append('file', file.file)
|
|
174
|
+ const uploadRes = await uploadFile(formData)
|
|
175
|
+ if (uploadRes) {
|
|
176
|
+ props.optionData.dataset = uploadRes?.fileStaticUri
|
|
177
|
+ const res = await downloadFile(uploadRes?.fileName)
|
|
178
|
+ console.log(res)
|
|
179
|
+ window['$message'].success('上传文件成功!')
|
|
180
|
+ }
|
|
181
|
+ } else {
|
|
182
|
+ window['$message'].error('上传文件失败,请稍后重试!')
|
|
183
|
+ }
|
|
184
|
+ })
|
|
185
|
+}
|
170
|
186
|
</script>
|
|
187
|
+
|
|
188
|
+<style lang="scss" scoped></style> |
...
|
...
|
|