@coffic/cosy-ui 0.6.10 → 0.6.14

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 (149) 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 +435 -0
  69. package/dist/vue/BannerBox/Basic.vue +32 -0
  70. package/dist/vue/BannerBox/CustomBg.vue +32 -0
  71. package/dist/vue/BannerBox/CustomComponent.vue +60 -0
  72. package/dist/vue/BannerBox/DisplayMode.vue +49 -0
  73. package/dist/vue/{FeatureCard.vue → BannerBox/FeatureCard.vue} +23 -42
  74. package/dist/vue/BannerBox/ImageExport.vue +37 -0
  75. package/dist/vue/BannerBox/SizePreset.vue +35 -0
  76. package/dist/vue/BannerBox/SmartBanner.vue +44 -0
  77. package/dist/vue/BannerBox/index.ts +76 -0
  78. package/dist/vue/FeatureButton.vue +25 -26
  79. package/dist/vue/Icons/AlertTriangleIcon.vue +30 -0
  80. package/dist/vue/Icons/CalendarIcon.vue +30 -0
  81. package/dist/vue/Icons/CheckCircleIcon.vue +30 -0
  82. package/dist/vue/Icons/CheckIcon.vue +30 -0
  83. package/dist/vue/Icons/ChevronDownIcon.vue +30 -0
  84. package/dist/vue/Icons/ClipboardIcon.vue +30 -0
  85. package/dist/vue/Icons/CloseIcon.vue +30 -0
  86. package/dist/vue/Icons/InfoCircleIcon.vue +30 -0
  87. package/dist/vue/Icons/InfoIcon.vue +30 -0
  88. package/dist/vue/Icons/LinkIcon.vue +30 -0
  89. package/dist/vue/Icons/MenuIcon.vue +30 -0
  90. package/dist/vue/Icons/SearchIcon.vue +30 -0
  91. package/dist/vue/Icons/SettingsIcon.vue +30 -0
  92. package/dist/vue/Icons/UserIcon.vue +30 -0
  93. package/dist/vue/Icons/VueIcon.vue +76 -0
  94. package/dist/vue/Icons/XCircleIcon.vue +30 -0
  95. package/dist/vue/MacWindow/Basic.vue +11 -0
  96. package/dist/vue/MacWindow/CustomHeight.vue +13 -0
  97. package/dist/vue/{MacWindow.vue → MacWindow/MacWindow.vue} +73 -38
  98. package/dist/vue/MacWindow/WithEvents.vue +34 -0
  99. package/dist/vue/MacWindow/WithSidebar.vue +21 -0
  100. package/dist/vue/MacWindow/WithTabs.vue +21 -0
  101. package/dist/vue/MacWindow/WithToolbar.vue +43 -0
  102. package/dist/vue/MacWindow/index.ts +50 -0
  103. package/dist/vue/SmartHero.vue +28 -34
  104. package/dist/vue/VueCounter.vue +29 -0
  105. package/dist/vue/iPhone/Basic.vue +33 -0
  106. package/dist/vue/iPhone/CustomBackground.vue +33 -0
  107. package/dist/vue/iPhone/NoFrame.vue +33 -0
  108. package/dist/vue/iPhone/WeatherApp.vue +97 -0
  109. package/dist/vue/iPhone/assets/iPhone 14 Pro - Deep Purple - Landscape.png +0 -0
  110. package/dist/vue/iPhone/assets/iPhone 14 Pro - Deep Purple - Portrait.png +0 -0
  111. package/dist/vue/iPhone/assets/iPhone 14 Pro - Gold - Landscape.png +0 -0
  112. package/dist/vue/iPhone/assets/iPhone 14 Pro - Gold - Portrait.png +0 -0
  113. package/dist/vue/iPhone/assets/iPhone 14 Pro - Silver - Landscape.png +0 -0
  114. package/dist/vue/iPhone/assets/iPhone 14 Pro - Silver - Portrait.png +0 -0
  115. package/dist/vue/iPhone/assets/iPhone 14 Pro - Space Black - Landscape.png +0 -0
  116. package/dist/vue/iPhone/assets/iPhone 14 Pro - Space Black - Portrait.png +0 -0
  117. package/dist/vue/{iPhoneWindow.vue → iPhone/iPhoneWindow.vue} +14 -7
  118. package/dist/vue/iPhone/index.ts +41 -0
  119. package/dist/vue/shims-vue.d.ts +5 -0
  120. package/package.json +13 -12
  121. package/dist/components/icons/AlertTriangle.astro +0 -35
  122. package/dist/components/icons/CalendarIcon.astro +0 -38
  123. package/dist/components/icons/CheckCircle.astro +0 -36
  124. package/dist/components/icons/CheckIcon.astro +0 -38
  125. package/dist/components/icons/ClipboardIcon.astro +0 -39
  126. package/dist/components/icons/CloseIcon.astro +0 -38
  127. package/dist/components/icons/ErrorIcon.astro +0 -35
  128. package/dist/components/icons/GithubIcon.astro +0 -31
  129. package/dist/components/icons/InfoCircle.astro +0 -37
  130. package/dist/components/icons/InfoIcon.astro +0 -38
  131. package/dist/components/icons/LinkIcon.astro +0 -39
  132. package/dist/components/icons/LinkedinIcon.astro +0 -31
  133. package/dist/components/icons/MenuIcon.astro +0 -38
  134. package/dist/components/icons/SearchIcon.astro +0 -36
  135. package/dist/components/icons/SettingsIcon.astro +0 -36
  136. package/dist/components/icons/SuccessIcon.astro +0 -35
  137. package/dist/components/icons/SunCloudyIcon.astro +0 -41
  138. package/dist/components/icons/TwitterIcon.astro +0 -31
  139. package/dist/components/icons/UserIcon.astro +0 -35
  140. package/dist/components/icons/WarningIcon.astro +0 -38
  141. package/dist/components/icons/XCircle.astro +0 -37
  142. package/dist/entities/Banner.ts +0 -105
  143. package/dist/icons.ts +0 -22
  144. package/dist/vue/BannerBox.vue +0 -267
  145. package/dist/vue/FeatureGroup.vue +0 -22
  146. package/dist/vue/SmartBanner.vue +0 -45
  147. package/dist/vue/WildBanner.vue +0 -15
  148. package/dist/vue.ts +0 -14
  149. /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="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,25 +89,19 @@ 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',
