Skip to content

Commit

Permalink
⛳ perf: unplugin & unocss background-image (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored May 21, 2024
1 parent 45c4be7 commit 2f5ad9f
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 75 deletions.
6 changes: 3 additions & 3 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ declare module 'vue' {
ElInput: typeof import('element-plus/es')['ElInput']
ElLink: typeof import('element-plus/es')['ElLink']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
Footer: typeof import('./src/components/Footer/index.vue')['default']
FooterOctocat: typeof import('./src/components/Footer/octocat.vue')['default']
FooterCustom: typeof import('./src/components/FooterCustom/index.vue')['default']
FooterCustomOctocat: typeof import('./src/components/FooterCustom/octocat.vue')['default']
HelloWorld: typeof import('./src/components/HelloWorld/index.vue')['default']
IconFont: typeof import('./src/components/IconFont/index.vue')['default']
Layout: typeof import('./src/components/Layout/index.vue')['default']
Expand All @@ -39,7 +39,7 @@ declare module 'vue' {
OptionsMenu: typeof import('./src/components/OptionsMenu/index.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Tooltip: typeof import('./src/components/Tooltip.vue')['default']
TooltipCustom: typeof import('./src/components/TooltipCustom/index.vue')['default']
}
export interface ComponentCustomProperties {
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default defineFlatConfig([
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'always'],
'no-console': ['error', {
allow: ['log', 'warn', 'error']
allow: ['log', 'dir', 'warn', 'error']
}],
'no-const-assign': 'error',
'no-control-regex': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,20 @@
</div>
</footer>
</template>
<script lang="ts">
<script lang="ts" setup>
import Octocat from './octocat.vue'
export default defineComponent({
name: 'MyFooter',
components: {
Octocat
},
props: {
showBorder: {
type: Boolean,
default: false
}
},
setup() {
const link = ref('https://github.com/pdsuwwz')
return {
link
}
withDefaults(
defineProps<{
showBorder?: boolean
}>(),
{
showBorder: false
}
})
)
const link = ref('https://github.com/pdsuwwz')
</script>
<style lang="scss" scoped>
.footer {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/Layout/LayoutArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</section>
</div>
</div>
<MyFooter show-border />
<FooterCustom show-border />
</div>
</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@
</el-tooltip>
</template>

<script lang="ts">
export default defineComponent({
name: 'TooltipCustom',
props: {
content: {
type: String,
default: ''
},
placement: {
type: String,
default: 'top'
}
<script lang="ts" setup>
import type { Placement } from 'element-plus'
interface Props {
content: string
placement: Placement
}
withDefaults(
defineProps<Props>(),
{
content: '',
placement: 'top'
}
})
)
</script>

<style lang="scss" scoped>
Expand Down
27 changes: 0 additions & 27 deletions src/components/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import App from '@/App.vue'

import '@/assets/fonts'

import GlobalComponents from '@/components'
import Mixin from '@/mixins'
import Widgets from '@/widgets'

const app = createApp(App)

function setupPlugins() {
app
.use(GlobalComponents)
.use(Widgets)
.mixin(Mixin)
}
Expand Down
25 changes: 15 additions & 10 deletions src/modules/UserAccount/pages/login.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
<template>
<div class="user-account-login">
<div
class="user-account-login"
:class="[
'bgimage-images-logo-background-jpg',
'bg-no-repeat bg-cover'
]"
>
<div class="user-account-nav">
<div class="nav-left">
<div class="nav-logo"></div>
<div
class="nav-logo"
:class="[
'bgimage-images-i18n-svg',
'bg-no-repeat bg-contain bg-center',
]"
></div>
<div class="nav-circle"></div>
<div class="nav-title">
{{ _t('base.systemTitle') }}
Expand Down Expand Up @@ -31,7 +43,7 @@
</template>
</UserAccountContainerLayout>
</div>
<MyFooter />
<FooterCustom />
</div>
</template>

Expand Down Expand Up @@ -203,9 +215,6 @@ export default defineComponent({
flex-direction: column;
min-height: 100vh;
background-color: #f0f2f5;
background-image: url("@/assets/images/logo-background.jpg");
background-repeat: no-repeat;
background-size: cover;
.user-account-nav {
display: flex;
Expand All @@ -229,10 +238,6 @@ export default defineComponent({
width: 32px;
height: 32px;
border-radius: 3px;
background-image: url("@/assets/images/i18n.svg");
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
.nav-circle {
Expand Down
10 changes: 10 additions & 0 deletions uno.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
defineConfig,
presetAttributify,
presetIcons,
presetUno,
transformerDirectives
Expand All @@ -8,6 +9,7 @@ import {
export default defineConfig({
presets: [
presetUno(),
presetAttributify(),
presetIcons()
],
transformers: [
Expand All @@ -28,6 +30,14 @@ export default defineConfig({
'login-navbar-shadow', {
'box-shadow': '0 -3px 8px 3px #727272'
}
],
[
/^bgimage-(\w+)-(.+)-(svg|png|jpg|gif)$/,
([, dir, fname, fext]) => {
return {
'background-image': `url(@/assets/${ dir }/${ fname }.${ fext })`
}
}
]
]
})

0 comments on commit 2f5ad9f

Please sign in to comment.