组件使用

This commit is contained in:
2025-12-08 18:05:49 +08:00
parent 19ff3e2a93
commit 4f1f455660
17 changed files with 256 additions and 521 deletions

View File

@@ -4397,7 +4397,7 @@
"dependencies": {
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"pinia": "^2.2.8",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
@@ -4417,7 +4417,7 @@
"dependencies": {
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"pinia": "^2.2.8",
"vue": "^3.5.13",
"vue-router": "^4.5.0"
@@ -6096,7 +6096,7 @@
"dependencies": {
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"pinia": "^2.2.8",
"vue": "^3.5.13",
"vue-router": "^4.5.0"

View File

@@ -12,7 +12,8 @@
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"pinia": "^2.2.8",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"@element-plus/icons-vue": "^2.3.2",
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9"
},

View File

@@ -5,6 +5,9 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@element-plus/icons-vue':
specifier: ^2.3.2
version: 2.3.2(vue@3.5.25)
'@vueuse/core':
specifier: ^11.3.0
version: 11.3.0(vue@3.5.25)
@@ -12,7 +15,7 @@ dependencies:
specifier: ^1.7.9
version: 1.13.2
element-plus:
specifier: ^2.9.1
specifier: ^2.12.0
version: 2.12.0(vue@3.5.25)
pinia:
specifier: ^2.2.8

View File

@@ -12,7 +12,8 @@
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"pinia": "^2.2.8",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"@element-plus/icons-vue": "^2.3.2",
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9"
},

View File

@@ -5,6 +5,9 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@element-plus/icons-vue':
specifier: ^2.3.2
version: 2.3.2(vue@3.5.25)
'@vueuse/core':
specifier: ^11.3.0
version: 11.3.0(vue@3.5.25)
@@ -12,7 +15,7 @@ dependencies:
specifier: ^1.7.9
version: 1.13.2
element-plus:
specifier: ^2.9.1
specifier: ^2.12.0
version: 2.12.0(vue@3.5.25)
pinia:
specifier: ^2.2.8

View File

@@ -9,7 +9,7 @@
"version": "1.0.0",
"dependencies": {
"@vueuse/core": "^11.3.0",
"element-plus": "^2.9.1",
"element-plus": "^2.12.0",
"pinia": "^2.2.8",
"vue": "^3.5.13",
"vue-router": "^4.5.0"

View File

@@ -14,7 +14,9 @@
"dependencies": {
"vue": "^3.5.13",
"ofetch": "^1.4.1",
"vue-router": "^4.2.0"
"vue-router": "^4.5.0",
"element-plus": "^2.12.0",
"@element-plus/icons-vue": "^2.3.2"
},
"devDependencies": {
"@types/node": "^20.10.0",

View File

@@ -5,6 +5,12 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@element-plus/icons-vue':
specifier: ^2.3.2
version: 2.3.2(vue@3.5.25)
element-plus:
specifier: ^2.12.0
version: 2.12.0(vue@3.5.25)
ofetch:
specifier: ^1.4.1
version: 1.5.1
@@ -12,7 +18,7 @@ dependencies:
specifier: ^3.5.13
version: 3.5.25(typescript@5.9.3)
vue-router:
specifier: ^4.2.0
specifier: ^4.5.0
version: 4.6.3(vue@3.5.25)
devDependencies:
@@ -304,6 +310,19 @@ packages:
resolution: {integrity: sha512-ckS3+vyJb5qGpEYv/s1OebUHDi/xSNtfgw1wqKZo7MR9F2z+qXr0q5XagafAG/9O0QPVIUfST0smluYSTpYFkg==}
dev: true
/@ctrl/tinycolor@3.6.1:
resolution: {integrity: sha512-SITSV6aIXsuVNV3f3O0f2n/cgyEDWoSqtZMYiAmcsYHydcKrOz3gUxB/iXd/Qf08+IZX4KpgNbvUdMBmWz+kcA==}
engines: {node: '>=10'}
dev: false
/@element-plus/icons-vue@2.3.2(vue@3.5.25):
resolution: {integrity: sha512-OzIuTaIfC8QXEPmJvB4Y4kw34rSXdCJzxcD1kFStBvr8bK6X1zQAYDo0CNMjojnfTqRQCJ0I7prlErcoRiET2A==}
peerDependencies:
vue: ^3.2.0
dependencies:
vue: 3.5.25(typescript@5.9.3)
dev: false
/@esbuild/aix-ppc64@0.25.12:
resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
engines: {node: '>=18'}
@@ -538,6 +557,23 @@ packages:
dev: true
optional: true
/@floating-ui/core@1.7.3:
resolution: {integrity: sha512-sGnvb5dmrJaKEZ+LDIpguvdX3bDlEllmv4/ClQ9awcmCZrlx5jQyyMWFM5kBI+EyNOCDDiKk8il0zeuX3Zlg/w==}
dependencies:
'@floating-ui/utils': 0.2.10
dev: false
/@floating-ui/dom@1.7.4:
resolution: {integrity: sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA==}
dependencies:
'@floating-ui/core': 1.7.3
'@floating-ui/utils': 0.2.10
dev: false
/@floating-ui/utils@0.2.10:
resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==}
dev: false
/@jridgewell/gen-mapping@0.3.13:
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
dependencies:
@@ -915,16 +951,34 @@ packages:
dev: true
optional: true
/@sxzz/popperjs-es@2.11.7:
resolution: {integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==}
dev: false
/@types/estree@1.0.8:
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
dev: true
/@types/lodash-es@4.17.12:
resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==}
dependencies:
'@types/lodash': 4.17.21
dev: false
/@types/lodash@4.17.21:
resolution: {integrity: sha512-FOvQ0YPD5NOfPgMzJihoT+Za5pdkDJWcbpuj1DjaKZIr/gxodQjY/uWEFlTNqW2ugXHUiL8lRQgw63dzKHZdeQ==}
dev: false
/@types/node@20.19.25:
resolution: {integrity: sha512-ZsJzA5thDQMSQO788d7IocwwQbI8B5OPzmqNvpf3NY/+MHDAS759Wo0gd2WQeXYt5AAAQjzcrTVC6SKCuYgoCQ==}
dependencies:
undici-types: 6.21.0
dev: true
/@types/web-bluetooth@0.0.16:
resolution: {integrity: sha512-oh8q2Zc32S6gd/j50GowEjKLoOVOwHP/bWVjKJInBwQqdOYMdPrf1oVlelTlyfFK3CKxL1uahMDAr+vy8T7yMQ==}
dev: false
/@vitejs/plugin-vue-jsx@4.2.0(vite@6.4.1)(vue@3.5.25):
resolution: {integrity: sha512-DSTrmrdLp+0LDNF77fqrKfx7X0ErRbOcUAgJL/HbSesqQwoUvUQ4uYQqaex+rovqgGcoPqVk+AwUh3v9CuiYIw==}
engines: {node: ^18.0.0 || >=20.0.0}
@@ -1063,6 +1117,31 @@ packages:
/@vue/shared@3.5.25:
resolution: {integrity: sha512-AbOPdQQnAnzs58H2FrrDxYj/TJfmeS2jdfEEhgiKINy+bnOANmVizIEgq1r+C5zsbs6l1CCQxtcj71rwNQ4jWg==}
/@vueuse/core@9.13.0(vue@3.5.25):
resolution: {integrity: sha512-pujnclbeHWxxPRqXWmdkKV5OX4Wk4YeK7wusHqRwU0Q7EFusHoqNA/aPhB6KCh9hEqJkLAJo7bb0Lh9b+OIVzw==}
dependencies:
'@types/web-bluetooth': 0.0.16
'@vueuse/metadata': 9.13.0
'@vueuse/shared': 9.13.0(vue@3.5.25)
vue-demi: 0.14.10(vue@3.5.25)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
dev: false
/@vueuse/metadata@9.13.0:
resolution: {integrity: sha512-gdU7TKNAUVlXXLbaF+ZCfte8BjRJQWPCa2J55+7/h+yDtzw3vOoGQDRXzI6pyKyo6bXFT5/QoPE4hAknExjRLQ==}
dev: false
/@vueuse/shared@9.13.0(vue@3.5.25):
resolution: {integrity: sha512-UrnhU+Cnufu4S6JLCPZnkWh0WwZGUp72ktOF2DFptMlOs3TOdVv8xJN53zhHGARmVOsz5KqOls09+J1NR6sBKw==}
dependencies:
vue-demi: 0.14.10(vue@3.5.25)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
dev: false
/ansi-styles@3.2.1:
resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==}
engines: {node: '>=4'}
@@ -1096,6 +1175,10 @@ packages:
engines: {node: '>= 0.4'}
dev: true
/async-validator@4.2.5:
resolution: {integrity: sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==}
dev: false
/available-typed-arrays@1.0.7:
resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
engines: {node: '>= 0.4'}
@@ -1253,6 +1336,10 @@ packages:
is-data-view: 1.0.2
dev: true
/dayjs@1.11.19:
resolution: {integrity: sha512-t5EcLVS6QPBNqM2z8fakk/NKel+Xzshgt8FFKAn+qwlD1pzZWxh0nVCrvFK7ZDb6XucZeF9z8C7CBWTRIVApAw==}
dev: false
/debug@4.4.3:
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
engines: {node: '>=6.0'}
@@ -1308,6 +1395,30 @@ packages:
resolution: {integrity: sha512-kgWEglXvkEfMH7rxP5OSZZwnaDWT7J9EoZCujhnpLbfi0bbNtRkgdX2E3gt0Uer11c61qCYktB3hwkAS325sJg==}
dev: true
/element-plus@2.12.0(vue@3.5.25):
resolution: {integrity: sha512-M9YLSn2np9OnqrSKWsiXvGe3qnF8pd94+TScsHj1aTMCD+nSEvucXermf807qNt6hOP040le0e5Aft7E9ZfHmA==}
peerDependencies:
vue: ^3.2.0
dependencies:
'@ctrl/tinycolor': 3.6.1
'@element-plus/icons-vue': 2.3.2(vue@3.5.25)
'@floating-ui/dom': 1.7.4
'@popperjs/core': /@sxzz/popperjs-es@2.11.7
'@types/lodash': 4.17.21
'@types/lodash-es': 4.17.12
'@vueuse/core': 9.13.0(vue@3.5.25)
async-validator: 4.2.5
dayjs: 1.11.19
lodash: 4.17.21
lodash-es: 4.17.21
lodash-unified: 1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21)
memoize-one: 6.0.0
normalize-wheel-es: 1.2.0
vue: 3.5.25(typescript@5.9.3)
transitivePeerDependencies:
- '@vue/composition-api'
dev: false
/entities@4.5.0:
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
engines: {node: '>=0.12'}
@@ -1878,6 +1989,26 @@ packages:
strip-bom: 3.0.0
dev: true
/lodash-es@4.17.21:
resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==}
dev: false
/lodash-unified@1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21):
resolution: {integrity: sha512-WK9qSozxXOD7ZJQlpSqOT+om2ZfcT4yO+03FuzAHD0wF6S0l0090LRPDx3vhTTLZ8cFKpBn+IOcVXK6qOcIlfQ==}
peerDependencies:
'@types/lodash-es': '*'
lodash: '*'
lodash-es: '*'
dependencies:
'@types/lodash-es': 4.17.12
lodash: 4.17.21
lodash-es: 4.17.21
dev: false
/lodash@4.17.21:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
dev: false
/lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
dependencies:
@@ -1901,6 +2032,10 @@ packages:
engines: {node: '>= 0.4'}
dev: true
/memoize-one@6.0.0:
resolution: {integrity: sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==}
dev: false
/memorystream@0.3.1:
resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==}
engines: {node: '>= 0.10.0'}
@@ -1958,6 +2093,10 @@ packages:
validate-npm-package-license: 3.0.4
dev: true
/normalize-wheel-es@1.2.0:
resolution: {integrity: sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==}
dev: false
/npm-run-all@4.1.5:
resolution: {integrity: sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==}
engines: {node: '>= 4'}
@@ -2796,6 +2935,21 @@ packages:
fsevents: 2.3.3
dev: true
/vue-demi@0.14.10(vue@3.5.25):
resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
peerDependencies:
'@vue/composition-api': ^1.0.0-rc.1
vue: ^3.0.0-0 || ^2.6.0
peerDependenciesMeta:
'@vue/composition-api':
optional: true
dependencies:
vue: 3.5.25(typescript@5.9.3)
dev: false
/vue-router@4.6.3(vue@3.5.25):
resolution: {integrity: sha512-ARBedLm9YlbvQomnmq91Os7ck6efydTSpRP3nuOKCvgJOHNrhRoJDSKtee8kcL1Vf7nz6U+PMBL+hTvR3bTVQg==}
peerDependencies:

