Skip to content

Commit

Permalink
fix: type error & local icon error
Browse files Browse the repository at this point in the history
  • Loading branch information
chansee97 committed Jul 25, 2024
1 parent 5c24fa1 commit 5cc410c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

14 changes: 5 additions & 9 deletions src/components/common/NovaIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Icon } from '@iconify/vue'
interface iconPorps {
/* 图标名称 */
icon?: string
icon: string
/* 图标颜色 */
color?: string
/* 图标大小 */
Expand All @@ -13,11 +13,10 @@ interface iconPorps {
}
const props = withDefaults(defineProps<iconPorps>(), {
size: 18,
isLocal: false,
})
const isLocal = computed(() => {
return props.icon && props.icon.startsWith('local:')
return props.icon.startsWith('local:')
})
function getLocalIcon(icon: string) {
Expand All @@ -28,25 +27,22 @@ function getLocalIcon(icon: string) {
eager: true,
})
const domparser = new DOMParser()
return domparser.parseFromString(svg[`/src/assets/svg-icons/${svgName}.svg`], 'image/svg+xml')
return svg[`/src/assets/svg-icons/${svgName}.svg`]
}
</script>

<template>
<n-icon
v-if="icon && !isLocal"
v-if="icon"
:size="size"
:depth="depth"
:color="color"
>
<template v-if="isLocal">
{{ getLocalIcon(icon) }}
<i v-html="getLocalIcon(icon)" />
</template>
<template v-else>
<Icon :icon="icon" />
</template>
</n-icon>
</template>

<style scoped></style>
4 changes: 2 additions & 2 deletions src/layouts/mixMenu.layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ onMounted(() => {
const sideMenu = ref<MenuOption[]>([])
function handleSideMenu(key: string) {
// @ts-expect-error no error at here
const targetMenu = routeStore.menus.find(i => i.key === key)
const routeMenu = routeStore.menus as MenuOption[]
const targetMenu = routeMenu.find(i => i.key === key)
if (targetMenu) {
sideMenu.value = targetMenu.children ? targetMenu.children : [targetMenu]
}
Expand Down
3 changes: 3 additions & 0 deletions src/views/demo/icons/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<div>
大大大:<svg-icons-cool class="text-4em" />
</div>
<div>
nova-icon组件加载:<nova-icon icon="local:cool" />
</div>
</n-card>
</n-space>
</template>
4 changes: 2 additions & 2 deletions src/views/list/commonList/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const columns: DataTableColumns<Entity.DemoList> = [
return (
<NSwitch
value={row.disabled}
onUpdateValue={disabled =>
handleUpdateDisabled(disabled, row.id)}
onUpdateValue={(value: boolean) =>
handleUpdateDisabled(value, row.id)}
>
{{ checked: () => '启用', unchecked: () => '禁用' }}
</NSwitch>
Expand Down
2 changes: 1 addition & 1 deletion src/views/setting/account/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const columns: DataTableColumns<Entity.User> = [
value={row.status}
checked-value={1}
unchecked-value={0}
onUpdateValue={value =>
onUpdateValue={(value: 0 | 1) =>
handleUpdateDisabled(value, row.id!)}
>
{{ checked: () => '启用', unchecked: () => '禁用' }}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"target": "ESNext",
"jsx": "preserve",
"jsxImportSource": "vue",
"lib": ["ESNext", "DOM"],
"baseUrl": ".",
"module": "ESNext",
Expand Down

0 comments on commit 5cc410c

Please sign in to comment.