Initial commit
This commit is contained in:
34
toolbox-app/src/api.js
Normal file
34
toolbox-app/src/api.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import axios from 'axios';
|
||||
import { useSettingsStore } from './store/settings';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'https://api.seiue.com',
|
||||
timeout: 60000,
|
||||
});
|
||||
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
const settingsStore = useSettingsStore();
|
||||
if (settingsStore.authorization) {
|
||||
config.headers['Authorization'] = settingsStore.authorization;
|
||||
}
|
||||
if (settingsStore.xSchoolId) {
|
||||
config.headers['X-School-ID'] = settingsStore.xSchoolId;
|
||||
}
|
||||
if (settingsStore.xRole) {
|
||||
config.headers['X-Role'] = settingsStore.xRole;
|
||||
}
|
||||
if (settingsStore.xReflectionId) {
|
||||
config.headers['X-Reflection-ID'] = settingsStore.xReflectionId;
|
||||
}
|
||||
if (settingsStore.semesterId) {
|
||||
config.headers['X-Semester-ID'] = settingsStore.semesterId;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default api;
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import axios from 'axios';
|
||||
import { useSettingsStore } from '../../store/settings';
|
||||
|
||||
const file = ref(null);
|
||||
const previewData = ref([]);
|
||||
@@ -8,6 +8,7 @@ const isParsing = ref(false);
|
||||
const isWithdrawing = ref(false);
|
||||
const fileInput = ref(null);
|
||||
const schoolName = ref('');
|
||||
const schoolNameError = ref('');
|
||||
const showFailedOnly = ref(false);
|
||||
const withdrawalResults = ref(null);
|
||||
|
||||
@@ -119,12 +120,19 @@ function clearPreview() {
|
||||
}
|
||||
}
|
||||
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const response = await axios.get('http://127.0.0.1:5001/api/school-name');
|
||||
schoolName.value = response.data.school_name;
|
||||
} catch (error) {
|
||||
console.error('Error fetching school name:', error);
|
||||
if (settingsStore.authorization) {
|
||||
schoolNameError.value = '令牌失效,请检查您的 Authorization';
|
||||
} else {
|
||||
schoolNameError.value = '请先在设置页面填写配置信息';
|
||||
}
|
||||
}
|
||||
});
|
||||
function getResultItemClass(studentId) {
|
||||
@@ -146,6 +154,9 @@ function getResultIcon(studentId) {
|
||||
<div v-if="schoolName" class="school-info-tag">
|
||||
正在给 {{ schoolName }} 学校退课
|
||||
</div>
|
||||
<div v-if="schoolNameError" class="school-info-tag school-info-error">
|
||||
{{ schoolNameError }}
|
||||
</div>
|
||||
|
||||
<div class="step-section">
|
||||
<div class="step-header">
|
||||
@@ -391,6 +402,12 @@ function getResultIcon(studentId) {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.school-info-error {
|
||||
background-color: #fff1f0;
|
||||
border-color: #ffa39e;
|
||||
color: #cf1322;
|
||||
}
|
||||
|
||||
.admin-classes-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 4px;
|
||||
|
||||
@@ -2,10 +2,14 @@ import { createApp } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import App from './App.vue';
|
||||
import router from './router';
|
||||
import api from './api';
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(createPinia());
|
||||
app.use(router);
|
||||
|
||||
app.config.globalProperties.$api = api;
|
||||
app.provide('api', api);
|
||||
|
||||
app.mount('#app');
|
||||
|
||||
@@ -2,11 +2,11 @@ import { defineStore } from 'pinia';
|
||||
|
||||
export const useSettingsStore = defineStore('settings', {
|
||||
state: () => ({
|
||||
authorization: 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIzIiwiZXhwIjoxNzYxMTk0MjQzLCJqdGkiOiJmZjdkYTlkMS05ZGEzLTRhZDctYWZhZS04Njc3YWEzMzI0ZGMiLCJpYXQiOjE3NjExMDc4NDMsImlzcyI6Imh0dHBzOi8vbWRwLnNlaXVlLmNvbS9zZWl1ZSIsInN1YiI6IjEwMjg1MjYiLCJjdHgiOiJsb2dpbl9yaWQ9OTY5MjY5XHUwMDI2cmVhZG9ubHk9MFx1MDAyNnN0YWZmX2lkPTI0MCIsInNpZCI6MTAzNDkyOTJ9.bDuRFltrbFkV5NPxMAABFhTxv9zDQDBq4S9ZCRmQwohANrUD7HriP7vmospkrA_5skxJtyi3iK5OtINyIVGFP9zK7jcrfGJlhTrQimfgnHH-39mYsk08fOH-MhDvr2Q87ng-2gACIpNvyvzP-VCxo6IGOk9ZZWg2aT6xua-cV-8',
|
||||
semesterId: '61626',
|
||||
xRole: 'shadow',
|
||||
xSchoolId: '665',
|
||||
xReflectionId: '969269',
|
||||
authorization: '',
|
||||
semesterId: '',
|
||||
xRole: '',
|
||||
xSchoolId: '',
|
||||
xReflectionId: '',
|
||||
}),
|
||||
actions: {
|
||||
setSettings(newSettings) {
|
||||
|
||||
@@ -4,23 +4,23 @@
|
||||
<form @submit.prevent="saveSettings">
|
||||
<div class="form-group">
|
||||
<label for="authorization">Authorization</label>
|
||||
<input type="text" id="authorization" v-model="settings.authorization">
|
||||
<input type="text" id="authorization" v-model="settings.authorization" placeholder="请输入您的 Authorization">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="semesterId">Semester ID</label>
|
||||
<input type="text" id="semesterId" v-model="settings.semesterId">
|
||||
<input type="text" id="semesterId" v-model="settings.semesterId" placeholder="请输入学期 ID">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xRole">X-Role</label>
|
||||
<input type="text" id="xRole" v-model="settings.xRole">
|
||||
<input type="text" id="xRole" v-model="settings.xRole" placeholder="请输入您的角色">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xSchoolId">X-School-ID</label>
|
||||
<input type="text" id="xSchoolId" v-model="settings.xSchoolId">
|
||||
<input type="text" id="xSchoolId" v-model="settings.xSchoolId" placeholder="请输入学校 ID">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="xReflectionId">X-Reflection-ID</label>
|
||||
<input type="text" id="xReflectionId" v-model="settings.xReflectionId">
|
||||
<input type="text" id="xReflectionId" v-model="settings.xReflectionId" placeholder="请输入 Reflection ID">
|
||||
</div>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user