View File

@@ -1,55 +0,0 @@
<template>
<button
:class="[
'btn',
`btn--${variant}`,
`btn--${size}`,
{
'btn--disabled': disabled,
'btn--loading': loading
}
]"
:type="type"
:disabled="disabled || loading"
:style="customStyle"
@click="handleClick"
>
<span v-if="loading" class="btn__spinner"></span>
<span class="btn__content">
<slot></slot>
</span>
</button>
</template>
<script setup lang="ts">
interface Props{
type?: 'button' | 'submit' | 'reset'
variant?: 'primary' | 'secondary' | 'danger' | 'success' | 'warning' | 'gradient-blue' | 'gradient-purple' | 'gradient-pink' | 'gradient-orange' | 'gradient-green' | 'gradient-blue-special'
size?: 'small' | 'medium' | 'large'
disabled?: boolean
loading?: boolean
customStyle?: string
}
const props = withDefaults(defineProps<Props>(), {
type: 'button',
variant: 'primary',
size: 'medium',
disabled: false,
loading: false
})
const emit = defineEmits<{
click: [event: MouseEvent]
}>()
const handleClick = (event: MouseEvent) => {
if (!props.disabled && !props.loading) {
emit('click', event)
}
}
</script>
<style lang="scss" scoped>
@import url("./button.scss");
</style>

