提交 bae26471 作者: 方治民

style: 添加 antfu eslint-config

上级 045c9851
......@@ -10,7 +10,12 @@ module.exports = {
jsx: true,
},
},
extends: ['plugin:vue/vue3-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
extends: [
'@antfu',
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
'vue/script-setup-uses-vars': 'error',
'@typescript-eslint/ban-ts-ignore': 'off',
......@@ -62,5 +67,6 @@ module.exports = {
},
],
'vue/multi-word-component-names': 'off',
'no-console': 'off',
},
}
import fs from 'fs'
import path from 'path'
import fs from 'node:fs'
import path from 'node:path'
import dotenv from 'dotenv'
export function isDevFn(mode: string): boolean {
......@@ -40,7 +40,7 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
*/
function getConfFiles() {
const script = process.env.npm_lifecycle_script
const reg = new RegExp('--mode ([a-z_\\d]+)')
const reg = /--mode ([a-z_\d]+)/
const result = reg.exec(script as string) as any
if (result) {
const mode = result[1] as string
......
import path from 'node:path'
import type { Plugin } from 'vite'
import path from 'path'
// https://github.com/antfu/unplugin-auto-import
import AutoImport from 'unplugin-auto-import/vite'
......@@ -39,7 +39,7 @@ export function configComponentsImportPlugin(): Plugin {
(name: string) => {
// FIX: 修复 easycom 在 APP 下不生效问题(原因不明
if (name.startsWith('fui-')) {
return path.resolve(__dirname, `src/components/firstui/${name}/${name}.vue`).replaceAll('\\', '/')
return path.resolve(__dirname, `src/components/FirstUI/${name}/${name}.vue`).replaceAll('\\', '/')
}
// if (name.startsWith('uni-')) {
// return `@dcloudio/uni-ui/lib/${name}/${name}.vue`
......
......@@ -98,6 +98,7 @@
"vue-types": "^5.0.2"
},
"devDependencies": {
"@antfu/eslint-config": "^0.37.0",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@dcloudio/types": "^3.3.2",
......@@ -106,6 +107,7 @@
"@dcloudio/uni-helper-json": "^1.0.13",
"@dcloudio/uni-stacktracey": "3.0.0-alpha-3070720230316001",
"@dcloudio/vite-plugin-uni": "3.0.0-alpha-3070720230316001",
"@iconify/json": "^2.2.36",
"@types/lodash-es": "^4.17.7",
"@types/mockjs": "^1.0.7",
"@types/node": "^18.15.3",
......
......@@ -24,11 +24,11 @@
})
onError((err) => {
Message.toast('App Error: ' + err)
Message.toast(`App Error: ${err}`)
})
onUnhandledRejection((err) => {
Message.toast('App UnhandledRejection: ' + err)
Message.toast(`App UnhandledRejection: ${err}`)
})
</script>
......
......@@ -30,10 +30,10 @@ export const Message = {
return new Promise((resolve, reject) => {
// #ifndef APP-PLUS
uni.showModal({
title: title,
title,
content: message,
showCancel: false,
confirmText: confirmText,
confirmText,
success: () => resolve(),
fail: (err) => reject(err),
})
......@@ -56,10 +56,10 @@ export const Message = {
return new Promise((resolve, reject) => {
// #ifndef APP-PLUS
uni.showModal({
title: title,
title,
content: message,
showCancel: showCancel,
confirmText: confirmText,
showCancel,
confirmText,
success: (res) => resolve(res.confirm),
fail: (err) => reject(err),
})
......
<template>
<view class="empty" :style="[{ background: bgColor }]">
<!-- 暂无数据/空数据 -->
<image src="../../static/images/empty.png" />
<!-- 提示内容 -->
<view class="empty-tips" :style="[{ color: tipsColor }]">{{ tips }}</view>
</view>
</template>
<script>
export default {
props: {
......@@ -24,6 +16,16 @@
},
}
</script>
<template>
<view class="empty" :style="[{ background: bgColor }]">
<!-- 暂无数据/空数据 -->
<image src="../../static/images/empty.png" />
<!-- 提示内容 -->
<view class="empty-tips" :style="[{ color: tipsColor }]">{{ tips }}</view>
</view>
</template>
<style>
.empty {
width: 100%;
......
<script lang="ts" setup>
import type { PropType } from 'vue'
import { nanoid } from 'nanoid'
import { isImage, isVideo, getPoster } from './utils'
import { getPoster, isImage, isVideo } from './utils'
type URLs = { url: string }[]
const props = defineProps({
......
......@@ -17,5 +17,5 @@ export function getPoster(url: string) {
return url
}
return url + '.jpg'
return `${url}.jpg`
}
import { i18n } from '/@/locales'
type I18nGlobalTranslation = {
interface I18nGlobalTranslation {
(key: string): string
(key: string, locale: string): string
(key: string, locale: string, list: unknown[]): string
......@@ -37,9 +37,13 @@ export function useI18n(namespace?: string): {
const { t, ...methods } = i18n.global
const tFn: I18nGlobalTranslation = (key: string, ...arg: any[]) => {
if (!key) return ''
if (!key.includes('.') && !namespace) return key
// @ts-ignore
if (!key) {
return ''
}
if (!key.includes('.') && !namespace) {
return key
}
// @ts-expect-error
return t(getKey(namespace, key), ...(arg as I18nTranslationRestParameters))
}
return {
......
......@@ -3,6 +3,7 @@ import type { I18n, I18nOptions } from 'vue-i18n'
import { createI18n } from 'vue-i18n'
import langs from './lang'
// eslint-disable-next-line import/no-mutable-exports
export let i18n: ReturnType<typeof createI18n>
function createI18nOptions(): I18nOptions {
......
......@@ -6,7 +6,7 @@ import { setupAppConfig } from '/@/config/app'
import { setupStore } from '/@/store'
import { setupI18n } from '/@/locales'
import fuiConfig from './components/firstui/fui-config'
import fuiConfig from './components/FirstUI/fui-config'
import 'uno.css'
......@@ -22,8 +22,8 @@ export function createApp() {
// 配置 i18n
setupI18n(app)
//全局组件配置
// @ts-ignore
// 全局组件配置
// @ts-expect-error
uni.$fui = fuiConfig
return {
......
......@@ -55,7 +55,7 @@
"autoscan": true,
"custom": {
// https://doc.firstui.cn/docs/introduce.html
"^fui-(.*)": "@/components/firstui/fui-$1/fui-$1.vue",
"^fui-(.*)": "@/components/FirstUI/fui-$1/fui-$1.vue",
// https://ext.dcloud.net.cn/plugin?id=55#detail
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
}
......
<script>
export default {
data() {
return {
resUrl: this.fui.resUrl(),
}
},
methods: {
goIndex() {
this.fui.href('/pages/tabbar/index/index', true)
},
},
}
</script>
<template>
<view class="fui-wrap">
<view class="fui-content__box">
......@@ -23,21 +38,6 @@
</view>
</template>
<script>
export default {
data() {
return {
resUrl: this.fui.resUrl(),
}
},
methods: {
goIndex() {
this.fui.href('/pages/tabbar/index/index', true)
},
},
}
</script>
<style>
page {
background-color: #fff;
......
......@@ -7,7 +7,6 @@
onLoad(({ uri }) => {
link.value = getExtranetUrl(uri)
name.value = URI(uri).filename()
console.log(uri, link.value, name.value)
// 设置标题栏为文件名
uni.setNavigationBarTitle({
......
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosPromise, AxiosError } from 'axios'
import type { AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios'
import type { RequestOptions, Result, UploadFileParams } from '/#/axios'
import type { CreateAxiosOptions } from './axiosTransform'
import axios from 'axios'
......@@ -7,8 +7,7 @@ import qs from 'qs'
import { AxiosCanceler } from './axiosCancel'
import { isFunction } from '/@/utils/is'
import { cloneDeep } from 'lodash-es'
import { ContentTypeEnum } from '/@/enums/httpEnum'
import { RequestEnum } from '/@/enums/httpEnum'
import { ContentTypeEnum, RequestEnum } from '/@/enums/httpEnum'
/**
* 覆盖实现,使用 uni.request 实现网络请求
......@@ -35,7 +34,7 @@ axios.defaults.adapter = function (config: CreateAxiosOptions): AxiosPromise<any
})
},
fail: (response) => {
// @ts-ignore
// @ts-expect-error
const { errMsg, statusCode } = response
const error = createError(errMsg, config, statusCode, request, {
config,
......@@ -117,7 +116,7 @@ export class VAxios {
// Request interceptor configuration processing
this.axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => {
// If cancel repeat request is turned on, then cancel repeat request is prohibited
// @ts-ignore
// @ts-expect-error
const { ignoreCancelToken } = config.requestOptions
const ignoreCancel =
ignoreCancelToken !== undefined ? ignoreCancelToken : this.options.requestOptions?.ignoreCancelToken
......@@ -147,7 +146,7 @@ export class VAxios {
responseInterceptorsCatch &&
isFunction(responseInterceptorsCatch) &&
this.axiosInstance.interceptors.response.use(undefined, (error) => {
// @ts-ignore
// @ts-expect-error
responseInterceptorsCatch(this.axiosInstance, error)
})
}
......@@ -191,7 +190,6 @@ export class VAxios {
data: formData,
headers: {
'Content-Type': ContentTypeEnum.FORM_DATA,
// @ts-ignore
ignoreCancelToken: true,
},
})
......
import { AxiosError, AxiosInstance } from 'axios'
import type { AxiosError, AxiosInstance } from 'axios'
/**
* 请求重试机制
*/
......@@ -9,15 +9,15 @@ export class AxiosRetry {
*/
retry(AxiosInstance: AxiosInstance, error: AxiosError) {
const { config } = error.response
// @ts-ignore
// @ts-expect-error
const { waitTime, count } = config?.requestOptions?.retryRequest
// @ts-ignore
// @ts-expect-error
config.__retryCount = config.__retryCount || 0
// @ts-ignore
// @ts-expect-error
if (config.__retryCount >= count) {
return Promise.reject(error)
}
// @ts-ignore
// @ts-expect-error
config.__retryCount += 1
return this.delay(waitTime).then(() => AxiosInstance(config))
}
......
......@@ -10,11 +10,11 @@ import { checkStatus } from './checkStatus'
import { useGlobSetting } from '/@/hooks/setting'
import { useI18n } from '/@/hooks/app/useI18n'
import { useMessage } from '/@/hooks/app/useMessage'
import { RequestEnum, ContentTypeEnum } from '/@/enums/httpEnum'
import { ContentTypeEnum, RequestEnum } from '/@/enums/httpEnum'
import { isString } from '/@/utils/is'
import { getToken, clearAuthCache } from '/@/utils/auth'
import { setObjToUrlParams, deepMerge } from '/@/utils'
import { joinTimestamp, formatRequestDate } from './helper'
import { clearAuthCache, getToken } from '/@/utils/auth'
import { deepMerge, setObjToUrlParams } from '/@/utils'
import { formatRequestDate, joinTimestamp } from './helper'
import { AxiosRetry } from '/@/utils/http/axios/axiosRetry'
import * as HTTP from '/@/api/types'
import { API_URL, API_URL_PREFIX } from '/@/utils/net'
......@@ -112,7 +112,7 @@ const transform: AxiosTransform = {
config.params = Object.assign(params || {}, joinTimestamp(joinTime, false))
} else {
// 兼容restful风格
config.url = config.url + params + `${joinTimestamp(joinTime, true)}`
config.url = `${config.url + params}${joinTimestamp(joinTime, true)}`
config.params = undefined
}
} else {
......@@ -172,7 +172,7 @@ const transform: AxiosTransform = {
let errMessage = ''
try {
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
if (code === 'ECONNABORTED' && message.includes('timeout')) {
errMessage = t('sys.api.apiTimeoutMessage')
}
if (err?.includes('Network Error')) {
......@@ -198,7 +198,7 @@ const transform: AxiosTransform = {
const { isOpenRetry } = config.requestOptions.retryRequest
config.method?.toUpperCase() === RequestEnum.GET &&
isOpenRetry &&
// @ts-ignore
// @ts-expect-error
retryRequest.retry(axiosInstance, error)
return Promise.reject(error)
},
......@@ -238,7 +238,7 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
// 接口地址
apiUrl: globSetting.apiUrl,
// 接口拼接地址
urlPrefix: urlPrefix,
urlPrefix,
// 是否加入时间戳
joinTime: true,
// 忽略重复请求
......
......@@ -25,7 +25,7 @@ export function getPopupContainer(node?: HTMLElement): HTMLElement {
export function setObjToUrlParams(baseUrl: string, obj: any): string {
let parameters = ''
for (const key in obj) {
parameters += key + '=' + encodeURIComponent(obj[key]) + '&'
parameters += `${key}=${encodeURIComponent(obj[key])}&`
}
parameters = parameters.replace(/&$/, '')
return /\?$/.test(baseUrl) ? baseUrl + parameters : baseUrl.replace(/\/?$/, '?') + parameters
......@@ -43,7 +43,7 @@ export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
export function getDynamicProps<T, U>(props: T): Partial<U> {
const ret: Recordable = {}
Object.keys(props).map((key) => {
Object.keys(props).forEach((key) => {
ret[key] = unref((props as Recordable)[key])
})
......
/* eslint-disable import/no-mutable-exports */
import { useGlobSetting } from '/@/hooks/setting'
const globSetting = useGlobSetting()
......
......@@ -2,7 +2,7 @@ export function setBadge(number = 0) {
// #ifdef APP-PLUS
// 清除消息角标
plus.runtime.setBadgeNumber(number)
if (plus.os.name.toLowerCase() == 'ios') {
if (plus.os.name.toLowerCase() === 'ios') {
// 导入个推原生类
const GeTuiSdk = plus.ios.importClass('GeTuiSdk')
GeTuiSdk?.setBadge(number)
......
import type { Client, Message, Frame } from 'stompjs'
import type { Client, Frame, Message } from 'stompjs'
import Stomp from './uni-stomp'
import UniWebSocket from './uni-websocket'
import { getToken } from '/@/utils/auth'
......@@ -156,7 +156,7 @@ class StompInstance {
// 订阅状态置false
Object.keys(this.subscribes).forEach((key) => {
this.subscribes[key]['subscribed'] = false
this.subscribes[key].subscribed = false
})
// 连接
......@@ -191,16 +191,15 @@ class StompInstance {
* @param {Function} callback 回调
*/
subscribe(destination: string, callback: (message: Message) => any) {
if (this.subscribes[destination] && this.subscribes[destination]['subscribed']) {
if (this.subscribes[destination] && this.subscribes[destination].subscribed) {
// 已订阅
return
} else if (this.client && this.client.connected) {
// 已连接:调用订阅,缓存订阅信息
const subscribe = this.client.subscribe(destination, (res) => callback(res))
this.subscribes[destination] = { callback: callback, subscribed: true, subscribe: subscribe }
this.subscribes[destination] = { callback, subscribed: true, subscribe }
} else {
// 未连接:缓存订阅信息
this.subscribes[destination] = { callback: callback, subscribed: false }
this.subscribes[destination] = { callback, subscribed: false }
}
}
......
/* eslint-disable eslint-comments/no-unlimited-disable */
/* eslint-disable */
// @ts-nocheck
......
......@@ -129,7 +129,7 @@ class UniWebSocket {
*/
send(data: string | ArrayBuffer) {
this.ws.send({
data: data,
data,
})
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论