@aquiferre/ui-kit 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,12 +3,12 @@
3
3
  <Transition name="fade">
4
4
  <div v-if="visible" class="dialog-overlay">
5
5
  <div class="fixed inset-0 bg-bg-overlay" @click="cancel" />
6
- <div class="dialog max-w-sm">
6
+ <div class="panel-glass dialog max-w-sm">
7
7
  <div class="px-6 py-4">
8
8
  <h3 class="dialog-title">{{ title }}</h3>
9
9
  <p v-if="content" class="text-text-secondary text-sm mt-2">{{ content }}</p>
10
10
  </div>
11
- <div class="dialog-actions px-6 py-4 border-t border-border-primary bg-bg-secondary rounded-b-2xl">
11
+ <div class="dialog-actions px-6 py-4 border-t border-border-primary bg-bg-secondary/50 rounded-b-2xl">
12
12
  <button class="btn-secondary" @click="cancel">
13
13
  {{ cancelText }}
14
14
  </button>
@@ -3,15 +3,15 @@
3
3
  <Transition name="fade">
4
4
  <div v-if="visible" class="dialog-overlay">
5
5
  <div class="fixed inset-0 bg-bg-overlay" @click="cancel" />
6
- <div class="dialog" :class="width || 'max-w-lg'">
6
+ <div class="panel-glass" :class="[width || 'max-w-lg', 'dialog']">
7
7
  <div class="flex items-center justify-between px-6 py-4 border-b border-border-primary">
8
8
  <h3 class="text-lg font-medium text-text-primary">{{ title }}</h3>
9
- <button class="text-text-tertiary hover:text-text-primary" @click="cancel">&times;</button>
9
+ <button class="text-text-tertiary hover:text-text-primary text-2xl leading-none" @click="cancel">&times;</button>
10
10
  </div>
11
11
  <div class="px-6 py-4">
12
12
  <slot />
13
13
  </div>
14
- <div class="dialog-actions px-6 py-4 border-t border-border-primary bg-bg-secondary rounded-b-2xl">
14
+ <div class="dialog-actions px-6 py-4 border-t border-border-primary bg-bg-secondary/50 rounded-b-2xl">
15
15
  <button
16
16
  class="btn-secondary"
17
17
  @click="cancel"
@@ -1,27 +1,36 @@
1
1
  <template>
2
- <div class="flex items-center justify-between px-6 py-3 bg-bg-elevated border-t border-border-primary">
3
- <div class="text-sm text-text-secondary">
4
- 共 {{ total }} 条记录
2
+ <div class="flex items-center justify-between px-6 py-2">
3
+ <div class="text-xs text-text-tertiary">
4
+ 共 {{ total }} 条,第 {{ startItem }} - {{ endItem }} 条
5
5
  </div>
6
- <div class="flex items-center space-x-2">
6
+ <div class="flex items-center space-x-1">
7
7
  <button
8
8
  :disabled="page <= 1"
9
- class="btn-secondary btn-sm disabled:opacity-50"
9
+ class="btn-glass btn-sm disabled:opacity-50"
10
10
  @click="changePage(page - 1)"
11
11
  >
12
- 上一页
12
+ 上一页
13
13
  </button>
14
- <span class="text-sm text-text-primary">{{ page }} / {{ totalPages }}</span>
14
+ <template v-for="p in visiblePages" :key="p">
15
+ <span v-if="p === '...'" class="btn-glass btn-sm pointer-events-none">…</span>
16
+ <button
17
+ v-else
18
+ :class="p === page ? 'pagination-btn-active btn-sm' : 'btn-glass btn-sm'"
19
+ @click="changePage(p as number)"
20
+ >
21
+ {{ p }}
22
+ </button>
23
+ </template>
15
24
  <button
16
25
  :disabled="page >= totalPages"
17
- class="btn-secondary btn-sm disabled:opacity-50"
26
+ class="btn-glass btn-sm disabled:opacity-50"
18
27
  @click="changePage(page + 1)"
19
28
  >
20
- 下一页
29
+ 下一页
21
30
  </button>
22
31
  <select
23
32
  :value="pageSize"
24
- class="select text-sm py-1"
33
+ class="select ml-2"
25
34
  @change="changePageSize(Number(($event.target as HTMLSelectElement).value))"
26
35
  >
27
36
  <option :value="10">10条/页</option>
