mirror of
				https://github.com/continew-org/continew-admin-ui.git
				synced 2025-11-04 08:59:22 +08:00 
			
		
		
		
	refactor: 调整 eslint.config.js,优化代码格式
This commit is contained in:
		@@ -17,7 +17,7 @@ function getFileName(url: string) {
 | 
			
		||||
export function downloadByUrl({
 | 
			
		||||
  url,
 | 
			
		||||
  target = '_blank',
 | 
			
		||||
  fileName
 | 
			
		||||
  fileName,
 | 
			
		||||
}: {
 | 
			
		||||
  url: string
 | 
			
		||||
  target?: '_self' | '_blank'
 | 
			
		||||
 
 | 
			
		||||
@@ -33,7 +33,7 @@ export function encryptByAes(word, keyWord = defaultKeyWork) {
 | 
			
		||||
  const arcs = CryptoJS.enc.Utf8.parse(word)
 | 
			
		||||
  const encrypted = CryptoJS.AES.encrypt(arcs, key, {
 | 
			
		||||
    mode: CryptoJS.mode.ECB,
 | 
			
		||||
    padding: CryptoJS.pad.Pkcs7
 | 
			
		||||
    padding: CryptoJS.pad.Pkcs7,
 | 
			
		||||
  })
 | 
			
		||||
  return encrypted.toString()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -48,5 +48,5 @@ export default {
 | 
			
		||||
  /** 验证用户是否含有指定角色,必须全部拥有 */
 | 
			
		||||
  hasRoleAnd(roles: string[]) {
 | 
			
		||||
    return roles.every((item) => authRole(item))
 | 
			
		||||
  }
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,12 +30,12 @@ const StatusCodeMessage: ICodeMessage = {
 | 
			
		||||
  501: '服务未实现(501)',
 | 
			
		||||
  502: '网络错误(502)',
 | 
			
		||||
  503: '服务不可用(503)',
 | 
			
		||||
  504: '网络超时(504)'
 | 
			
		||||
  504: '网络超时(504)',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const http: AxiosInstance = axios.create({
 | 
			
		||||
  baseURL: import.meta.env.VITE_API_PREFIX ?? import.meta.env.VITE_API_BASE_URL,
 | 
			
		||||
  timeout: 30 * 1000
 | 
			
		||||
  timeout: 30 * 1000,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
// 请求拦截器
 | 
			
		||||
@@ -53,7 +53,7 @@ http.interceptors.request.use(
 | 
			
		||||
  },
 | 
			
		||||
  (error) => {
 | 
			
		||||
    return Promise.reject(error)
 | 
			
		||||
  }
 | 
			
		||||
  },
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// 响应拦截器
 | 
			
		||||
@@ -84,7 +84,7 @@ http.interceptors.response.use(
 | 
			
		||||
          const userStore = useUserStore()
 | 
			
		||||
          userStore.logoutCallBack()
 | 
			
		||||
          router.replace('/login')
 | 
			
		||||
        }
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    } else {
 | 
			
		||||
      NProgress.done()
 | 
			
		||||
@@ -92,7 +92,7 @@ http.interceptors.response.use(
 | 
			
		||||
      if (msg.length <= 15) {
 | 
			
		||||
        messageErrorWrapper({
 | 
			
		||||
          content: msg || '服务器端错误',
 | 
			
		||||
          duration: 5 * 1000
 | 
			
		||||
          duration: 5 * 1000,
 | 
			
		||||
        })
 | 
			
		||||
      } else {
 | 
			
		||||
        notificationErrorWrapper(msg || '服务器端错误')
 | 
			
		||||
@@ -106,11 +106,10 @@ http.interceptors.response.use(
 | 
			
		||||
    response
 | 
			
		||||
    && messageErrorWrapper({
 | 
			
		||||
      content: StatusCodeMessage[response.status] || '服务器暂时未响应,请刷新页面并重试。若无法解决,请联系管理员',
 | 
			
		||||
      duration: 5 * 1000
 | 
			
		||||
      duration: 5 * 1000,
 | 
			
		||||
    })
 | 
			
		||||
    console.log(response.status)
 | 
			
		||||
    return Promise.reject(error)
 | 
			
		||||
  }
 | 
			
		||||
  },
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const request = <T = unknown>(config: AxiosRequestConfig): Promise<ApiRes<T>> => {
 | 
			
		||||
@@ -139,7 +138,7 @@ const get = <T = any>(url: string, params?: object, config?: AxiosRequestConfig)
 | 
			
		||||
    paramsSerializer: (obj) => {
 | 
			
		||||
      return qs.stringify(obj)
 | 
			
		||||
    },
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -148,7 +147,7 @@ const post = <T = any>(url: string, params?: object, config?: AxiosRequestConfig
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    url,
 | 
			
		||||
    data: params,
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -157,7 +156,7 @@ const put = <T = any>(url: string, params?: object, config?: AxiosRequestConfig)
 | 
			
		||||
    method: 'put',
 | 
			
		||||
    url,
 | 
			
		||||
    data: params,
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -166,7 +165,7 @@ const patch = <T = any>(url: string, params?: object, config?: AxiosRequestConfi
 | 
			
		||||
    method: 'patch',
 | 
			
		||||
    url,
 | 
			
		||||
    data: params,
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -175,7 +174,7 @@ const del = <T = any>(url: string, params?: object, config?: AxiosRequestConfig)
 | 
			
		||||
    method: 'delete',
 | 
			
		||||
    url,
 | 
			
		||||
    data: params,
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
const download = (url: string, params?: object, config?: AxiosRequestConfig): Promise<AxiosResponse> => {
 | 
			
		||||
@@ -187,7 +186,7 @@ const download = (url: string, params?: object, config?: AxiosRequestConfig): Pr
 | 
			
		||||
    paramsSerializer: (obj) => {
 | 
			
		||||
      return qs.stringify(obj)
 | 
			
		||||
    },
 | 
			
		||||
    ...config
 | 
			
		||||
    ...config,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
export default { get, post, put, patch, del, request, requestNative, download }
 | 
			
		||||
 
 | 
			
		||||
@@ -297,7 +297,7 @@ export function dateFormat(date = new Date(), pattern = YMD_HMS) {
 | 
			
		||||
    'm+': date.getMinutes(),
 | 
			
		||||
    's+': date.getSeconds(),
 | 
			
		||||
    'q+': Math.floor((date.getMonth() + 3) / 3),
 | 
			
		||||
    'S+': date.getMilliseconds()
 | 
			
		||||
    'S+': date.getMilliseconds(),
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let formattedDate = pattern // Start with the pattern
 | 
			
		||||
@@ -341,7 +341,7 @@ export function parseCron(cron: string) {
 | 
			
		||||
  try {
 | 
			
		||||
    const parse = expressionNoYear(cron)
 | 
			
		||||
    const iter = CronParser.parseExpression(parse, {
 | 
			
		||||
      currentDate: dateFormat(new Date())
 | 
			
		||||
      currentDate: dateFormat(new Date()),
 | 
			
		||||
    })
 | 
			
		||||
    const result: string[] = []
 | 
			
		||||
    for (let i = 1; i <= 5; i++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
import mitt from 'mitt'
 | 
			
		||||
 | 
			
		||||
type Events = {
 | 
			
		||||
interface Events {
 | 
			
		||||
  // 自定义事件名称
 | 
			
		||||
  event: void
 | 
			
		||||
  // 任意传递的参数
 | 
			
		||||
 
 | 
			
		||||
@@ -19,13 +19,14 @@ export const Code_4 = /^\d{4}$/
 | 
			
		||||
 | 
			
		||||
/** @desc 正则-url链接 */
 | 
			
		||||
export const Url
 | 
			
		||||
  = /(((^https?:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)$/
 | 
			
		||||
  // eslint-disable-next-line regexp/no-useless-quantifier
 | 
			
		||||
  = /(((^https?:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-]*)?\??[-+=&;%@.\w]*#?\w*)?)$/
 | 
			
		||||
 | 
			
		||||
/** @desc 正则-16进颜色值 #333 #8c8c8c */
 | 
			
		||||
export const ColorRegex = /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
 | 
			
		||||
export const ColorRegex = /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
 | 
			
		||||
 | 
			
		||||
/** @desc 正则-只能是中文 */
 | 
			
		||||
export const OnlyCh = /^[\u4E00-\u9FA5]+$/gi
 | 
			
		||||
export const OnlyCh = /^[\u4E00-\u9FA5]+$/g
 | 
			
		||||
 | 
			
		||||
/** @desc 正则-只能是英文 */
 | 
			
		||||
export const OnlyEn = /^[a-zA-Z]*$/
 | 
			
		||||
export const OnlyEn = /^[a-z]*$/i
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,6 @@ export function resetSize(vm) {
 | 
			
		||||
    imgWidth: img_width,
 | 
			
		||||
    imgHeight: img_height,
 | 
			
		||||
    barWidth: bar_width,
 | 
			
		||||
    barHeight: bar_height
 | 
			
		||||
    barHeight: bar_height,
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user