inital commit 1

This commit is contained in:
mxdyeah committed 2026-07-08 19:25:27 +08:00
commit 90d8b97673
138 files changed
+23684

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
function broadcast (componentName, eventName, params) {
this.$children.forEach(child => {
const name = child.$options.name
if (name === componentName) {
child.$emit.apply(child, [eventName].concat(params))
} else {
// todo 如果 params 是空数组,接收到的会是 undefined
broadcast.apply(child, [componentName, eventName].concat([params]))
}
})
}
export default {
methods: {
dispatch (componentName, eventName, params) {
let parent = this.$parent || this.$root
let name = parent.$options.name
while (parent && (!name || name !== componentName)) {
parent = parent.$parent
if (parent) {
name = parent.$options.name
}
}
if (parent) {
parent.$emit.apply(parent, [eventName].concat(params))
}
},
broadcast (componentName, eventName, params) {
broadcast.call(this, componentName, eventName, params)
}
}
}
+27
View File
@@ -0,0 +1,27 @@
import api from '@oj/api'
export default {
data () {
return {
captchaSrc: ''
}
},
methods: {
validateForm (formName) {
return new Promise((resolve, reject) => {
this.$refs[formName].validate(valid => {
if (!valid) {
this.$error('please validate the error fields')
} else {
resolve(valid)
}
})
})
},
getCaptchaSrc () {
api.getCaptcha().then(res => {
this.captchaSrc = res.data.data
})
}
}
}
+5
View File
@@ -0,0 +1,5 @@
import Emitter from './emitter'
import ProblemMixin from './problem'
import FormMixin from './form'
export {Emitter, ProblemMixin, FormMixin}
+47
View File
@@ -0,0 +1,47 @@
import utils from '@/utils/utils'
export default {
data () {
return {
statusColumn: false
}
},
methods: {
getACRate (ACCount, TotalCount) {
return utils.getACRate(ACCount, TotalCount)
},
addStatusColumn (tableColumns, dataProblems) {
// 已添加过直接返回
if (this.statusColumn) return
// 只在有做题记录时才添加column
let needAdd = dataProblems.some((item, index) => {
if (item.my_status !== null && item.my_status !== undefined) {
return true
}
})
if (!needAdd) {
return
}
tableColumns.splice(0, 0, {
width: 60,
title: ' ',
render: (h, params) => {
let status = params.row.my_status
if (status === null || status === undefined) {
return undefined
}
return h('Icon', {
props: {
type: status === 0 ? 'checkmark-round' : 'minus-round',
size: '16'
},
style: {
color: status === 0 ? '#19be6b' : '#ed3f14'
}
})
}
})
this.statusColumn = true
}
}
}