Skip to content

Commit

Permalink
fix: 修复漏洞
Browse files Browse the repository at this point in the history
  • Loading branch information
SilianZ committed Nov 2, 2024
1 parent 4149a56 commit a5c25f2
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/components/AdminReservationTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import DataTable from "primevue/datatable";
import Column from "primevue/column";
import Tag from "primevue/tag";
import { postReservation, type ReservationInfo } from "../api";
import { computed, onMounted, watch, ref, Ref } from "vue";
import { computed, onMounted, watch, ref } from "vue";
import InputText from "primevue/inputtext";
import DatePicker from "primevue/datepicker";
import Button from "primevue/button";
import Select from "primevue/select";
import SelectButton from "primevue/selectbutton";
import { useI18n } from "vue-i18n";
const data: Ref<ReservationInfo | null> = ref(null);
const data = ref<ReservationInfo | null>(null);
const queried = ref(false);
const query = ref("");
const date: Ref<Date | null> = ref(null);
const date = ref<Date | null>(null);
const room = ref("");
const { t, locale } = useI18n();
const options = computed(() => [
Expand Down
10 changes: 5 additions & 5 deletions src/components/ApplicationForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DatePicker from "primevue/datepicker";
import Card from "primevue/card";
import DataTable from "primevue/datatable";
import Column from "primevue/column";
import { computed, ref, Ref, watch } from "vue";
import { computed, ref, watch } from "vue";
import { useToast } from "primevue/usetoast";
import { useRequest } from "vue-request";
import Dialog from "primevue/dialog";
Expand All @@ -26,7 +26,7 @@ const { data: policyData } = useRequest(fetchPolicy);
const policy = computed(() => policyData.value?.policy || []);
const { t, locale } = useI18n();
const reservation: Ref<ApplicationInfo> = ref({
const reservation = ref<ApplicationInfo>({
class: "",
studentName: "",
selectedRoom: null,
Expand Down Expand Up @@ -120,7 +120,7 @@ const formatTime = (date: Date): string =>
`${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
const interval = ref(15);
const date: Ref<Date | null> = ref(null);
const date = ref<Date | null>(null);
const generateTimeOptions = (
startHour: number,
Expand Down Expand Up @@ -171,7 +171,7 @@ const formatDate = (date: Date): string => {
return `${year}-${month}-${day}`;
};
const roomMapping: { [key: string]: number } = {
const roomMapping: Record<string, number> = {
"iStudy Meeting Room 1": 101,
"iStudy Meeting Room 2": 102,
"Writing Center 1": 103,
Expand Down Expand Up @@ -232,7 +232,7 @@ const formatTableDate = (time: string) => {
const formatTableDay = (time: string) => {
const days = time.split(",");
const daysMapping: { [key: string]: string } = {
const daysMapping: Record<string, string> = {
"1": "Mon.",
"2": "Tue.",
"3": "Wed.",
Expand Down
6 changes: 3 additions & 3 deletions src/components/ReservationTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import DataTable from "primevue/datatable";
import Column from "primevue/column";
import Tag from "primevue/tag";
import { postReservation, type ReservationInfo } from "../api";
import { computed, ref, Ref, watch } from "vue";
import { computed, ref, watch } from "vue";
import InputText from "primevue/inputtext";
import DatePicker from "primevue/datepicker";
import Button from "primevue/button";
import Select from "primevue/select";
import SelectButton from "primevue/selectbutton";
import { useI18n } from "vue-i18n";
const data: Ref<ReservationInfo | null> = ref(null);
const data = ref<ReservationInfo | null>(null);
const queried = ref(false);
const query = ref("");
const date: Ref<Date | null> = ref(null);
const date = ref<Date | null>(null);
const room = ref("");
const { t, locale } = useI18n();
Expand Down
2 changes: 1 addition & 1 deletion src/views/Homeview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useI18n } from "vue-i18n";
const { t } = useI18n();
const { run, data } = useRequest(() => getHitokoto(), {
const { run, data } = useRequest(getHitokoto, {
pollingInterval: 5000,
pollingWhenHidden: false,
manual: true,
Expand Down
6 changes: 3 additions & 3 deletions src/views/MaintenenceReportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Dialog from "primevue/dialog";
import { useToast } from "primevue/usetoast";
import FileUpload, { FileUploadSelectEvent } from "primevue/fileupload";
import { ref, Ref, computed, onMounted, watch } from "vue";
import { ref, computed, onMounted, watch } from "vue";
import {
generateCosKey,
getMaintenance,
Expand Down Expand Up @@ -71,7 +71,7 @@ const status = computed(() => [
]);
const severity = ["info", "success", "danger", "warn"];
const query = ref("");
const maintenance: Ref<MaintenanceInfo> = ref({
const maintenance = ref<MaintenanceInfo>({
studentName: "",
subject: "",
location: "",
Expand Down Expand Up @@ -173,8 +173,8 @@ const onClickEvent = async () => {
detail: maintenanceResult.message,
life: 3000,
});
resetForm();
run();
};
const resetForm = () => {
Expand Down
21 changes: 9 additions & 12 deletions src/views/PolicySettingsView.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<script setup lang="ts">
import { useToast } from "primevue/usetoast";
import router from "../router/router";
import { ref, onMounted, computed, Ref } from "vue";
import { ref, onMounted, computed } from "vue";
import {
RoomPolicyInfo,
verifyAdmin,
postPolicy,
postPolicyResume,
Expand All @@ -26,11 +25,9 @@ const token = ref("");
const toast = useToast();
const { t } = useI18n();
const id = ref(-1);
const { data: policy } = useRequest(
(): Promise<{ success: boolean; policy: RoomPolicyInfo[] }> =>
postPolicy(token.value),
{ pollingInterval: 3000 },
);
const { data: policy } = useRequest(() => postPolicy(token.value), {
pollingInterval: 3000,
});
const rooms = ref([
"iStudy Meeting Room 1",
Expand Down Expand Up @@ -58,8 +55,8 @@ const convertedDays = computed(() =>
const isValid = ref(true);
const isStartTimeValid = ref(true);
const isEndTimeValid = ref(true);
const startDate: Ref<Date | null> = ref(null);
const endDate: Ref<Date | null> = ref(null);
const startDate = ref<Date | null>(null);
const endDate = ref<Date | null>(null);
const minStartDate = computed(() => {
let time = new Date();
Expand Down Expand Up @@ -204,7 +201,7 @@ const days = ref([
const formatDays = (time: string) => {
const days = time.split(",");
const daysMapping: { [key: string]: string } = {
const daysMapping: Record<string, string> = {
"1": "Monday",
"2": "Tuesday",
"3": "Wednesday",
Expand All @@ -220,14 +217,14 @@ const formatDays = (time: string) => {
return convertedDays.join(", ");
};
const roomMappingToString: { [key: number]: string } = {
const roomMappingToString: Record<number, string> = {
101: "iStudy Meeting Room 1",
102: "iStudy Meeting Room 2",
103: "Writing Center 1",
106: "Writing Center 2",
};
const roomMappingToNumber: { [key: string]: number } = {
const roomMappingToNumber: Record<string, number> = {
"iStudy Meeting Room 1": 101,
"iStudy Meeting Room 2": 102,
"Writing Center 1": 103,
Expand Down
2 changes: 1 addition & 1 deletion src/views/ReservationActionsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const color = computed(() =>
const token = props.token;
const isValid = ref(false);
const { t } = useI18n();
const roomMapping: { [key: number]: string } = {
const roomMapping: Record<number, string> = {
101: "iStudy Meeting Room 1",
102: "iStudy Meeting Room 2",
103: "Writing Center 1",
Expand Down
17 changes: 8 additions & 9 deletions src/views/ReservationsManagementView.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { useToast } from "primevue/usetoast";
import { onMounted, ref, Ref, computed } from "vue";
import { onMounted, ref, computed } from "vue";
import {
postReservationAccept,
postReservationReject,
verifyAdmin,
} from "../api";
import { useRequest } from "vue-request";
import { ReservationInfo, postAdminReservation } from "../api";
import { postAdminReservation } from "../api";
import router from "../router/router";
import Card from "primevue/card";
import Skeleton from "primevue/skeleton";
Expand Down Expand Up @@ -49,10 +49,9 @@ const reasons = ref([
{ name: "特殊活动优先 - 由于特殊活动或紧急情况,优先安排资源", code: "9" },
]);
const { data: booking } = useRequest(
(): Promise<ReservationInfo> => postAdminReservation(token.value),
{ pollingInterval: 3000 },
);
const { data: booking } = useRequest(() => postAdminReservation(token.value), {
pollingInterval: 3000,
});
const filteredBookingData = computed(
() =>
Expand Down Expand Up @@ -144,19 +143,19 @@ const onRejectEvent = () => {
visible.value = false;
};
const status: Ref<{ [key: string]: string }> = computed(() => ({
const status = computed<Record<string, string>>(() => ({
non: t("reservation.card.tag.pending"),
no: t("reservation.card.tag.rejected"),
yes: t("reservation.card.tag.approved"),
}));
const severity: { [key: string]: string } = {
const severity: Record<string, string> = {
non: "info",
no: "danger",
yes: "success",
};
const roomMapping: { [key: number]: string } = {
const roomMapping: Record<string, string> = {
101: "iStudy Meeting Room 1",
102: "iStudy Meeting Room 2",
103: "Writing Center 1",
Expand Down

0 comments on commit a5c25f2

Please sign in to comment.