Skip to content

Commit

Permalink
🕹️ fix: eslint for vue template order (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored Jul 22, 2024
1 parent bee268b commit 729f25e
Show file tree
Hide file tree
Showing 21 changed files with 489 additions and 487 deletions.
28 changes: 14 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
<template>
<NConfigProvider
class="h-full"
:locale="zhCN"
:date-locale="dateZhCN"
:theme="theme"
:theme-overrides="themeOverrides"
>
<NaiveProvider>
<RouterView />
</NaiveProvider>
</NConfigProvider>
</template>

<script lang="ts" setup>
import NaiveProvider from './provider/NaiveProvider.vue'
Expand All @@ -27,6 +13,20 @@ const route = useRoute()
</script>

<template>
<NConfigProvider
class="h-full"
:locale="zhCN"
:date-locale="dateZhCN"
:theme="theme"
:theme-overrides="themeOverrides"
>
<NaiveProvider>
<RouterView />
</NaiveProvider>
</NConfigProvider>
</template>

<style lang="scss">
@use "@/styles/index.scss";
</style>
12 changes: 6 additions & 6 deletions src/components/404.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<template>
<div>
<h1>NOT-FOUND 404</h1>
</div>
</template>

<script lang="ts" setup>
defineOptions({
name: 'NotFound'
})
</script>

<template>
<div>
<h1>NOT-FOUND 404</h1>
</div>
</template>

<style>
</style>
30 changes: 16 additions & 14 deletions src/components/FooterCustom/index.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
<script lang="ts" setup>
import Octocat from './octocat.vue'
withDefaults(
defineProps<{
showBorder?: boolean
}>(),
{
showBorder: false
}
)
const link = ref('https://github.com/pdsuwwz')
</script>

<template>
<footer
class="footer"
Expand All @@ -23,21 +39,7 @@
</div>
</footer>
</template>
<script lang="ts" setup>
import Octocat from './octocat.vue'

withDefaults(
defineProps<{
showBorder?: boolean
}>(),
{
showBorder: false
}
)
const link = ref('https://github.com/pdsuwwz')
</script>
<style lang="scss" scoped>
.footer {
margin: 0 auto;
Expand Down
23 changes: 12 additions & 11 deletions src/components/FooterCustom/octocat.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<script lang="ts">
export default defineComponent({
name: 'Octocat',
setup() {
const link = ref('https://github.com/pdsuwwz/vite-naive-template')
return {
link
}
}
})
</script>

<template>
<a
class="octocat-link c-#71717a dark:c-#666 hover-c-#3f3f46 dark:hover-c-#f6f5f7"
Expand All @@ -19,17 +31,6 @@
</a>
</template>

<script lang="ts">
export default defineComponent({
name: 'Octocat',
setup() {
const link = ref('https://github.com/pdsuwwz/vite-naive-template')
return {
link
}
}
})
</script>
<style lang="scss" scoped>
.octocat-link {
width: 22px;
Expand Down
118 changes: 55 additions & 63 deletions src/components/IconFont/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,62 @@
<script lang="ts" setup>
const props = defineProps({
icon: {
type: String,
default: ''
},
shadow: {
type: Boolean,
default: false
},
verticalCenter: {
type: Boolean,
default: false
},
cursor: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['click'])
const getClassNames = computed(() => {
const classNames: string[] = []
if (props.verticalCenter) {
classNames.push('middle')
}
if (props.cursor) {
classNames.push('cursor')
}
if (props.disabled) {
classNames.push('disabled')
}
return classNames
})
const handleClick = () => {
!props.disabled && emit('click')
}
const getAttrs = () => {
const attrs: any = {}
props.shadow &&
(attrs.filter = 'url(#drop-shadow)')
return attrs
}
</script>

<template>
<svg
class="icon-font"
aria-hidden="true"
:class="getClassName"
:class="getClassNames"
@click="handleClick()"
>
<filter
Expand Down Expand Up @@ -37,68 +91,6 @@
</svg>
</template>

<script lang="ts">
export default defineComponent({
name: 'IconFont',
props: {
icon: {
type: String,
default: ''
},
shadow: {
type: Boolean,
default: false
},
verticalCenter: {
type: Boolean,
default: false
},
cursor: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
}
},
emits: ['click'],
setup (props, { emit }) {
const getClassName = computed(() => {
const className: string[] = []
if (props.verticalCenter) {
className.push('middle')
}
if (props.cursor) {
className.push('cursor')
}
if (props.disabled) {
className.push('disabled')
}
return className
})
const handleClick = () => {
!props.disabled && emit('click')
}
const getAttrs = () => {
const attrs: any = {}
props.shadow &&
(attrs.filter = 'url(#drop-shadow)')
return attrs
}
return {
getClassName,
handleClick,
getAttrs
}
}
})
</script>

<style lang="scss" scoped>
.icon-font {
width: 1em;
Expand Down
46 changes: 23 additions & 23 deletions src/components/Layout/LayoutSection.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
<script lang="ts">
/**
* 上下布局,顶部 header 大标题 + 底部内容区域
*/
export default defineComponent({
name: 'LayoutSection',
props: {
hasDivider: {
type: Boolean,
default: false
},
flexContent: {
type: Boolean,
default: false
},
title: {
type: String,
default: ''
}
}
})
</script>

<template>
<div class="layout-section-container">
<div class="layout-section-container__header">
Expand Down Expand Up @@ -32,29 +55,6 @@
</div>
</template>

<script lang="ts">
/**
* 上下布局,顶部 header 大标题 + 底部内容区域
*/
export default defineComponent({
name: 'LayoutSection',
props: {
hasDivider: {
type: Boolean,
default: false
},
flexContent: {
type: Boolean,
default: false
},
title: {
type: String,
default: ''
}
}
})
</script>

<style lang="scss" scoped>
.layout-section-container {
display: flex;
Expand Down
12 changes: 6 additions & 6 deletions src/components/Layout/index.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<template>
<router-view v-slot="{ Component }">
<Component :is="Component" />
</router-view>
</template>

<script lang="ts">
export default {
name: 'AppMain'
}
</script>

<template>
<router-view v-slot="{ Component }">
<Component :is="Component" />
</router-view>
</template>
33 changes: 17 additions & 16 deletions src/components/Navigation/Avatar.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<template>
<n-dropdown
trigger="hover"
:options="commandList"
>
<div class="navigation-avatar">
<!-- <img
src="@/assets/images/navigation-avatar.webp"
> -->
<n-icon :size="24">
<div class="i-carbon:user-avatar"></div>
</n-icon>
</div>
</n-dropdown>
</template>

<script lang="ts">
import Cookie from 'js-cookie'
Expand Down Expand Up @@ -58,6 +42,23 @@ export default defineComponent({
}
})
</script>

<template>
<n-dropdown
trigger="hover"
:options="commandList"
>
<div class="navigation-avatar">
<!-- <img
src="@/assets/images/navigation-avatar.webp"
> -->
<n-icon :size="24">
<div class="i-carbon:user-avatar"></div>
</n-icon>
</div>
</n-dropdown>
</template>

<style lang="scss">
.navigation-avatar {
display: flex;
Expand Down
Loading

0 comments on commit 729f25e

Please sign in to comment.