@coffic/cosy-ui 0.9.78 → 0.9.79
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/src-astro/apple-phone/ApplePhone.astro +4 -4
- package/dist/src-astro/apple-phone/StatusBarContent.astro +0 -1
- package/dist/src-astro/container/ContainerBg.astro +0 -1
- package/dist/src-astro/container/ContainerBox.astro +0 -1
- package/dist/src-astro/container/ContainerError.astro +0 -1
- package/dist/src-astro/container/ExplicitHeightAspectRatioBox.astro +0 -1
- package/dist/src-astro/layout-app/AppLayout.astro +36 -1
- package/dist/src-astro/picture-book/PictureBookTextBox.astro +6 -37
- package/dist/src-vue/apple-phone/StatusBarContent.vue +66 -53
- package/package.json +1 -1
|
@@ -70,8 +70,6 @@ interface Props extends IApplePhonePropsBase {}
|
|
|
70
70
|
|
|
71
71
|
const {
|
|
72
72
|
height = DEFAULT_HEIGHT,
|
|
73
|
-
title = "",
|
|
74
|
-
withShadow = true,
|
|
75
73
|
showFrame = true,
|
|
76
74
|
backgroundColor = undefined,
|
|
77
75
|
} = Astro.props as Props;
|
|
@@ -84,7 +82,6 @@ const scaleRatio = currentHeight / 500;
|
|
|
84
82
|
const uniqueId = `apple-phone-${Math.random().toString(36).substr(2, 9)}`;
|
|
85
83
|
|
|
86
84
|
// 响应式数据
|
|
87
|
-
let showAlertDialog = false;
|
|
88
85
|
let alertMessage = "";
|
|
89
86
|
---
|
|
90
87
|
|
|
@@ -105,7 +102,7 @@ let alertMessage = "";
|
|
|
105
102
|
<!-- 内容区域 -->
|
|
106
103
|
<div
|
|
107
104
|
class="cosy:inset-0 cosy:h-full cosy:flex cosy:flex-col"
|
|
108
|
-
style={`width: ${MAIN_CONTENT_WIDTH_ASPECT_RATIO * 100}%; height: ${MAIN_CONTENT_HEIGHT_ASPECT_RATIO * 100}%; left: 50%; top: 50%; transform: translate(-50%, -50%); position: absolute
|
|
105
|
+
style={`width: ${MAIN_CONTENT_WIDTH_ASPECT_RATIO * 100}%; height: ${MAIN_CONTENT_HEIGHT_ASPECT_RATIO * 100}%; left: 50%; top: 50%; transform: translate(-50%, -50%); position: absolute;`}>
|
|
109
106
|
<Container
|
|
110
107
|
rounded="lg"
|
|
111
108
|
height="full"
|
|
@@ -115,6 +112,9 @@ let alertMessage = "";
|
|
|
115
112
|
<slot />
|
|
116
113
|
</Container>
|
|
117
114
|
</div>
|
|
115
|
+
|
|
116
|
+
<!-- iPhone 边框(第二次渲染,盖住内容四角) -->
|
|
117
|
+
{showFrame && <PhoneFrame />}
|
|
118
118
|
</div>
|
|
119
119
|
|
|
120
120
|
<AlertDialog id={`${uniqueId}-alert`} message={alertMessage} />
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import ContainerBg from "./ContainerBg.astro";
|
|
3
3
|
import AspectRatioBox from "./AspectRatioBox.astro";
|
|
4
4
|
import HeightDrivenAspect from "./HeightDrivenAspect.astro";
|
|
5
|
-
import "../../style.ts";
|
|
6
5
|
import type { IContainerProps } from "./props.ts";
|
|
7
6
|
import { getContainerCombinedClasses } from "./class.ts";
|
|
8
7
|
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* @prop {Object} [sidebarConfig] - 侧边栏配置,包含导航项等
|
|
17
17
|
* @prop {...HTMLAttributes<'div'>} [rest] - 其他HTML div标签属性
|
|
18
18
|
* @slots
|
|
19
|
+
* @slot background - 自定义背景层(最低层,用于渐变、图片等背景效果)
|
|
19
20
|
* @slot default - 主内容区域
|
|
20
21
|
* @slot footer - 自定义全局footer(优先级最高,会覆盖内置Footer)
|
|
21
22
|
* @slot header - 自定义全局header(优先级最高,会覆盖内置AppHeader)
|
|
@@ -305,6 +306,29 @@
|
|
|
305
306
|
* </footer>
|
|
306
307
|
* </AppLayout>
|
|
307
308
|
* ```
|
|
309
|
+
*
|
|
310
|
+
* 自定义背景示例:
|
|
311
|
+
* ```astro
|
|
312
|
+
* <AppLayout
|
|
313
|
+
* metaConfig={{
|
|
314
|
+
* title: "文档标题",
|
|
315
|
+
* description: "文档描述"
|
|
316
|
+
* }}
|
|
317
|
+
* sidebarConfig={{
|
|
318
|
+
* sidebarItems: sidebarItems
|
|
319
|
+
* }}
|
|
320
|
+
* >
|
|
321
|
+
* <!-- 自定义背景层,渲染在最底层 -->
|
|
322
|
+
* <div slot="background" class="cosy:fixed cosy:inset-0 cosy:bg-gradient-to-br cosy:from-blue-600 cosy:to-purple-800">
|
|
323
|
+
* <!-- 装饰性模糊元素 -->
|
|
324
|
+
* <div class="cosy:absolute cosy:top-10 cosy:left-10 cosy:w-96 cosy:h-96 cosy:bg-white/10 cosy:rounded-full cosy:blur-3xl"></div>
|
|
325
|
+
* <div class="cosy:absolute cosy:bottom-10 cosy:right-10 cosy:w-96 cosy:h-96 cosy:bg-white/10 cosy:rounded-full cosy:blur-3xl"></div>
|
|
326
|
+
* </div>
|
|
327
|
+
*
|
|
328
|
+
* <h1>文档内容</h1>
|
|
329
|
+
* <p>背景层会在所有内容下方渲染</p>
|
|
330
|
+
* </AppLayout>
|
|
331
|
+
* ```
|
|
308
332
|
*/
|
|
309
333
|
|
|
310
334
|
import "../../style.ts";
|
|
@@ -360,6 +384,17 @@ const sidebarHeightClass = getSidebarHeightClass(
|
|
|
360
384
|
bodyOnly={bodyOnly}
|
|
361
385
|
theme={theme}
|
|
362
386
|
enableClientRouter={enableClientRouter}>
|
|
387
|
+
<!-- 背景层(最底层,z-index: 0) -->
|
|
388
|
+
{
|
|
389
|
+
Astro.slots.has('background') && (
|
|
390
|
+
<div
|
|
391
|
+
aria-label="AppLayout-Background"
|
|
392
|
+
style="position: fixed; inset: 0; z-index: 0; pointer-events: none;">
|
|
393
|
+
<slot name="background" />
|
|
394
|
+
</div>
|
|
395
|
+
)
|
|
396
|
+
}
|
|
397
|
+
|
|
363
398
|
{
|
|
364
399
|
// 优先级:自定义 header slot > 内置 AppHeader > 不显示
|
|
365
400
|
Astro.slots.has('header') ? (
|
|
@@ -383,7 +418,7 @@ const sidebarHeightClass = getSidebarHeightClass(
|
|
|
383
418
|
padding="none"
|
|
384
419
|
width="full"
|
|
385
420
|
centered={true}
|
|
386
|
-
class="cosy:min-h-screen">
|
|
421
|
+
class="cosy:min-h-screen cosy:relative cosy:z-[1]">
|
|
387
422
|
<!-- 侧边栏容器 -->
|
|
388
423
|
{
|
|
389
424
|
showSidebar && (
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* - width?: number - 宽度(百分比)
|
|
27
27
|
* - heightPx?: number - 高度(像素)。不设置则根据内容自适应高度
|
|
28
28
|
* - zIndex?: number - 层叠顺序,默认 10
|
|
29
|
-
* - bg?:
|
|
29
|
+
* - bg?: BackgroundColor - 预设背景,支持所有通用背景色
|
|
30
30
|
* - backdropBlur?: number - 背景虚化像素(backdrop-filter: blur(px))
|
|
31
31
|
* - paddingPx?: number - 内边距(px)
|
|
32
32
|
* - roundedPx?: number - 圆角(px)
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
import "../../style.ts";
|
|
40
|
+
import type { BackgroundColor } from "../../src/common/backgrounds";
|
|
41
|
+
import { getBackgroundClass } from "../../src/common/backgrounds";
|
|
40
42
|
|
|
41
43
|
export interface IPictureBookTextBoxProps {
|
|
42
44
|
top?: number;
|
|
@@ -47,17 +49,7 @@ export interface IPictureBookTextBoxProps {
|
|
|
47
49
|
heightPx?: number;
|
|
48
50
|
height?: number; // 百分比高度,建议与 width/top 等配合以实现同比缩放
|
|
49
51
|
zIndex?: number;
|
|
50
|
-
bg?:
|
|
51
|
-
| "none"
|
|
52
|
-
| "paper"
|
|
53
|
-
| "muted"
|
|
54
|
-
| "primary"
|
|
55
|
-
| "secondary"
|
|
56
|
-
| "accent"
|
|
57
|
-
| "info"
|
|
58
|
-
| "success"
|
|
59
|
-
| "warning"
|
|
60
|
-
| "error";
|
|
52
|
+
bg?: BackgroundColor;
|
|
61
53
|
backdropBlur?: number;
|
|
62
54
|
paddingPx?: number; // 固定像素内边距(不随容器缩放)
|
|
63
55
|
roundedPx?: number; // 固定像素圆角(不随容器缩放)
|
|
@@ -71,31 +63,8 @@ const props = Astro.props as IPictureBookTextBoxProps;
|
|
|
71
63
|
|
|
72
64
|
const pct = (v?: number) => (typeof v === "number" ? `${v}%` : undefined);
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
case "paper":
|
|
77
|
-
return "cosy:bg-base-100/80 cosy:text-base-content";
|
|
78
|
-
case "muted":
|
|
79
|
-
return "cosy:bg-base-200/70 cosy:text-base-content";
|
|
80
|
-
case "primary":
|
|
81
|
-
return "cosy:bg-primary/20 cosy:text-base-content";
|
|
82
|
-
case "secondary":
|
|
83
|
-
return "cosy:bg-secondary/20 cosy:text-base-content";
|
|
84
|
-
case "accent":
|
|
85
|
-
return "cosy:bg-accent/20 cosy:text-base-content";
|
|
86
|
-
case "info":
|
|
87
|
-
return "cosy:bg-info/20 cosy:text-base-content";
|
|
88
|
-
case "success":
|
|
89
|
-
return "cosy:bg-success/20 cosy:text-base-content";
|
|
90
|
-
case "warning":
|
|
91
|
-
return "cosy:bg-warning/20 cosy:text-base-content";
|
|
92
|
-
case "error":
|
|
93
|
-
return "cosy:bg-error/20 cosy:text-base-content";
|
|
94
|
-
case "none":
|
|
95
|
-
default:
|
|
96
|
-
return "";
|
|
97
|
-
}
|
|
98
|
-
})();
|
|
66
|
+
// 使用通用背景色类名
|
|
67
|
+
const bgClass = getBackgroundClass(props.bg);
|
|
99
68
|
|
|
100
69
|
const paddingStyle = (() => {
|
|
101
70
|
if (typeof props.paddingCqw === "number")
|
|
@@ -68,8 +68,12 @@ const scaledIconHeight = computed(() => {
|
|
|
68
68
|
// 设置定时器更新时间
|
|
69
69
|
let timeInterval: number;
|
|
70
70
|
onMounted(() => {
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
// 使用 requestAnimationFrame 确保在客户端渲染完成后再更新时间
|
|
72
|
+
// 这样可以避免 SSR hydration mismatch 问题
|
|
73
|
+
requestAnimationFrame(() => {
|
|
74
|
+
updateTime();
|
|
75
|
+
timeInterval = window.setInterval(updateTime, 60000); // 每分钟更新一次
|
|
76
|
+
});
|
|
73
77
|
});
|
|
74
78
|
|
|
75
79
|
onUnmounted(() => {
|
|
@@ -80,69 +84,78 @@ onUnmounted(() => {
|
|
|
80
84
|
</script>
|
|
81
85
|
|
|
82
86
|
<template>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
87
|
+
<div class="cosy:flex cosy:items-center cosy:h-full cosy:justify-between">
|
|
88
|
+
<!-- 左侧时间 -->
|
|
89
|
+
<span
|
|
90
|
+
class="cosy:font-medium time-text"
|
|
91
|
+
:style="{ fontSize: scaledFontSize }">
|
|
92
|
+
{{ currentTime }}
|
|
93
|
+
</span>
|
|
94
|
+
|
|
95
|
+
<!-- 右侧状态图标 -->
|
|
96
|
+
<div
|
|
97
|
+
class="cosy:flex cosy:flex-row cosy:items-center cosy:space-x-1 cosy:h-full">
|
|
98
|
+
<!-- 信号图标 -->
|
|
99
|
+
<div
|
|
100
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
101
|
+
:style="{
|
|
102
|
+
width: scaledIconSize,
|
|
103
|
+
height: scaledIconHeight,
|
|
104
|
+
minWidth: 0,
|
|
105
|
+
minHeight: 0,
|
|
106
|
+
}">
|
|
107
|
+
<IPhoneSignalIcon class="status-icon" />
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<!-- WiFi图标 -->
|
|
111
|
+
<div
|
|
112
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
113
|
+
:style="{
|
|
114
|
+
width: scaledIconSize,
|
|
115
|
+
height: scaledIconHeight,
|
|
116
|
+
minWidth: 0,
|
|
117
|
+
minHeight: 0,
|
|
118
|
+
}">
|
|
119
|
+
<IPhoneWifiIcon class="status-icon" />
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<!-- 电池图标 -->
|
|
123
|
+
<div
|
|
124
|
+
class="cosy:flex cosy:items-center cosy:justify-center"
|
|
125
|
+
:style="{
|
|
126
|
+
width: scaledIconSize,
|
|
127
|
+
height: scaledIconHeight,
|
|
128
|
+
minWidth: 0,
|
|
129
|
+
minHeight: 0,
|
|
130
|
+
}">
|
|
131
|
+
<IPhoneBatteryIcon class="battery-icon" />
|
|
132
|
+
</div>
|
|
121
133
|
</div>
|
|
134
|
+
</div>
|
|
122
135
|
</template>
|
|
123
136
|
|
|
124
137
|
<style scoped>
|
|
125
|
-
/* 确保图标渲染更平滑 */
|
|
126
|
-
svg {
|
|
138
|
+
/* 确保图标渲染更平滑 */
|
|
139
|
+
svg {
|
|
127
140
|
shape-rendering: geometricPrecision;
|
|
128
|
-
}
|
|
141
|
+
}
|
|
129
142
|
|
|
130
|
-
/* 时间文字基础样式 */
|
|
131
|
-
.time-text {
|
|
143
|
+
/* 时间文字基础样式 */
|
|
144
|
+
.time-text {
|
|
132
145
|
line-height: 1;
|
|
133
146
|
transition: font-size 0.2s ease;
|
|
134
|
-
}
|
|
147
|
+
}
|
|
135
148
|
|
|
136
|
-
/* 状态图标通用样式 */
|
|
137
|
-
.status-icon,
|
|
138
|
-
.battery-icon {
|
|
149
|
+
/* 状态图标通用样式 */
|
|
150
|
+
.status-icon,
|
|
151
|
+
.battery-icon {
|
|
139
152
|
color: #000000;
|
|
140
153
|
fill: currentColor;
|
|
141
|
-
}
|
|
154
|
+
}
|
|
142
155
|
|
|
143
|
-
.status-icon svg,
|
|
144
|
-
.battery-icon svg {
|
|
156
|
+
.status-icon svg,
|
|
157
|
+
.battery-icon svg {
|
|
145
158
|
width: 100%;
|
|
146
159
|
height: 100%;
|
|
147
|
-
}
|
|
160
|
+
}
|
|
148
161
|
</style>
|