View File

@@ -1,165 +0,0 @@
<template>
<div class="button-test">
<h2>按钮组件测试</h2>
<!-- 基础按钮 -->
<section class="test-section">
<h3>基础按钮</h3>
<div class="button-group">
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="danger">Danger</Button>
<Button variant="success">Success</Button>
<Button variant="warning">Warning</Button>
</div>
</section>
<!-- 渐变按钮 -->
<section class="test-section">
<h3>渐变按钮</h3>
<div class="button-group">
<Button variant="gradient-blue">Gradient Blue</Button>
<Button variant="gradient-purple">Gradient Purple</Button>
<Button variant="gradient-pink">Gradient Pink</Button>
<Button variant="gradient-orange">Gradient Orange</Button>
<Button variant="gradient-green">Gradient Green</Button>
<Button variant="gradient-blue-special">Special Blue</Button>
</div>
</section>
<!-- 尺寸测试 -->
<section class="test-section">
<h3>按钮尺寸渐变示例</h3>
<div class="button-group">
<Button variant="gradient-blue" size="small">Small</Button>
<Button variant="gradient-pink" size="medium">Medium</Button>
<Button variant="gradient-green" size="large">Large</Button>
</div>
</section>
<!-- 状态测试 -->
<section class="test-section">
<h3>按钮状态</h3>
<div class="button-group">
<Button variant="gradient-blue" :loading="isLoading" @click="toggleLoading">
{{ isLoading ? '加载中...' : '点击加载' }}
</Button>
<Button variant="gradient-purple" disabled>禁用按钮</Button>
<Button variant="gradient-pink" :loading="true">持续加载</Button>
</div>
</section>
<!-- 混合展示 -->
<section class="test-section">
<h3>混合展示</h3>
<div class="mixed-demo">
<div class="card">
<h4>渐变卡片演示</h4>
<p>这是一个使用渐变按钮的卡片示例</p>
<div class="card-actions">
<Button variant="gradient-blue" size="small">详情</Button>
<Button variant="gradient-green" size="small">确认</Button>
</div>
</div>
</div>
</section>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import Button from './Button.vue'
// 响应式数据
const isLoading = ref(false)
// 方法
const toggleLoading = () => {
isLoading.value = true
setTimeout(() => {
isLoading.value = false
}, 2000)
}
</script>
<style lang="scss" scoped>
.button-test {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
h2 {
text-align: center;
color: #333;
margin-bottom: 30px;
font-size: 28px;
}
.test-section {
margin-bottom: 40px;
padding: 20px;
border: 1px solid #e1e5e9;
border-radius: 8px;
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
h3 {
margin: 0 0 20px 0;
color: #495057;
font-size: 20px;
border-bottom: 2px solid #f8f9fa;
padding-bottom: 10px;
}
.button-group {
display: flex;
gap: 12px;
flex-wrap: wrap;
align-items: center;
}
}
.mixed-demo {
.card {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
padding: 24px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
max-width: 400px;
h4 {
margin: 0 0 12px 0;
color: #374151;
font-size: 18px;
}
p {
margin: 0 0 20px 0;
color: #6b7280;
line-height: 1.6;
}
.card-actions {
display: flex;
gap: 8px;
justify-content: flex-end;
}
}
}
}
// 响应式设计
@media (max-width: 768px) {
.button-test {
padding: 16px;
.test-section {
padding: 16px;
.button-group {
gap: 8px;
}
}
}
}
</style>

