This commit is contained in:
BianLzhaoMin 2026-02-04 11:26:08 +08:00
parent 95ced0d8fa
commit 37d0bc12d9
2 changed files with 340 additions and 4 deletions

View File

@ -36,8 +36,9 @@
</template>
<script setup name="Index">
import { ref, markRaw } from 'vue'
import { ref, computed, markRaw } from 'vue'
import { useRouter } from 'vue-router'
import auth from '@/plugins/auth'
import {
User,
Lock,
@ -50,39 +51,65 @@ import {
const router = useRouter()
// - 使 markRaw
const iconItems = ref([
// -
const allIconItems = [
{
icon: markRaw(User),
title: '用户管理',
path: '/system/user',
permissions: ['system:user:list', 'system:user:query'], //
},
{
icon: markRaw(Lock),
title: '角色管理',
path: '/system/role',
permissions: ['system:role:list', 'system:role:query'],
},
{
icon: markRaw(OfficeBuilding),
title: '部门管理',
path: '/system/dept',
permissions: ['system:dept:list', 'system:dept:query'],
},
{
icon: markRaw(UserFilled),
title: '人员管理',
path: '/basicManage/personManage',
permissions: ['person:person:list', 'person:person:query', 'basicManage:personManage:list'],
},
{
icon: markRaw(Collection),
title: '分组管理',
path: '/basicManage/groupManage',
permissions: [
'basicManage:groupManage:list',
'basicManage:groupManage:query',
'group:group:list',
],
},
{
icon: markRaw(Message),
title: '短信任务',
path: '/sMsSendManage/loopSend',
permissions: [
'sMsSendManage:loopSend:list',
'sMsSendManage:loopSend:query',
'sms:loopSend:list',
],
},
])
]
//
const iconItems = computed(() => {
return allIconItems.filter((item) => {
//
if (item.permissions && item.permissions.length > 0) {
return auth.hasPermiOr(item.permissions)
}
//
return false
})
})
//
function handleIconClick(path) {

View File

@ -426,9 +426,318 @@ const handleShowCron = () => {
cronDialogConfig.outerVisible = true
}
//
const getWeekName = (week) => {
const weekMap = {
0: '日',
1: '一',
2: '二',
3: '三',
4: '四',
5: '五',
6: '六',
7: '日',
}
return weekMap[week] || week
}
// Cron
const parseCronToChinese = (cronExpression) => {
if (!cronExpression) return ''
const parts = cronExpression.trim().split(/\s+/)
if (parts.length < 6) return ''
const [second, minute, hour, day, month, week, year] = parts
//
const formatTime = (h, m, s) => {
// *0
const hVal = h === '*' || h === '**' ? '0' : h
const mVal = m === '*' || m === '**' ? '0' : m
const sVal = s === '*' || s === '**' ? '0' : s
const hStr = String(hVal).replace(/\*/g, '0').padStart(2, '0')
const mStr = String(mVal).replace(/\*/g, '0').padStart(2, '0')
const sStr = String(sVal).replace(/\*/g, '0').padStart(2, '0')
return `${hStr}${mStr}${sStr}`
}
//
const getSingleValue = (value) => {
if (value.includes(',')) {
return value.split(',')[0]
}
return value
}
//
const parseWeek = (weekValue) => {
if (!weekValue || weekValue === '?' || weekValue === '*') return ''
if (weekValue.includes(',')) {
const weeks = weekValue.split(',').map(getWeekName)
return `每周${weeks.join('、')}`
}
if (weekValue.includes('-')) {
const [start, end] = weekValue.split('-')
return `每周${getWeekName(start)}到周${getWeekName(end)}`
}
return `每周${getWeekName(weekValue)}`
}
//
const parseDay = (dayValue, isYearly = false) => {
if (!dayValue || dayValue === '?' || dayValue === '*') return ''
if (dayValue.includes(',')) {
const days = dayValue.split(',')
return isYearly ? `${days.join('、')}` : `每月${days.join('、')}`
}
if (dayValue.includes('-')) {
const [start, end] = dayValue.split('-')
return isYearly ? `${start}${end}` : `每月${start}${end}`
}
return isYearly ? `${dayValue}` : `每月${dayValue}`
}
//
const parseMonth = (monthValue) => {
if (!monthValue || monthValue === '*') return ''
if (monthValue.includes(',')) {
const months = monthValue.split(',')
return `${months.join('、')}`
}
if (monthValue.includes('-')) {
const [start, end] = monthValue.split('-')
return `${start}月到${end}`
}
return `${monthValue}`
}
//
const parseYear = (yearValue) => {
if (!yearValue || yearValue === '*') return ''
if (yearValue.includes(',')) {
const years = yearValue.split(',')
return `${years.join('、')}`
}
if (yearValue.includes('-')) {
const [start, end] = yearValue.split('-')
return `${start}年到${end}`
}
return `${yearValue}`
}
//
const hasStep = (value) => {
return value.includes('/') && value.split('/')[0] === '*'
}
// 1
if (
second !== '?' &&
minute !== '?' &&
hour !== '?' &&
day === '*' &&
month === '*' &&
week === '?' &&
(!year || year === '*')
) {
const s = getSingleValue(second)
const m = getSingleValue(minute)
const h = getSingleValue(hour)
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
let result = `每天${formatTime(h, m, s)}执行`
// *
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
return result
}
}
// 2
if (
second !== '?' &&
minute !== '?' &&
hour !== '?' &&
day === '?' &&
month === '*' &&
week !== '?' &&
week !== '*' &&
(!year || year === '*')
) {
const s = getSingleValue(second)
const m = getSingleValue(minute)
const h = getSingleValue(hour)
const weekDesc = parseWeek(week)
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
let result = `${weekDesc}${formatTime(h, m, s)}执行`
// *
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
return result
}
}
// 3
if (
second !== '?' &&
minute !== '?' &&
hour !== '?' &&
day !== '*' &&
day !== '?' &&
month === '*' &&
week === '?' &&
(!year || year === '*')
) {
const s = getSingleValue(second)
const m = getSingleValue(minute)
const h = getSingleValue(hour)
const dayDesc = parseDay(day)
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
let result = `${dayDesc}${formatTime(h, m, s)}执行`
// *
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
return result
}
}
// 4
if (
second !== '?' &&
minute !== '?' &&
hour !== '?' &&
day !== '*' &&
day !== '?' &&
month !== '*' &&
week === '?' &&
(!year || year === '*' || year === '')
) {
const s = getSingleValue(second)
const m = getSingleValue(minute)
const h = getSingleValue(hour)
const dayDesc = parseDay(day, true) // ""
const monthDesc = parseMonth(month)
if (!hasStep(second) && !hasStep(minute) && !hasStep(hour)) {
let result = `每年${monthDesc}${dayDesc}${formatTime(h, m, s)}执行`
// *
result = result.replace(/(\d)\*/g, '$10').replace(/\*/g, '0')
return result
}
}
//
const partsDesc = []
// *
const isYearlyMode = month !== '*' && day !== '*' && day !== '?' && (!year || year === '*')
//
if (year && year !== '*' && year !== '') {
const yearDesc = parseYear(year)
if (yearDesc) partsDesc.push(yearDesc)
} else if (isYearlyMode) {
// ""
partsDesc.push('每年')
}
//
if (month !== '*') {
const monthDesc = parseMonth(month)
if (monthDesc) partsDesc.push(monthDesc)
}
//
if (day !== '?' && day !== '*') {
// ""
const dayDesc = parseDay(day, isYearlyMode)
if (dayDesc) partsDesc.push(dayDesc)
} else if (week !== '?' && week !== '*') {
const weekDesc = parseWeek(week)
if (weekDesc) partsDesc.push(weekDesc)
}
//
const timeParts = []
if (hour !== '*' && !hasStep(hour)) {
const h = getSingleValue(hour)
timeParts.push(h.padStart(2, '0'))
} else {
timeParts.push('**')
}
if (minute !== '*' && !hasStep(minute)) {
const m = getSingleValue(minute)
timeParts.push(m.padStart(2, '0'))
} else {
timeParts.push('**')
}
if (second !== '*' && !hasStep(second)) {
const s = getSingleValue(second)
timeParts.push(s.padStart(2, '0'))
} else {
timeParts.push('**')
}
//
if (timeParts.some((t) => t !== '**')) {
// **00*
const timeStr = timeParts.map((t) => (t === '**' ? '00' : t)).join('')
if (timeStr !== '000000' || (hour === '*' && minute === '*' && second === '*')) {
partsDesc.push(timeStr)
}
}
//
if (hour.includes('/') && hour.split('/')[0] === '*') {
const step = hour.split('/')[1]
partsDesc.push(`${step}小时`)
}
if (minute.includes('/') && minute.split('/')[0] === '*') {
const step = minute.split('/')[1]
partsDesc.push(`${step}分钟`)
}
if (second.includes('/') && second.split('/')[0] === '*') {
const step = second.split('/')[1]
partsDesc.push(`${step}`)
}
//
if (partsDesc.length === 0) {
if (
second === '*' &&
minute === '*' &&
hour === '*' &&
day === '*' &&
month === '*' &&
week === '?'
) {
return '每秒执行'
}
return `Cron表达式${cronExpression}`
}
let result = `${partsDesc.join('')}执行`
// *0*00
result = result.replace(/(\d)\*/g, '$10')
result = result.replace(/\*/g, '0')
return result
}
// Cron
const crontabFill = (value) => {
formData.value.cronExpression = value
//
const chineseDesc = parseCronToChinese(value)
if (chineseDesc) {
//
formData.value.remark = chineseDesc
}
cronDialogConfig.outerVisible = false
}