@coffic/cosy-ui 0.6.12 → 0.6.16

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.
Files changed (152) hide show
  1. package/dist/app.css +1 -1
  2. package/dist/assets/iconData.ts +93 -0
  3. package/dist/components/base/Alert.astro +1 -1
  4. package/dist/components/base/Button.astro +102 -91
  5. package/dist/components/base/Image.astro +1 -1
  6. package/dist/components/base/Link.astro +1 -1
  7. package/dist/components/containers/Container.astro +1 -1
  8. package/dist/components/containers/Main.astro +1 -1
  9. package/dist/components/containers/Section.astro +96 -94
  10. package/dist/components/data-display/Blog.astro +1 -1
  11. package/dist/components/data-display/ProductCard.astro +2 -4
  12. package/dist/components/data-display/Products.astro +2 -2
  13. package/dist/components/data-display/TeamMember.astro +2 -4
  14. package/dist/components/data-display/TeamMembers.astro +1 -1
  15. package/dist/components/display/Banner.astro +1 -1
  16. package/dist/components/display/Card.astro +1 -1
  17. package/dist/components/display/CodeBlock.astro +1 -1
  18. package/dist/components/display/CodeExample.astro +1 -1
  19. package/dist/components/display/Hero.astro +1 -1
  20. package/dist/components/display/Modal.astro +1 -1
  21. package/dist/components/layouts/AppLayout.astro +2 -6
  22. package/dist/components/layouts/BaseLayout.astro +1 -1
  23. package/dist/components/layouts/DashboardLayout.astro +1 -1
  24. package/dist/components/layouts/Footer.astro +2 -5
  25. package/dist/components/layouts/Grid.astro +1 -1
  26. package/dist/components/layouts/Header.astro +1 -1
  27. package/dist/components/layouts/NavItems.astro +1 -1
  28. package/dist/components/layouts/Sidebar.astro +2 -2
  29. package/dist/components/layouts/SidebarNav.astro +1 -1
  30. package/dist/components/layouts/Stack.astro +72 -70
  31. package/dist/components/navigation/LanguageSwitcher.astro +2 -2
  32. package/dist/components/navigation/TableOfContents.astro +1 -1
  33. package/dist/components/navigation/ThemeSwitcher.astro +2 -2
  34. package/dist/components/typography/Article.astro +2 -2
  35. package/dist/components/typography/Heading.astro +2 -2
  36. package/dist/components/typography/Text.astro +1 -1
  37. package/dist/icons/AlertTriangle.astro +24 -0
  38. package/dist/icons/AstroIcon.astro +46 -0
  39. package/dist/icons/CalendarIcon.astro +24 -0
  40. package/dist/icons/CheckCircle.astro +23 -0
  41. package/dist/icons/CheckIcon.astro +27 -0
  42. package/dist/{components/icons → icons}/ChevronDownIcon.astro +3 -13
  43. package/dist/icons/ClipboardIcon.astro +27 -0
  44. package/dist/icons/CloseIcon.astro +27 -0
  45. package/dist/icons/ErrorIcon.astro +24 -0
  46. package/dist/icons/GithubIcon.astro +24 -0
  47. package/dist/icons/InfoCircle.astro +24 -0
  48. package/dist/icons/InfoIcon.astro +26 -0
  49. package/dist/icons/LinkIcon.astro +27 -0
  50. package/dist/icons/LinkedinIcon.astro +23 -0
  51. package/dist/icons/MenuIcon.astro +27 -0
  52. package/dist/icons/SearchIcon.astro +23 -0
  53. package/dist/icons/SettingsIcon.astro +18 -0
  54. package/dist/{components/icons → icons}/SocialIcon.astro +14 -14
  55. package/dist/icons/SuccessIcon.astro +24 -0
  56. package/dist/icons/SunCloudyIcon.astro +23 -0
  57. package/dist/icons/TwitterIcon.astro +24 -0
  58. package/dist/icons/UserIcon.astro +24 -0
  59. package/dist/icons/WarningIcon.astro +27 -0
  60. package/dist/icons/XCircle.astro +24 -0
  61. package/dist/index.ts +1 -1
  62. package/dist/index_icons.ts +23 -0
  63. package/dist/index_vue.ts +41 -0
  64. package/dist/vue/{AlertDialog.vue → AlertDialog/AlertDialog.vue} +1 -1
  65. package/dist/vue/AlertDialog/Basic.vue +38 -0
  66. package/dist/vue/AlertDialog/Multilang.vue +48 -0
  67. package/dist/vue/AlertDialog/index.ts +58 -0
  68. package/dist/vue/BannerBox/BannerBox.vue +296 -0
  69. package/dist/vue/BannerBox/DownloadButton.vue +202 -0
  70. package/dist/vue/BannerBox/ExampleBasic.vue +32 -0
  71. package/dist/vue/BannerBox/ExampleCustomBg.vue +32 -0
  72. package/dist/vue/BannerBox/ExampleDisplayModeAlways.vue +34 -0
  73. package/dist/vue/BannerBox/ExampleDisplayModeHover.vue +34 -0
  74. package/dist/vue/BannerBox/ExampleDisplayModeNever.vue +34 -0
  75. package/dist/vue/BannerBox/ExampleImageExport.vue +37 -0
  76. package/dist/vue/BannerBox/ExampleSizePreset.vue +35 -0
  77. package/dist/vue/{FeatureCard.vue → BannerBox/FeatureCard.vue} +28 -47
  78. package/dist/vue/BannerBox/SmartBanner.vue +44 -0
  79. package/dist/vue/BannerBox/bgStyles.ts +55 -0
  80. package/dist/vue/BannerBox/index.ts +83 -0
  81. package/dist/vue/BannerBox/sizePresets.ts +23 -0
  82. package/dist/vue/FeatureButton.vue +25 -26
  83. package/dist/vue/Icons/AlertTriangleIcon.vue +30 -0
  84. package/dist/vue/Icons/CalendarIcon.vue +30 -0
  85. package/dist/vue/Icons/CheckCircleIcon.vue +30 -0
  86. package/dist/vue/Icons/CheckIcon.vue +30 -0
  87. package/dist/vue/Icons/ChevronDownIcon.vue +30 -0
  88. package/dist/vue/Icons/ClipboardIcon.vue +30 -0
  89. package/dist/vue/Icons/CloseIcon.vue +30 -0
  90. package/dist/vue/Icons/InfoCircleIcon.vue +30 -0
  91. package/dist/vue/Icons/InfoIcon.vue +30 -0
  92. package/dist/vue/Icons/LinkIcon.vue +30 -0
  93. package/dist/vue/Icons/MenuIcon.vue +30 -0
  94. package/dist/vue/Icons/SearchIcon.vue +30 -0
  95. package/dist/vue/Icons/SettingsIcon.vue +30 -0
  96. package/dist/vue/Icons/UserIcon.vue +30 -0
  97. package/dist/vue/Icons/VueIcon.vue +76 -0
  98. package/dist/vue/Icons/XCircleIcon.vue +30 -0
  99. package/dist/vue/MacWindow/Basic.vue +11 -0
  100. package/dist/vue/MacWindow/CustomHeight.vue +13 -0
  101. package/dist/vue/{MacWindow.vue → MacWindow/MacWindow.vue} +70 -38
  102. package/dist/vue/MacWindow/WithEvents.vue +34 -0
  103. package/dist/vue/MacWindow/WithSidebar.vue +21 -0
  104. package/dist/vue/MacWindow/WithTabs.vue +21 -0
  105. package/dist/vue/MacWindow/WithToolbar.vue +43 -0
  106. package/dist/vue/MacWindow/index.ts +50 -0
  107. package/dist/vue/SmartHero.vue +28 -34
  108. package/dist/vue/VueCounter.vue +29 -0
  109. package/dist/vue/iPhone/Basic.vue +33 -0
  110. package/dist/vue/iPhone/CustomBackground.vue +33 -0
  111. package/dist/vue/iPhone/NoFrame.vue +33 -0
  112. package/dist/vue/iPhone/WeatherApp.vue +97 -0
  113. package/dist/vue/iPhone/assets/iPhone 14 Pro - Deep Purple - Landscape.png +0 -0
  114. package/dist/vue/iPhone/assets/iPhone 14 Pro - Deep Purple - Portrait.png +0 -0
  115. package/dist/vue/iPhone/assets/iPhone 14 Pro - Gold - Landscape.png +0 -0
  116. package/dist/vue/iPhone/assets/iPhone 14 Pro - Gold - Portrait.png +0 -0
  117. package/dist/vue/iPhone/assets/iPhone 14 Pro - Silver - Landscape.png +0 -0
  118. package/dist/vue/iPhone/assets/iPhone 14 Pro - Silver - Portrait.png +0 -0
  119. package/dist/vue/iPhone/assets/iPhone 14 Pro - Space Black - Landscape.png +0 -0
  120. package/dist/vue/iPhone/assets/iPhone 14 Pro - Space Black - Portrait.png +0 -0
  121. package/dist/vue/{iPhoneWindow.vue → iPhone/iPhoneWindow.vue} +11 -7
  122. package/dist/vue/iPhone/index.ts +41 -0
  123. package/package.json +13 -12
  124. package/dist/components/icons/AlertTriangle.astro +0 -35
  125. package/dist/components/icons/CalendarIcon.astro +0 -38
  126. package/dist/components/icons/CheckCircle.astro +0 -36
  127. package/dist/components/icons/CheckIcon.astro +0 -38
  128. package/dist/components/icons/ClipboardIcon.astro +0 -39
  129. package/dist/components/icons/CloseIcon.astro +0 -38
  130. package/dist/components/icons/ErrorIcon.astro +0 -35
  131. package/dist/components/icons/GithubIcon.astro +0 -31
  132. package/dist/components/icons/InfoCircle.astro +0 -37
  133. package/dist/components/icons/InfoIcon.astro +0 -38
  134. package/dist/components/icons/LinkIcon.astro +0 -39
  135. package/dist/components/icons/LinkedinIcon.astro +0 -31
  136. package/dist/components/icons/MenuIcon.astro +0 -38
  137. package/dist/components/icons/SearchIcon.astro +0 -36
  138. package/dist/components/icons/SettingsIcon.astro +0 -36
  139. package/dist/components/icons/SuccessIcon.astro +0 -35
  140. package/dist/components/icons/SunCloudyIcon.astro +0 -41
  141. package/dist/components/icons/TwitterIcon.astro +0 -31
  142. package/dist/components/icons/UserIcon.astro +0 -35
  143. package/dist/components/icons/WarningIcon.astro +0 -38
  144. package/dist/components/icons/XCircle.astro +0 -37
  145. package/dist/entities/Banner.ts +0 -105
  146. package/dist/icons.ts +0 -22
  147. package/dist/vue/BannerBox.vue +0 -267
  148. package/dist/vue/FeatureGroup.vue +0 -22
  149. package/dist/vue/SmartBanner.vue +0 -45
  150. package/dist/vue/WildBanner.vue +0 -15
  151. package/dist/vue.ts +0 -14
  152. /package/dist/{collection.ts → index_collection.ts} +0 -0
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="info" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="link" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="menu" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="search" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="settings" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="user" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,76 @@
1
+ <!--
2
+ @component Icon
3
+
4
+ @description
5
+ Icon 组件是一个可重用的SVG图标组件,用于显示各种图标。
6
+ 使用共享的图标数据,便于维护和一致性。
7
+
8
+ @usage
9
+ ```vue
10
+ <template>
11
+ <Icon name="alertTriangle" />
12
+
13
+ <Icon name="settings" size="32px" color="red" />
14
+
15
+ <Icon name="check" class="cosy:w-6 cosy:h-6 cosy:text-success" />
16
+ </template>
17
+
18
+ <script setup>
19
+ import { Icon } from 'cosy-ui';
20
+ </script>
21
+ ```
22
+
23
+ @props
24
+ @prop {string} name - 图标名称,必须在iconData中存在
25
+ @prop {string} [size='24px'] - 图标大小
26
+ @prop {string} [color='currentColor'] - 图标颜色
27
+ @prop {string} [class=''] - 自定义类名
28
+ -->
29
+
30
+ <script setup lang="ts">
31
+ import '../../style.ts'
32
+ import { computed } from 'vue'
33
+ import { iconData } from '../../assets/iconData'
34
+
35
+ interface Props {
36
+ /**
37
+ * 图标名称,必须在iconData中存在
38
+ */
39
+ name: string;
40
+ /**
41
+ * 图标大小
42
+ * @default "24px"
43
+ */
44
+ size?: string;
45
+ /**
46
+ * 图标颜色
47
+ * @default "currentColor"
48
+ */
49
+ color?: string;
50
+ /**
51
+ * 自定义类名
52
+ */
53
+ class?: string;
54
+ }
55
+
56
+ const props = withDefaults(defineProps<Props>(), {
57
+ size: '24px',
58
+ color: 'currentColor',
59
+ class: ''
60
+ })
61
+
62
+ const icon = computed(() => {
63
+ return iconData[props.name] || null
64
+ })
65
+
66
+ const viewBox = computed(() => {
67
+ return icon.value?.viewBox || '0 0 24 24'
68
+ })
69
+ </script>
70
+
71
+ <template>
72
+ <svg xmlns="http://www.w3.org/2000/svg" :width="size" :height="size" :viewBox="viewBox" fill="none" :stroke="color"
73
+ stroke-width="2" stroke-linecap="round" stroke-linejoin="round" :class="props.class">
74
+ <path v-if="icon" :d="icon.path" />
75
+ </svg>
76
+ </template>
@@ -0,0 +1,30 @@
1
+ <script setup lang="ts">
2
+ import Icon from './VueIcon.vue';
3
+
4
+ interface Props {
5
+ /**
6
+ * 图标的大小
7
+ * @default "24px"
8
+ */
9
+ size?: string;
10
+ /**
11
+ * 图标的颜色
12
+ * @default "currentColor"
13
+ */
14
+ color?: string;
15
+ /**
16
+ * 自定义类名
17
+ */
18
+ class?: string;
19
+ }
20
+
21
+ const props = withDefaults(defineProps<Props>(), {
22
+ size: '24px',
23
+ color: 'currentColor',
24
+ class: ''
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <Icon name="xCircle" :size="size" :color="color" :class="props.class" />
30
+ </template>
@@ -0,0 +1,11 @@
1
+ <script setup>
2
+ import { MacWindow } from './index';
3
+ </script>
4
+
5
+ <template>
6
+ <MacWindow title="代码编辑器">
7
+ <div class="cosy:p-4">
8
+ 窗口内容区域
9
+ </div>
10
+ </MacWindow>
11
+ </template>
@@ -0,0 +1,13 @@
1
+ <script setup>
2
+ import { MacWindow } from './index';
3
+ </script>
4
+
5
+ <template>
6
+ <MacWindow title="终端" height="cosy:h-64">
7
+ <div class="cosy:p-4 cosy:bg-gray-900 cosy:text-green-400 cosy:font-mono">
8
+ $ echo "Hello, World!"<br />
9
+ Hello, World!<br />
10
+ $ _
11
+ </div>
12
+ </MacWindow>
13
+ </template>
@@ -18,16 +18,15 @@ MacWindow 组件模拟 macOS 风格的应用窗口,包含标题栏、工具栏
18
18
  <template>
19
19
  <MacWindow
20
20
  title="设置"
21
- v-model="activeTab"
22
- :tabs="[
23
- { label: '通用', value: 'general' },
24
- { label: '外观', value: 'appearance' },
25
- { label: '高级', value: 'advanced' }
26
- ]"
21
+ :tabs="['通用', '外观', '高级']"
22
+ :onTabClick="(tab) => {
23
+ activeTab = tab;
24
+ console.log('切换到标签:', tab);
25
+ }"
27
26
  >
