diff --git a/core/core-frontend/src/locales/en.ts b/core/core-frontend/src/locales/en.ts index cea0ca1cc8..598326e6ae 100644 --- a/core/core-frontend/src/locales/en.ts +++ b/core/core-frontend/src/locales/en.ts @@ -3702,7 +3702,7 @@ export default { 'Unit: minutes, range: [0-1440], 0 means no time limit, starting from the first access using the ticket', arg_val_tips: 'Please enter parameter values', arg_format_tips: - 'Please use JSON format string, example single valued [argVal], multi valued [argVal1, argVal2]', + 'Please use JSON array format, example single valued [argVal], multi valued [argVal1, argVal2]', param_error: 'Ticket parameter error!', exp_error: 'Ticket has expired!', disable_error: 'Sharing feature has been disabled, please contact administrator!', diff --git a/core/core-frontend/src/locales/tw.ts b/core/core-frontend/src/locales/tw.ts index 5171defaed..2cbe4eeae3 100644 --- a/core/core-frontend/src/locales/tw.ts +++ b/core/core-frontend/src/locales/tw.ts @@ -3595,7 +3595,7 @@ export default { refresh: '刷新', time_tips: '單位: 分鐘,範圍: [0-1440],0代表無期限,自首次使用ticket訪問開始', arg_val_tips: '請輸入參數值', - arg_format_tips: '請使用JSON格式字符串,示例單值[argVal],多值[argVal1, argVal2]', + arg_format_tips: '請使用JSON數組格式,示例單值[argVal],多值[argVal1, argVal2]', param_error: 'Ticket 參數錯誤!', exp_error: 'Ticket 已過期!', disable_error: '已禁用分享功能,請聯系管理員!', diff --git a/core/core-frontend/src/locales/zh-CN.ts b/core/core-frontend/src/locales/zh-CN.ts index 3eb66cc4cd..eee796b03c 100644 --- a/core/core-frontend/src/locales/zh-CN.ts +++ b/core/core-frontend/src/locales/zh-CN.ts @@ -3601,7 +3601,7 @@ export default { refresh: '刷新', time_tips: '单位: 分钟,范围: [0-1440],0代表无期限,自首次使用ticket访问开始', arg_val_tips: '请输入参数值', - arg_format_tips: '请使用JSON格式字符串,示例单值[argVal],多值[argVal1, argVal2]', + arg_format_tips: '请使用JSON数组格式,示例单值[argVal],多值[argVal1, argVal2]', param_error: 'Ticket 参数错误!', exp_error: 'Ticket 已过期!', disable_error: '已禁用分享功能,请联系管理员!', diff --git a/core/core-frontend/src/views/share/share/TicketEdit.vue b/core/core-frontend/src/views/share/share/TicketEdit.vue index 76504c9121..ab91bd16e4 100644 --- a/core/core-frontend/src/views/share/share/TicketEdit.vue +++ b/core/core-frontend/src/views/share/share/TicketEdit.vue @@ -16,6 +16,7 @@ const { t } = useI18n() const dialogVisible = ref(false) const loadingInstance = ref(null) const ticketForm = ref() +const inputRefList = ref([]) const props = defineProps({ uuid: propTypes.string.def('') }) @@ -171,6 +172,52 @@ const argList2Args = () => { }) state.form.args = JSON.stringify(argObj) } +const setErrorStatus = (index, value, status?: boolean) => { + let valid = !!status + if (!value?.length) { + valid = true + } else if (status === null || typeof status === 'undefined') { + try { + JSON.parse(value) + valid = true + } catch (error) { + valid = false + } + } + debugger + const domRef = inputRefList[index] + const e = domRef.input + const className = 'link-ticket-error-msg' + const fullClassName = `.${className}` + if (valid) { + e.style = null + e.style.borderColor = null + const child = e.parentElement.querySelector(fullClassName) + if (child) { + e.parentElement['style'] = null + e.parentElement.removeChild(child) + } + } else { + const msg = 'JSON格式错误' + e.style.color = 'red' + e.style.borderColor = 'red' + e.parentElement['style']['box-shadow'] = '0 0 0 1px red inset' + const child = e.parentElement.querySelector(fullClassName) + if (!child) { + const errorDom = document.createElement('div') + errorDom.className = className + errorDom.innerText = msg + e.parentElement.appendChild(errorDom) + } else { + child.innerText = msg + } + } +} +const setInputRef = (el, index) => { + if (el) { + inputRefList[index] = el + } +} const copyTicket = async ticket => { const url = `${linkUrl.value}?ticket=${ticket}` try { @@ -287,7 +334,12 @@ defineExpose({
- +