102
+ components: {
103
+ AlertDialog
104
+ },
98
105
  props: {
99
106
  height: {
100
107
  type: String,
@@ -109,44 +116,71 @@ export default defineComponent({
109
116
  default: true
110
117
  },
111
118
  tabs: {
112
- type: Array as () => Tab[],
119
+ type: Array as PropType<string[]>,
113
120
  default: () => []
114
121
  },
115
- modelValue: {
116
- type: String,
117
- 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
118
137
  }
119
138
  },
120
- emits: ['close', 'minimize', 'maximize', 'update:modelValue'],
121
- setup(props, { emit }) {
139
+ setup(props) {
122
140
  const showAlertDialog = ref(false)
123
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
+ }
124
148
 
125
149
  const handleCloseWindow = () => {
126
150
  alertMessage.value = '关闭APP窗口(这是演示,不会真实操作)'
127
151
  showAlertDialog.value = true
128
- emit('close')
152
+ if (props.onCloseWindow) {
153
+ props.onCloseWindow()
154
+ }
129
155
  }
130
156
 
131
157
  const handleMinimizeWindow = () => {
132
158
  alertMessage.value = '最小化窗口(这是演示,不会真实操作)'
133
159
  showAlertDialog.value = true
134
- emit('minimize')
160
+ if (props.onMinimizeWindow) {
161
+ props.onMinimizeWindow()
162
+ }
135
163
  }
136
164
 
137
165
  const handleMaximizeWindow = () => {
138
166
  alertMessage.value = '最大化窗口(这是演示,不会真实操作)'
139
167
  showAlertDialog.value = true
140
- emit('maximize')
168
+ if (props.onMaximizeWindow) {
169
+ props.onMaximizeWindow()
170
+ }
141
171
  }
142
172
 
143
- const handleTabClick = (value: string) => {
144
- emit('update:modelValue', value)
173
+ const handleTabClick = (tab: string) => {
174
+ activeTab.value = tab
175
+ if (props.onTabClick) {
176
+ props.onTabClick(tab)
177
+ }
145
178
  }
146
179
 
147
180
  return {
148
181
  showAlertDialog,
149
182
  alertMessage,
183
+ activeTab,
150
184
  handleCloseWindow,
151
185
  handleMinimizeWindow,
152
186
  handleMaximizeWindow,
@@ -182,11 +216,11 @@ export default defineComponent({
182
216
  <div class="cosy:inline-flex cosy:rounded-lg cosy:bg-base-300 cosy:p-1">
183
217
  <button v-for="(tab, index) in tabs" :key="index" :class="[
184
218
  'cosy:px-3 cosy:py-1 cosy:text-sm cosy:rounded-md cosy:transition-colors',
185
- modelValue === tab.value
219
+ activeTab === tab
186
220
  ? 'cosy:bg-base-100 cosy:text-base-content cosy:shadow'
187
221
  : 'cosy:text-base-content/70 hover:cosy:text-base-content'
188
- ]" @click="handleTabClick(tab.value)">
189
- {{ tab.label }}
222
+ ]" @click="handleTabClick(tab)">
223
+ {{ tab }}
190
224
  </button>
191
225
  </div>
192
226
  </div>
@@ -216,6 +250,7 @@ export default defineComponent({
216
250
  </div>
217
251
  </div>
218
252
  </div>
253
+
219
254
  <!-- AlertDialog 组件 -->
220
255
  <AlertDialog v-model="showAlertDialog" :message="alertMessage" />
221
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>
@@ -0,0 +1,50 @@
1
+ import Basic from './Basic.vue';
2
+ import WithTabs from './WithTabs.vue';
3
+ import WithEvents from './WithEvents.vue';
4
+ import WithToolbar from './WithToolbar.vue';
5
+ import WithSidebar from './WithSidebar.vue';
6
+ import CustomHeight from './CustomHeight.vue';
7
+ import BasicSource from './Basic.vue?raw';
8
+ import WithTabsSource from './WithTabs.vue?raw';
9
+ import WithEventsSource from './WithEvents.vue?raw';
10
+ import WithToolbarSource from './WithToolbar.vue?raw';
11
+ import WithSidebarSource from './WithSidebar.vue?raw';
12
+ import CustomHeightSource from './CustomHeight.vue?raw';
13
+
14
+ // 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
15
+ function extractSimpleExample(source: string): string {
16
+ // 提取模板部分
17
+ const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
18
+ const template = templateMatch ? templateMatch[1].trim() : '';
19
+
20
+ // 创建简化版本的代码
21
+ return `<template>${template}</template>
22
+
23
+ <script setup>
24
+ import { MacWindow } from 'cosy-ui';
25
+ import { SearchIcon, SettingsIcon, InfoIcon } from 'cosy-ui/icons';
26
+ </script>`;
27
+ }
28
+
29
+ // 导出主组件
30
+ export { default as MacWindow } from './MacWindow.vue';
31
+
32
+ // 将示例组件整合为一个对象导出
33
+ export const MacWindowExamples = {
34
+ Basic,
35
+ WithTabs,
36
+ WithEvents,
37
+ WithToolbar,
38
+ WithSidebar,
39
+ CustomHeight,
40
+ };
41
+
42
+ // 导出示例组件的源代码(简化版本)
43
+ export const MacWindowExampleCodes = {
44
+ Basic: extractSimpleExample(BasicSource),
45
+ WithTabs: extractSimpleExample(WithTabsSource),
46
+ WithEvents: extractSimpleExample(WithEventsSource),
47
+ WithToolbar: extractSimpleExample(WithToolbarSource),
48
+ WithSidebar: extractSimpleExample(WithSidebarSource),
49
+ CustomHeight: extractSimpleExample(CustomHeightSource),
50
+ };
@@ -1,45 +1,33 @@
1
1
  <template>
2
- <div
3
- class="py-16 px-8 text-center w-full min-h-screen relative overflow-hidden
4
- "
5
- >
6
- <div class="relative z-10 rounded-lg w-full h-full">
7
- <template v-if="image.src">
8
- <img
9
- :src="image.src"
10
- :alt="image.alt"
11
- class="h-1/2 mx-auto mb-8 drop-shadow-xl"
12
- >
13
- </template>
2
+ <div class="py-16 px-8 text-center w-full min-h-screen relative overflow-hidden
3
+ ">
4
+ <div class="relative z-10 rounded-lg w-full h-full">
5
+ <template v-if="image.src">
6
+ <img :src="image.src" :alt="image.alt" class="h-1/2 mx-auto mb-8 drop-shadow-xl">
7
+ </template>
14
8
 
15
- <h2 class="text-4xl mb-4 animate-fade-up">
16
- {{ title }}
17
- </h2>
18
- <p class="text-lg mb-12 text-center max-w-2xl mx-auto">
19
- {{ description }}
20
- </p>
9
+ <h2 class="text-4xl mb-4 animate-fade-up">
10
+ {{ title }}
11
+ </h2>
12
+ <p class="text-lg mb-12 text-center max-w-2xl mx-auto">
13
+ {{ description }}
14
+ </p>
21
15
 
22
- <div class="my-12 w-full">
23
- <slot name="app" />
24
- </div>
16
+ <div class="my-12 w-full">
17
+ <slot name="app" />
18
+ </div>
25
19
 
26
- <div class="flex flex-row justify-center gap-8 mx-auto w-full">
27
- <a
28
- v-for="link in links"
29
- :key="link.text"
30
- :href="link.href"
31
- target="_blank"
32
- class="px-6 py-3 rounded-lg bg-blue-600 text-white font-medium
20
+ <div class="flex flex-row justify-center gap-8 mx-auto w-full">
21
+ <a v-for="link in links" :key="link.text" :href="link.href" target="_blank" class="px-6 py-3 rounded-lg bg-blue-600 text-white font-medium
33
22
  transition-all duration-300 ease-in-out
34
23
  hover:bg-blue-700 hover:shadow-lg hover:-translate-y-0.5
35
24
  focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
36
- active:bg-blue-800 active:translate-y-0"
37
- >
38
- {{ link.text }}
39
- </a>
40
- </div>
25
+ active:bg-blue-800 active:translate-y-0">
26
+ {{ link.text }}
27
+ </a>
28
+ </div>
29
+ </div>
41
30
  </div>
42
- </div>
43
31
  </template>
44
32
 
45
33
  <script setup lang="ts">
@@ -92,3 +80,9 @@ defineProps({
92
80
  animation: fade-up 0.8s ease-out forwards;
93
81
  }
94
82
  </style>
83
+
84
+ <script lang="ts">
85
+ export default {
86
+ name: 'SmartHero'
87
+ }
88
+ </script>