Skip to content

Commit

Permalink
chore: 优化部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 6, 2024
1 parent 948158f commit cb03111
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default antfu(
'style/brace-style': [2, '1tbs', { allowSingleLine: true }], // 对块执行一致的大括号样式
'style/comma-dangle': [2, 'never'], // 要求或不允许尾随逗号
'ts/consistent-type-definitions': 0,
'ts/no-unused-expressions': 0,
'node/prefer-global/process': 0,
'antfu/top-level-function': 0,
'antfu/if-newline': 0
Expand Down
7 changes: 0 additions & 7 deletions src/components/GiCodeView/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ const defaultConfig = {
const config = defaultConfig
const codeValue = computed(() => props.codeJson)
const visible = ref(false)
// 打开
const open = () => {
visible.value = true
}
const extensions = computed(() => {
const arr = [isDark.value ? oneDark : githubLight]
Expand All @@ -53,8 +48,6 @@ const extensions = computed(() => {
}
return arr
})
defineExpose({ open })
</script>

<style lang="scss" scoped>
Expand Down
4 changes: 2 additions & 2 deletions src/components/GiSvgIcon/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const iconSize = computed<string | number>(() => {
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}`
return 'svg-icon'
})
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/modules/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Message, Modal } from '@arco-design/web-vue'
import type { Options as paginationOptions } from './usePagination'
import { usePagination } from '@/hooks'

interface Options<T> {
formatResult?: (data: T[]) => any
interface Options<T, U> {
formatResult?: (data: T[]) => U[]
onSuccess?: () => void
immediate?: boolean
rowKey?: keyof T
Expand All @@ -14,11 +14,11 @@ interface Options<T> {
type PaginationParams = { page: number, size: number }
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 { pagination, setTotal } = usePagination(() => getTableData(), options?.paginationOption)
const loading = ref(false)
const tableData = ref<T[]>([])
const tableData: Ref<U[]> = ref([])

async function getTableData() {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/stores/modules/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const storeSetup = () => {
// 深色菜单主题色变量
const themeCSSVar = computed<Record<string, string>>(() => {
const obj: Record<string, string> = {}
const list = generate(settingConfig.themeColor, { list: true, dark: true })
list.forEach((color: string, index: number) => {
const list = generate(settingConfig.themeColor, { list: true, dark: true }) as string[]
list.forEach((color, index) => {
obj[`--primary-${index + 1}`] = getRgbStr(color)
})
return obj
Expand All @@ -24,8 +24,8 @@ const storeSetup = () => {
const setThemeColor = (color: string) => {
if (!color) return
settingConfig.themeColor = color
const list = generate(settingConfig.themeColor, { list: true, dark: settingConfig.theme === 'dark' })
list.forEach((color: string, index: number) => {
const list = generate(settingConfig.themeColor, { list: true, dark: settingConfig.theme === 'dark' }) as string[]
list.forEach((color, index) => {
const rgbStr = getRgbStr(color)
document.body.style.setProperty(`--primary-${index + 1}`, rgbStr)
})
Expand Down
7 changes: 0 additions & 7 deletions src/types/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
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']
GiCellAvatar: typeof import('./../components/GiCell/GiCellAvatar.vue')['default']
GiCellGender: typeof import('./../components/GiCell/GiCellGender.vue')['default']
Expand Down

0 comments on commit cb03111

Please sign in to comment.