28
- <div v-if="activeTab === 'general'">通用设置内容</div>
29
- <div v-if="activeTab === 'appearance'">外观设置内容</div>
30
- <div v-if="activeTab === 'advanced'">高级设置内容</div>
27
+ <div v-if="activeTab === '通用'">通用设置内容</div>
28
+ <div v-if="activeTab === '外观'">外观设置内容</div>
29
+ <div v-if="activeTab === '高级'">高级设置内容</div>
31
30
  </MacWindow>
32
31
  </template>
33
32
 
@@ -35,10 +34,21 @@ MacWindow 组件模拟 macOS 风格的应用窗口,包含标题栏、工具栏
35
34
  import { ref } from 'vue';
36
35
  import { MacWindow } from 'cosy-ui';
37
36
 
38
- const activeTab = ref('general');
37
+ const activeTab = ref('通用');
39
38
  </script>
40
39
  ```
41
40
 
41
+ 带自定义事件处理:
42
+ ```vue
43
+ <MacWindow
44
+ title="文件浏览器"
45
+ :onCloseWindow="() => handleClose()"
46
+ :onTabClick="(tab) => handleTabChange(tab)"
47
+ >
48
+ <div>窗口内容</div>
49
+ </MacWindow>
50
+ ```
51
+
42
52
  带工具栏和状态栏:
43
53
  ```vue
