chore: 优化部分代码

This commit is contained in:
2024-09-06 20:43:31 +08:00
parent 948158f1fa
commit cb03111c22
6 changed files with 11 additions and 24 deletions

View File

@@ -47,6 +47,7 @@ export default antfu(
'style/brace-style': [2, '1tbs', { allowSingleLine: true }], // 对块执行一致的大括号样式 'style/brace-style': [2, '1tbs', { allowSingleLine: true }], // 对块执行一致的大括号样式
'style/comma-dangle': [2, 'never'], // 要求或不允许尾随逗号 'style/comma-dangle': [2, 'never'], // 要求或不允许尾随逗号
'ts/consistent-type-definitions': 0, 'ts/consistent-type-definitions': 0,
'ts/no-unused-expressions': 0,
'node/prefer-global/process': 0, 'node/prefer-global/process': 0,
'antfu/top-level-function': 0, 'antfu/top-level-function': 0,
'antfu/if-newline': 0 'antfu/if-newline': 0

View File

@@ -37,11 +37,6 @@ const defaultConfig = {
const config = defaultConfig const config = defaultConfig
const codeValue = computed(() => props.codeJson) const codeValue = computed(() => props.codeJson)
const visible = ref(false)
// 打开
const open = () => {
visible.value = true
}
const extensions = computed(() => { const extensions = computed(() => {
const arr = [isDark.value ? oneDark : githubLight] const arr = [isDark.value ? oneDark : githubLight]
@@ -53,8 +48,6 @@ const extensions = computed(() => {
} }
return arr return arr
}) })
defineExpose({ open })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -33,9 +33,9 @@ const iconSize = computed<string | number>(() => {
return getUnitValue(props.size) return getUnitValue(props.size)
}) })
const iconName = computed<string>(() => `#icon-${props.name}`) const iconName = computed(() => `#icon-${props.name}`)
const svgClass = computed<string>(() => { const svgClass = computed(() => {
if (props.name) return `svg-icon icon-${props.name}` if (props.name) return `svg-icon icon-${props.name}`
return 'svg-icon' return 'svg-icon'
}) })

View File

@@ -3,8 +3,8 @@ import { Message, Modal } from '@arco-design/web-vue'
import type { Options as paginationOptions } from './usePagination' import type { Options as paginationOptions } from './usePagination'
import { usePagination } from '@/hooks' import { usePagination } from '@/hooks'
interface Options<T> { interface Options<T, U> {
formatResult?: (data: T[]) => any formatResult?: (data: T[]) => U[]
onSuccess?: () => void onSuccess?: () => void
immediate?: boolean immediate?: boolean
rowKey?: keyof T rowKey?: keyof T
@@ -14,11 +14,11 @@ interface Options<T> {
type PaginationParams = { page: number, size: number } type PaginationParams = { page: number, size: number }
type Api<T> = (params: PaginationParams) => Promise<ApiRes<PageRes<T[]>>> | Promise<ApiRes<T[]>> type Api<T> = (params: PaginationParams) => Promise<ApiRes<PageRes<T[]>>> | Promise<ApiRes<T[]>>
export function useTable<T>(api: Api<T>, options?: Options<T>) { export function useTable<T extends U, U = T>(api: Api<T>, options?: Options<T, U>) {
const { formatResult, onSuccess, immediate, rowKey } = options || {} const { formatResult, onSuccess, immediate, rowKey } = options || {}
const { pagination, setTotal } = usePagination(() => getTableData(), options?.paginationOption) const { pagination, setTotal } = usePagination(() => getTableData(), options?.paginationOption)
const loading = ref(false) const loading = ref(false)
const tableData = ref<T[]>([]) const tableData: Ref<U[]> = ref([])
async function getTableData() { async function getTableData() {
try { try {

View File

@@ -13,8 +13,8 @@ const storeSetup = () => {
// 深色菜单主题色变量 // 深色菜单主题色变量
const themeCSSVar = computed<Record<string, string>>(() => { const themeCSSVar = computed<Record<string, string>>(() => {
const obj: Record<string, string> = {} const obj: Record<string, string> = {}
const list = generate(settingConfig.themeColor, { list: true, dark: true }) const list = generate(settingConfig.themeColor, { list: true, dark: true }) as string[]
list.forEach((color: string, index: number) => { list.forEach((color, index) => {
obj[`--primary-${index + 1}`] = getRgbStr(color) obj[`--primary-${index + 1}`] = getRgbStr(color)
}) })
return obj return obj
@@ -24,8 +24,8 @@ const storeSetup = () => {
const setThemeColor = (color: string) => { const setThemeColor = (color: string) => {
if (!color) return if (!color) return
settingConfig.themeColor = color settingConfig.themeColor = color
const list = generate(settingConfig.themeColor, { list: true, dark: settingConfig.theme === 'dark' }) const list = generate(settingConfig.themeColor, { list: true, dark: settingConfig.theme === 'dark' }) as string[]
list.forEach((color: string, index: number) => { list.forEach((color, index) => {
const rgbStr = getRgbStr(color) const rgbStr = getRgbStr(color)
document.body.style.setProperty(`--primary-${index + 1}`, rgbStr) document.body.style.setProperty(`--primary-${index + 1}`, rgbStr)
}) })

View File

@@ -8,13 +8,6 @@ export {}
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default'] Breadcrumb: typeof import('./../components/Breadcrumb/index.vue')['default']
CrontabDay: typeof import('./../components/CornTab/CrontabDay.vue')['default']
CrontabField: typeof import('./../components/CornTab/CrontabField.vue')['default']
CrontabGenerator: typeof import('./../components/CornTab/CrontabGenerator.vue')['default']
CrontabModel: typeof import('./../components/CornTab/CrontabModel.vue')['default']
CrontabMonth: typeof import('./../components/CornTab/CrontabMonth.vue')['default']
CrontabWeek: typeof import('./../components/CornTab/CrontabWeek.vue')['default']
CrontabYear: typeof import('./../components/CornTab/CrontabYear.vue')['default']
DateRangePicker: typeof import('./../components/DateRangePicker/index.vue')['default'] DateRangePicker: typeof import('./../components/DateRangePicker/index.vue')['default']
GiCellAvatar: typeof import('./../components/GiCell/GiCellAvatar.vue')['default'] GiCellAvatar: typeof import('./../components/GiCell/GiCellAvatar.vue')['default']
GiCellGender: typeof import('./../components/GiCell/GiCellGender.vue')['default'] GiCellGender: typeof import('./../components/GiCell/GiCellGender.vue')['default']