新增控制台界面与相关资源,修复激活命令误判失败,并兼容 package 版本与 CardsoonServer 打包路径。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
24kycj
2026-08-05 11:29:55 +08:00
parent 8248767b89
commit eb27d72927
63 changed files with 16696 additions and 11321 deletions
@@ -0,0 +1,280 @@
let outTimer = null
export function getShPath(platform) {
return platform.hasRunCmd && platform.hasRunCmd()
? platform.pathJoin(platform.getAppRoot(), 'CardsoonServer', 'control.sh')
: ''
}
export function getActivePath(platform) {
return platform.hasRunCmd && platform.hasRunCmd()
? platform.pathJoin(platform.getAppRoot(), 'CardsoonServer', 'regist.sh')
: ''
}
export function serviceChange(vm, enabled) {
if (enabled) startService(vm)
else stopService(vm)
}
export function startService(vm) {
vm.$prompt('请输入管理员密码并点击确定以执行开启服务操作', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'password'
})
.then(({ value }) => {
vm.serviceLoading = true
vm.serviceText = '服务启动中'
const shPath = getShPath(vm.$platform || require('@/platform').default)
vm.$runCmd(`bash ${shPath} start ${value}`)
.then(() => {
vm.$store.dispatch('chat/setDatas', { name: 'workStatus', data: true })
setTimeout(() => {
vm.$store.dispatch('chat/initWebSocket')
vm.serviceLoading = false
}, 500)
})
.catch((err) => {
vm.$message({ message: err, type: 'error' })
vm.serviceLoading = false
})
})
.catch(() => {
vm.serviceLoading = false
})
}
export function stopService(vm) {
vm.$prompt('请输入管理员密码并点击确定以执行关闭服务操作', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'password'
})
.then(({ value }) => {
vm.serviceLoading = true
vm.serviceText = '服务关闭中'
const shPath = getShPath(vm.$platform || require('@/platform').default)
vm.$runCmd(`bash ${shPath} stop ${value}`)
.then(() => {
vm.$store.dispatch('chat/setDatas', { name: 'workStatus', data: false })
setTimeout(() => {
vm.$store.dispatch('chat/closeWebsocket')
vm.serviceLoading = false
vm.$message({ message: '服务已关闭', type: 'success' })
}, 500)
})
.catch((err) => {
vm.$message({ message: err, type: 'error' })
vm.serviceLoading = false
})
})
.catch(() => {
vm.serviceLoading = false
})
}
export function handleActive(vm) {
vm.$prompt('请输入管理员密码并点击确定以前往激活设备', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputType: 'password'
})
.then(({ value }) => {
const activePath = getActivePath(vm.$platform || require('@/platform').default)
vm.$runCmd(`bash "${activePath}" '${String(value).replace(/'/g, `'\\''`)}'`).catch((err) => {
vm.$message({ message: err, type: 'error' })
})
})
.catch(() => {})
}
export function openWork(vm, platform) {
if (!vm.workStatus) {
vm.$message({ message: '请先连接服务', type: 'warning' })
return
}
if (vm.printer_info.is_set_cddev === 1) {
vm.$confirm('上下光驱未设置,请前往设置', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => goSet(vm, '/manage?type=cddev'))
.catch(() => {})
return
}
vm.isNew = false
platform
.showOpenFileDialog({
title: '打开作业文件',
filters: [{ name: 'Soon Work', extensions: ['dwk'] }]
})
.then((res) => {
const pathOrName = (res.filePaths && res.filePaths[0]) || res.path
const contentP = res.content != null
? Promise.resolve(res.content)
: platform.readFile(pathOrName, 'utf8')
contentP
.then((data) => {
const sep = pathOrName.lastIndexOf('\\') >= 0 ? '\\' : '/'
const fileName = pathOrName.trim().split(sep).pop() || pathOrName
vm.saveWorkList = JSON.parse(data)
vm.saveWorkList.task_name = fileName
vm.workShow = true
vm.$nextTick(() => {
vm.$refs.workAdd.show()
})
})
.catch((err) => {
vm.$message({ message: err && err.message ? err.message : '打开失败', type: 'error' })
})
})
.catch(() => {})
}
export function showWork(vm) {
vm.isNew = true
vm.workShow = true
vm.$nextTick(() => {
vm.$refs.workAdd.show()
})
}
export function workRetry(vm, row) {
vm.$store
.dispatch('chat/websocketsend', {
req_name: 'retry_task',
req_type: 1,
req_info: { task_uuid: row.task_uuid }
})
.then(() => {
vm.$message({ message: '重试成功', type: 'success' })
row.task_status = 1
if (row.ass_task && row.ass_task.length) {
row.ass_task.forEach((item) => { item.task_status = 1 })
}
})
}
export function workCancel(vm, row) {
vm.$store.dispatch('chat/websocketsend', {
req_name: 'cancle_task',
req_type: 1,
req_info: { task_uuid: row.task_uuid }
})
}
export function handleRun(vm, runVal) {
const cd_list = vm.cd_list
if (!vm.workStatus) {
vm.$message({ message: '请先连接服务', type: 'warning' })
return
}
if (!runVal) {
vm.$message({ message: '请先选择需要执行的操作', type: 'warning' })
return
}
if ((cd_list[0] && cd_list[0].copy_scheduler) || (cd_list[1] && cd_list[1].copy_scheduler)) {
vm.$message({ message: '正在任务中,无法进行操作', type: 'warning' })
return
}
clearTimeout(outTimer)
const send = (req_name, req_type, req_info, confirmMsg) => {
vm.$confirm(confirmMsg, '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
vm.$store.dispatch('chat/websocketsend', { req_name, req_type, req_info }).then(() => {
vm.$message({ message: '已发送指令', type: 'success' })
})
}).catch(() => {})
}
switch (parseInt(runVal)) {
case 1:
send('resetPrinter', 2, {}, '确定执行重启设备操作吗?')
break
case 2:
send('cleanError', 2, {}, '确定执行清除错误操作吗?')
break
case 6:
outTimer = setTimeout(() => {
vm.currentRunVal = 0
vm.changeCD.req_info.strong_list = JSON.parse(JSON.stringify(vm.default_cd))
}, 120000)
break
case 7:
send('RefreshCdNum', 2, {}, '点击确定后将刷新所有光盘桶的光盘数量。')
break
default:
break
}
vm.currentRunVal = runVal
}
export function handleCommandCD(vm, e, type) {
vm.changeCD.req_info.strong_list[type - 1].strong_type = parseInt(e, 10)
}
export function sureCD(vm) {
vm.$store
.dispatch('chat/websocketsend', vm.changeCD)
.then(() => {
clearTimeout(outTimer)
vm.currentRunVal = 0
const { getCurrentOSDiscTypes } = require('@/utils/fileSize')
let typeLists = getCurrentOSDiscTypes()
const isBD = vm.changeCD.req_info.strong_list.findIndex((item) => parseInt(item.strong_type) > 3)
if (isBD === -1) typeLists = typeLists.slice(0, 3)
vm.$store.dispatch('chat/setDatas', { name: 'cd_types', data: typeLists })
})
.catch(() => {
clearTimeout(outTimer)
vm.currentRunVal = 0
})
}
export function cancleCD(vm) {
clearTimeout(outTimer)
vm.currentRunVal = 0
vm.changeCD.req_info.strong_list = JSON.parse(JSON.stringify(vm.default_cd))
}
export function noticeChange(vm) {
if (!vm.workStatus) {
vm.$message({ message: '请先连接服务', type: 'warning' })
return
}
vm.showAll = !vm.showAll
}
export function goSet(vm, path) {
vm.$router.push({ path })
}
export function goOut(vm) {
vm.$store.dispatch('FedLogOut').then(() => {
location.reload()
})
}
export function help() {
const platform = require('@/platform').default
if (platform.openHelp) {
platform.openHelp()
}
}
export function getChangeCDDefault() {
return {
req_name: 'setCDStrong',
req_type: 2,
req_info: {
strong_list: [
{ strong_pos: 1, strong_type: 1 },
{ strong_pos: 2, strong_type: 1 }
]
}
}
}
+59
View File
@@ -0,0 +1,59 @@
export const TASK_STATUS_LABELS = {
0: '新建中',
1: '准备中',
2: '等待中',
3: '正在刻录',
4: '正在打印',
5: '已失败',
6: '运行中',
7: '已取消',
100: '已完成'
}
export function taskStatusVariant(status) {
if (status === 100) return 'online'
if (status === 5) return 'error'
if (status === 7) return 'neutral'
if ([3, 4, 6].includes(status)) return 'busy'
if ([0, 1, 2].includes(status)) return 'info'
return 'idle'
}
export const CD_TYPE_LABELS = {
1: 'CD',
2: 'DVD',
3: 'DVD_DL',
4: 'BD',
5: 'BD_DL',
6: 'BD_TL',
7: 'BD_QL'
}
export function getDeviceImages() {
const dp4200 = {
img1: require('@/assets/images/DP-4200.png'),
img2: require('@/assets/images/DP-4200-open.png'),
num1: 5,
num2: 10
}
const dpSe3 = {
img1: require('@/assets/images/DP-SE3.png'),
img2: require('@/assets/images/DP-SE3-open.png'),
num1: 3,
num2: 6
}
return {
4200: dp4200,
SE3: dpSe3,
'DP-4200': dp4200,
'DP-SE3': dpSe3
}
}
export function resolveDeviceImageKey(printerName) {
if (!printerName) return '4200'
const images = getDeviceImages()
if (images[printerName]) return printerName
if (String(printerName).indexOf('SE3') > -1) return 'SE3'
return '4200'
}
+7
View File
@@ -0,0 +1,7 @@
export function isConsoleV2Enabled() {
return process.env.VUE_APP_CONSOLE_V2 === 'true'
}
export function getDefaultHomeRoute() {
return isConsoleV2Enabled() ? '/console' : '/'
}
@@ -0,0 +1,21 @@
export function getRunText({ printer_info, isConnect, serviceStatus, PrinterStatus }) {
let text = PrinterStatus[printer_info.printer_status] || '未知'
if (printer_info.lack_ink) text = '缺墨警告'
if (!isConnect) text = '服务已关闭'
if (!serviceStatus) text = '正在连接服务器,请检查服务器是否正常'
return text
}
export function getDeviceTagVariant({ printer_info, isConnect, serviceStatus }) {
if (!isConnect || !serviceStatus) return 'error'
if (printer_info.lack_ink) return 'warning'
if (printer_info.printer_status === 'I') return 'online'
if (['B', 'P'].includes(printer_info.printer_status)) return 'busy'
return 'idle'
}
export function getDeviceTagLabel({ printer_info, isConnect, serviceStatus, PrinterStatus }) {
if (!isConnect || !serviceStatus) return '离线'
if (printer_info.lack_ink) return '缺墨'
return PrinterStatus[printer_info.printer_status] || '空闲'
}
@@ -0,0 +1,45 @@
export function buildRunList(printerName) {
const isSe3 = printerName && printerName.indexOf('SE3') > -1
const base = [
{ value: 1, label: '重启设备' },
{ value: 2, label: '清除错误' }
]
if (isSe3) {
return base.concat([{ value: 7, label: '刷新光盘桶' }])
}
return base.concat([
{ value: 6, label: '设置光盘桶' },
{ value: 7, label: '刷新光盘桶' }
])
}
export function buildChangeCDStrongList(printerName, strongList, currentRunVal) {
if (currentRunVal === 6) return null
const isSe3 = printerName && printerName.indexOf('SE3') > -1
if (isSe3) {
return [
{ strong_pos: 1, strong_type: strongList[0] ? strongList[0].cd_type : 1 }
]
}
return [
{ strong_pos: 1, strong_type: strongList[0] ? strongList[0].cd_type : 1 },
{ strong_pos: 2, strong_type: strongList[1] ? strongList[1].cd_type : 1 }
]
}
export function applyPrinterInfoSideEffects(printerInfo, ctx) {
const { currentRunVal, router, is_set_cddev_flag } = ctx
const result = {
runList: buildRunList(printerInfo.printer_name),
changeCDStrongList: buildChangeCDStrongList(
printerInfo.printer_name,
printerInfo.strong_list || [],
currentRunVal
),
shouldRedirectCddev: false
}
if (printerInfo.is_set_cddev === 1 && !is_set_cddev_flag) {
result.shouldRedirectCddev = true
}
return result
}
@@ -0,0 +1,33 @@
export function transformTaskList(tasks, CDTypes, accAdd) {
if (!tasks || !tasks.length) {
return { list: [], taskNum: [0, 0, 0] }
}
const nums = [0, 0, 0]
const list = tasks.map((item) => {
const row = { ...item }
if (row.task_status === 100) nums[0]++
else if (row.task_status === 7) nums[1]++
else if (row.task_status === 5) nums[2]++
if (row.ass_task && row.ass_task.length) {
let task_size = 0
row.cdType = CDTypes[row.ass_task[0].cd_type]
row.id = row.task_uuid
row.ass_task.forEach((sub, idx) => {
sub.id = row.task_uuid + '_' + (idx + 1)
sub.cdType = CDTypes[sub.cd_type] + '_' + (idx + 1)
task_size = accAdd(task_size, sub.task_size)
})
row.task_size = task_size
}
return row
})
list.sort((a, b) => {
if (a.task_status === 100 && b.task_status !== 100) return 1
if (b.task_status === 100 && a.task_status !== 100) return -1
return 0
})
return { list, taskNum: nums }
}