44
54
  <MacWindow title="文件浏览器">
@@ -66,8 +76,11 @@ const activeTab = ref('general');
66
76
  @prop {String} [height='h-96'] - 窗口高度
67
77
  @prop {String} [title=''] - 窗口标题
68
78
  @prop {Boolean} [withShadow=true] - 是否显示阴影效果
69
- @prop {Array} [tabs=[]] - 标签页数组,每个标签包含label和value属性
70
- @prop {String} [modelValue=''] - 当前选中的标签页value值,可使用v-model绑定
79
+ @prop {Array} [tabs=[]] - 标签页字符串数组,如 ['标签1', '标签2', '标签3']
80
+ @prop {Function} [onCloseWindow=null] - 关闭窗口时调用的函数
81
+ @prop {Function} [onMinimizeWindow=null] - 最小化窗口时调用的函数
82
+ @prop {Function} [onMaximizeWindow=null] - 最大化窗口时调用的函数
83
+ @prop {Function} [onTabClick=null] - 点击标签页时调用的函数,接收标签页值作为参数
71
84
 
72
85
  @slots
73
86
  @slot default - 窗口主要内容
@@ -76,22 +89,13 @@ const activeTab = ref('general');
76
89
  @slot status - 状态栏内容,位于窗口底部
77
90
 
