112
112
<span class =" input-help" >{{ loadStatus(currentInfo.loadUsagePercent) }}</span >
113
113
</el-col >
114
114
<template v-for =" (item , index ) of currentInfo .diskData " :key =" index " >
115
- <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" v-if =" showMore || index < 4 " >
115
+ <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" v-if =" isShow('disk', index) " >
116
116
<el-popover placement =" bottom" :width =" 300" trigger =" hover" v-if =" chartsOption[`disk${index}`]" >
117
117
<el-row :gutter =" 5" >
118
118
<el-tag style =" font-weight : 500 " >{{ $t('home.baseInfo') }}:</el-tag >
165
165
</el-col >
166
166
</template >
167
167
<template v-for =" (item , index ) of currentInfo .gpuData " :key =" index " >
168
- <el-col
169
- :xs =" 12"
170
- :sm =" 12"
171
- :md =" 6"
172
- :lg =" 6"
173
- :xl =" 6"
174
- align =" center"
175
- v-if =" showMore || index < 4 - currentInfo.diskData.length"
176
- >
168
+ <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" v-if =" isShow('gpu', index)" >
177
169
<el-popover placement =" bottom" :width =" 250" trigger =" hover" v-if =" chartsOption[`gpu${index}`]" >
178
170
<el-row :gutter =" 5" >
179
171
<el-tag style =" font-weight : 500 " >{{ $t('home.baseInfo') }}:</el-tag >
218
210
</el-col >
219
211
</template >
220
212
<template v-for =" (item , index ) of currentInfo .xpuData " :key =" index " >
221
- <el-col
222
- :xs =" 12"
223
- :sm =" 12"
224
- :md =" 6"
225
- :lg =" 6"
226
- :xl =" 6"
227
- align =" center"
228
- v-if =" showMore || index < 4 - currentInfo.diskData.length"
229
- >
230
- <el-popover placement =" bottom" :width =" 250" trigger =" hover" v-if =" chartsOption[`gpu${index}`]" >
213
+ <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" v-if =" isShow('xpu', index)" >
214
+ <el-popover placement =" bottom" :width =" 250" trigger =" hover" v-if =" chartsOption[`xpu${index}`]" >
231
215
<el-row :gutter =" 5" >
232
216
<el-tag style =" font-weight : 500 " >{{ $t('home.baseInfo') }}:</el-tag >
233
217
</el-row >
249
233
<v-charts
250
234
@click =" goGPU()"
251
235
height =" 160px"
252
- :id =" `gpu ${index}`"
236
+ :id =" `xpu ${index}`"
253
237
type =" pie"
254
- :option =" chartsOption[`gpu ${index}`]"
255
- v-if =" chartsOption[`gpu ${index}`]"
238
+ :option =" chartsOption[`xpu ${index}`]"
239
+ v-if =" chartsOption[`xpu ${index}`]"
256
240
/>
257
241
</template >
258
242
</el-popover >
262
246
<span class =" input-help" v-else >{{ item.deviceName }}</span >
263
247
</el-col >
264
248
</template >
265
- <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" >
266
- <el-button v-if =" !showMore" link type =" primary" @click =" showMore = true" class =" buttonClass" >
249
+ <el-col :xs =" 12" :sm =" 12" :md =" 6" :lg =" 6" :xl =" 6" align =" center" v-if = " totalCount > 5 " >
250
+ <el-button v-if =" !showMore" link type =" primary" @click =" changeShowMore( true) " class =" buttonClass" >
267
251
{{ $t('tabs.more') }}
268
252
<el-icon ><Bottom /></el-icon >
269
253
</el-button >
270
- <el-button
271
- v-if =" showMore && currentInfo.diskData.length > 5"
272
- type =" primary"
273
- link
274
- @click =" showMore = false"
275
- class =" buttonClass"
276
- >
254
+ <el-button v-if =" showMore" type =" primary" link @click =" changeShowMore(false)" class =" buttonClass" >
277
255
{{ $t('tabs.hide') }}
278
256
<el-icon ><Top /></el-icon >
279
257
</el-button >
@@ -288,6 +266,7 @@ import router from '@/routers';
288
266
import i18n from ' @/lang' ;
289
267
import { nextTick , ref } from ' vue' ;
290
268
const showMore = ref (false );
269
+ const totalCount = ref ();
291
270
292
271
const baseInfo = ref <Dashboard .BaseInfo >({
293
272
websiteNumber: 0 ,
@@ -355,7 +334,7 @@ const cpuShowAll = ref();
355
334
356
335
const chartsOption = ref ({ cpu: null , memory: null , load: null });
357
336
358
- const acceptParams = (current : Dashboard .CurrentInfo , base : Dashboard .BaseInfo , isInit : boolean ): void => {
337
+ const acceptParams = (current : Dashboard .CurrentInfo , base : Dashboard .BaseInfo ): void => {
359
338
currentInfo .value = current ;
360
339
baseInfo .value = base ;
361
340
chartsOption .value [' cpu' ] = {
@@ -389,14 +368,15 @@ const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo,
389
368
}
390
369
currentInfo .value .xpuData = currentInfo .value .xpuData || [];
391
370
for (let i = 0 ; i < currentInfo .value .xpuData .length ; i ++ ) {
392
- chartsOption .value [' gpu ' + i ] = {
393
- title: ' GPU -' + currentInfo .value .xpuData [i ].deviceID ,
371
+ chartsOption .value [' xpu ' + i ] = {
372
+ title: ' XPU -' + currentInfo .value .xpuData [i ].deviceID ,
394
373
data: formatNumber (Number (currentInfo .value .xpuData [i ].memoryUtil .replaceAll (' %' , ' ' ))),
395
374
};
396
375
}
397
- if (currentInfo .value .diskData .length + currentInfo .value .gpuData .length > 5 ) {
398
- showMore .value = isInit ? false : showMore .value || false ;
399
- }
376
+
377
+ totalCount .value =
378
+ currentInfo .value .diskData .length + currentInfo .value .gpuData .length + currentInfo .value .xpuData .length ;
379
+ showMore .value = localStorage .getItem (' dashboard_show' ) === ' more' ;
400
380
});
401
381
};
402
382
@@ -413,10 +393,29 @@ function loadStatus(val: number) {
413
393
return i18n .global .t (' home.runJam' );
414
394
}
415
395
396
+ const isShow = (val : string , index : number ) => {
397
+ let showCount = totalCount .value < 6 ? 5 : 4 ;
398
+ switch (val ) {
399
+ case ' disk' :
400
+ return showMore .value || index < showCount ;
401
+ case ' gpu' :
402
+ let gpuCount = showCount - currentInfo .value .diskData .length ;
403
+ return showMore .value || index < gpuCount ;
404
+ case ' xpu' :
405
+ let xpuCount = showCount - currentInfo .value .diskData .length - currentInfo .value .gpuData .length ;
406
+ return showMore .value || index < xpuCount ;
407
+ }
408
+ };
409
+
416
410
const goGPU = () => {
417
411
router .push ({ name: ' GPU' });
418
412
};
419
413
414
+ const changeShowMore = (show : boolean ) => {
415
+ showMore .value = show ;
416
+ localStorage .setItem (' dashboard_show' , show ? ' more' : ' hide' );
417
+ };
418
+
420
419
const loadWidth = () => {
421
420
if (! cpuShowAll .value || currentInfo .value .cpuPercent .length < 32 ) {
422
421
return 310 ;
0 commit comments