diff --git a/frontend/src/components/DescriptionList/DescriptionList.vue b/frontend/src/components/DescriptionList/DescriptionList.vue index cb84bec..0e858bf 100644 --- a/frontend/src/components/DescriptionList/DescriptionList.vue +++ b/frontend/src/components/DescriptionList/DescriptionList.vue @@ -1,32 +1,36 @@ + \ No newline at end of file diff --git a/frontend/src/components/DescriptionList/index.js b/frontend/src/components/DescriptionList/index.js index 7aed83d..c5aef69 100644 --- a/frontend/src/components/DescriptionList/index.js +++ b/frontend/src/components/DescriptionList/index.js @@ -1,2 +1,7 @@ -import DescriptionList from './DescriptionList' -export default DescriptionList +// 导入名为 DescriptionList 的Vue组件 +// 这个组件位于当前目录下的 DescriptionList.vue 文件中 +import DescriptionList from './DescriptionList'; + +// 将导入的 DescriptionList 组件设置为默认导出 +// 这样其他文件就可以通过 import DescriptionList 来使用这个组件 +export default DescriptionList; \ No newline at end of file diff --git a/frontend/src/components/Exception/ExceptionPage.vue b/frontend/src/components/Exception/ExceptionPage.vue index 132e346..7bc1d11 100644 --- a/frontend/src/components/Exception/ExceptionPage.vue +++ b/frontend/src/components/Exception/ExceptionPage.vue @@ -1,130 +1,103 @@ + + \ No newline at end of file diff --git a/frontend/src/components/Exception/index.js b/frontend/src/components/Exception/index.js index dda91be..f3e42d9 100644 --- a/frontend/src/components/Exception/index.js +++ b/frontend/src/components/Exception/index.js @@ -1,2 +1,6 @@ -import ExceptionPage from './ExceptionPage.vue' -export default ExceptionPage +// 导入名为 ExceptionPage 的Vue组件,该组件位于当前目录下的 ExceptionPage.vue 文件中 +import ExceptionPage from './ExceptionPage.vue'; + +// 将导入的 ExceptionPage 组件设置为默认导出 +// 这样其他文件就可以通过 import ExceptionPage 来使用这个组件 +export default ExceptionPage; \ No newline at end of file diff --git a/frontend/src/components/Exception/type.js b/frontend/src/components/Exception/type.js index 8158f0f..02c9aa9 100644 --- a/frontend/src/components/Exception/type.js +++ b/frontend/src/components/Exception/type.js @@ -1,19 +1,33 @@ +// 定义一个对象,用于存储不同HTTP状态码的错误信息 const types = { + // 定义403状态码的错误信息 403: { - img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg', + // 错误页面的图片URL + img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOYFcZDnb.svg', + // 错误标题 title: '403', + // 错误描述 desc: '抱歉,你无权访问该页面' }, + // 定义404状态码的错误信息 404: { - img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg', + // 错误页面的图片URL + img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozI.svg', + // 错误标题 title: '404', + // 错误描述 desc: '抱歉,你访问的页面不存在或仍在开发中' }, + // 定义500状态码的错误信息 500: { + // 错误页面的图片URL img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg', + // 错误标题 title: '500', + // 错误描述 desc: '抱歉,服务器出错了' } } -export default types +// 导出types对象,使其可以在其他模块中使用 +export default types; \ No newline at end of file diff --git a/frontend/src/components/_util/util.js b/frontend/src/components/_util/util.js index dd33231..cefaf49 100644 --- a/frontend/src/components/_util/util.js +++ b/frontend/src/components/_util/util.js @@ -1,46 +1,59 @@ /** - * components util + * 工具组件集合 */ /** - * 清理空值,对象 - * @param children - * @returns {*[]} + * 清理数组中的空值或空对象 + * @param {Array} children - 要处理的数组,默认为空数组 + * @returns {Array} - 过滤后的数组 */ -export function filterEmpty (children = []) { +export function filterEmpty(children = []) { + // 使用Array.prototype.filter方法移除数组中的空值或空对象 return children.filter(c => c.tag || (c.text && c.text.trim() !== '')) } /** - * 获取字符串长度,英文字符 长度1,中文字符长度2 - * @param {*} str + * 获取字符串的完整长度,英文字符长度为1,中文字符长度为2 + * @param {string} str - 要处理的字符串,默认为空字符串 + * @returns {number} - 字符串的完整长度 */ export const getStrFullLength = (str = '') => + // 使用Array.prototype.split方法将字符串转换为字符数组 str.split('').reduce((pre, cur) => { + // 获取字符的Unicode编码 const charCode = cur.charCodeAt(0) + // 如果字符是ASCII字符(英文字符),则长度加1 if (charCode >= 0 && charCode <= 128) { return pre + 1 } + // 如果字符是双字节字符(中文字符),则长度加2 return pre + 2 }, 0) /** - * 截取字符串,根据 maxLength 截取后返回 - * @param {*} str - * @param {*} maxLength + * 根据最大长度截取字符串,保留完整字符 + * @param {string} str - 要截取的字符串,默认为空字符串 + * @param {number} maxLength - 最大长度,默认无限制 + * @returns {string} - 截取后的字符串 */ export const cutStrByFullLength = (str = '', maxLength) => { let showLength = 0 + // 使用Array.prototype.split方法将字符串转换为字符数组 return str.split('').reduce((pre, cur) => { + // 获取字符的Unicode编码 const charCode = cur.charCodeAt(0) + // 如果字符是ASCII字符(英文字符),则长度加1 if (charCode >= 0 && charCode <= 128) { showLength += 1 } else { + // 如果字符是双字节字符(中文字符),则长度加2 showLength += 2 } + // 如果当前长度小于等于最大长度,则继续累加字符 if (showLength <= maxLength) { return pre + cur } + // 如果超过最大长度,则返回当前累加的字符串 return pre }, '') -} +} \ No newline at end of file