Skip to content

Commit af7c54c

Browse files
committed
feat: analyze uncategorized websites (#671)
1 parent 0d01de9 commit af7c54c

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/pages/app/components/Analysis/components/AnalysisFilter/TargetSelect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useDebounceState, useRequest } from "@hooks"
44
import Flex from "@pages/components/Flex"
55
import { selectAllSites } from "@service/site-service"
66
import { listHosts } from "@service/stat-service"
7-
import { identifySiteKey, parseSiteKeyFromIdentity, SiteMap } from "@util/site"
7+
import { CATE_NOT_SET_ID, identifySiteKey, parseSiteKeyFromIdentity, SiteMap } from "@util/site"
88
import { ElSelectV2, ElTag, useNamespace } from "element-plus"
99
import type { OptionType } from "element-plus/es/components/select-v2/src/select.types"
1010
import { computed, defineComponent, type FunctionalComponent, onMounted, ref, type StyleValue } from "vue"
@@ -111,7 +111,7 @@ const TargetSelect = defineComponent(() => {
111111
})
112112

113113
const { data: allItems } = useRequest(
114-
() => fetchItems(cate.all),
114+
() => fetchItems([...cate.all, { id: CATE_NOT_SET_ID, name: t(msg => msg.shared.cate.notSet) }]),
115115
{ defaultValue: [[], []], deps: [() => cate.all] },
116116
)
117117

src/pages/app/components/Analysis/components/Summary/TargetInfo.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { t } from "@app/locale"
1010
import { useRequest } from "@hooks"
1111
import Flex from "@pages/components/Flex"
1212
import { getSite } from '@service/site-service'
13+
import { CATE_NOT_SET_ID } from '@util/site'
1314
import { ElTag } from "element-plus"
1415
import { computed, defineComponent, type StyleValue, toRef } from "vue"
1516
import { useAnalysisTarget } from "../../context"
@@ -50,13 +51,17 @@ const SiteInfo = defineComponent<{ value: timer.site.SiteKey }>(props => {
5051
}, { props: ['value'] })
5152

5253
const CateInfo = defineComponent<{ value: number }>(props => {
53-
const cateId = toRef(props, 'value')
54-
const cateInst = useCategory()
55-
const cate = computed(() => cateInst.all.find(c => c.id === cateId.value))
54+
const { all } = useCategory()
55+
const cateName = computed(() => {
56+
const cateId = props.value
57+
return cateId === CATE_NOT_SET_ID
58+
? t(msg => msg.shared.cate.notSet)
59+
: all.find(c => c.id === cateId)?.name ?? ''
60+
})
5661

5762
return () => (
5863
<Flex width="100%" gap={5} column align="center">
59-
<h1 style={TITLE_STYLE}>{cate.value?.name}</h1>
64+
<h1 style={TITLE_STYLE}>{cateName.value}</h1>
6065
<ElTag type='info' size="small">{t(msg => msg.analysis.target.cate)}</ElTag>
6166
</Flex>
6267
)

src/pages/app/components/common/filter/CategoryFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const CategoryFilter = defineComponent<Props>(props => {
1313
const cate = useCategory()
1414

1515
const options = computed(() => [
16+
...cate.all.map(c => ({ value: c.id, label: c.name })),
1617
{ value: CATE_NOT_SET_ID, label: t(msg => msg.shared.cate.notSet) },
17-
...cate.all.map(c => ({ value: c.id, label: c.name }))
1818
])
1919

2020
return () => cate.enabled ? (

0 commit comments

Comments
 (0)