@coffic/cosy-ui 1.0.14 → 1.0.15
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/index-astro.ts +1 -0
- package/dist/index-vue.ts +1 -0
- package/dist/src/components/apple-pad/applePadPropsBase.d.ts +31 -0
- package/dist/src/components/apple-pad/applePadPropsBase.js +1 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Blue - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Blue - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Purple - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Purple - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Space Gray - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Space Gray - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Stardust - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 11/" - M2 - Stardust - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Blue - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Blue - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Purple - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Purple - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Space Gray - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Space Gray - Portrait.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Stardust - Landscape.png +0 -0
- package/dist/src/components/apple-pad/assets/iPad Air 13/" - M2 - Stardust - Portrait.png +0 -0
- package/dist/src/components/apple-pad/constants.d.ts +36 -0
- package/dist/src/components/apple-pad/constants.js +43 -0
- package/dist/src-astro/apple-pad/ApplePad.astro +165 -0
- package/dist/src-astro/apple-pad/PadFrame.astro +23 -0
- package/dist/src-astro/apple-pad/StatusBarContent.astro +119 -0
- package/dist/src-astro/apple-pad/index.ts +5 -0
- package/dist/src-astro/apple-pad/props.ts +6 -0
- package/dist/src-vue/apple-pad/ApplePad.vue +117 -0
- package/dist/src-vue/apple-pad/PadFrame.vue +20 -0
- package/dist/src-vue/apple-pad/StatusBarContent.vue +153 -0
- package/dist/src-vue/apple-pad/index.ts +2 -0
- package/dist/src-vue/apple-pad/props.ts +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onMounted, onUnmounted, ref } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
IPhoneBatteryIcon,
|
|
5
|
+
IPhoneSignalIcon,
|
|
6
|
+
IPhoneWifiIcon,
|
|
7
|
+
} from "../icons/index";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @component StatusBarContent
|
|
11
|
+
* @description StatusBarContent 组件显示 iPad 状态栏的内容,包括时间、信号、WiFi 和电池图标。
|
|
12
|
+
* 组件会自动更新时间显示,并支持根据设备大小进行缩放。
|
|
13
|
+
* @usage
|
|
14
|
+
* 基本用法:
|
|
15
|
+
* ```vue
|
|
16
|
+
* <StatusBarContent />
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* 带缩放比例:
|
|
20
|
+
* ```vue
|
|
21
|
+
* <StatusBarContent :scaleRatio="1.5" />
|
|
22
|
+
* ```
|
|
23
|
+
* @props
|
|
24
|
+
* @prop {Number} [scaleRatio=1] - 缩放比例,用于根据设备大小调整文字和图标大小
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// Props 定义
|
|
28
|
+
interface Props {
|
|
29
|
+
scaleRatio?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
33
|
+
scaleRatio: 1,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// 响应式数据
|
|
37
|
+
const currentTime = ref("12:00");
|
|
38
|
+
|
|
39
|
+
// 更新时间的函数
|
|
40
|
+
const updateTime = () => {
|
|
41
|
+
const now = new Date();
|
|
42
|
+
const hours = now.getHours().toString().padStart(2, "0");
|
|
43
|
+
const minutes = now.getMinutes().toString().padStart(2, "0");
|
|
44
|
+
currentTime.value = `${hours}:${minutes}`;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// 计算缩放后的字体大小
|
|
48
|
+
const scaledFontSize = computed(() => {
|
|
49
|
+
const baseFontSize = 14;
|
|
50
|
+
return `${baseFontSize * props.scaleRatio}px`;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// 计算缩放后的图标尺寸
|
|
54
|
+
const scaledIconSize = computed(() => {
|
|
55
|
+
const baseIconSize = 15;
|
|
56
|
+
return `${baseIconSize * props.scaleRatio}px`;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// 计算缩放后的图标高度
|
|
60
|
+
const scaledIconHeight = computed(() => {
|
|
61
|
+
const baseIconSize = 15;
|
|
62
|
+
return `${baseIconSize * props.scaleRatio}px`;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// 设置定时器更新时间
|
|
66
|
+
let timeInterval: number;
|
|
67
|
+
onMounted(() => {
|
|
68
|
+
requestAnimationFrame(() => {
|
|
69
|
+
updateTime();
|
|
70
|
+
timeInterval = window.setInterval(updateTime, 60000);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
onUnmounted(() => {
|
|
75
|
+
if (timeInterval) {
|
|
76
|
+
clearInterval(timeInterval);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<div class="cosy:flex cosy:items-center cosy:h-full cosy:justify-between">
|
|
83
|
+
<!-- 左侧时间 -->
|
|
84
|
+
<span
|
|
85
|
+
class="cosy:font-medium time-text"
|
|
86
|
+
:style="{ fontSize: scaledFontSize }">
|
|
87
|
+
{{ currentTime }}
|
|
88
|
+
</span>
|
|
89
|
+
|
|
90
|
+
<!-- 右侧状态图标 -->
|
|
91
|
+
<div
|
|
92
|
+
class="cosy:flex cosy:flex-row cosy:items-center cosy:space-x-1 cosy:h-full">
|
|
93
|
+
<!-- 信号图标 -->
|
|
94
|
+
<div
|
|
95
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
96
|
+
:style="{
|
|
97
|
+
width: scaledIconSize,
|
|
98
|
+
height: scaledIconHeight,
|
|
99
|
+
minWidth: 0,
|
|
100
|
+
minHeight: 0,
|
|
101
|
+
}">
|
|
102
|
+
<IPhoneSignalIcon class="status-icon" />
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<!-- WiFi图标 -->
|
|
106
|
+
<div
|
|
107
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
108
|
+
:style="{
|
|
109
|
+
width: scaledIconSize,
|
|
110
|
+
height: scaledIconHeight,
|
|
111
|
+
minWidth: 0,
|
|
112
|
+
minHeight: 0,
|
|
113
|
+
}">
|
|
114
|
+
<IPhoneWifiIcon class="status-icon" />
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<!-- 电池图标 -->
|
|
118
|
+
<div
|
|
119
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
120
|
+
:style="{
|
|
121
|
+
width: scaledIconSize,
|
|
122
|
+
height: scaledIconHeight,
|
|
123
|
+
minWidth: 0,
|
|
124
|
+
minHeight: 0,
|
|
125
|
+
}">
|
|
126
|
+
<IPhoneBatteryIcon class="battery-icon" />
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
</template>
|
|
131
|
+
|
|
132
|
+
<style scoped>
|
|
133
|
+
svg {
|
|
134
|
+
shape-rendering: geometricPrecision;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.time-text {
|
|
138
|
+
line-height: 1;
|
|
139
|
+
transition: font-size 0.2s ease;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.status-icon,
|
|
143
|
+
.battery-icon {
|
|
144
|
+
color: #000000;
|
|
145
|
+
fill: currentColor;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.status-icon svg,
|
|
149
|
+
.battery-icon svg {
|
|
150
|
+
width: 100%;
|
|
151
|
+
height: 100%;
|
|
152
|
+
}
|
|
153
|
+
</style>
|