fix: fixed how operator updated status is handled

This commit is contained in:
Haoyu Xu
2025-10-05 18:10:40 +08:00
parent 5c9e9eba84
commit a5961da45c
4 changed files with 29 additions and 38 deletions

View File

@@ -11,20 +11,21 @@
"lint:fix": "biome check --write ."
},
"dependencies": {
"react": "^19.2.0",
"react-dom": "^19.2.0",
"jotai": "^2.15.0",
"react-router-dom": "^7.9.3",
"react-simple-typewriter": "^5.0.1",
"reset-css": "^5.0.2",
"@aklive2d/postcss-config": "workspace:*",
"@aklive2d/assets": "workspace:*",
"@aklive2d/config": "workspace:*",
"@aklive2d/libs": "workspace:*",
"@aklive2d/assets": "workspace:*",
"@aklive2d/module": "workspace:*",
"@aklive2d/operator": "workspace:*",
"@aklive2d/vite-helpers": "workspace:*",
"@aklive2d/postcss-config": "workspace:*",
"@aklive2d/showcase": "workspace:*",
"@aklive2d/module": "workspace:*"
"@aklive2d/vite-helpers": "workspace:*",
"jotai": "^2.15.0",
"lodash-es": "^4.17.21",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.9.3",
"react-simple-typewriter": "^5.0.1",
"reset-css": "^5.0.2"
},
"peerDependencies": {
"typescript": ">=5.9.3"

View File

@@ -23,7 +23,7 @@ export default function Home() {
const _trackEvt = useInsight()
const { setTitle, setTabs, currentTab, setHeaderIcon, setFastNavigation } =
useHeader()
const { config, operators, officialUpdate } = useConfig()
const { config, operators, newOperators } = useConfig()
const { i18n } = useI18n()
const [content, setContent] = useState([])
const [voiceOn] = useAtom(voiceOnAtom)
@@ -174,7 +174,7 @@ export default function Home() {
return (
<section>
{officialUpdate.length > operators.length && (
{newOperators.length > 0 && (
<section>
<section
className={`${classes['official-update']} ${classes.group}`}
@@ -182,30 +182,17 @@ export default function Home() {
<section className={classes.info}>
<section className={classes.content}>
<section className={classes.text}>
{officialUpdate.length - operators.length}{' '}
{i18n('new_op_wait_to_update')}
{`${newOperators.length} ${i18n('new_op_wait_to_update')}`}
</section>
<section
className={`${classes['styled-selection']}`}
>
{officialUpdate.info
.filter(
(e) =>
!operators.find(
(o) =>
o.official_id ===
e.id.toString()
)
)
.map((entry, index) => {
{newOperators.map((entry, index) => {
return (
<Link
reloadDocument
to={entry.link}
target="_blank"
style={{
color: entry.color,
}}
key={index}
>
<section
@@ -301,7 +288,7 @@ export default function Home() {
</section>
</section>
<section className={classes.date}>
{officialUpdate.latest}
{newOperators[0].date}
</section>
</section>
<Border />

View File

@@ -1,18 +1,15 @@
import CONFIG from '!/config.json'
import { atom, useAtom } from 'jotai'
import { difference } from 'lodash-es'
import { useCallback } from 'react'
const officialUpdateAtom = atom({})
let operators = []
CONFIG.operators.forEach((item) => {
operators = [...operators, ...item]
})
const OPERATORS = operators
const newOperatorsAtom = atom({})
const OPERATORS = CONFIG.operators.flat()
export function useConfig() {
const config = CONFIG
const operators = OPERATORS
const [officialUpdate, setOfficialUpdate] = useAtom(officialUpdateAtom)
const [newOperators, setNewOperators] = useAtom(newOperatorsAtom)
const fetchOfficialUpdate = useCallback(async () => {
const res = await fetch(
@@ -24,8 +21,11 @@ export function useConfig() {
length: 0,
}
})
setOfficialUpdate(data)
}, [setOfficialUpdate])
const compiledIds = operators.map((item) => item.official_id.toString())
const updatedIds = data.info.map((item) => item.id.toString())
const newIds = difference(updatedIds, compiledIds)
setNewOperators(data.info.filter((item) => newIds.includes(item.id.toString())))
}, [])
return { config, operators, officialUpdate, fetchOfficialUpdate }
return { config, operators, newOperators, fetchOfficialUpdate }
}