Repository navigation
feat: some skeleton #7936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: some skeleton #7936
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,15 +118,15 @@ function loadResources() { | |
| }) | ||
| } | ||
| function handleNavigate(card: HomeResourceCard) { | ||
| if (card.disabled) return | ||
| if (loading.value || card.disabled) return | ||
| router.push({ name: card.route, params: { workspaceId: props.workspaceId } }) | ||
| } | ||
| onMounted(loadResources) | ||
| defineExpose({ refresh: loadResources }) | ||
| </script> | ||
| <template> | ||
| <section> | ||
| <div v-loading="loading" class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4"> | ||
| <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4"> | ||
| <template v-for="card in resourceGroups" :key="card.route"> | ||
| <!-- 进入未禁用资源的列表 --> | ||
| <el-card | ||
|
|
@@ -135,29 +135,31 @@ defineExpose({ refresh: loadResources }) | |
| :style="{ color: card.color, backgroundImage: `linear-gradient(to bottom, ${card.color}0A 0%, #FFFFFF 40%, #FFFFFF 100%)` }" | ||
| @click="handleNavigate(card)" | ||
| > | ||
| <div class="flex-between text-N900"> | ||
| <div> | ||
| <p class="text-N600 mb-1">{{ card.label }}</p> | ||
| <p class="text-3xl leading-9.5 font-semibold tabular-nums">{{ toThousands(card.total) }}</p> | ||
| </div> | ||
| <el-skeleton :loading="loading" animated> | ||
| <div class="flex-between text-N900"> | ||
| <div> | ||
| <p class="text-N600 mb-1">{{ card.label }}</p> | ||
| <p class="text-3xl leading-9.5 font-semibold tabular-nums">{{ toThousands(card.total) }}</p> | ||
| </div> | ||
|
|
||
| <el-avatar | ||
| shape="square" | ||
| :size="44" | ||
| :style="{ color: card.color, backgroundColor: `${card.color}14`, '--el-avatar-border-radius': '12px' }" | ||
| > | ||
| <MkIcon :name="card.icon" :size="26" /> | ||
| </el-avatar> | ||
| </div> | ||
| <el-avatar | ||
| shape="square" | ||
| :size="44" | ||
| :style="{ color: card.color, backgroundColor: `${card.color}14`, '--el-avatar-border-radius': '12px' }" | ||
| > | ||
| <MkIcon :name="card.icon" :size="26" /> | ||
| </el-avatar> | ||
| </div> | ||
|
|
||
| <div class="flex mt-4 gap-4"> | ||
| <template v-for="[label, value] in card.details" :key="String(label)"> | ||
| <div class="min-w-0 flex-1"> | ||
| <p class="text-N600">{{ label }}</p> | ||
| <h2 class="mt-1 text-N900">{{ toThousands(value) }}</h2> | ||
| </div> | ||
| </template> | ||
| </div> | ||
| <div class="flex mt-4 gap-4"> | ||
| <template v-for="[label, value] in card.details" :key="String(label)"> | ||
| <div class="min-w-0 flex-1"> | ||
| <p class="text-N600">{{ label }}</p> | ||
| <h2 class="mt-1 text-N900">{{ toThousands(value) }}</h2> | ||
| </div> | ||
| </template> | ||
| </div> | ||
| </el-skeleton> | ||
| </el-card> | ||
| </template> | ||
| </div> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The diff is generally reasonable, but there are a few potential issues and improvements:
Overall, no syntax error is visible, but the main risk is the empty- |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,39 +81,43 @@ watch(() => [props.workspaceId, props.applicationId], loadMonitoring, { immediat | |
| <slot name="application" :loading="loading" /> | ||
| </div> | ||
| </div> | ||
| <div v-loading="loading" class="min-h-40"> | ||
| <div class="min-h-40"> | ||
| <div class="mb-4 grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4"> | ||
| <template v-for="metric in metrics" :key="metric.id"> | ||
| <el-card shadow="never"> | ||
| <p class="text-N600">{{ metric.title }}</p> | ||
| <div class="mt-1 flex-align-center gap-4 tabular-nums"> | ||
| <template v-if="metric.id === 'feedback'"> | ||
| <template v-for="(series, index) in metric.series" :key="series.name"> | ||
| <div class="flex-align-center gap-2" :title="series.name"> | ||
| <MkIcon | ||
| :name="index === 0 ? 'icon_thumbsup_filled' : 'icon_thumbdown_filled'" | ||
| class="shrink-0" | ||
| :class="index === 0 ? 'text-[#FFC60A]!' : 'text-danger!'" | ||
| /> | ||
| <h2>{{ numberFormat(series.total) }}</h2> | ||
| </div> | ||
| <el-skeleton :loading="loading" :rows="1" animated> | ||
| <p class="text-N600">{{ metric.title }}</p> | ||
| <div class="mt-1 flex-align-center gap-4 tabular-nums"> | ||
| <template v-if="metric.id === 'feedback'"> | ||
| <template v-for="(series, index) in metric.series" :key="series.name"> | ||
| <div class="flex-align-center gap-2" :title="series.name"> | ||
| <MkIcon | ||
| :name="index === 0 ? 'icon_thumbsup_filled' : 'icon_thumbdown_filled'" | ||
| class="shrink-0" | ||
| :class="index === 0 ? 'text-[#FFC60A]!' : 'text-danger!'" | ||
| /> | ||
| <h2>{{ numberFormat(series.total) }}</h2> | ||
| </div> | ||
| </template> | ||
| </template> | ||
| </template> | ||
| <template v-else> | ||
| <h2> | ||
| {{ metric.id === 'tokens' ? formatTokenNumber(metric.series[0]?.total) : numberFormat(metric.series[0]?.total) }} | ||
| </h2> | ||
| <h6 v-if="metric.id === 'activeUsers'" class="-ml-1 text-danger" title="新增用户">+{{ numberFormat(metric.series[1]?.total) }}</h6> | ||
| </template> | ||
| </div> | ||
| <template v-else> | ||
| <h2> | ||
| {{ metric.id === 'tokens' ? formatTokenNumber(metric.series[0]?.total) : numberFormat(metric.series[0]?.total) }} | ||
| </h2> | ||
| <h6 v-if="metric.id === 'activeUsers'" class="-ml-1 text-danger" title="新增用户">+{{ numberFormat(metric.series[1]?.total) }}</h6> | ||
| </template> | ||
| </div> | ||
| </el-skeleton> | ||
| </el-card> | ||
| </template> | ||
| </div> | ||
| <div class="grid grid-cols-1 gap-4 xl:grid-cols-2"> | ||
| <template v-for="metric in metrics" :key="metric.id"> | ||
| <el-card shadow="never"> | ||
| <h4>{{ metric.title }}</h4> | ||
| <el-skeleton v-if="loading" animated class="h-89 mt-4" :rows="8" /> | ||
| <MkLineChart | ||
| v-else | ||
| :value-formatter="metric.id === 'tokens' ? formatTokenNumber : numberFormat" | ||
| class="-mt-6" | ||
| :option="{ xData: days, yData: metric.series }" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change is reasonable, but there are a few issues worth addressing:
The |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff looks mostly fine, but here are the irregularities and suggestions:
Potential issues
initialLoadingnever resets / no retry handling.initialLoading.value = falseis set in.finally(), which runs on both success and failure — that part is correct. However, ifloadApplicationGroups()can be called again (e.g., a refresh or retry),initialLoadingis leftfalse. That's probably intended for a "first load only" flag; if it's meant as a general loading indicator, it should be set totrueat the start of each call.completeGroupConversations()rejection is silent to the caller.Because
.finally()is chained after.then(), the returned promise still rejects if either the page request orcompleteGroupConversations()fails. Callers must handle this. Pairing.finally()with an unhandled rejection could produce console errors if callers don't.catch(). Consider returning a handled promise or documenting the rejection contract.Error state not tracked.
There's no
errorref. If loading fails,initialLoadingbecomesfalsebut consumers can't distinguish "loaded empty" from "failed." Consider addingloadError.Race conditions on repeated calls.
If
loadApplicationGroups()is invoked twice concurrently, the later.finally()may clearinitialLoadingbefore the first completes. A request-token / sequence guard would make this robust.Optimization / style
Indentation-only reformatting inflates the diff. Keeping the original
.then(...)single-expression form and just appending.finally(() => { initialLoading.value = false })would reduce review noise.Consider extracting the mapping logic (
records -> expanded groups) into a helper; the arrow-chain is getting long.Naming:
initialLoadingis fine, but if it only tracks the very first fetch, a name likeisInitialLoadDone/hasLoadedOnce(inverted) or a comment clarifies semantics.Verdict: No functional bugs introduced; main concerns are the missing error state and concurrent-call guarding.