mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-06-13 18:45:07 +00:00
Compare commits
No commits in common. "d83dd3993d56777630af1b3ebe6deb5bac35fa7c" and "fb4da655c61269f280aa4670e30a07e6dd68468f" have entirely different histories.
d83dd3993d
...
fb4da655c6
@ -19,48 +19,5 @@ export default [
|
|||||||
rules: {
|
rules: {
|
||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
languageOptions: {
|
|
||||||
globals: {
|
|
||||||
// Browser globals
|
|
||||||
window: 'readonly',
|
|
||||||
document: 'readonly',
|
|
||||||
navigator: 'readonly',
|
|
||||||
localStorage: 'readonly',
|
|
||||||
sessionStorage: 'readonly',
|
|
||||||
console: 'readonly',
|
|
||||||
alert: 'readonly',
|
|
||||||
confirm: 'readonly',
|
|
||||||
prompt: 'readonly',
|
|
||||||
setTimeout: 'readonly',
|
|
||||||
setInterval: 'readonly',
|
|
||||||
fetch: 'readonly',
|
|
||||||
XMLHttpRequest: 'readonly',
|
|
||||||
URL: 'readonly',
|
|
||||||
URLSearchParams: 'readonly',
|
|
||||||
atob: 'readonly',
|
|
||||||
btoa: 'readonly',
|
|
||||||
// Vite globals
|
|
||||||
import: 'readonly',
|
|
||||||
process: 'readonly',
|
|
||||||
// Service Worker globals
|
|
||||||
self: 'readonly',
|
|
||||||
caches: 'readonly',
|
|
||||||
// Web API
|
|
||||||
Notification: 'readonly',
|
|
||||||
ServiceWorker: 'readonly',
|
|
||||||
PushManager: 'readonly',
|
|
||||||
PushSubscription: 'readonly',
|
|
||||||
// Web Storage API
|
|
||||||
Storage: 'readonly',
|
|
||||||
StorageEvent: 'readonly',
|
|
||||||
// Web Socket
|
|
||||||
WebSocket: 'readonly',
|
|
||||||
// Web Workers
|
|
||||||
Worker: 'readonly',
|
|
||||||
SharedWorker: 'readonly',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -153,9 +153,7 @@
|
|||||||
variant="tonal"
|
variant="tonal"
|
||||||
@click="handleCardClick('dialog', subject.name)"
|
@click="handleCardClick('dialog', subject.name)"
|
||||||
>
|
>
|
||||||
<v-icon start size="small">
|
<v-icon start size="small">mdi-plus</v-icon>
|
||||||
{{ isReadOnlyToken ? 'mdi-cancel' : 'mdi-plus' }}
|
|
||||||
</v-icon>
|
|
||||||
{{ subject.name }}
|
{{ subject.name }}
|
||||||
</v-chip>
|
</v-chip>
|
||||||
</div>
|
</div>
|
||||||
@ -167,9 +165,7 @@
|
|||||||
:key="subject.name"
|
:key="subject.name"
|
||||||
@click="handleCardClick('dialog', subject.name)"
|
@click="handleCardClick('dialog', subject.name)"
|
||||||
>
|
>
|
||||||
<v-icon start>
|
<v-icon start> mdi-plus</v-icon>
|
||||||
{{ isReadOnlyToken ? 'mdi-cancel' : 'mdi-plus' }}
|
|
||||||
</v-icon>
|
|
||||||
{{ subject.name }}
|
{{ subject.name }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-btn-group>
|
</v-btn-group>
|
||||||
@ -187,14 +183,8 @@
|
|||||||
{{ subject.name }}
|
{{ subject.name }}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text class="text-center">
|
<v-card-text class="text-center">
|
||||||
<template v-if="isReadOnlyToken">
|
<v-icon color="grey" size="small"> mdi-plus</v-icon>
|
||||||
<v-icon color="grey" size="small"> mdi-cancel </v-icon>
|
<div class="text-caption text-grey">点击添加作业</div>
|
||||||
<div class="text-caption text-grey"> 当日无作业 </div>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<v-icon color="grey" size="small"> mdi-plus </v-icon>
|
|
||||||
<div class="text-caption text-grey"> 点击添加作业 </div>
|
|
||||||
</template>
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</TransitionGroup>
|
</TransitionGroup>
|
||||||
@ -243,17 +233,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
emits: ["open-dialog", "open-attendance", "disabled-click"],
|
emits: ["open-dialog", "open-attendance", "disabled-click"],
|
||||||
data() {
|
mounted() {
|
||||||
return {
|
|
||||||
isReadOnlyToken: false,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async mounted() {
|
|
||||||
/* eslint-disable no-undef */
|
|
||||||
this.resizeObserver = new ResizeObserver(() => {
|
this.resizeObserver = new ResizeObserver(() => {
|
||||||
this.resizeAllGridItems();
|
this.resizeAllGridItems();
|
||||||
});
|
});
|
||||||
/* eslint-enable no-undef */
|
|
||||||
|
|
||||||
// Observe the grid container for width changes
|
// Observe the grid container for width changes
|
||||||
if (this.$refs.gridContainer) {
|
if (this.$refs.gridContainer) {
|
||||||
@ -273,9 +256,6 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 检查只读状态
|
|
||||||
await this.checkReadOnlyStatus();
|
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
// When items change, re-observe new items
|
// When items change, re-observe new items
|
||||||
@ -296,53 +276,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async checkReadOnlyStatus() {
|
|
||||||
// 尝试获取父组件中的StudentNameManager引用
|
|
||||||
try {
|
|
||||||
// 在Vue 2中,通过$parent或$root访问父组件
|
|
||||||
let manager = null;
|
|
||||||
|
|
||||||
// 首先尝试直接访问父组件的引用
|
|
||||||
if (this.$parent && this.$parent.$refs && this.$parent.$refs.studentNameManager) {
|
|
||||||
manager = this.$parent.$refs.studentNameManager;
|
|
||||||
} else if (this.$root && this.$root.$refs && this.$root.$refs.studentNameManager) {
|
|
||||||
manager = this.$root.$refs.studentNameManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (manager && typeof manager.isReadOnly !== 'undefined') {
|
|
||||||
this.isReadOnlyToken = manager.isReadOnly;
|
|
||||||
} else {
|
|
||||||
// 如果无法直接访问manager,尝试通过全局设置获取token信息
|
|
||||||
// 这里需要使用utils/settings中的函数
|
|
||||||
const { getSetting } = await import('@/utils/settings');
|
|
||||||
const token = getSetting('server.kvToken');
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
// 通过API获取token信息来判断是否只读
|
|
||||||
const { default: axios } = await import('@/axios/axios');
|
|
||||||
const serverUrl = getSetting('server.domain');
|
|
||||||
|
|
||||||
if (serverUrl) {
|
|
||||||
try {
|
|
||||||
const tokenResponse = await axios.get(`${serverUrl}/kv/_token`, {
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bearer ${token}`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (tokenResponse.data && typeof tokenResponse.data.isReadOnly !== 'undefined') {
|
|
||||||
this.isReadOnlyToken = tokenResponse.data.isReadOnly;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.error('获取Token信息失败:', err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('检查只读状态失败:', error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resizeGridItem(item) {
|
resizeGridItem(item) {
|
||||||
const grid = this.$refs.gridContainer;
|
const grid = this.$refs.gridContainer;
|
||||||
if (!grid) return;
|
if (!grid) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user