-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
169 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { computed } from 'vue' | ||
import type { ComputedRef } from 'vue' | ||
|
||
import type { SchoolInfo, SchoolInfoBase } from '../types/school' | ||
|
||
import logoDefault from '../assets/images/bjut-logo.svg?url' | ||
|
||
export const schoolDefault: SchoolInfoBase = { | ||
name: '信息学部', | ||
logo: logoDefault | ||
} | ||
|
||
export const schools: SchoolInfo[] = [ | ||
{ | ||
domain: 'https://appeal.bjut.tech', | ||
name: '信息科学技术学院' | ||
}, | ||
{ | ||
domain: 'https://appeal-cs.bjut.tech', | ||
name: '计算机学院' | ||
} | ||
] | ||
|
||
const schoolRef = computed<SchoolInfoBase>(() => { | ||
const domain = window.location.origin | ||
const school = schools.find(school => school.domain === domain) | ||
return Object.assign({}, schoolDefault, school) | ||
}) | ||
|
||
export const useSchool = (): ComputedRef<SchoolInfoBase> => { | ||
return schoolRef | ||
} | ||
|
||
type SchoolListItem = SchoolInfoBase & SchoolInfo & { | ||
active: boolean | ||
} | ||
|
||
const schoolListRef = computed<SchoolListItem[]>(() => { | ||
const domain = window.location.origin | ||
return schools.map((school) => { | ||
return Object.assign({}, schoolDefault, school, { | ||
active: school.domain === domain | ||
}) | ||
}) | ||
}) | ||
|
||
export const useSchoolList = (): ComputedRef<SchoolListItem[]> => { | ||
return schoolListRef | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script setup lang="ts"> | ||
import { useSchoolList } from '../lib/school' | ||
import type { SchoolInfo } from '../types/school' | ||
const schools = useSchoolList() | ||
const navigate = (school: SchoolInfo): void => { | ||
location.href = school.domain | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col items-stretch py-6 gap-4"> | ||
<van-cell-group inset> | ||
<van-cell | ||
v-for="school of schools" | ||
:key="school.name" | ||
size="large" | ||
:title="school.name" | ||
:label="school.domain" | ||
:is-link="!school.active" | ||
center | ||
@click="navigate(school)" | ||
> | ||
<template #icon> | ||
<img | ||
:src="school.logo" | ||
:alt="'logo of ' + school.name" | ||
class="w-12 h-12 mr-3 rounded-full" | ||
> | ||
</template> | ||
<template | ||
v-if="school.active" | ||
#right-icon | ||
> | ||
<van-icon | ||
size="18" | ||
class="text-green-500" | ||
class-prefix="bi" | ||
name="check2-circle" | ||
/> | ||
</template> | ||
</van-cell> | ||
</van-cell-group> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface SchoolInfoBase { | ||
domain?: string | ||
name: string | ||
logo: string | ||
logoHorizontal?: string | ||
} | ||
|
||
export interface SchoolInfo { | ||
domain: string | ||
name: string | ||
logo?: string | ||
logoHorizontal?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type { Attachment } from '../types/Attachment' | ||
|
||
export const getUrl = (attachment: Attachment): string => { | ||
return `${import.meta.env.VITE_API_URL}/attachments/${attachment.id}` | ||
return `/api/attachments/${attachment.id}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters