首次提交
This commit is contained in:
@@ -58,10 +58,16 @@
|
||||
</div>
|
||||
|
||||
<!-- 添加新科目 -->
|
||||
<v-card class="mb-4" variant="outlined">
|
||||
<v-card
|
||||
class="mb-4"
|
||||
variant="outlined"
|
||||
>
|
||||
<v-card-text>
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6">
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="6"
|
||||
>
|
||||
<v-text-field
|
||||
v-model="newSubjectName"
|
||||
:rules="[v => !!v || '科目名称不能为空']"
|
||||
@@ -85,7 +91,7 @@
|
||||
v-for="(subject, index) in subjects"
|
||||
:key="subject.order"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<template #prepend>
|
||||
<div class="d-flex flex-column align-center mr-2">
|
||||
<v-btn
|
||||
:disabled="index === 0"
|
||||
@@ -114,7 +120,7 @@
|
||||
/>
|
||||
</v-list-item-title>
|
||||
|
||||
<template v-slot:append>
|
||||
<template #append>
|
||||
<v-btn
|
||||
color="error"
|
||||
icon="mdi-delete"
|
||||
@@ -191,9 +197,13 @@ export default {
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await dataProvider.loadData("classworks-config-subject");
|
||||
if (response) {
|
||||
|
||||
// 兼容返回数组或包含 value 属性的对象
|
||||
const dataArray = Array.isArray(response) ? response : (response && Array.isArray(response.value) ? response.value : null);
|
||||
|
||||
if (response && response.success !== false && dataArray) {
|
||||
// 数据存在且加载成功
|
||||
this.subjects = response.map((subject, index) => ({
|
||||
this.subjects = dataArray.map((subject, index) => ({
|
||||
name: subject.name,
|
||||
order: subject.order ?? index
|
||||
})).sort((a, b) => a.order - b.order);
|
||||
@@ -203,7 +213,9 @@ export default {
|
||||
// 数据不存在,使用空数组
|
||||
this.subjects = [];
|
||||
this.originalSubjects = [];
|
||||
this.showMessage('使用默认配置', 'info');
|
||||
if (response && response.success === false) {
|
||||
this.showMessage('未找到已有配置,使用默认配置', 'info');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load config:', error);
|
||||
|
||||
Reference in New Issue
Block a user