Commit 08532c05b85e9419069bbdff19d85928e40be87b
Merge branch 'perf/editor/10-24-59/2024' into 'main_dev'
perf(src/packages): 3D模型预览添加loading效果 See merge request yunteng/thingskit-view!302
Showing
8 changed files
with
66 additions
and
55 deletions
... | ... | @@ -18,7 +18,7 @@ function Menubar( editor ) { |
18 | 18 | container.add( new MenubarView( editor ) ); |
19 | 19 | container.add( new MenubarHelp( editor ) ); |
20 | 20 | |
21 | - container.add( new MenubarStatus( editor ) ); | |
21 | + // container.add( new MenubarStatus( editor ) ); | |
22 | 22 | |
23 | 23 | return container; |
24 | 24 | ... | ... |
... | ... | @@ -25,3 +25,13 @@ export function getThreeJsModel(id) { |
25 | 25 | url: API['URL'] + '/' + id |
26 | 26 | }) |
27 | 27 | } |
28 | + | |
29 | +/** | |
30 | + * @description: 3D模型 获取json数据 api | |
31 | + */ | |
32 | +export function getThreeJsModelByJson(id) { | |
33 | + return defHttp.get({ | |
34 | + url: API['URL'] + '/json' +'/'+id + '/root.json', | |
35 | + timeout: 30 * 1000 | |
36 | + }) | |
37 | +} | |
\ No newline at end of file | ... | ... |
... | ... | @@ -8,7 +8,7 @@ import { Player } from './js/Player.js' |
8 | 8 | import { Sidebar } from './js/Sidebar.js' |
9 | 9 | import { Menubar } from './js/Menubar.js' |
10 | 10 | import { Resizer } from './js/Resizer.js' |
11 | -import { getThreeJsModel } from './js/libs/http/api.js' | |
11 | +import { getThreeJsModelByJson } from './js/libs/http/api.js' | |
12 | 12 | import { useSpin } from './js/libs/spin/useSpin.js' |
13 | 13 | |
14 | 14 | window.URL = window.URL || window.webkitURL |
... | ... | @@ -58,10 +58,9 @@ editor.storage.init(async function () { |
58 | 58 | const { spin, stop } = useSpin() |
59 | 59 | try { |
60 | 60 | spin() |
61 | - const fileData = await getThreeJsModel(file_uuid) | |
61 | + const fileData = await getThreeJsModelByJson(file_uuid) | |
62 | 62 | if (!fileData) return |
63 | - if (!fileData['content']) return | |
64 | - await editor.fromJSON(fileData['content']) | |
63 | + await editor.fromJSON(fileData) | |
65 | 64 | } finally { |
66 | 65 | stop() |
67 | 66 | } | ... | ... |
... | ... | @@ -15,21 +15,19 @@ |
15 | 15 | :intersectRecursive="true" |
16 | 16 | /> |
17 | 17 | <div v-show="show" class="process"> |
18 | - <span> 拼命加载中... </span> | |
19 | - <n-progress type="line" :color="themeColor" :percentage="process" :indicator-placement="'inside'" processing /> | |
18 | + <n-spin :show="show"> | |
19 | + <template #description> 拼命加载中... </template> | |
20 | + </n-spin> | |
20 | 21 | </div> |
21 | 22 | </div> |
22 | 23 | </div> |
23 | 24 | </template> |
24 | 25 | <script setup lang="ts"> |
25 | -import { PropType, toRefs, ref, nextTick, computed } from 'vue' | |
26 | +import { PropType, toRefs, ref, nextTick } from 'vue' | |
26 | 27 | import { CreateComponentType } from '@/packages/index.d' |
27 | 28 | import { vue3dLoader } from 'vue-3d-loader' |
28 | -import { useDesignStore } from '@/store/modules/designStore/designStore' | |
29 | 29 | import { getJwtToken } from '@/utils/external/auth' |
30 | 30 | |
31 | -const designStore = useDesignStore() | |
32 | - | |
33 | 31 | const props = defineProps({ |
34 | 32 | chartConfig: { |
35 | 33 | type: Object as PropType<CreateComponentType>, |
... | ... | @@ -37,10 +35,6 @@ const props = defineProps({ |
37 | 35 | } |
38 | 36 | }) |
39 | 37 | |
40 | -const themeColor = computed(() => { | |
41 | - return designStore.getAppTheme | |
42 | -}) | |
43 | - | |
44 | 38 | const vue3dLoaderRef = ref(null) |
45 | 39 | |
46 | 40 | const headers = { |
... | ... | @@ -54,12 +48,16 @@ const webGLRendererOptions = { |
54 | 48 | } |
55 | 49 | |
56 | 50 | //三维模型加载 |
57 | -const show = ref(false) | |
51 | +const show = ref(true) | |
52 | + | |
53 | +const { dataset, backgroundColor, backgroundAlpha, borderConfig } = toRefs(props.chartConfig.option) as Recordable | |
58 | 54 | |
59 | 55 | const onLoad = async () => { |
60 | 56 | //加载完成 |
61 | 57 | await nextTick() |
62 | - show.value = false | |
58 | + if (dataset.value) { | |
59 | + show.value = false | |
60 | + } | |
63 | 61 | } |
64 | 62 | |
65 | 63 | //三维模型进度条 |
... | ... | @@ -70,8 +68,6 @@ const onProcess = (event: Recordable) => { |
70 | 68 | } |
71 | 69 | |
72 | 70 | const { w, h } = toRefs(props.chartConfig.attr) |
73 | - | |
74 | -const { dataset, backgroundColor, backgroundAlpha,borderConfig } = toRefs(props.chartConfig.option) as Recordable | |
75 | 71 | </script> |
76 | 72 | |
77 | 73 | <style lang="scss" scoped> |
... | ... | @@ -86,6 +82,9 @@ const { dataset, backgroundColor, backgroundAlpha,borderConfig } = toRefs(props. |
86 | 82 | left: 50%; |
87 | 83 | width: 50%; |
88 | 84 | transform: translate(-50%, -50%); |
85 | + display:flex; | |
86 | + align-items: center; | |
87 | + justify-content: center; | |
89 | 88 | } |
90 | 89 | } |
91 | 90 | </style> | ... | ... |
... | ... | @@ -108,7 +108,6 @@ export async function getPlayUrl( |
108 | 108 | } |
109 | 109 | } else if (accessMode === AccessMode.GBT28181) { |
110 | 110 | const { securityPolicy } = useGlobSetting() |
111 | - console.log(useGlobSetting()) | |
112 | 111 | const { deviceId, channelNo } = params?.params || {}; |
113 | 112 | const result = await getVideoControlStart({ channelId: channelNo!, deviceId: deviceId! }); |
114 | 113 | return { url: securityPolicy ? result.data.https_flv : result.data.flv, type: 'flv' }; | ... | ... |
... | ... | @@ -20,28 +20,29 @@ |
20 | 20 | <template #action> |
21 | 21 | <div class="go-flex-items-center list-footer" justify="space-between"> |
22 | 22 | <div style="display: flex; flex-direction: column; align-items: start"> |
23 | - <n-text v-if="!focus" @click="handleFocus"> | |
24 | - <n-button | |
25 | - class="list-footer-button" | |
26 | - secondary | |
27 | - size="tiny" | |
28 | - > | |
29 | - <span class="title"> | |
30 | - {{ cardData.name || cardData.id }} | |
31 | - </span> | |
32 | - </n-button> | |
33 | - </n-text> | |
34 | - <n-input | |
35 | - v-else | |
36 | - ref="inputInstRef" | |
37 | - size="small" | |
38 | - type="text" | |
39 | - maxlength="16" | |
40 | - show-count | |
41 | - v-model:value.trim="title" | |
42 | - @keyup.enter="handleBlur" | |
43 | - @blur="handleBlur" | |
44 | - ></n-input> | |
23 | + <n-tooltip trigger="hover"> | |
24 | + <template #trigger> | |
25 | + <n-text v-if="!focus" @click="handleFocus"> | |
26 | + <n-button class="list-footer-button" secondary size="tiny"> | |
27 | + <span class="title"> | |
28 | + {{ cardData.name || cardData.id }} | |
29 | + </span> | |
30 | + </n-button> | |
31 | + </n-text> | |
32 | + <n-input | |
33 | + v-else | |
34 | + ref="inputInstRef" | |
35 | + size="small" | |
36 | + type="text" | |
37 | + maxlength="16" | |
38 | + show-count | |
39 | + v-model:value.trim="title" | |
40 | + @keyup.enter="handleBlur" | |
41 | + @blur="handleBlur" | |
42 | + ></n-input> | |
43 | + </template> | |
44 | + {{ cardData.name || cardData.id }} | |
45 | + </n-tooltip> | |
45 | 46 | <n-text style="font-size: 12px; margin-left: 6px">{{ cardData.createTime }}</n-text> |
46 | 47 | </div> |
47 | 48 | <!-- 工具 --> |
... | ... | @@ -241,7 +242,7 @@ $contentHeight: 180px; |
241 | 242 | .list-footer-button { |
242 | 243 | display: flex; |
243 | 244 | // justify-content: flex-start; |
244 | - width: 135px; | |
245 | + width: 125px; | |
245 | 246 | overflow: hidden; |
246 | 247 | text-overflow: ellipsis; |
247 | 248 | white-space: nowrap; | ... | ... |
... | ... | @@ -88,21 +88,22 @@ export const useDataListInit = (formValue: { name: string; state: string | null |
88 | 88 | // 发布处理 |
89 | 89 | const releaseHandle = async (cardData: ChartType) => { |
90 | 90 | const { id, state } = cardData |
91 | - await putThreeJsModelRelease({ | |
91 | + const res = await putThreeJsModelRelease({ | |
92 | 92 | id, |
93 | 93 | // [0未发布, 1发布] |
94 | 94 | state: state === 1 ? 0 : 1 |
95 | 95 | }) |
96 | - list.value = [] | |
97 | - fetchList() | |
98 | - // 发布 -> 未发布 | |
99 | 96 | if (state === 1) { |
100 | 97 | window['$message'].success(window['$t']('common.cancelReleaseSuccessText')) |
101 | - return | |
98 | + } else { | |
99 | + window['$message'].success(window['$t']('common.releaseSuccessText')) | |
100 | + } | |
101 | + if(res) { | |
102 | + setTimeout(() => { | |
103 | + list.value = [] | |
104 | + fetchList() | |
105 | + }, 500) | |
102 | 106 | } |
103 | - // 未发布 -> 发布 | |
104 | - window['$message'].success(window['$t']('common.releaseSuccessText')) | |
105 | - return | |
106 | 107 | } |
107 | 108 | |
108 | 109 | // 立即请求 | ... | ... |
... | ... | @@ -161,14 +161,15 @@ const releaseGoDialog = (message: string, state: number, messageText: string) => |
161 | 161 | // eslint-disable-next-line @typescript-eslint/no-empty-function |
162 | 162 | onPositiveCallback: () => {}, |
163 | 163 | promiseResCallback: async () => { |
164 | - console.log(list.value) | |
165 | 164 | // eslint-disable-next-line no-case-declarations |
166 | 165 | const bulkDeleteIds = list.value |
167 | 166 | ?.filter((item: ChartType) => item.checkedValue) |
168 | 167 | ?.map((item: ChartType) => item.id) |
169 | 168 | await putReleaseThreeJsModel(state, bulkDeleteIds as unknown as string[]) |
170 | 169 | window['$message'].success(window['$t'](messageText)) |
171 | - handleSearchClick() | |
170 | + setTimeout(() => { | |
171 | + handleSearchClick() | |
172 | + }, 500) | |
172 | 173 | isBulkOperationFlag.value = true |
173 | 174 | selectAllTextFlag.value = true |
174 | 175 | operationKey.value = '' |
... | ... | @@ -188,14 +189,15 @@ const handleOperationSelect = async (key: string) => { |
188 | 189 | // eslint-disable-next-line @typescript-eslint/no-empty-function |
189 | 190 | onPositiveCallback: () => {}, |
190 | 191 | promiseResCallback: async () => { |
191 | - console.log(list.value) | |
192 | 192 | // eslint-disable-next-line no-case-declarations |
193 | 193 | const bulkDeleteIds = list.value |
194 | 194 | ?.filter((item: ChartType) => item.checkedValue) |
195 | 195 | ?.map((item: ChartType) => item.id) |
196 | 196 | await threeJsDeleteApi([bulkDeleteIds] as unknown as string[]) |
197 | 197 | window['$message'].success(window['$t']('common.deleteSuccessText')) |
198 | - handleSearchClick() | |
198 | + setTimeout(() => { | |
199 | + handleSearchClick() | |
200 | + }, 500) | |
199 | 201 | isBulkOperationFlag.value = true |
200 | 202 | selectAllTextFlag.value = true |
201 | 203 | operationKey.value = '' | ... | ... |