feat:增加docker部署

This commit is contained in:
2026-07-29 22:38:46 +08:00
parent 4d49660b18
commit 78237984ec
13 changed files with 86 additions and 11 deletions

View File

@@ -121,6 +121,7 @@ import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'
import { uploadLibraryFileApi } from '@/apis/library.ts'
import { getModuleOptions } from '@/utils/libraryUtil.ts'
import { getFileExtension, getFileHashName } from '@/utils/file.ts'
const libraryStore = useLibraryStore()
const libraryFileFormRef = ref<FormInstance>()
@@ -166,9 +167,11 @@ const upload = async (options: UploadRequestOptions) => {
const { file } = options
libraryStore.currentFile.size = file.size
libraryStore.currentFile.type = 'image'
const fileName = `${getFileHashName(file)}.${getFileExtension(file.name)}`
const formData = new FormData()
formData.append('file', file)
formData.append('filename', fileName)
const loading = ElLoading.service({
lock: true,

View File

@@ -21,7 +21,7 @@
</div>
</div>
<el-empty v-if="!filterLibraryFileList.length" description="暂无文件" :image-size="80" />
<el-empty v-if="!filterLibraryFileList.length" description="暂无数据"/>
</div>
</template>

View File

@@ -45,7 +45,7 @@
<script setup lang="ts">
import { usePracticeStore } from '@/stores/practice.ts'
import { ElMessage } from 'element-plus'
import { ElLoading, ElMessage } from 'element-plus'
const practiceStore = usePracticeStore()
@@ -65,7 +65,20 @@ const submitAnswerClick = async () => {
return
}
await practiceStore.checkQuestion()
const loading = ElLoading.service({
lock: true,
text: '答案提交中 请等待',
background: 'rgba(0, 0, 0, 0.7)'
})
try {
await practiceStore.checkQuestion()
ElMessage.success('提交成功')
} catch (error) {
console.log(error)
ElMessage.error('提交失败 请联系管理员')
} finally {
loading.close()
}
}
}
</script>

View File

@@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '../layout/index.vue'
const routes = [
@@ -42,7 +42,7 @@ const routes = [
]
const router = createRouter({
history: createWebHistory(),
history: createWebHashHistory(),
routes
})

View File

@@ -42,9 +42,12 @@ export const useLibraryStore = defineStore('library', {
this.fileList = await queryLibraryFileListApi()
this.subjectTree = getSubjectTree(this.fileList)
this.subjectOptions = getSubjectOptions(this.subjectTree)
this.selectedSubject = this.subjectOptions[0].value
this.moduleOptions = getModuleOptions(this.subjectTree, this.selectedSubject)
this.selectedModule = this.moduleOptions[0].value
if (this.subjectOptions.length > 0) {
this.selectedSubject = this.subjectOptions[0].value
this.moduleOptions = getModuleOptions(this.subjectTree, this.selectedSubject)
this.selectedModule = this.moduleOptions[0].value
}
},
async queryFileById(id: number) {
this.currentFile = await queryLibraryFileByIdApi(id)

13
src/utils/file.ts Normal file
View File

@@ -0,0 +1,13 @@
import * as CryptoJS from 'crypto-js'
const hashSHA256 = (message: string) => {
return CryptoJS.SHA256(message).toString(CryptoJS.enc.Hex)
}
export const getFileHashName = (file: File) => {
return hashSHA256(`${file.name}_${file.lastModified}`)
}
export const getFileExtension = (name: string) => {
return name.substring(name.lastIndexOf('.') + 1).toLowerCase()
}

View File

@@ -8,7 +8,7 @@
</div>
<div class="mistake-record">
<div class="mistake-list">
<div v-if="mistakeStore.mistakeList.length" class="mistake-list">
<el-card
v-for="item in mistakeStore.mistakeList"
:key="item.id"
@@ -30,6 +30,8 @@
</div>
</el-card>
</div>
<el-empty v-else description="暂无数据"></el-empty>
</div>
</div>
</template>

View File

@@ -12,7 +12,7 @@
</div>
</div>
<library-filter />
<library-filter v-if="libraryStore.fileList.length" />
<practice-question v-if="practiceStore.hasStart"/>