View File

@@ -1,189 +0,0 @@
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: 500;
transition: all 0.2s ease;
text-decoration: none;
white-space: nowrap;
&:focus {
outline: 2px solid rgba(59, 130, 246, 0.5);
outline-offset: 2px;
}
// 尺寸
&--small {
padding: 6px 12px;
font-size: 12px;
line-height: 1.4;
}
&--medium {
padding: 8px 16px;
font-size: 14px;
line-height: 1.5;
}
&--large {
padding: 12px 20px;
font-size: 16px;
line-height: 1.5;
}
// 变体
&--primary {
background-color: #3b82f6;
color: white;
&:hover:not(.btn--disabled):not(.btn--loading) {
background-color: #2563eb;
}
}
&--secondary {
background-color: #f1f5f9;
color: #475569;
border: 1px solid #e2e8f0;
&:hover:not(.btn--disabled):not(.btn--loading) {
background-color: #e2e8f0;
}
}
&--danger {
background-color: #ef4444;
color: white;
&:hover:not(.btn--disabled):not(.btn--loading) {
background-color: #dc2626;
}
}
&--success {
background-color: #10b981;
color: white;
&:hover:not(.btn--disabled):not(.btn--loading) {
background-color: #059669;
}
}
&--warning {
background-color: #f59e0b;
color: white;
&:hover:not(.btn--disabled):not(.btn--loading) {
background-color: #d97706;
}
}
// 渐变变体
&--gradient-blue {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
}
&--gradient-purple {
background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
color: #374151;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(135deg, #96e6e2 0%, #fcc4d1 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(168, 237, 234, 0.4);
}
}
&--gradient-pink {
background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
color: white;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(135deg, #ff888c 0%, #feb7dd 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(255, 154, 158, 0.4);
}
}
&--gradient-orange {
background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
color: #374151;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(135deg, #ffe4c0 0%, #fba88d 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(252, 182, 159, 0.4);
}
}
&--gradient-green {
background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 100%);
color: #374151;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(135deg, #96dfbf 0%, #d0e6af 100%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(168, 230, 207, 0.4);
}
}
&--gradient-blue-special {
background: linear-gradient(281.59deg, #162C8E 8.51%, #1D72D3 66.15%, #AEF1FF 100.83%);
color: white;
border: none;
&:hover:not(.btn--disabled):not(.btn--loading) {
background: linear-gradient(281.59deg, #142558 8.51%, #1a64b8 66.15%, #9ce8f5 100.83%);
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(29, 114, 211, 0.4);
}
}
// 状态
&--disabled {
opacity: 0.5;
cursor: not-allowed;
}
&--loading {
cursor: wait;
}
// 加载动画
&__spinner {
width: 16px;
height: 16px;
border: 2px solid transparent;
border-top: 2px solid currentColor;
border-radius: 50%;
animation: spin 1s linear infinite;
}
&__content {
display: flex;
align-items: center;
gap: 8px;
}
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}

View File

@@ -1 +0,0 @@
export { default as Button } from './button/Button.vue'

View File

@@ -52,58 +52,21 @@
// 弹窗模式
&.dialog {
.overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
.dialog-content {
padding: 0;
}
.modal {
background: white;
border-radius: 12px;
padding: 24px;
width: 90%;
max-width: 500px;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 12px;
border-bottom: 1px solid #e2e8f0;
h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #1e293b;
}
}
.footer {
.dialog-footer {
display: flex;
gap: 12px;
justify-content: flex-end;
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #e2e8f0;
}
}
// 内容模式
&.content {}
&.content {
display: block;
}
// 通用容器
.container {

View File

@@ -6,9 +6,9 @@
<img :src="currentCoverImg" class="image" :class="coverImageClass" @load="handleCoverImageLoad"
alt="封面图片" />
<div class="actions">
<Button variant="danger" size="small" @click="handleRemoveCover">
<ElButton type="danger" size="small" @click="handleRemoveCover">
×
</Button>
</ElButton>
</div>
</div>
@@ -35,64 +35,64 @@
<!-- 弹窗模式 -->
<div v-else-if="mode === 'dialog'" class="file-upload dialog">
<Button @click="showDialog = true" variant="primary">
<ElButton @click="showDialog = true" type="primary">
{{ buttonText || '上传文件' }}
</Button>
</ElButton>
<div v-if="showDialog" class="overlay" @click="closeDialog">
<div class="modal" @click.stop>
<div class="header">
<h3>{{ title || '文件上传' }}</h3>
<Button variant="secondary" size="small" @click="closeDialog">×</Button>
<ElDialog
v-model="showDialog"
:title="title || '文件上传'"
width="500px"
:before-close="handleDialogClose"
>
<div class="dialog-content">
<div class="area" :class="{ dragover: isDragover, disabled: uploading }" @click="triggerFileInput"
@drop.prevent="handleDrop" @dragover.prevent="handleDragOver"
@dragleave.prevent="handleDragLeave">
<div class="icon">
<div class="plus"></div>
</div>
<div class="text">
将文件拖到此处<span class="link">点击上传</span>
</div>
<div class="tip">{{ getUploadTip() }}</div>
</div>
<div class="container">
<div class="area" :class="{ dragover: isDragover, disabled: uploading }" @click="triggerFileInput"
@drop.prevent="handleDrop" @dragover.prevent="handleDragOver"
@dragleave.prevent="handleDragLeave">
<div class="icon">
<div class="plus"></div>
<input ref="fileInputRef" type="file" :accept="accept" :multiple="maxCount > 1"
@change="handleFileSelect" hidden />
<!-- 文件列表 -->
<div v-if="selectedFiles.length > 0" class="files">
<div v-for="(file, index) in selectedFiles" :key="index" class="file">
<div class="preview">
<img v-if="isImageFile(file)" :src="getFilePreviewUrl(file)" class="thumb" />
<span v-else class="type-icon">{{ getFileTypeIcon(file) }}</span>
</div>
<div class="text">
将文件拖到此处<span class="link">点击上传</span>
<div class="info">
<div class="name">{{ file.name }}</div>
<div class="size">{{ formatFileSize(file.size) }}</div>
</div>
<div class="tip">{{ getUploadTip() }}</div>
</div>
<input ref="fileInputRef" type="file" :accept="accept" :multiple="maxCount > 1"
@change="handleFileSelect" hidden />
<!-- 文件列表 -->
<div v-if="selectedFiles.length > 0" class="files">
<div v-for="(file, index) in selectedFiles" :key="index" class="file">
<div class="preview">
<img v-if="isImageFile(file)" :src="getFilePreviewUrl(file)" class="thumb" />
<span v-else class="type-icon">{{ getFileTypeIcon(file) }}</span>
</div>
<div class="info">
<div class="name">{{ file.name }}</div>
<div class="size">{{ formatFileSize(file.size) }}</div>
</div>
<div class="actions">
<Button variant="danger" size="small" @click="removeFile(index)" :disabled="uploading">
删除
</Button>
</div>
<div class="actions">
<ElButton type="danger" size="small" @click="removeFile(index)" :disabled="uploading">
删除
</ElButton>
</div>
</div>
</div>
<div class="footer">
<Button variant="secondary" @click="closeDialog" :disabled="uploading">取消</Button>
<Button variant="primary" @click="uploadFiles" :loading="uploading"
:disabled="selectedFiles.length === 0">
{{ uploading ? '上传中...' : '确定上传' }}
</Button>
</div>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<ElButton @click="closeDialog" :disabled="uploading">取消</ElButton>
<ElButton type="primary" @click="uploadFiles" :loading="uploading"
:disabled="selectedFiles.length === 0">
{{ uploading ? '上传中...' : '确定上传' }}
</ElButton>
</div>
</template>
</ElDialog>
</div>
<!-- 内容模式 -->
@@ -127,19 +127,19 @@
</div>
<div class="actions">
<Button variant="danger" size="small" @click="removeFile(index)" :disabled="uploading">
<ElButton type="danger" size="small" @click="removeFile(index)" :disabled="uploading">
删除
</Button>
</ElButton>
</div>
</div>
</div>
<!-- 上传按钮 -->
<div v-if="selectedFiles.length > 0" class="actions">
<Button variant="primary" @click="uploadFiles" :loading="uploading"
<ElButton type="primary" @click="uploadFiles" :loading="uploading"
:disabled="selectedFiles.length === 0">
{{ uploading ? '上传中...' : '确定上传' }}
</Button>
</ElButton>
</div>
</div>
</div>
@@ -148,10 +148,10 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { Button } from '@/components'
import { FILE_DOWNLOAD_URL } from '@/config'
import { fileAPI } from '@/api/file/file'
import type { TbSysFileDTO } from '@/types/file/file'
import { ElButton, ElDialog } from 'element-plus'
import {
formatFileSize,
isImageFile,
@@ -334,6 +334,15 @@ const closeDialog = () => {
isDragover.value = false
}
// 处理弹窗关闭前的回调
const handleDialogClose = (done: () => void) => {
if (uploading.value) {
return
}
closeDialog()
done()
}
// 上传文件
const uploadFiles = async () => {
if (selectedFiles.value.length === 0) return
@@ -400,5 +409,5 @@ const uploadFiles = async () => {
</script>
<style lang="scss" scoped>
@import './FileUpload.scss';
@import url('./FileUpload.scss');
</style>

View File

@@ -1,5 +1,10 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
createApp(App).use(router).mount('#app')
const app = createApp(App)
app.use(ElementPlus)
app.use(router)
app.mount('#app')

View File

@@ -12,7 +12,8 @@
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"pinia": "^2.2.8",
"element-plus": "^2.9.1",
"element-plus": "^2.8.6",
"@element-plus/icons-vue": "^2.3.2",
"@vueuse/core": "^11.3.0",
"axios": "^1.7.9"
},

View File

@@ -5,6 +5,9 @@ settings:
excludeLinksFromLockfile: false
dependencies:
'@element-plus/icons-vue':
specifier: ^2.3.2
version: 2.3.2(vue@3.5.25)
'@vueuse/core':
specifier: ^11.3.0
version: 11.3.0(vue@3.5.25)
@@ -12,7 +15,7 @@ dependencies:
specifier: ^1.7.9
version: 1.13.2
element-plus:
specifier: ^2.9.1
specifier: ^2.8.6
version: 2.12.0(vue@3.5.25)
pinia:
specifier: ^2.2.8