modify team store and font
This commit is contained in:
35
frontend/package.json
Normal file
35
frontend/package.json
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "formula1",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite --host=0.0.0.0",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@element-plus/icons-vue": "^2.3.2",
|
||||||
|
"element-plus": "^2.11.7",
|
||||||
|
"pinia": "^3.0.4",
|
||||||
|
"vue": "^3.5.22",
|
||||||
|
"vue-router": "^4.6.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tsconfig/node22": "^22.0.2",
|
||||||
|
"@types/node": "^22.18.11",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
|
"@vue/tsconfig": "^0.8.1",
|
||||||
|
"npm-run-all2": "^8.0.4",
|
||||||
|
"sass-embedded": "^1.93.3",
|
||||||
|
"typescript": "~5.9.0",
|
||||||
|
"vite": "^7.1.11",
|
||||||
|
"vite-plugin-vue-devtools": "^8.0.3",
|
||||||
|
"vue-tsc": "^3.1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
frontend/public/favicon.ico
Executable file
BIN
frontend/public/favicon.ico
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -115,12 +115,23 @@ const hideHeader = computed(() => route.name === 'login' || route.name === 'regi
|
|||||||
.main {
|
.main {
|
||||||
margin-top: 90px;
|
margin-top: 90px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
height: calc(100vh - 90px);
|
||||||
|
overflow-y: auto;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main::before {
|
||||||
|
content: "";
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
background-image: url('@/assets/far.jpg');
|
background-image: url('@/assets/far.jpg');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
height: calc(100vh - 90px);
|
filter: blur(10px);
|
||||||
&>*{
|
transform: scale(1.1);
|
||||||
backdrop-filter: blur(10px);
|
z-index: -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.main-no-header {
|
.main-no-header {
|
||||||
|
|||||||
46
frontend/src/store/Team.ts
Normal file
46
frontend/src/store/Team.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export const useTeamsStore = defineStore('teams', () => {
|
||||||
|
const teamsList = ref<any[]>([])
|
||||||
|
const hasFetched = ref(false)
|
||||||
|
const isLoading = ref(false)
|
||||||
|
|
||||||
|
const fetchTeams = async (forceRefresh = false) => {
|
||||||
|
if (hasFetched.value && !forceRefresh) {
|
||||||
|
return teamsList.value
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoading.value = true
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/teams')
|
||||||
|
const data = await response.json()
|
||||||
|
|
||||||
|
teamsList.value = Array.isArray(data) ? data : (data?.data ?? [])
|
||||||
|
|
||||||
|
hasFetched.value = true // 标记为已获取
|
||||||
|
return teamsList.value
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取teams失败:', error)
|
||||||
|
throw error
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ensureTeamsLoaded = async () => {
|
||||||
|
if (!hasFetched.value) {
|
||||||
|
await fetchTeams()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchTeams(true).catch(() => {})
|
||||||
|
|
||||||
|
return {
|
||||||
|
teamsList,
|
||||||
|
isLoading,
|
||||||
|
hasFetched,
|
||||||
|
fetchTeams,
|
||||||
|
ensureTeamsLoaded
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -191,6 +191,14 @@ const goBack = () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@font-face {
|
||||||
|
font-family: 'F1';
|
||||||
|
src: url('../assets/Formula1-Black.woff2') format('woff2');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
.driver-detail {
|
.driver-detail {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
@@ -213,8 +221,13 @@ const goBack = () => {
|
|||||||
margin-top: 750px;
|
margin-top: 750px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
font-family: 'F1';
|
||||||
|
}
|
||||||
|
|
||||||
.info h1 {
|
.info h1 {
|
||||||
font-size: 36px;
|
font-size: 36px;
|
||||||
|
font-family: 'F1';
|
||||||
}
|
}
|
||||||
|
|
||||||
.vertical-bar1 {
|
.vertical-bar1 {
|
||||||
|
|||||||
@@ -54,6 +54,14 @@ const goDriver = (id: number) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@font-face {
|
||||||
|
font-family: 'F1';
|
||||||
|
src: url('../assets/Formula1-Black.woff2') format('woff2');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
.intro h1 {
|
.intro h1 {
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const goResult = (type: string) => {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.racepage {
|
.racepage {
|
||||||
background-color: #f7f4f1;
|
background-color: #f7f4f1;
|
||||||
height: 100%;
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
|
|||||||
@@ -219,6 +219,14 @@ const goResult = () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
@font-face {
|
||||||
|
font-family: 'F1';
|
||||||
|
src: url('../assets/Formula1-Black.woff2') format('woff2');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
.team-detail {
|
.team-detail {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
@@ -257,6 +265,7 @@ const goResult = () => {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-family: 'F1';
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo {
|
.logo {
|
||||||
@@ -267,6 +276,7 @@ const goResult = () => {
|
|||||||
|
|
||||||
.info h1 {
|
.info h1 {
|
||||||
font-size: 50px;
|
font-size: 50px;
|
||||||
|
font-family: 'F1';
|
||||||
}
|
}
|
||||||
|
|
||||||
.meta {
|
.meta {
|
||||||
|
|||||||
@@ -20,20 +20,21 @@ import { useRouter } from 'vue-router'
|
|||||||
import TeamCard from '@/components/TeamCard.vue'
|
import TeamCard from '@/components/TeamCard.vue'
|
||||||
import { getColor, getCarImage, getLogo } from '@/assets/source'
|
import { getColor, getCarImage, getLogo } from '@/assets/source'
|
||||||
import { useDriversStore } from '@/store/SeasonDrivers'
|
import { useDriversStore } from '@/store/SeasonDrivers'
|
||||||
|
import { useTeamsStore } from '@/store/Team'
|
||||||
|
import { te } from 'element-plus/es/locales.mjs'
|
||||||
// import { teams } from '@/assets/source'
|
// import { teams } from '@/assets/source'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
const teams = ref<any[]>([])
|
const teams = ref<any[]>([])
|
||||||
|
const teamsStore = useTeamsStore()
|
||||||
const driversStore = useDriversStore()
|
const driversStore = useDriversStore()
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/teams')
|
await teamsStore.ensureTeamsLoaded()
|
||||||
const json = await res.json()
|
teams.value = teamsStore.teamsList.map((t: any) => ({
|
||||||
const list = Array.isArray(json) ? json : (json?.data ?? [])
|
|
||||||
teams.value = list.map((t: any) => ({
|
|
||||||
id: t.id ?? t.teamId,
|
id: t.id ?? t.teamId,
|
||||||
name: t.name,
|
name: t.name,
|
||||||
nation: t.nation,
|
nation: t.nation,
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': 'http://localhost:8080',
|
// '/api': 'http://localhost:8080',
|
||||||
// '/api': 'http://10.128.50.6:8080',
|
'/api': 'http://10.128.50.6:8080',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user