@coffic/cosy-ui 0.6.8 → 0.6.10

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.
@@ -0,0 +1,186 @@
1
+ <!--
2
+ @component iPhoneWindow
3
+
4
+ @description
5
+ iPhoneWindow 组件模拟 iPhone 设备的外观,包含状态栏、时间显示和设备边框。
6
+ 适用于创建移动应用界面原型或展示移动端设计效果。
7
+
8
+ @usage
9
+ 基本用法:
10
+ ```vue
11
+ <iPhoneWindow>
12
+ <div>应用内容</div>
13
+ </iPhoneWindow>
14
+ ```
15
+
16
+ 不显示边框:
17
+ ```vue
18
+ <iPhoneWindow :showFrame="false">
19
+ <div>应用内容</div>
20
+ </iPhoneWindow>
21
+ ```
22
+
23
+ 自定义背景色:
24
+ ```vue
25
+ <iPhoneWindow backgroundColor="bg-blue-50">
26
+ <div>应用内容</div>
27
+ </iPhoneWindow>
28
+ ```
29
+
30
+ @props
31
+ @prop {String} [height='h-96'] - 窗口高度
32
+ @prop {String} [title=''] - 窗口标题
33
+ @prop {Array} [statusBarButtons=[]] - 状态栏按钮数组
34
+ @prop {Boolean} [withShadow=true] - 是否显示阴影效果
35
+ @prop {Boolean} [showFrame=true] - 是否显示 iPhone 边框
36
+ @prop {String} [backgroundColor=''] - 内容区域背景色
37
+
38
+ @slots
39
+ @slot default - 主要内容区域
40
+
41
+ @emits
42
+ -->
43
+ <script lang="ts">
44
+ import '../app.css'
45
+ import AlertDialog from './AlertDialog.vue'
46
+ import { ref, onMounted, onUnmounted, defineComponent } from 'vue'
47
+
48
+ export default defineComponent({
49
+ name: 'iPhoneWindow',
50
+ props: {
51
+ height: {
52
+ type: String,
53
+ default: 'h-96'
54
+ },
55
+ title: {
56
+ type: String,
57
+ default: ''
58
+ },
59
+ statusBarButtons: {
60
+ type: Array,
61
+ default: () => []
62
+ },
63
+ withShadow: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ showFrame: {
68
+ type: Boolean,
69
+ default: true
70
+ },
71
+ backgroundColor: {
72
+ type: String,
73
+ default: ''
74
+ }
75
+ },
76
+ setup() {
77
+ const showAlertDialog = ref(false)
78
+ const alertMessage = ref('')
79
+
80
+ const currentTime = ref('12:00')
81
+
82
+ // 更新时间的函数
83
+ const updateTime = () => {
84
+ const now = new Date()
85
+ const hours = now.getHours().toString().padStart(2, '0')
86
+ const minutes = now.getMinutes().toString().padStart(2, '0')
87
+ currentTime.value = `${hours}:${minutes}`
88
+ }
89
+
90
+ // 设置定时器更新时间
91
+ let timeInterval: number
92
+ onMounted(() => {
93
+ updateTime()
94
+ timeInterval = window.setInterval(updateTime, 60000) // 每分钟更新一次
95
+ })
96
+
97
+ onUnmounted(() => {
98
+ if (timeInterval) {
99
+ clearInterval(timeInterval)
100
+ }
101
+ })
102
+
103
+ return {
104
+ showAlertDialog,
105
+ alertMessage,
106
+ currentTime
107
+ }
108
+ }
109
+ })
110
+ </script>
111
+
112
+ <template>
113
+ <div class="cosy:relative cosy:w-full">
114
+ <div class="cosy:relative cosy:aspect-[9/19.5]">
115
+ <!-- iPhone 边框 (放在最底层) -->
116
+ <img v-if="showFrame"
117
+ src="/assets/iPhone 14 Pro/iPhone 14 Pro - Deep Purple - Portrait.imageset/iPhone 14 Pro - Deep Purple - Portrait.png"
118
+ alt="iPhone frame" class="cosy:absolute cosy:inset-0 cosy:w-full cosy:h-full cosy:object-contain">
119
+
120
+ <!-- 内容区域 -->
121
+ <div :class="[
122
+ 'cosy:absolute cosy:inset-0',
123
+ showFrame ? 'cosy:px-[6%] cosy:pt-[13%] cosy:pb-[13%]' : '',
124
+ ]">
125
+ <div :class="[
126
+ 'cosy:w-full cosy:h-full cosy:flex cosy:flex-col cosy:overflow-hidden',
127
+ showFrame ? 'cosy:rounded-t-[2.5em] cosy:rounded-b-[2.5rem]' : 'cosy:rounded-lg cosy:shadow',
128
+ backgroundColor || 'cosy:bg-transparent'
129
+ ]">
130
+ <!-- 顶部状态栏 (z-index 设为负数,确保在边框下方) -->
131
+ <div class="cosy:flex-none cosy:h-12 cosy:px-4 cosy:z-0 cosy:relative">
132
+ <div class="cosy:flex cosy:items-center cosy:h-full cosy:justify-between">
133
+ <!-- 左侧时间 -->
134
+ <div class="cosy:flex cosy:items-center">
135
+ <span
136
+ class="cosy:text-sm cosy:font-medium cosy:text-gray-700 cosy:dark:text-gray-200">{{
137
+ currentTime
138
+ }}</span>
139
+ </div>
140
+ <!-- 右侧状态图标 -->
141
+ <div class="cosy:flex cosy:items-center cosy:space-x-1.5">
142
+ <!-- 信号图标 -->
143
+ <svg class="cosy:w-5 cosy:h-3.5 cosy:text-gray-700 cosy:dark:text-gray-200"
144
+ viewBox="0 0 20 12" fill="none" stroke="currentColor">
145
+ <path d="M1 11h2V6H1v5zm4 0h2V4H5v7zm4 0h2V2H9v9zm4 0h2V0h-2v11z"
146
+ fill="currentColor" />
147
+ <path d="M17 11h2V0h-2v11z" fill="currentColor" opacity="0.4" />
148
+ </svg>
149
+ <!-- Wi-Fi图标 -->
150
+ <svg class="cosy:w-5 cosy:h-4 cosy:text-gray-700 cosy:dark:text-gray-200"
151
+ viewBox="0 0 16 12" fill="currentColor">
152
+ <path
153
+ d="M8 10.5a1 1 0 100-2 1 1 0 000 2zM4.25 7.25a5 5 0 017.5 0l-1.06 1.06a3.5 3.5 0 00-5.38 0L4.25 7.25z" />
154
+ <path d="M1.75 4.75a8.5 8.5 0 0112.5 0l-1.06 1.06a7 7 0 00-10.38 0L1.75 4.75z" />
155
+ </svg>
156
+ <!-- 电池图标 -->
157
+ <div class="cosy:flex cosy:items-center cosy:space-x-0.5">
158
+ <svg class="cosy:w-6 cosy:h-3.5 cosy:text-gray-700 cosy:dark:text-gray-200"
159
+ viewBox="0 0 25 12" fill="none" stroke="currentColor">
160
+ <rect x="0.5" y="0.5" width="21" height="11" rx="2.5" stroke-width="1" />
161
+ <rect x="2" y="2" width="18" height="8" rx="1" fill="currentColor" />
162
+ <path d="M23 4h1a1 1 0 011 1v2a1 1 0 01-1 1h-1V4z" fill="currentColor" />
163
+ </svg>
164
+ </div>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <!-- 主要内容区域 -->
170
+ <div class="cosy:flex-1 cosy:flex cosy:flex-col cosy:overflow-hidden cosy:relative">
171
+ <slot />
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+ <!-- 添加 AlertDialog 组件 -->
178
+ <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
179
+ </template>
180
+
181
+ <style scoped>
182
+ /* 确保图标渲染更平滑 */
183
+ svg {
184
+ shape-rendering: geometricPrecision;
185
+ }
186
+ </style>
package/dist/vue.ts ADDED
@@ -0,0 +1,14 @@
1
+ export * from './vue/TagList.vue';
2
+ export { default as AlertDialog } from './vue/AlertDialog.vue';
3
+ export * from './vue/BannerBox.vue';
4
+ export * from './vue/SmartHero.vue';
5
+ export * from './vue/ConfirmDialog.vue';
6
+ export * from './vue/FeatureButton.vue';
7
+ export * from './vue/FeatureCard.vue';
8
+ export * from './vue/FeatureGroup.vue';
9
+ export { default as iPhoneWindow } from './vue/iPhoneWindow.vue';
10
+ export * from './vue/ListItem.vue';
11
+ export { default as MacWindow } from './vue/MacWindow.vue';
12
+ export * from './vue/SmartBanner.vue';
13
+ export * from './vue/SmartLink.vue';
14
+ export * from './vue/WildBanner.vue';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coffic/cosy-ui",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "An astro component library",
5
5
  "author": {
6
6
  "name": "nookery",
@@ -25,7 +25,9 @@
25
25
  "main": "./dist/index.js",
26
26
  "exports": {
27
27
  ".": "./dist/index.js",
28
- "./collection": "./dist/collection.js"
28
+ "./collection": "./dist/collection.js",
29
+ "./icons": "./dist/icons.js",
30
+ "./vue": "./dist/vue.js"
29
31
  },
30
32
  "files": [
31
33
  "dist",
@@ -45,8 +47,10 @@
45
47
  "astro": "^5.1.3"
46
48
  },
47
49
  "dependencies": {
50
+ "@remixicon/vue": "^4.6.0",
48
51
  "astro-integration-kit": "^0.18.0",
49
- "fs-extra": "^11.3.0"
52
+ "fs-extra": "^11.3.0",
53
+ "html-to-image": "^1.11.13"
50
54
  },
51
55
  "devDependencies": {
52
56
  "@astrojs/check": "^0.9.4",