@@ -33,6 +42,7 @@
33
42
  </template>
34
43
 
35
44
  <script setup lang="ts">
45
+ // @ts-nocheck
36
46
  import { computed } from 'vue'
37
47
 
38
48
  const props = defineProps<{
@@ -49,7 +59,46 @@ const emit = defineEmits<{
49
59
 
50
60
  const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
51
61
 
62
+ const startItem = computed(() => (props.page - 1) * props.pageSize + 1)
63
+ const endItem = computed(() => Math.min(props.page * props.pageSize, props.total))
64
+
65
+ /**
66
+ * 生成可见页码数组,当前页 ±2 范围内显示,其余用 '...' 省略
67
+ * 始终显示首页和末页
68
+ */
69
+ const visiblePages = computed(() => {
70
+ const total = totalPages.value
71
+ const current = props.page
72
+ const delta = 2
73
+ const pages: (number | string)[] = []
74
+
75
+ if (total <= 7) {
76
+ for (let i = 1; i <= total; i++) pages.push(i)
77
+ return pages
78
+ }
79
+
80
+ // Always show first page
81
+ pages.push(1)
82
+
83
+ const rangeStart = Math.max(2, current - delta)
84
+ const rangeEnd = Math.min(total - 1, current + delta)
85
+
86
+ if (rangeStart > 2) pages.push('...')
87
+
88
+ for (let i = rangeStart; i <= rangeEnd; i++) {
89
+ pages.push(i)
90
+ }
91
+
92
+ if (rangeEnd < total - 1) pages.push('...')
93
+
94
+ // Always show last page
95
+ pages.push(total)
96
+
97
+ return pages
98
+ })
99
+
52
100
  function changePage(p: number) {
101
+ if (p < 1 || p > totalPages.value) return
53
102
  emit('update:page', p)
54
103
  emit('change', p, props.pageSize)
55
104
  }
@@ -2,7 +2,7 @@
2
2
  <header class="navbar">
3
3
  <div class="flex items-center gap-3">
4
4
  <slot name="brand">
5
- <div class="w-8 h-8 rounded-lg bg-gradient-to-br from-accent-primary to-accent-secondary flex items-center justify-center">
5
+ <div class="w-8 h-8 rounded-lg bg-accent-primary flex items-center justify-center">
6
6
  <svg class="w-5 h-5 text-text-inverse" viewBox="0 0 24 24" fill="currentColor">
7
7
  <path d="M12 2L2 7l10 5 10-5-10-5z"/>
8
8
  </svg>
@@ -10,21 +10,21 @@
10
10
  <span class="navbar-brand">{{ title }}</span>
11
11
  </slot>
12
12
  <span v-if="tenantLabel" class="text-xs text-text-tertiary">| {{ tenantLabel }}</span>
13
- </div>
14
13
 
15
- <nav v-if="modules.length > 0" class="flex items-center gap-1">
16
- <router-link
17
- v-for="mod in modules"
18
- :key="mod.key"
19
- :to="mod.href"
20
- class="px-3 py-1.5 text-sm rounded-t-md transition-all duration-150 border-b-2"
21
- :class="activeModule === mod.key
22
- ? 'text-accent-primary border-accent-primary font-medium'
23
- : 'text-text-secondary hover:text-text-primary border-transparent'"
24
- >
25
- {{ mod.label }}
26
- </router-link>
27
- </nav>
14
+ <nav v-if="modules.length > 0" class="flex items-center gap-1 ml-4">
15
+ <router-link
16
+ v-for="mod in modules"
17
+ :key="mod.key"
18
+ :to="mod.href"
19
+ class="px-3 py-1.5 text-sm rounded-t-md transition-all duration-150 border-b-2"
20
+ :class="activeModule === mod.key
21
+ ? 'font-medium border-accent-primary'
22
+ : 'text-text-secondary hover:text-text-primary border-transparent'"
23
+ >
24
+ {{ mod.label }}
25
+ </router-link>
26
+ </nav>
27
+ </div>
28
28
 
29
29
  <div class="navbar-user">
30
30
  <!-- 主题切换 -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquiferre/ui-kit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/types.ts CHANGED
@@ -23,6 +23,7 @@ export interface NavModule {
23
23
  href: string
24
24
  paths: string[]
25
25
  permissions: string[]
26
+ superAdminOnly?: boolean
26
27
  }
27
28
 
28
29
  export interface DropdownItem {