@coffic/cosy-ui 0.6.8 → 0.6.12
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.
- package/dist/app.css +1 -1
- package/dist/components/icons/SettingsIcon.astro +36 -0
- package/dist/entities/Banner.ts +105 -0
- package/dist/entities/Feature.ts +53 -0
- package/dist/icons.ts +22 -0
- package/dist/index.ts +1 -21
- package/dist/vue/AlertDialog.vue +120 -0
- package/dist/vue/BannerBox.vue +267 -0
- package/dist/vue/ConfirmDialog.vue +76 -0
- package/dist/vue/FeatureButton.vue +95 -0
- package/dist/vue/FeatureCard.vue +209 -0
- package/dist/vue/FeatureGroup.vue +22 -0
- package/dist/vue/ListItem.vue +5 -0
- package/dist/vue/MacWindow.vue +224 -0
- package/dist/vue/SmartBanner.vue +45 -0
- package/dist/vue/SmartHero.vue +94 -0
- package/dist/vue/SmartLink.vue +21 -0
- package/dist/vue/TagList.vue +23 -0
- package/dist/vue/WildBanner.vue +15 -0
- package/dist/vue/iPhoneWindow.vue +189 -0
- package/dist/vue.ts +14 -0
- package/package.json +7 -3
@@ -0,0 +1,189 @@
|
|
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
|
+
components: {
|
51
|
+
AlertDialog
|
52
|
+
},
|
53
|
+
props: {
|
54
|
+
height: {
|
55
|
+
type: String,
|
56
|
+
default: 'h-96'
|
57
|
+
},
|
58
|
+
title: {
|
59
|
+
type: String,
|
60
|
+
default: ''
|
61
|
+
},
|
62
|
+
statusBarButtons: {
|
63
|
+
type: Array,
|
64
|
+
default: () => []
|
65
|
+
},
|
66
|
+
withShadow: {
|
67
|
+
type: Boolean,
|
68
|
+
default: true
|
69
|
+
},
|
70
|
+
showFrame: {
|
71
|
+
type: Boolean,
|
72
|
+
default: true
|
73
|
+
},
|
74
|
+
backgroundColor: {
|
75
|
+
type: String,
|
76
|
+
default: ''
|
77
|
+
}
|
78
|
+
},
|
79
|
+
setup() {
|
80
|
+
const showAlertDialog = ref(false)
|
81
|
+
const alertMessage = ref('')
|
82
|
+
|
83
|
+
const currentTime = ref('12:00')
|
84
|
+
|
85
|
+
// 更新时间的函数
|
86
|
+
const updateTime = () => {
|
87
|
+
const now = new Date()
|
88
|
+
const hours = now.getHours().toString().padStart(2, '0')
|
89
|
+
const minutes = now.getMinutes().toString().padStart(2, '0')
|
90
|
+
currentTime.value = `${hours}:${minutes}`
|
91
|
+
}
|
92
|
+
|
93
|
+
// 设置定时器更新时间
|
94
|
+
let timeInterval: number
|
95
|
+
onMounted(() => {
|
96
|
+
updateTime()
|
97
|
+
timeInterval = window.setInterval(updateTime, 60000) // 每分钟更新一次
|
98
|
+
})
|
99
|
+
|
100
|
+
onUnmounted(() => {
|
101
|
+
if (timeInterval) {
|
102
|
+
clearInterval(timeInterval)
|
103
|
+
}
|
104
|
+
})
|
105
|
+
|
106
|
+
return {
|
107
|
+
showAlertDialog,
|
108
|
+
alertMessage,
|
109
|
+
currentTime
|
110
|
+
}
|
111
|
+
}
|
112
|
+
})
|
113
|
+
</script>
|
114
|
+
|
115
|
+
<template>
|
116
|
+
<div class="cosy:relative cosy:w-full">
|
117
|
+
<div class="cosy:relative cosy:aspect-[9/19.5]">
|
118
|
+
<!-- iPhone 边框 (放在最底层) -->
|
119
|
+
<img v-if="showFrame"
|
120
|
+
src="/assets/iPhone 14 Pro/iPhone 14 Pro - Deep Purple - Portrait.imageset/iPhone 14 Pro - Deep Purple - Portrait.png"
|
121
|
+
alt="iPhone frame" class="cosy:absolute cosy:inset-0 cosy:w-full cosy:h-full cosy:object-contain">
|
122
|
+
|
123
|
+
<!-- 内容区域 -->
|
124
|
+
<div :class="[
|
125
|
+
'cosy:absolute cosy:inset-0',
|
126
|
+
showFrame ? 'cosy:px-[6%] cosy:pt-[13%] cosy:pb-[13%]' : '',
|
127
|
+
]">
|
128
|
+
<div :class="[
|
129
|
+
'cosy:w-full cosy:h-full cosy:flex cosy:flex-col cosy:overflow-hidden',
|
130
|
+
showFrame ? 'cosy:rounded-t-[2.5em] cosy:rounded-b-[2.5rem]' : 'cosy:rounded-lg cosy:shadow',
|
131
|
+
backgroundColor || 'cosy:bg-transparent'
|
132
|
+
]">
|
133
|
+
<!-- 顶部状态栏 (z-index 设为负数,确保在边框下方) -->
|
134
|
+
<div class="cosy:flex-none cosy:h-12 cosy:px-4 cosy:z-0 cosy:relative">
|
135
|
+
<div class="cosy:flex cosy:items-center cosy:h-full cosy:justify-between">
|
136
|
+
<!-- 左侧时间 -->
|
137
|
+
<div class="cosy:flex cosy:items-center">
|
138
|
+
<span
|
139
|
+
class="cosy:text-sm cosy:font-medium cosy:text-gray-700 cosy:dark:text-gray-200">{{
|
140
|
+
currentTime
|
141
|
+
}}</span>
|
142
|
+
</div>
|
143
|
+
<!-- 右侧状态图标 -->
|
144
|
+
<div class="cosy:flex cosy:items-center cosy:space-x-1.5">
|
145
|
+
<!-- 信号图标 -->
|
146
|
+
<svg class="cosy:w-5 cosy:h-3.5 cosy:text-gray-700 cosy:dark:text-gray-200"
|
147
|
+
viewBox="0 0 20 12" fill="none" stroke="currentColor">
|
148
|
+
<path d="M1 11h2V6H1v5zm4 0h2V4H5v7zm4 0h2V2H9v9zm4 0h2V0h-2v11z"
|
149
|
+
fill="currentColor" />
|
150
|
+
<path d="M17 11h2V0h-2v11z" fill="currentColor" opacity="0.4" />
|
151
|
+
</svg>
|
152
|
+
<!-- Wi-Fi图标 -->
|
153
|
+
<svg class="cosy:w-5 cosy:h-4 cosy:text-gray-700 cosy:dark:text-gray-200"
|
154
|
+
viewBox="0 0 16 12" fill="currentColor">
|
155
|
+
<path
|
156
|
+
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" />
|
157
|
+
<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" />
|
158
|
+
</svg>
|
159
|
+
<!-- 电池图标 -->
|
160
|
+
<div class="cosy:flex cosy:items-center cosy:space-x-0.5">
|
161
|
+
<svg class="cosy:w-6 cosy:h-3.5 cosy:text-gray-700 cosy:dark:text-gray-200"
|
162
|
+
viewBox="0 0 25 12" fill="none" stroke="currentColor">
|
163
|
+
<rect x="0.5" y="0.5" width="21" height="11" rx="2.5" stroke-width="1" />
|
164
|
+
<rect x="2" y="2" width="18" height="8" rx="1" fill="currentColor" />
|
165
|
+
<path d="M23 4h1a1 1 0 011 1v2a1 1 0 01-1 1h-1V4z" fill="currentColor" />
|
166
|
+
</svg>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
</div>
|
171
|
+
|
172
|
+
<!-- 主要内容区域 -->
|
173
|
+
<div class="cosy:flex-1 cosy:flex cosy:flex-col cosy:overflow-hidden cosy:relative">
|
174
|
+
<slot />
|
175
|
+
</div>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
<!-- 添加 AlertDialog 组件 -->
|
181
|
+
<AlertDialog v-model="showAlertDialog" :message="alertMessage" />
|
182
|
+
</template>
|
183
|
+
|
184
|
+
<style scoped>
|
185
|
+
/* 确保图标渲染更平滑 */
|
186
|
+
svg {
|
187
|
+
shape-rendering: geometricPrecision;
|
188
|
+
}
|
189
|
+
</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.
|
3
|
+
"version": "0.6.12",
|
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",
|