feat 搭建架构骨架

This commit is contained in:
Ironsp
2026-09-24 09:09:47 +08:00
parent dd9f6b77a4
commit 7a2efa3fea
180 changed files with 18967 additions and 9 deletions

View File

@@ -0,0 +1,103 @@
<script setup lang="ts">
interface Props {
type?: 'primary' | 'default' | 'text'
size?: 'sm' | 'md' | 'lg'
loading?: boolean
disabled?: boolean
}
const props = withDefaults(defineProps<Props>(), {
type: 'default',
size: 'md',
loading: false,
disabled: false,
})
const emit = defineEmits<{ click: [e: MouseEvent] }>()
function onClick(e: MouseEvent): void {
if (props.disabled || props.loading) return
emit('click', e)
}
</script>
<template>
<button
class="app-button"
:class="[`app-button--${type}`, `app-button--${size}`, { 'is-loading': loading, 'is-disabled': disabled }]"
:disabled="disabled || loading"
@click="onClick"
>
<span v-if="loading" class="app-button__loading">…</span>
<slot />
</button>
</template>
<style lang="less" scoped>
.app-button {
.flex(row, center);
gap: @spacing-xs;
border-radius: @radius-base;
font-size: @font-size-base;
transition: all 0.2s;
&--sm {
height: 28px;
padding: 0 @spacing-sm;
font-size: @font-size-sm;
}
&--md {
height: 36px;
padding: 0 @spacing-base;
}
&--lg {
height: 44px;
padding: 0 @spacing-lg;
font-size: @font-size-lg;
}
&--primary {
background: @primary-color;
color: @white;
&:hover {
background: @primary-hover;
}
}
&--default {
border: 1px solid @border-color-dark;
background: @white;
color: @text-color;
&:hover {
border-color: @primary-color;
color: @primary-color;
}
}
&--text {
color: @primary-color;
&:hover {
color: @primary-hover;
}
}
&.is-loading {
opacity: 0.6;
cursor: default;
}
&.is-disabled {
opacity: 0.4;
cursor: not-allowed;
}
&__loading {
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,146 @@
<script setup lang="ts">
import { useSiteStore } from '@/stores/modules/site'
const siteStore = useSiteStore()
const quickLinks = [
{ label: '首页', path: '/' },
{ label: '案例中心', path: '/cases' },
{ label: '需求提报', path: '/demand' },
{ label: '下载 APP', path: '/' },
{ label: '帮助中心', path: '/profile/help' },
]
const coreBusiness = [
'互联网软件开发',
'硬件电路开发',
'物联网软硬一体化全案',
'PCB 制版 & SMT 贴片生产',
'元器件集采与整机装配',
]
</script>
<template>
<footer class="app-footer">
<div class="app-footer__inner container">
<div class="app-footer__about">
<div class="app-footer__brand">
<!-- TODO(蓝湖): 替换 logo 切图 -->
<img src="@/assets/vue.svg" class="app-footer__logo" alt="虫子智造 logo">
<span class="app-footer__name">虫子智造</span>
</div>
<p class="app-footer__desc">
研发智造一体化自营平台,打通研发‑仿真‑设计‑PCB‑SMT‑整机装配‑售后迭代全链路,为科技企业、硬件厂商、创客团队提供软硬一体化定制与量产落地服务。平台自营不开放第三方服务商入驻,对项目质量全权兜底。
</p>
<p class="app-footer__legal">
©2026 虫子智造 研发智造一体化平台 版权所有|自营研发生产平台,所有项目源码、图纸受平台知识产权保护,禁止盗用、复制、二次分发
</p>
<p class="app-footer__legal">
{{ siteStore.siteInfo.icp }} | {{ siteStore.siteInfo.police }}
</p>
</div>
<div class="app-footer__col">
<h4 class="app-footer__title">
快速导航
</h4>
<RouterLink
v-for="link in quickLinks"
:key="link.label"
:to="link.path"
class="app-footer__link"
>
{{ link.label }}
</RouterLink>
</div>
<div class="app-footer__col">
<h4 class="app-footer__title">
核心业务
</h4>
<span
v-for="item in coreBusiness"
:key="item"
class="app-footer__link"
>{{ item }}</span>
</div>
<div class="app-footer__col">
<h4 class="app-footer__title">
联系我们
</h4>
<span class="app-footer__contact">商务合作:{{ siteStore.siteInfo.businessEmail }}</span>
<span class="app-footer__contact">技术支持:{{ siteStore.siteInfo.supportEmail }}</span>
<span class="app-footer__contact">客服热线:{{ siteStore.siteInfo.hotline }}</span>
<span class="app-footer__contact">工作时间:{{ siteStore.siteInfo.workTime }}</span>
</div>
</div>
</footer>
</template>
<style lang="less" scoped>
.app-footer {
background: @heading-color;
color: @text-color-secondary;
&__inner {
.flex(row, space-between, flex-start);
gap: @spacing-xl;
padding-top: @spacing-xxl;
padding-bottom: @spacing-xxl;
}
&__about {
max-width: 480px;
}
&__brand {
.flex(row, flex-start);
gap: @spacing-sm;
margin-bottom: @spacing-base;
}
&__logo {
width: 28px;
height: 28px;
}
&__name {
font-size: @font-size-lg;
font-weight: 600;
color: @white;
}
&__desc,
&__legal {
margin-top: @spacing-sm;
font-size: @font-size-sm;
line-height: 1.6;
}
&__col {
.flex(column, flex-start);
gap: @spacing-sm;
}
&__title {
margin-bottom: @spacing-sm;
font-size: @font-size-base;
color: @white;
}
&__link {
font-size: @font-size-sm;
cursor: pointer;
transition: color 0.2s;
&:hover {
color: @primary-color;
}
}
&__contact {
font-size: @font-size-sm;
}
}
</style>

View File

@@ -0,0 +1,138 @@
<script setup lang="ts">
import { onMounted } from 'vue'
import { storeToRefs } from 'pinia'
import { useMessageStore } from '@/stores/modules/message'
interface NavItem {
label: string
path: string
}
const navItems: NavItem[] = [
{ label: '首页', path: '/' },
{ label: '案例库', path: '/cases' },
{ label: '需求提报', path: '/demand' },
{ label: '项目中心', path: '/project' },
{ label: '合同中心', path: '/contract' },
{ label: '财务中心', path: '/finance' },
{ label: '个人中心', path: '/profile' },
]
const messageStore = useMessageStore()
const { unreadCount } = storeToRefs(messageStore)
onMounted(() => void messageStore.fetchUnreadCount())
</script>
<template>
<header class="app-header">
<div class="app-header__inner container">
<RouterLink to="/" class="app-header__logo">
<!-- TODO(蓝湖): 替换 logo 切图 -->
<img src="@/assets/vue.svg" class="app-header__logo-icon" alt="虫子智造 logo">
<span class="app-header__logo-text">虫子智造</span>
</RouterLink>
<nav class="app-header__nav">
<RouterLink
v-for="item in navItems"
:key="item.path"
:to="item.path"
class="app-header__nav-item"
>
{{ item.label }}
</RouterLink>
</nav>
<div class="app-header__actions">
<RouterLink to="/message" class="app-header__bell" aria-label="消息中心">
<span class="app-header__bell-icon">🔔</span>
<span v-if="unreadCount > 0" class="app-header__badge">{{ unreadCount }}</span>
</RouterLink>
<RouterLink to="/login" class="app-header__login link">
登录
</RouterLink>
</div>
</div>
</header>
</template>
<style lang="less" scoped>
.app-header {
position: sticky;
top: 0;
z-index: 100;
height: @header-height;
background: @white;
box-shadow: @shadow-base;
&__inner {
.flex(row, space-between);
height: 100%;
}
&__logo {
.flex(row, flex-start);
gap: @spacing-sm;
&-icon {
width: 32px;
height: 32px;
}
&-text {
font-size: @font-size-xl;
font-weight: 600;
color: @heading-color;
}
}
&__nav {
.flex(row, center);
gap: @spacing-lg;
&-item {
font-size: @font-size-base;
color: @text-color;
transition: color 0.2s;
&:hover,
&.router-link-active {
color: @primary-color;
}
}
}
&__actions {
.flex(row, flex-end);
gap: @spacing-base;
}
&__bell {
position: relative;
&-icon {
font-size: @font-size-lg;
}
}
&__badge {
position: absolute;
top: -6px;
right: -8px;
min-width: 16px;
height: 16px;
padding: 0 4px;
border-radius: @radius-round;
background: @danger-color;
color: @white;
font-size: @font-size-sm;
line-height: 16px;
text-align: center;
}
&__login {
font-size: @font-size-base;
}
}
</style>

125
src/components/CaseCard.vue Normal file
View File

@@ -0,0 +1,125 @@
<script setup lang="ts">
import { formatBusinessType } from '@/utils/format'
import type { Case } from '@/types/business/cases'
interface Props {
item: Case
}
defineProps<Props>()
const emit = defineEmits<{ view: [id: string] }>()
function onView(id: string): void {
emit('view', id)
}
</script>
<template>
<article class="case-card" @click="onView(item.id)">
<div class="case-card__cover">
<!-- TODO(蓝湖): 替换案例封面切图,接入 v-lazy -->
<img v-if="item.cover" v-lazy="item.cover" class="case-card__img" :alt="item.title">
<div v-else class="case-card__img case-card__img--placeholder" />
<span class="case-card__tag">{{ formatBusinessType(item.category) }}</span>
<span class="case-card__more">查看详情 ></span>
</div>
<div class="case-card__body">
<h3 class="case-card__title">
{{ item.title }}
</h3>
<ul class="case-card__meta">
<li>完成时间:{{ item.finishDate }}</li>
<li>服务团队:{{ item.teamSize }}人</li>
<li>规模:{{ item.scale }}</li>
<li>所属行业:{{ item.industry }}</li>
<li>项目周期:{{ item.duration }}</li>
<li>客户类型:{{ item.clientType }}</li>
</ul>
</div>
</article>
</template>
<style lang="less" scoped>
.case-card {
overflow: hidden;
border-radius: @radius-lg;
background: @white;
box-shadow: @shadow-base;
cursor: pointer;
transition: box-shadow 0.2s, transform 0.2s;
&:hover {
box-shadow: @shadow-lg;
transform: translateY(-2px);
.case-card__more {
opacity: 1;
}
}
&__cover {
position: relative;
height: 160px;
overflow: hidden;
}
&__img {
width: 100%;
height: 100%;
object-fit: cover;
&--placeholder {
background: linear-gradient(135deg, @primary-light, @bg-color);
}
}
&__tag {
position: absolute;
top: @spacing-sm;
left: @spacing-sm;
padding: 2px @spacing-sm;
border-radius: @radius-round;
background: rgba(0, 0, 0, 0.55);
color: @white;
font-size: @font-size-sm;
}
&__more {
position: absolute;
right: @spacing-sm;
bottom: @spacing-sm;
padding: 2px @spacing-sm;
border-radius: @radius-round;
background: @primary-color;
color: @white;
font-size: @font-size-sm;
opacity: 0;
transition: opacity 0.2s;
}
&__body {
padding: @spacing-base;
}
&__title {
margin-bottom: @spacing-sm;
font-size: @font-size-lg;
font-weight: 600;
color: @heading-color;
.multi-ellipsis(1);
}
&__meta {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px @spacing-sm;
font-size: @font-size-sm;
color: @text-color-secondary;
li {
.ellipsis();
}
}
}
</style>

View File

@@ -0,0 +1,132 @@
<script setup lang="ts">
interface Props {
title?: string
message?: string
confirmText?: string
cancelText?: string
danger?: boolean
}
withDefaults(defineProps<Props>(), {
title: '提示',
message: '',
confirmText: '确认',
cancelText: '取消',
danger: false,
})
const visible = defineModel<boolean>('visible', { default: false })
const emit = defineEmits<{ confirm: []; cancel: [] }>()
function onConfirm(): void {
emit('confirm')
visible.value = false
}
function onCancel(): void {
emit('cancel')
visible.value = false
}
</script>
<template>
<Teleport to="body">
<div v-if="visible" class="confirm-dialog" @click.self="onCancel">
<div class="confirm-dialog__panel">
<h3 class="confirm-dialog__title">
{{ title }}
</h3>
<div class="confirm-dialog__body">
<slot>{{ message }}</slot>
</div>
<div class="confirm-dialog__footer">
<button class="confirm-dialog__btn" @click="onCancel">
{{ cancelText }}
</button>
<button
class="confirm-dialog__btn confirm-dialog__btn--confirm"
:class="{ 'is-danger': danger }"
@click="onConfirm"
>
{{ confirmText }}
</button>
</div>
</div>
</div>
</Teleport>
</template>
<style lang="less" scoped>
.confirm-dialog {
position: fixed;
inset: 0;
z-index: 1000;
.flex(row, center);
background: rgba(0, 0, 0, 0.45);
&__panel {
width: 400px;
max-width: calc(100vw - 32px);
padding: @spacing-lg;
border-radius: @radius-lg;
background: @white;
box-shadow: @shadow-lg;
}
&__title {
margin-bottom: @spacing-base;
font-size: @font-size-lg;
font-weight: 600;
color: @heading-color;
}
&__body {
margin-bottom: @spacing-lg;
font-size: @font-size-base;
color: @text-color;
line-height: 1.6;
}
&__footer {
.flex(row, flex-end);
gap: @spacing-sm;
}
&__btn {
height: 34px;
padding: 0 @spacing-base;
border: 1px solid @border-color-dark;
border-radius: @radius-base;
background: @white;
color: @text-color;
font-size: @font-size-base;
transition: all 0.2s;
&:hover {
border-color: @primary-color;
color: @primary-color;
}
&--confirm {
border-color: @primary-color;
background: @primary-color;
color: @white;
&:hover {
background: @primary-hover;
color: @white;
}
&.is-danger {
border-color: @danger-color;
background: @danger-color;
&:hover {
background: fade(@danger-color, 85%);
}
}
}
}
}
</style>

View File

@@ -0,0 +1,93 @@
<script setup lang="ts">
import type { FileInfo } from '@/types/api'
import { formatFileSize } from '@/utils/format'
interface Props {
files: FileInfo[]
showActions?: boolean
}
withDefaults(defineProps<Props>(), { showActions: true })
const emit = defineEmits<{
preview: [file: FileInfo]
download: [file: FileInfo]
delete: [file: FileInfo]
}>()
</script>
<template>
<ul v-if="files.length > 0" class="file-list">
<li v-for="(file, index) in files" :key="`${file.name}-${index}`" class="file-list__item">
<div class="file-list__info">
<span class="file-list__name" :title="file.name">{{ file.name }}</span>
<span class="file-list__meta text-secondary">
{{ formatFileSize(file.size) }} · 上传于{{ file.uploadTime }}
</span>
</div>
<div v-if="showActions" class="file-list__actions">
<button class="file-list__btn" @click="emit('preview', file)">
预览
</button>
<button class="file-list__btn" @click="emit('download', file)">
下载
</button>
<button class="file-list__btn file-list__btn--danger" @click="emit('delete', file)">
删除
</button>
</div>
</li>
</ul>
</template>
<style lang="less" scoped>
.file-list {
.flex(column, flex-start);
gap: @spacing-sm;
&__item {
.flex(row, space-between);
gap: @spacing-base;
padding: @spacing-sm @spacing-base;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @bg-color-light;
}
&__info {
.flex(column, flex-start);
gap: 2px;
min-width: 0;
}
&__name {
font-size: @font-size-base;
color: @heading-color;
.ellipsis();
}
&__meta {
font-size: @font-size-sm;
}
&__actions {
.flex(row, center);
gap: @spacing-sm;
flex-shrink: 0;
}
&__btn {
font-size: @font-size-sm;
color: @primary-color;
transition: opacity 0.2s;
&:hover {
opacity: 0.75;
}
&--danger {
color: @danger-color;
}
}
}
</style>

View File

@@ -0,0 +1,162 @@
<script setup lang="ts">
export interface FilterChip {
key: string
label: string
}
interface Props {
chips?: FilterChip[]
keywordPlaceholder?: string
searchLabel?: string
showResultCount?: boolean
resultCount?: number
}
withDefaults(defineProps<Props>(), {
chips: () => [],
keywordPlaceholder: '关键字搜索',
searchLabel: '搜索',
showResultCount: false,
resultCount: 0,
})
const keyword = defineModel<string>('keyword', { default: '' })
const emit = defineEmits<{
search: []
reset: []
removeChip: [key: string]
clearChips: []
}>()
</script>
<template>
<div class="filter-panel">
<div class="filter-panel__bar">
<input
v-model="keyword"
class="filter-panel__input"
:placeholder="keywordPlaceholder"
@keyup.enter="emit('search')"
>
<button class="filter-panel__btn filter-panel__btn--primary" @click="emit('search')">
{{ searchLabel }}<template v-if="showResultCount">({{ resultCount }}个结果)</template>
</button>
<button class="filter-panel__btn" @click="emit('reset')">
重置
</button>
</div>
<div v-if="chips.length > 0" class="filter-panel__chips">
<span class="filter-panel__chips-label text-secondary">已选条件({{ chips.length }}个)</span>
<button
v-for="chip in chips"
:key="chip.key"
class="filter-panel__chip"
:title="`移除 ${chip.label}`"
@click="emit('removeChip', chip.key)"
>
{{ chip.label }} ×
</button>
<button class="filter-panel__chip filter-panel__chip--clear" @click="emit('clearChips')">
清空
</button>
</div>
<div class="filter-panel__body">
<slot />
</div>
</div>
</template>
<style lang="less" scoped>
.filter-panel {
padding: @spacing-base @spacing-lg;
border-radius: @radius-lg;
background: @white;
box-shadow: @shadow-base;
&__bar {
.flex(row, flex-start);
gap: @spacing-sm;
}
&__input {
width: 240px;
height: 34px;
padding: 0 @spacing-base;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @bg-color-light;
font-size: @font-size-base;
outline: none;
transition: border-color 0.2s;
&:focus {
border-color: @primary-color;
}
}
&__btn {
height: 34px;
padding: 0 @spacing-base;
border: 1px solid @border-color-dark;
border-radius: @radius-base;
background: @white;
color: @text-color;
font-size: @font-size-base;
transition: all 0.2s;
&:hover {
border-color: @primary-color;
color: @primary-color;
}
&--primary {
border-color: @primary-color;
background: @primary-color;
color: @white;
&:hover {
background: @primary-hover;
color: @white;
}
}
}
&__chips {
.flex(row, flex-start, center);
flex-wrap: wrap;
gap: @spacing-sm;
margin-top: @spacing-base;
font-size: @font-size-sm;
}
&__chip {
height: 26px;
padding: 0 @spacing-sm;
border: 1px solid @primary-light;
border-radius: @radius-round;
background: @primary-light;
color: @primary-color;
font-size: @font-size-sm;
transition: all 0.2s;
&:hover {
border-color: @primary-color;
}
&--clear {
border-color: @border-color;
background: @white;
color: @text-color-secondary;
}
}
&__body {
margin-top: @spacing-base;
.flex(column, flex-start);
gap: @spacing-base;
}
}
</style>

View File

@@ -0,0 +1,108 @@
<script setup lang="ts">
import { computed } from 'vue'
interface Props {
page: number
pageSize: number
total: number
}
const props = defineProps<Props>()
const emit = defineEmits<{ pageChange: [page: number] }>()
const pageCount = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
/** 页码序列:≤7 全部展示,否则首尾 + 当前页窗口(… 省略) */
const pages = computed<Array<number | '...'>>(() => {
const n = pageCount.value
const { page } = props
if (n <= 7) return Array.from({ length: n }, (_, i) => i + 1)
const window: Array<number | '...'> = []
for (let p = page - 1; p <= page + 1; p++) {
if (p >= 1 && p <= n) window.push(p)
}
if (page > 3) window.unshift('...')
if (page < n - 2) window.push('...')
return [1, ...window.filter((item) => item !== 1 && item !== n), n].filter(
(item, index, arr) => arr.indexOf(item) === index,
)
})
function go(page: number): void {
if (page < 1 || page > pageCount.value || page === props.page) return
emit('pageChange', page)
}
</script>
<template>
<nav class="pagination" aria-label="分页">
<button
class="pagination__btn"
:disabled="page <= 1"
@click="go(page - 1)"
>
‹
</button>
<button
v-for="(item, index) in pages"
:key="`${item}-${index}`"
class="pagination__btn"
:class="{ 'is-active': item === page, 'is-ellipsis': item === '...' }"
:disabled="item === '...'"
@click="go(item as number)"
>
{{ item }}
</button>
<button
class="pagination__btn"
:disabled="page >= pageCount"
@click="go(page + 1)"
>
›
</button>
</nav>
</template>
<style lang="less" scoped>
.pagination {
.flex(row, center);
gap: @spacing-xs;
padding: @spacing-base 0;
&__btn {
.flex(row, center);
min-width: 32px;
height: 32px;
padding: 0 @spacing-xs;
border: 1px solid @border-color;
border-radius: @radius-sm;
background: @white;
color: @text-color;
font-size: @font-size-base;
transition: all 0.2s;
&:hover:not(:disabled):not(.is-ellipsis) {
border-color: @primary-color;
color: @primary-color;
}
&.is-active {
border-color: @primary-color;
background: @primary-color;
color: @white;
}
&.is-ellipsis {
border-color: transparent;
background: transparent;
cursor: default;
}
&:disabled:not(.is-ellipsis) {
opacity: 0.4;
cursor: not-allowed;
}
}
}
</style>

View File

@@ -0,0 +1,88 @@
<script setup lang="ts">
import { computed } from 'vue'
import { getPasswordLevel } from '@/utils/validate'
interface Props {
password: string
}
const props = defineProps<Props>()
const level = computed(() => getPasswordLevel(props.password))
const levelText = computed(() => {
if (!props.password) return ''
return level.value === 'strong' ? '强' : level.value === 'medium' ? '中' : '弱'
})
const levelIndex = computed(() => (level.value === 'strong' ? 3 : level.value === 'medium' ? 2 : 1))
</script>
<template>
<div v-if="password" class="pwd-strength">
<div class="pwd-strength__bars">
<span
v-for="i in 3"
:key="i"
class="pwd-strength__bar"
:class="{ 'is-on': i <= levelIndex, [`is-${level}`]: i <= levelIndex }"
/>
</div>
<span class="pwd-strength__label" :class="`is-${level}`">密码强度:{{ levelText }}</span>
<p v-if="level === 'weak'" class="pwd-strength__tip">
密码等级过低,请重新输入(建议字母+数字+符号组合)
</p>
</div>
</template>
<style lang="less" scoped>
.pwd-strength {
.flex(column, flex-start);
gap: @spacing-xs;
&__bars {
.flex(row, center);
gap: 4px;
}
&__bar {
width: 56px;
height: 4px;
border-radius: @radius-round;
background: @border-color;
&.is-on.is-weak {
background: @danger-color;
}
&.is-on.is-medium {
background: @warning-color;
}
&.is-on.is-strong {
background: @success-color;
}
}
&__label {
font-size: @font-size-sm;
&.is-weak {
color: @danger-color;
}
&.is-medium {
color: @warning-color;
}
&.is-strong {
color: @success-color;
}
}
&__tip {
font-size: @font-size-sm;
color: @danger-color;
}
}
</style>

View File

@@ -0,0 +1,114 @@
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useCountDown } from '@/composables/useCountDown'
interface Props {
/** 二维码有效期(秒),默认 4:32 */
expiresIn?: number
size?: number
}
const props = withDefaults(defineProps<Props>(), {
expiresIn: 272,
size: 200,
})
const emit = defineEmits<{ refresh: [] }>()
const { seconds, start } = useCountDown(props.expiresIn)
const started = ref(false)
const expired = computed(() => started.value && seconds.value <= 0)
const countdownText = computed(() => {
const m = Math.floor(seconds.value / 60)
const s = seconds.value % 60
return `${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
})
function refresh(): void {
start(props.expiresIn)
emit('refresh')
}
onMounted(() => {
start(props.expiresIn)
started.value = true
})
</script>
<template>
<div class="qr-panel">
<div
class="qr-panel__box"
:class="{ 'is-expired': expired }"
:style="{ width: `${size}px`, height: `${size}px` }"
@click="refresh"
>
<!-- TODO(api): 二维码内容由支付/签署接口返回后渲染 -->
<template v-if="!expired">
<span class="qr-panel__icon">▦</span>
<span class="qr-panel__tip">扫码支付/签署</span>
</template>
<template v-else>
<span class="qr-panel__icon">⟳</span>
<span class="qr-panel__tip">二维码已过期<br>点击刷新</span>
</template>
</div>
<p class="qr-panel__status text-secondary">
<template v-if="!expired">
二维码将在 <strong class="qr-panel__count">{{ countdownText }}</strong> 后失效(过期可点击二维码刷新)
</template>
<template v-else>
二维码已过期,请点击刷新
</template>
</p>
</div>
</template>
<style lang="less" scoped>
.qr-panel {
.flex(column, center);
gap: @spacing-sm;
&__box {
.flex(column, center);
gap: @spacing-xs;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @white;
cursor: pointer;
transition: border-color 0.2s;
&:hover {
border-color: @primary-color;
}
&.is-expired {
background: @bg-color;
color: @text-color-secondary;
}
}
&__icon {
font-size: 56px;
color: @heading-color;
line-height: 1;
}
&__tip {
font-size: @font-size-sm;
color: @text-color-secondary;
text-align: center;
}
&__status {
font-size: @font-size-sm;
}
&__count {
color: @danger-color;
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,79 @@
<script setup lang="ts">
import { useCountDown } from '@/composables/useCountDown'
const code = defineModel<string>('code', { default: '' })
const emit = defineEmits<{ getCode: [] }>()
const { seconds, isCounting, start } = useCountDown(60)
function onGetCode(): void {
if (isCounting.value) return
start(60)
emit('getCode')
}
</script>
<template>
<div class="sms-code">
<input
v-model="code"
class="sms-code__input"
type="text"
placeholder="请输入验证码"
>
<button
class="sms-code__btn"
:disabled="isCounting"
@click="onGetCode"
>
{{ isCounting ? `${seconds}秒后重新获取` : '获取验证码' }}
</button>
</div>
</template>
<style lang="less" scoped>
.sms-code {
.flex(row, stretch);
gap: @spacing-sm;
&__input {
flex: 1;
min-width: 0;
height: 40px;
padding: 0 @spacing-base;
border: 1px solid @border-color;
border-radius: @radius-base;
background: @bg-color-light;
font-size: @font-size-base;
outline: none;
transition: border-color 0.2s;
&:focus {
border-color: @primary-color;
}
}
&__btn {
flex-shrink: 0;
width: 132px;
height: 40px;
border: 1px solid @primary-color;
border-radius: @radius-base;
background: @white;
color: @primary-color;
font-size: @font-size-sm;
transition: all 0.2s;
&:hover:not(:disabled) {
background: @primary-light;
}
&:disabled {
border-color: @border-color-dark;
color: @text-color-disabled;
cursor: not-allowed;
}
}
}
</style>

View File

@@ -0,0 +1,50 @@
<script setup lang="ts">
interface Props {
label: string
variant?: 'primary' | 'success' | 'warning' | 'danger' | 'info'
}
withDefaults(defineProps<Props>(), { variant: 'info' })
</script>
<template>
<span class="status-tag" :class="`status-tag--${variant}`">
{{ label }}
</span>
</template>
<style lang="less" scoped>
.status-tag {
display: inline-block;
padding: 2px @spacing-sm;
border-radius: @radius-sm;
font-size: @font-size-sm;
line-height: 1.5;
white-space: nowrap;
&--primary {
background: @primary-light;
color: @primary-color;
}
&--success {
background: fade(@success-color, 12%);
color: @success-color;
}
&--warning {
background: fade(@warning-color, 12%);
color: @warning-color;
}
&--danger {
background: fade(@danger-color, 12%);
color: @danger-color;
}
&--info {
background: @bg-color;
color: @text-color-secondary;
}
}
</style>

View File

@@ -0,0 +1,86 @@
<script setup lang="ts">
interface Props {
titles: string[]
current: number
}
defineProps<Props>()
</script>
<template>
<div class="step-form">
<div class="step-form__header">
<template v-for="(title, index) in titles" :key="title">
<div
class="step-form__step"
:class="{ 'is-active': index === current, 'is-done': index < current }"
>
<span class="step-form__dot">{{ index + 1 }}</span>
<span class="step-form__label">{{ title }}</span>
</div>
<div v-if="index < titles.length - 1" class="step-form__line" />
</template>
</div>
<div class="step-form__body">
<slot />
</div>
</div>
</template>
<style lang="less" scoped>
.step-form {
padding: @spacing-lg @spacing-xl;
border-radius: @radius-lg;
background: @white;
box-shadow: @shadow-base;
&__header {
.flex(row, center);
gap: @spacing-sm;
margin-bottom: @spacing-lg;
padding-bottom: @spacing-base;
border-bottom: 1px solid @border-color;
}
&__step {
.flex(row, center);
gap: @spacing-xs;
&.is-active .step-form__dot {
background: @primary-color;
color: @white;
}
&.is-done .step-form__dot {
border-color: @primary-color;
color: @primary-color;
}
&.is-active .step-form__label {
color: @primary-color;
font-weight: 600;
}
}
&__dot {
.flex(row, center);
width: 24px;
height: 24px;
border: 1px solid @border-color-dark;
border-radius: @radius-round;
font-size: @font-size-sm;
color: @text-color-secondary;
}
&__label {
font-size: @font-size-base;
color: @text-color;
}
&__line {
flex: 1;
height: 1px;
background: @border-color;
}
}
</style>

View File

@@ -0,0 +1,100 @@
<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
interface Props {
hint?: string
disabled?: boolean
}
withDefaults(defineProps<Props>(), {
hint: '支持图片/文档/压缩包,大小不超过1G',
disabled: false,
})
const emit = defineEmits<{ upload: [file: File] }>()
const inputRef = ref<HTMLInputElement | null>(null)
const dragging = ref(false)
const MAX_SIZE = 1024 * 1024 * 1024
function pick(): void {
inputRef.value?.click()
}
function handleFiles(list: FileList | null): void {
if (!list) return
for (const file of Array.from(list)) {
if (file.size > MAX_SIZE) {
ElMessage.warning(`「${file.name}」超过1G,未添加`)
continue
}
emit('upload', file)
}
}
function onDrop(event: DragEvent): void {
dragging.value = false
handleFiles(event.dataTransfer?.files ?? null)
}
</script>
<template>
<div
class="upload-area"
:class="{ 'is-dragging': dragging, 'is-disabled': disabled }"
@click="pick"
@dragover.prevent="dragging = true"
@dragleave.prevent="dragging = false"
@drop.prevent="onDrop"
>
<span class="upload-area__icon">⬆</span>
<span class="upload-area__hint text-secondary">{{ hint }}</span>
<input
ref="inputRef"
type="file"
multiple
class="upload-area__input"
:disabled="disabled"
@change="handleFiles(($event.target as HTMLInputElement).files)"
>
</div>
</template>
<style lang="less" scoped>
.upload-area {
.flex(column, center);
gap: @spacing-xs;
padding: @spacing-lg;
border: 1px dashed @border-color-dark;
border-radius: @radius-base;
background: @bg-color-light;
cursor: pointer;
transition: border-color 0.2s, background 0.2s;
&:hover,
&.is-dragging {
border-color: @primary-color;
background: @primary-light;
}
&.is-disabled {
opacity: 0.5;
cursor: not-allowed;
}
&__icon {
font-size: @font-size-xl;
color: @primary-color;
}
&__hint {
font-size: @font-size-sm;
}
&__input {
display: none;
}
}
</style>

15
src/components/index.ts Normal file
View File

@@ -0,0 +1,15 @@
export { default as AppHeader } from './AppHeader.vue'
export { default as AppFooter } from './AppFooter.vue'
export { default as AppButton } from './AppButton.vue'
export { default as CaseCard } from './CaseCard.vue'
export { default as FilterPanel } from './FilterPanel.vue'
export type { FilterChip } from './FilterPanel.vue'
export { default as PaginationBar } from './PaginationBar.vue'
export { default as StatusTag } from './StatusTag.vue'
export { default as FileList } from './FileList.vue'
export { default as UploadArea } from './UploadArea.vue'
export { default as StepForm } from './StepForm.vue'
export { default as SmsCodeInput } from './SmsCodeInput.vue'
export { default as PasswordStrength } from './PasswordStrength.vue'
export { default as ConfirmDialog } from './ConfirmDialog.vue'
export { default as QrCodePanel } from './QrCodePanel.vue'