78
91
  @emits
79
- @emit {close} - 点击关闭按钮时触发
80
- @emit {minimize} - 点击最小化按钮时触发
81
- @emit {maximize} - 点击最大化按钮时触发
82
92
  @emit {update:modelValue} - 切换标签页时触发,用于v-model
83
93
  -->
84
94
 
85
95
  <script lang="ts">
86
- import '../app.css'
87
- import AlertDialog from './AlertDialog.vue'
88
- import { ref, defineComponent } from 'vue'
89
-
90
- // 定义标签页类型
91
- interface Tab {
92
- label: string;
93
- value: string;
94
- }
96
+ import '../../style.ts'
97
+ import AlertDialog from '../AlertDialog/AlertDialog.vue'
98
+ import { ref, defineComponent, type PropType } from 'vue'
95
99
 
96
100
  export default defineComponent({
97
101
  name: 'MacWindow',
@@ -112,44 +116,71 @@ export default defineComponent({
112
116
  default: true
113
117
  },
114
118
  tabs: {
115
- type: Array as () => Tab[],
119
+ type: Array as PropType<string[]>,
116
120
  default: () => []
117
121
  },
118
- modelValue: {
119
- type: String,
120
- default: ''
122
+ onCloseWindow: {
123
+ type: Function,
124
+ default: null
125
+ },
126
+ onMinimizeWindow: {
127
+ type: Function,
128
+ default: null
129
+ },
130
+ onMaximizeWindow: {
131
+ type: Function,
132
+ default: null
133
+ },
134
+ onTabClick: {
135
+ type: Function,
136
+ default: null
121
137
  }
122
138
  },
123
- emits: ['close', 'minimize', 'maximize', 'update:modelValue'],
124
- setup(props, { emit }) {
139
+ setup(props) {
125
140
  const showAlertDialog = ref(false)
126
141
  const alertMessage = ref('')
142
+ const activeTab = ref('')
143
+
144
+ // 默认选择第一个标签
145
+ if (props.tabs.length > 0 && !activeTab.value) {
146
+ activeTab.value = props.tabs[0] as string
147
+ }
127
148
 
128
149
  const handleCloseWindow = () => {
129
150
  alertMessage.value = '关闭APP窗口(这是演示,不会真实操作)'
130
151
  showAlertDialog.value = true
131
- emit('close')
152
+ if (props.onCloseWindow) {
153
+ props.onCloseWindow()
154
+ }
132
155
  }
133
156
 
134
157
  const handleMinimizeWindow = () => {
135
158
  alertMessage.value = '最小化窗口(这是演示,不会真实操作)'
136
159
  showAlertDialog.value = true
137
- emit('minimize')
160
+ if (props.onMinimizeWindow) {
161
+ props.onMinimizeWindow()
162
+ }
138
163
  }
139
164
 
140
165
  const handleMaximizeWindow = () => {
141
166
  alertMessage.value = '最大化窗口(这是演示,不会真实操作)'
142
167
  showAlertDialog.value = true
143
- emit('maximize')
168
+ if (props.onMaximizeWindow) {
169
+ props.onMaximizeWindow()
170
+ }
144
171
  }
145
172
 
146
- const handleTabClick = (value: string) => {
147
- emit('update:modelValue', value)
173
+ const handleTabClick = (tab: string) => {
174
+ activeTab.value = tab
175
+ if (props.onTabClick) {
176
+ props.onTabClick(tab)
177
+ }
148
178
  }
149
179
 
150
180
  return {
151
181
  showAlertDialog,
152
182
  alertMessage,
183
+ activeTab,
153
184
  handleCloseWindow,
154
185
  handleMinimizeWindow,
155
186
  handleMaximizeWindow,
@@ -185,11 +216,11 @@ export default defineComponent({
185
216
  <div class="cosy:inline-flex cosy:rounded-lg cosy:bg-base-300 cosy:p-1">
186
217
  <button v-for="(tab, index) in tabs" :key="index" :class="[
187
218
  'cosy:px-3 cosy:py-1 cosy:text-sm cosy:rounded-md cosy:transition-colors',
188
- modelValue === tab.value
219
+ activeTab === tab
189
220
  ? 'cosy:bg-base-100 cosy:text-base-content cosy:shadow'
190
221
  : 'cosy:text-base-content/70 hover:cosy:text-base-content'
191
- ]" @click="handleTabClick(tab.value)">
192
- {{ tab.label }}
222
+ ]" @click="handleTabClick(tab)">
223
+ {{ tab }}
193
224
  </button>
194
225
  </div>
195
226
  </div>
@@ -219,6 +250,7 @@ export default defineComponent({
219
250
  </div>
220
251
  </div>
221
252
  </div>
253
+
222
254
  <!-- AlertDialog 组件 -->
223
255
  <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
224
256
  </template>
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ import { ref } from 'vue';
3
+ import { MacWindow } from './index';
4
+
5
+ const activeTab = ref('信息');
6
+
7
+ const handleTabClick = (tab) => {
8
+ activeTab.value = tab;
9
+ console.log('切换到标签:', tab);
10
+ };
11
+
12
+ const handleClose = () => {
13
+ alert('关闭窗口');
14
+ };
15
+
16
+ const handleMinimize = () => {
17
+ alert('最小化窗口');
18
+ };
19
+
20
+ const handleMaximize = () => {
21
+ alert('最大化窗口');
22
+ };
23
+ </script>
24
+
25
+ <template>
26
+ <MacWindow title="应用窗口" :tabs="['信息', '设置', '帮助']" :onTabClick="handleTabClick" :onCloseWindow="handleClose"
27
+ :onMinimizeWindow="handleMinimize" :onMaximizeWindow="handleMaximize">
28
+ <div class="cosy:p-4">
29
+ <div v-if="activeTab === '信息'">信息内容</div>
30
+ <div v-if="activeTab === '设置'">设置内容</div>
31
+ <div v-if="activeTab === '帮助'">帮助内容</div>
32
+ </div>
33
+ </MacWindow>
34
+ </template>
@@ -0,0 +1,21 @@
1
+ <script setup>
2
+ import { MacWindow } from './index';
3
+ </script>
4
+
5
+ <template>
6
+ <MacWindow title="文件浏览器">
7
+ <template #sidebar>
8
+ <div class="cosy:w-48 cosy:border-r cosy:border-base-300 cosy:p-2">
9
+ <div class="cosy:font-medium cosy:mb-2">文件夹</div>
10
+ <ul>
11
+ <li class="cosy:py-1 cosy:px-2 hover:cosy:bg-base-200 cosy:rounded cosy:cursor-pointer">文档</li>
12
+ <li class="cosy:py-1 cosy:px-2 hover:cosy:bg-base-200 cosy:rounded cosy:cursor-pointer">下载</li>
13
+ <li class="cosy:py-1 cosy:px-2 hover:cosy:bg-base-200 cosy:rounded cosy:cursor-pointer">图片</li>
14
+ </ul>
15
+ </div>
16
+ </template>
17
+ <div class="cosy:p-4">
18
+ 主内容区域
19
+ </div>
20
+ </MacWindow>
21
+ </template>
@@ -0,0 +1,21 @@
1
+ <script setup>
2
+ import { ref } from 'vue';
3
+ import { MacWindow } from './index';
4
+
5
+ const activeTab = ref('通用');
6
+
7
+ const handleTabClick = (tab) => {
8
+ activeTab.value = tab;
9
+ console.log('当前标签:', tab);
10
+ };
11
+ </script>
12
+
13
+ <template>
14
+ <MacWindow title="设置" :tabs="['通用', '外观', '高级']" :onTabClick="handleTabClick">
15
+ <div class="cosy:p-4">
16
+ <div v-if="activeTab === '通用'">通用设置内容</div>
17
+ <div v-if="activeTab === '外观'">外观设置内容</div>
18
+ <div v-if="activeTab === '高级'">高级设置内容</div>
19
+ </div>
20
+ </MacWindow>
21
+ </template>
@@ -0,0 +1,43 @@
1
+ <script setup>
2
+ import { MacWindow } from './index';
3
+ import { SearchIcon, SettingsIcon, InfoIcon } from '../../index_vue';
4
+
5
+ const handleSearch = () => {
6
+ console.log('搜索');
7
+ };
8
+
9
+ const handleSettings = () => {
10
+ console.log('设置');
11
+ };
12
+
13
+ const handleInfo = () => {
14
+ console.log('信息');
15
+ };
16
+ </script>
17
+
18
+ <template>
19
+ <MacWindow title="文件浏览器">
20
+ <!-- 工具栏插槽 -->
21
+ <template #toolbar>
22
+ <button class="cosy:btn cosy:btn-ghost cosy:btn-sm" @click="handleSearch">
23
+ <SearchIcon class="cosy:w-4 cosy:h-4" />
24
+ </button>
25
+ <button class="cosy:btn cosy:btn-ghost cosy:btn-sm" @click="handleSettings">
26
+ <SettingsIcon class="cosy:w-4 cosy:h-4" />
27
+ </button>
28
+ </template>
29
+
30
+ <!-- 主内容 -->
31
+ <div class="cosy:p-4">
32
+ 窗口内容区域
33
+ </div>
34
+
35
+ <!-- 状态栏插槽 -->
36
+ <template #status>
37
+ <div class="cosy:text-xs">就绪</div>
38
+ <button class="cosy:btn cosy:btn-ghost cosy:btn-xs" @click="handleInfo">
39
+ <InfoIcon class="cosy:w-4 cosy:h-4" />
40
+ </button>
41
+ </template>
42
+ </MacWindow>
43
+ </template>