@coffic/cosy-ui 0.6.26 → 0.6.30
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/README.md +1 -0
- package/dist/{components/base → alert}/Alert.astro +6 -3
- package/dist/alert/AlertBasic.astro +11 -0
- package/dist/alert/AlertCustomStyle.astro +14 -0
- package/dist/alert/AlertTypes.astro +17 -0
- package/dist/alert/AlertWithTitle.astro +12 -0
- package/dist/alert/index.ts +20 -0
- package/dist/app.css +1 -1
- package/dist/{components/typography → article}/Article.astro +2 -2
- package/dist/article/ArticleBasic.astro +31 -0
- package/dist/article/index.ts +11 -0
- package/dist/{components/base → button}/Button.astro +1 -2
- package/dist/button/ButtonBasic.astro +18 -0
- package/dist/button/ButtonShapes.astro +23 -0
- package/dist/button/ButtonSizes.astro +15 -0
- package/dist/button/ButtonStates.astro +12 -0
- package/dist/button/ButtonWithIcons.astro +25 -0
- package/dist/button/index.ts +23 -0
- package/dist/components/containers/Main.astro +1 -2
- package/dist/components/data-display/ProductCard.astro +2 -1
- package/dist/components/data-display/TeamMember.astro +2 -1
- package/dist/components/data-display/TeamMembers.astro +2 -1
- package/dist/components/display/Hero.astro +1 -1
- package/dist/components/display/Modal.astro +1 -1
- package/dist/{components/errors → errors}/404.astro +1 -1
- package/dist/errors/404Basic.astro +5 -0
- package/dist/errors/index.ts +11 -0
- package/dist/flex/FlexBasic.astro +9 -0
- package/dist/flex/index.ts +11 -0
- package/dist/{components/layouts → footer}/Footer.astro +8 -8
- package/dist/footer/FooterBasic.astro +12 -0
- package/dist/footer/FooterSection.astro +46 -0
- package/dist/footer/index.ts +11 -0
- package/dist/{components/layouts → grid}/Grid.astro +1 -1
- package/dist/grid/GridBasic.astro +9 -0
- package/dist/grid/index.ts +11 -0
- package/dist/{components/layouts → header}/Header.astro +20 -56
- package/dist/header/HeaderBasic.astro +14 -0
- package/dist/header/HeaderCustomNavbarCenter.astro +23 -0
- package/dist/header/HeaderCustomNavbarEnd.astro +20 -0
- package/dist/header/HeaderCustomNavbarStart.astro +20 -0
- package/dist/header/HeaderCustomPosition.astro +23 -0
- package/dist/header/HeaderWithNavigation.astro +22 -0
- package/dist/header/index.ts +26 -0
- package/dist/{components/typography → heading}/Heading.astro +2 -2
- package/dist/heading/HeadingBasic.astro +10 -0
- package/dist/heading/index.ts +11 -0
- package/dist/{components/base → image}/Image.astro +9 -7
- package/dist/image/ImageBasic.astro +1 -0
- package/dist/image/ImageEffects.astro +32 -0
- package/dist/image/ImageLoading.astro +35 -0
- package/dist/image/index.ts +17 -0
- package/dist/index.ts +2 -95
- package/dist/index_astro.ts +78 -0
- package/dist/index_utils.ts +8 -0
- package/dist/{components/navigation → language-switcher}/LanguageSwitcher.astro +3 -3
- package/dist/language-switcher/LanguageSwitcherBasic.astro +7 -0
- package/dist/language-switcher/index.ts +11 -0
- package/dist/{components/layouts → layout-app}/AppLayout.astro +25 -5
- package/dist/layout-app/AppLayoutBasic.astro +53 -0
- package/dist/layout-app/index.ts +11 -0
- package/dist/{components/layouts → layout-basic}/BaseLayout.astro +2 -2
- package/dist/layout-basic/BaseLayoutBasic.astro +16 -0
- package/dist/layout-basic/index.ts +11 -0
- package/dist/{components/layouts → layout-dashboard}/DashboardLayout.astro +2 -2
- package/dist/layout-dashboard/DashboardLayoutBasic.astro +48 -0
- package/dist/layout-dashboard/index.ts +11 -0
- package/dist/{components/base → link}/Link.astro +1 -1
- package/dist/link/LinkAnimations.astro +21 -0
- package/dist/link/LinkBasic.astro +17 -0
- package/dist/link/LinkVariants.astro +20 -0
- package/dist/link/index.ts +17 -0
- package/dist/module/Module.astro +61 -0
- package/dist/module/ModuleBasic.astro +12 -0
- package/dist/module/ModuleCustom.astro +14 -0
- package/dist/module/ModuleGrid.astro +26 -0
- package/dist/module/index.ts +17 -0
- package/dist/{components/layouts → nav-item}/NavItems.astro +2 -3
- package/dist/nav-item/NavItemsBasic.astro +27 -0
- package/dist/nav-item/index.ts +11 -0
- package/dist/nav-section/NavSection.astro +42 -0
- package/dist/nav-section/NavSectionBasic.astro +12 -0
- package/dist/nav-section/index.ts +11 -0
- package/dist/{components/layouts → sidebar}/Sidebar.astro +5 -6
- package/dist/sidebar/SidebarBasic.astro +1 -0
- package/dist/sidebar/index.ts +11 -0
- package/dist/{components/layouts → sidebar-nav}/SidebarNav.astro +3 -3
- package/dist/sidebar-nav/SidebarNavBasic.astro +32 -0
- package/dist/sidebar-nav/index.ts +11 -0
- package/dist/speak/Speak.astro +65 -0
- package/dist/speak/SpeakBasic.astro +13 -0
- package/dist/speak/SpeakGrid.astro +29 -0
- package/dist/speak/index.ts +14 -0
- package/dist/{components/layouts → stack}/Stack.astro +1 -1
- package/dist/stack/StackBasic.astro +15 -0
- package/dist/stack/index.ts +11 -0
- package/dist/{components/typography → text}/Text.astro +1 -1
- package/dist/text/TextBasic.astro +12 -0
- package/dist/text/TextSizes.astro +11 -0
- package/dist/text/index.ts +11 -0
- package/dist/theme-item/ThemeItem.astro +45 -0
- package/dist/theme-item/ThemeItemBasic.astro +10 -0
- package/dist/theme-item/index.ts +11 -0
- package/dist/{components/navigation → theme-switcher}/ThemeSwitcher.astro +4 -4
- package/dist/theme-switcher/ThemeSwitcherBasic.astro +7 -0
- package/dist/theme-switcher/index.ts +11 -0
- package/dist/{components/navigation → toc}/TableOfContents.astro +3 -3
- package/dist/toc/TableOfContentsBasic.astro +25 -0
- package/dist/toc/index.ts +11 -0
- package/dist/types/image.ts +16 -0
- package/dist/types/menu.ts +24 -0
- package/dist/utils/component.ts +39 -0
- package/dist/vue/AlertDialog/index.ts +3 -41
- package/dist/vue/BannerBox/index.ts +9 -44
- package/dist/vue/BlogList/index.ts +5 -27
- package/dist/vue/Buttons/index.ts +5 -27
- package/dist/vue/ConfirmDialog/index.ts +3 -41
- package/dist/vue/MacWindow/index.ts +7 -21
- package/dist/vue/SmartHero/index.ts +4 -26
- package/dist/vue/iPhone/index.ts +5 -18
- package/package.json +7 -7
- package/dist/components/base/Module.astro +0 -18
- package/dist/components/base/Speak.astro +0 -22
- package/dist/components/base/ThemeItem.astro +0 -21
- package/dist/components/layouts/NavSection.astro +0 -32
- /package/dist/{components/layouts → flex}/Flex.astro +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
import Stack from './Stack.astro';
|
2
|
+
import StackBasic from './StackBasic.astro';
|
3
|
+
import BasicSourceCode from './StackBasic.astro?raw';
|
4
|
+
import { extractSimpleExample } from '../utils/component';
|
5
|
+
|
6
|
+
export { Stack, StackBasic };
|
7
|
+
|
8
|
+
// 导出示例源代码
|
9
|
+
export const StackExampleCodes = {
|
10
|
+
Basic: extractSimpleExample(BasicSourceCode, 'Stack'),
|
11
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
---
|
2
|
+
import Text from './Text.astro';
|
3
|
+
---
|
4
|
+
|
5
|
+
<Text>这是一段普通文本</Text>
|
6
|
+
<Text size="xl" color="primary" weight="bold">超大主色粗体文本</Text>
|
7
|
+
<Text size="sm" color="secondary" italic>小号次色斜体文本</Text>
|
8
|
+
<Text size="lg" align="center" underline>居中大号带下划线文本</Text>
|
9
|
+
<Text size="md" weight="light" color="muted">中号柔和色细体文本</Text>
|
10
|
+
<Text truncate style="max-width: 120px; display: block;"
|
11
|
+
>这是一段很长的文本,将会被截断并显示省略号...</Text
|
12
|
+
>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
import Text from './Text.astro';
|
3
|
+
---
|
4
|
+
|
5
|
+
<div class="cosy:space-y-4">
|
6
|
+
<Text size="xs">超小号文本 (xs)</Text>
|
7
|
+
<Text size="sm">小号文本 (sm)</Text>
|
8
|
+
<Text size="md">中号文本 (md)</Text>
|
9
|
+
<Text size="lg">大号文本 (lg)</Text>
|
10
|
+
<Text size="xl">超大号文本 (xl)</Text>
|
11
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import Text from './Text.astro';
|
2
|
+
import TextBasic from './TextBasic.astro';
|
3
|
+
import BasicSourceCode from './TextBasic.astro?raw';
|
4
|
+
import { extractSimpleExample } from '../utils/component';
|
5
|
+
|
6
|
+
export { Text, TextBasic };
|
7
|
+
|
8
|
+
// 导出示例源代码
|
9
|
+
export const TextExampleCodes = {
|
10
|
+
Basic: extractSimpleExample(BasicSourceCode, 'Text'),
|
11
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
/**
|
3
|
+
* @component ThemeItem
|
4
|
+
*
|
5
|
+
* @description
|
6
|
+
* ThemeItem 组件用于主题切换菜单中的单个主题项。
|
7
|
+
* 它基于 Button 组件,提供了主题切换的交互功能。
|
8
|
+
*
|
9
|
+
* @usage
|
10
|
+
* 基本用法:
|
11
|
+
* ```astro
|
12
|
+
* <ThemeItem theme="light" label="浅色主题" />
|
13
|
+
* <ThemeItem theme="dark" label="深色主题" />
|
14
|
+
* ```
|
15
|
+
*/
|
16
|
+
|
17
|
+
import { Button } from '../index';
|
18
|
+
import '../style.ts';
|
19
|
+
|
20
|
+
interface Props {
|
21
|
+
/**
|
22
|
+
* 主题名称
|
23
|
+
*/
|
24
|
+
theme: string;
|
25
|
+
/**
|
26
|
+
* 显示的标签文本
|
27
|
+
*/
|
28
|
+
label: string;
|
29
|
+
/**
|
30
|
+
* 自定义类名
|
31
|
+
*/
|
32
|
+
class?: string;
|
33
|
+
}
|
34
|
+
|
35
|
+
const { theme, label, class: className = '' } = Astro.props;
|
36
|
+
---
|
37
|
+
|
38
|
+
<Button
|
39
|
+
variant="ghost"
|
40
|
+
size="sm"
|
41
|
+
block
|
42
|
+
class={`cosy:text-left cosy:justify-start ${className}`}
|
43
|
+
data-set-theme={theme}>
|
44
|
+
{label}
|
45
|
+
</Button>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
---
|
2
|
+
import ThemeItem from './ThemeItem.astro';
|
3
|
+
---
|
4
|
+
|
5
|
+
<div class="cosy:w-48 cosy:space-y-2">
|
6
|
+
<ThemeItem theme="light" label="浅色主题" />
|
7
|
+
<ThemeItem theme="dark" label="深色主题" />
|
8
|
+
<ThemeItem theme="cupcake" label="糖果主题" />
|
9
|
+
<ThemeItem theme="dracula" label="德古拉主题" />
|
10
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import ThemeItem from './ThemeItem.astro';
|
2
|
+
import ThemeItemBasic from './ThemeItemBasic.astro';
|
3
|
+
import BasicSourceCode from './ThemeItemBasic.astro?raw';
|
4
|
+
import { extractSimpleExample } from '../utils/component';
|
5
|
+
|
6
|
+
export { ThemeItem, ThemeItemBasic };
|
7
|
+
|
8
|
+
// 导出示例源代码
|
9
|
+
export const ThemeItemExampleCodes = {
|
10
|
+
Basic: extractSimpleExample(BasicSourceCode, 'ThemeItem'),
|
11
|
+
};
|
@@ -25,9 +25,9 @@
|
|
25
25
|
* ```
|
26
26
|
*/
|
27
27
|
|
28
|
-
import Button from '../
|
29
|
-
import SunCloudyIcon from '
|
30
|
-
import '
|
28
|
+
import Button from '../button/Button.astro';
|
29
|
+
import SunCloudyIcon from '../icons/SunCloudyIcon.astro';
|
30
|
+
import '../style.ts';
|
31
31
|
|
32
32
|
interface Props {
|
33
33
|
/**
|
@@ -75,7 +75,7 @@ const themes = [
|
|
75
75
|
</div>
|
76
76
|
|
77
77
|
<script>
|
78
|
-
import { createThemeManager } from '
|
78
|
+
import { createThemeManager } from '../utils/theme';
|
79
79
|
|
80
80
|
const themeManager = createThemeManager();
|
81
81
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import ThemeSwitcher from './ThemeSwitcher.astro';
|
2
|
+
import ThemeSwitcherBasic from './ThemeSwitcherBasic.astro';
|
3
|
+
import BasicSourceCode from './ThemeSwitcherBasic.astro?raw';
|
4
|
+
import { extractSimpleExample } from '../utils/component';
|
5
|
+
|
6
|
+
export { ThemeSwitcher, ThemeSwitcherBasic };
|
7
|
+
|
8
|
+
// 导出示例源代码
|
9
|
+
export const ThemeSwitcherExampleCodes = {
|
10
|
+
Basic: extractSimpleExample(BasicSourceCode, 'ThemeSwitcher'),
|
11
|
+
};
|
@@ -53,9 +53,9 @@
|
|
53
53
|
*/
|
54
54
|
|
55
55
|
// 导入样式
|
56
|
-
import '
|
57
|
-
import { createTextGetter } from '
|
58
|
-
import { LanguageUtil } from '
|
56
|
+
import '../style.ts';
|
57
|
+
import { createTextGetter } from '../utils/i18n';
|
58
|
+
import { LanguageUtil } from '../utils/language';
|
59
59
|
|
60
60
|
interface Props {
|
61
61
|
/**
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
import TableOfContents from './TableOfContents.astro';
|
3
|
+
---
|
4
|
+
|
5
|
+
<div class="cosy:flex cosy:gap-4">
|
6
|
+
<div class="cosy:w-64">
|
7
|
+
<TableOfContents />
|
8
|
+
</div>
|
9
|
+
<div class="cosy:flex-1">
|
10
|
+
<h2 id="introduction">介绍</h2>
|
11
|
+
<p>这是一个示例内容。</p>
|
12
|
+
|
13
|
+
<h2 id="features">功能特点</h2>
|
14
|
+
<p>这里列出了主要功能。</p>
|
15
|
+
|
16
|
+
<h3 id="feature-1">功能 1</h3>
|
17
|
+
<p>功能 1 的详细说明。</p>
|
18
|
+
|
19
|
+
<h3 id="feature-2">功能 2</h3>
|
20
|
+
<p>功能 2 的详细说明。</p>
|
21
|
+
|
22
|
+
<h2 id="conclusion">总结</h2>
|
23
|
+
<p>这是总结部分。</p>
|
24
|
+
</div>
|
25
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import TableOfContents from './TableOfContents.astro';
|
2
|
+
import TableOfContentsBasic from './TableOfContentsBasic.astro';
|
3
|
+
import BasicSourceCode from './TableOfContentsBasic.astro?raw';
|
4
|
+
import { extractSimpleExample } from '../utils/component';
|
5
|
+
|
6
|
+
export { TableOfContents, TableOfContentsBasic };
|
7
|
+
|
8
|
+
// 导出示例源代码
|
9
|
+
export const TableOfContentsExampleCodes = {
|
10
|
+
Basic: extractSimpleExample(BasicSourceCode, 'TableOfContents'),
|
11
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* 图片元数据接口
|
3
|
+
* 用于统一管理项目中的图片元数据类型
|
4
|
+
*/
|
5
|
+
export interface ImageMetadata {
|
6
|
+
src: string;
|
7
|
+
width: number;
|
8
|
+
height: number;
|
9
|
+
format: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
/**
|
13
|
+
* 图片源类型
|
14
|
+
* 可以是 ImageMetadata 对象或字符串 URL
|
15
|
+
*/
|
16
|
+
export type ImageSource = ImageMetadata | string;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// 提取简单示例源代码函数
|
2
|
+
export function extractSimpleExample(source: string, name: string): string {
|
3
|
+
// 提取模板部分
|
4
|
+
const templateMatch = source.match(/<template>([\s\S]*)<\/template>/m);
|
5
|
+
const scriptMatch = source.match(/<script[\s\S]*?>([\s\S]*)<\/script>/m);
|
6
|
+
|
7
|
+
if (!templateMatch) {
|
8
|
+
return source;
|
9
|
+
}
|
10
|
+
|
11
|
+
let importSection = `<script setup lang="ts">
|
12
|
+
import { ref } from 'vue'
|
13
|
+
import { ${name} } from '@cosy/index_vue'
|
14
|
+
`;
|
15
|
+
|
16
|
+
// 从源码中提取导入语句(除了组件的导入和app.css)
|
17
|
+
if (scriptMatch && scriptMatch[1]) {
|
18
|
+
const importLines = scriptMatch[1]
|
19
|
+
.split('\n')
|
20
|
+
.filter(
|
21
|
+
(line) => line.includes('import') && !line.includes('../../app.css') && !line.includes(name)
|
22
|
+
);
|
23
|
+
|
24
|
+
if (importLines.length > 0) {
|
25
|
+
importSection += importLines.join('\n') + '\n';
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
importSection += '</script>\n\n';
|
30
|
+
|
31
|
+
// 提取模板内容,并替换组件路径
|
32
|
+
const templateContent = templateMatch[1]
|
33
|
+
.replace(`./${name}.vue`, name)
|
34
|
+
.replace(`../${name}.vue`, name)
|
35
|
+
.replace(`./${name}.astro`, name)
|
36
|
+
.replace(`../${name}.astro`, name);
|
37
|
+
|
38
|
+
return importSection + '<template>' + templateContent + '</template>';
|
39
|
+
}
|
@@ -2,45 +2,7 @@ import Basic from './Basic.vue';
|
|
2
2
|
import Multilang from './Multilang.vue';
|
3
3
|
import BasicSource from './Basic.vue?raw';
|
4
4
|
import MultilangSource from './Multilang.vue?raw';
|
5
|
-
|
6
|
-
// 提取简单示例源代码函数
|
7
|
-
function extractSimpleExample(source: string): string {
|
8
|
-
// 提取模板部分
|
9
|
-
const templateMatch = source.match(/<template>([\s\S]*)<\/template>/m);
|
10
|
-
const scriptMatch = source.match(/<script[\s\S]*?>([\s\S]*)<\/script>/m);
|
11
|
-
|
12
|
-
if (!templateMatch) {
|
13
|
-
return source;
|
14
|
-
}
|
15
|
-
|
16
|
-
let importSection = `<script setup lang="ts">
|
17
|
-
import { ref } from 'vue'
|
18
|
-
import { AlertDialog } from '@cosy/index_vue'
|
19
|
-
`;
|
20
|
-
|
21
|
-
// 从源码中提取导入语句(除了组件的导入和app.css)
|
22
|
-
if (scriptMatch && scriptMatch[1]) {
|
23
|
-
const importLines = scriptMatch[1]
|
24
|
-
.split('\n')
|
25
|
-
.filter(
|
26
|
-
(line) =>
|
27
|
-
line.includes('import') &&
|
28
|
-
!line.includes('../../app.css') &&
|
29
|
-
!line.includes('AlertDialog')
|
30
|
-
);
|
31
|
-
|
32
|
-
if (importLines.length > 0) {
|
33
|
-
importSection += importLines.join('\n') + '\n';
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
importSection += '</script>\n\n';
|
38
|
-
|
39
|
-
// 提取模板内容,并替换组件路径
|
40
|
-
const templateContent = templateMatch[1].replace('../AlertDialog.vue', 'AlertDialog');
|
41
|
-
|
42
|
-
return importSection + '<template>' + templateContent + '</template>';
|
43
|
-
}
|
5
|
+
import { extractSimpleExample } from '../../utils/component';
|
44
6
|
|
45
7
|
// 导出主组件
|
46
8
|
export { default as AlertDialog } from './AlertDialog.vue';
|
@@ -53,6 +15,6 @@ export const AlertDialogExamples = {
|
|
53
15
|
|
54
16
|
// 导出示例源代码
|
55
17
|
export const AlertDialogExampleCodes = {
|
56
|
-
Basic: extractSimpleExample(BasicSource),
|
57
|
-
Multilang: extractSimpleExample(MultilangSource),
|
18
|
+
Basic: extractSimpleExample(BasicSource, 'Basic'),
|
19
|
+
Multilang: extractSimpleExample(MultilangSource, 'Multilang'),
|
58
20
|
};
|
@@ -14,42 +14,7 @@ import DisplayModeNeverSource from './ExampleDisplayModeNever.vue?raw';
|
|
14
14
|
import SmartBannerSource from './SmartBanner.vue?raw';
|
15
15
|
import SizePresetSource from './ExampleSizePreset.vue?raw';
|
16
16
|
import ImageExportSource from './ExampleImageExport.vue?raw';
|
17
|
-
|
18
|
-
// 提取简单示例源代码函数
|
19
|
-
function extractSimpleExample(source: string): string {
|
20
|
-
// 提取模板部分
|
21
|
-
const templateMatch = source.match(/<template>([\s\S]*)<\/template>/m);
|
22
|
-
const scriptMatch = source.match(/<script[\s\S]*?>([\s\S]*)<\/script>/m);
|
23
|
-
|
24
|
-
if (!templateMatch) {
|
25
|
-
return source;
|
26
|
-
}
|
27
|
-
|
28
|
-
let importSection = `<script setup>
|
29
|
-
import { BannerBox } from 'cosy-ui'
|
30
|
-
`;
|
31
|
-
|
32
|
-
// 从源码中提取导入语句(除了组件的导入和app.css)
|
33
|
-
if (scriptMatch && scriptMatch[1]) {
|
34
|
-
const importLines = scriptMatch[1]
|
35
|
-
.split('\n')
|
36
|
-
.filter(
|
37
|
-
(line) =>
|
38
|
-
line.includes('import') && !line.includes('../../app.css') && !line.includes('BannerBox')
|
39
|
-
);
|
40
|
-
|
41
|
-
if (importLines.length > 0) {
|
42
|
-
importSection += importLines.join('\n') + '\n';
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
importSection += '</script>\n\n';
|
47
|
-
|
48
|
-
// 提取模板内容,并替换组件路径
|
49
|
-
const templateContent = templateMatch[1].replace('../BannerBox.vue', 'BannerBox');
|
50
|
-
|
51
|
-
return importSection + '<template>' + templateContent + '</template>';
|
52
|
-
}
|
17
|
+
import { extractSimpleExample } from '../../utils/component';
|
53
18
|
|
54
19
|
// 获取 BannerBox 和 FeatureCard 组件
|
55
20
|
export { default as BannerBox } from './BannerBox.vue';
|
@@ -72,12 +37,12 @@ export const BannerBoxExamples = {
|
|
72
37
|
|
73
38
|
// 导出示例源代码
|
74
39
|
export const BannerBoxExampleCodes = {
|
75
|
-
Basic: extractSimpleExample(BasicSource),
|
76
|
-
CustomBg: extractSimpleExample(CustomBgSource),
|
77
|
-
DisplayModeAlways: extractSimpleExample(DisplayModeAlwaysSource),
|
78
|
-
DisplayModeHover: extractSimpleExample(DisplayModeHoverSource),
|
79
|
-
DisplayModeNever: extractSimpleExample(DisplayModeNeverSource),
|
80
|
-
SmartBanner: extractSimpleExample(SmartBannerSource),
|
81
|
-
SizePreset: extractSimpleExample(SizePresetSource),
|
82
|
-
ImageExport: extractSimpleExample(ImageExportSource),
|
40
|
+
Basic: extractSimpleExample(BasicSource, 'BannerBox'),
|
41
|
+
CustomBg: extractSimpleExample(CustomBgSource, 'BannerBox'),
|
42
|
+
DisplayModeAlways: extractSimpleExample(DisplayModeAlwaysSource, 'BannerBox'),
|
43
|
+
DisplayModeHover: extractSimpleExample(DisplayModeHoverSource, 'BannerBox'),
|
44
|
+
DisplayModeNever: extractSimpleExample(DisplayModeNeverSource, 'BannerBox'),
|
45
|
+
SmartBanner: extractSimpleExample(SmartBannerSource, 'BannerBox'),
|
46
|
+
SizePreset: extractSimpleExample(SizePresetSource, 'BannerBox'),
|
47
|
+
ImageExport: extractSimpleExample(ImageExportSource, 'BannerBox'),
|
83
48
|
};
|
@@ -6,29 +6,7 @@ import BasicSource from './Basic.vue?raw';
|
|
6
6
|
import EmptySource from './Empty.vue?raw';
|
7
7
|
import EnglishSource from './English.vue?raw';
|
8
8
|
import EmptyEnglishSource from './EmptyEnglish.vue?raw';
|
9
|
-
|
10
|
-
// 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
|
11
|
-
function extractSimpleExample(source: string): string {
|
12
|
-
// 提取模板部分
|
13
|
-
const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
|
14
|
-
const template = templateMatch ? templateMatch[1].trim() : '';
|
15
|
-
|
16
|
-
// 提取script setup部分(去除import部分)
|
17
|
-
const scriptMatch = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/);
|
18
|
-
let script = '';
|
19
|
-
if (scriptMatch) {
|
20
|
-
// 只保留相关变量定义,去除导入语句
|
21
|
-
script = scriptMatch[1]
|
22
|
-
.replace(/import [^;]+;/g, '')
|
23
|
-
.replace(/import BlogList from '[^']+';/g, "import { BlogList } from 'cosy-ui';")
|
24
|
-
.trim();
|
25
|
-
}
|
26
|
-
|
27
|
-
// 创建简化版本的代码
|
28
|
-
return `<template>${template}</template>
|
29
|
-
|
30
|
-
<script setup lang="ts">${script}</script>`;
|
31
|
-
}
|
9
|
+
import { extractSimpleExample } from '../../utils/component';
|
32
10
|
|
33
11
|
// 导出主组件
|
34
12
|
export { default as BlogList } from './BlogList.vue';
|
@@ -44,8 +22,8 @@ export const BlogListExamples = {
|
|
44
22
|
|
45
23
|
// 导出示例组件的源代码(简化版本)
|
46
24
|
export const BlogListExampleCodes = {
|
47
|
-
Basic: extractSimpleExample(BasicSource),
|
48
|
-
Empty: extractSimpleExample(EmptySource),
|
49
|
-
English: extractSimpleExample(EnglishSource),
|
50
|
-
EmptyEnglish: extractSimpleExample(EmptyEnglishSource),
|
25
|
+
Basic: extractSimpleExample(BasicSource, 'BlogList'),
|
26
|
+
Empty: extractSimpleExample(EmptySource, 'BlogList'),
|
27
|
+
English: extractSimpleExample(EnglishSource, 'BlogList'),
|
28
|
+
EmptyEnglish: extractSimpleExample(EmptyEnglishSource, 'BlogList'),
|
51
29
|
};
|
@@ -6,29 +6,7 @@ import FeatureBasicSource from './FeatureBasic.vue?raw';
|
|
6
6
|
import FeatureWithTipsSource from './FeatureWithTips.vue?raw';
|
7
7
|
import MultipleSource from './Multiple.vue?raw';
|
8
8
|
import LinkBasicSource from './LinkBasic.vue?raw';
|
9
|
-
|
10
|
-
// 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
|
11
|
-
function extractSimpleExample(source: string): string {
|
12
|
-
// 提取模板部分
|
13
|
-
const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
|
14
|
-
const template = templateMatch ? templateMatch[1].trim() : '';
|
15
|
-
|
16
|
-
// 提取script setup部分(去除import部分)
|
17
|
-
const scriptMatch = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/);
|
18
|
-
let script = '';
|
19
|
-
if (scriptMatch) {
|
20
|
-
// 只保留相关变量定义,去除导入语句
|
21
|
-
script = scriptMatch[1]
|
22
|
-
.replace(/import [^;]+;/g, '')
|
23
|
-
.replace(/import (FeatureButton|LinkButton) from '[^']+';/g, "import { $1 } from 'cosy-ui';")
|
24
|
-
.trim();
|
25
|
-
}
|
26
|
-
|
27
|
-
// 创建简化版本的代码
|
28
|
-
return `<template>${template}</template>
|
29
|
-
|
30
|
-
<script setup lang="ts">${script}</script>`;
|
31
|
-
}
|
9
|
+
import { extractSimpleExample } from '../../utils/component';
|
32
10
|
|
33
11
|
// 导出组件
|
34
12
|
export { default as FeatureButton } from './FeatureButton.vue';
|
@@ -49,11 +27,11 @@ export const ButtonsExamples = {
|
|
49
27
|
// 导出示例组件的源代码(简化版本)
|
50
28
|
export const ButtonsExampleCodes = {
|
51
29
|
FeatureButton: {
|
52
|
-
Basic: extractSimpleExample(FeatureBasicSource),
|
53
|
-
WithTips: extractSimpleExample(FeatureWithTipsSource),
|
30
|
+
Basic: extractSimpleExample(FeatureBasicSource, 'Button'),
|
31
|
+
WithTips: extractSimpleExample(FeatureWithTipsSource, 'Button'),
|
54
32
|
},
|
55
33
|
LinkButton: {
|
56
|
-
Basic: extractSimpleExample(LinkBasicSource),
|
57
|
-
Multiple: extractSimpleExample(MultipleSource),
|
34
|
+
Basic: extractSimpleExample(LinkBasicSource, 'Button'),
|
35
|
+
Multiple: extractSimpleExample(MultipleSource, 'Button'),
|
58
36
|
},
|
59
37
|
};
|
@@ -2,45 +2,7 @@ import Basic from './Basic.vue';
|
|
2
2
|
import CustomButtons from './CustomButtons.vue';
|
3
3
|
import BasicSource from './Basic.vue?raw';
|
4
4
|
import CustomButtonsSource from './CustomButtons.vue?raw';
|
5
|
-
|
6
|
-
// 提取简单示例源代码函数
|
7
|
-
function extractSimpleExample(source: string): string {
|
8
|
-
// 提取模板部分
|
9
|
-
const templateMatch = source.match(/<template>([\s\S]*)<\/template>/m);
|
10
|
-
const scriptMatch = source.match(/<script[\s\S]*?>([\s\S]*)<\/script>/m);
|
11
|
-
|
12
|
-
if (!templateMatch) {
|
13
|
-
return source;
|
14
|
-
}
|
15
|
-
|
16
|
-
let importSection = `<script setup lang="ts">
|
17
|
-
import { ref } from 'vue'
|
18
|
-
import { ConfirmDialog } from '@cosy/index_vue'
|
19
|
-
`;
|
20
|
-
|
21
|
-
// 从源码中提取导入语句(除了组件的导入和app.css)
|
22
|
-
if (scriptMatch && scriptMatch[1]) {
|
23
|
-
const importLines = scriptMatch[1]
|
24
|
-
.split('\n')
|
25
|
-
.filter(
|
26
|
-
(line) =>
|
27
|
-
line.includes('import') &&
|
28
|
-
!line.includes('../../app.css') &&
|
29
|
-
!line.includes('ConfirmDialog')
|
30
|
-
);
|
31
|
-
|
32
|
-
if (importLines.length > 0) {
|
33
|
-
importSection += importLines.join('\n') + '\n';
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
importSection += '</script>\n\n';
|
38
|
-
|
39
|
-
// 提取模板内容,并替换组件路径
|
40
|
-
const templateContent = templateMatch[1].replace('../ConfirmDialog.vue', 'ConfirmDialog');
|
41
|
-
|
42
|
-
return importSection + '<template>' + templateContent + '</template>';
|
43
|
-
}
|
5
|
+
import { extractSimpleExample } from '../../utils/component';
|
44
6
|
|
45
7
|
// 导出主组件
|
46
8
|
export { default as ConfirmDialog } from './ConfirmDialog.vue';
|
@@ -53,6 +15,6 @@ export const ConfirmDialogExamples = {
|
|
53
15
|
|
54
16
|
// 导出示例源代码
|
55
17
|
export const ConfirmDialogExampleCodes = {
|
56
|
-
Basic: extractSimpleExample(BasicSource),
|
57
|
-
CustomButtons: extractSimpleExample(CustomButtonsSource),
|
18
|
+
Basic: extractSimpleExample(BasicSource, 'ConfirmDialog'),
|
19
|
+
CustomButtons: extractSimpleExample(CustomButtonsSource, 'ConfirmDialog'),
|
58
20
|
};
|
@@ -10,21 +10,7 @@ import WithEventsSource from './WithEvents.vue?raw';
|
|
10
10
|
import WithToolbarSource from './WithToolbar.vue?raw';
|
11
11
|
import WithSidebarSource from './WithSidebar.vue?raw';
|
12
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
|
-
}
|
13
|
+
import { extractSimpleExample } from '../../utils/component';
|
28
14
|
|
29
15
|
// 导出主组件
|
30
16
|
export { default as MacWindow } from './MacWindow.vue';
|
@@ -41,10 +27,10 @@ export const MacWindowExamples = {
|
|
41
27
|
|
42
28
|
// 导出示例组件的源代码(简化版本)
|
43
29
|
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),
|
30
|
+
Basic: extractSimpleExample(BasicSource, 'MacWindow'),
|
31
|
+
WithTabs: extractSimpleExample(WithTabsSource, 'MacWindow'),
|
32
|
+
WithEvents: extractSimpleExample(WithEventsSource, 'MacWindow'),
|
33
|
+
WithToolbar: extractSimpleExample(WithToolbarSource, 'MacWindow'),
|
34
|
+
WithSidebar: extractSimpleExample(WithSidebarSource, 'MacWindow'),
|
35
|
+
CustomHeight: extractSimpleExample(CustomHeightSource, 'MacWindow'),
|
50
36
|
};
|
@@ -4,29 +4,7 @@ import WithCustomContent from './WithCustomContent.vue';
|
|
4
4
|
import BasicSource from './Basic.vue?raw';
|
5
5
|
import WithImageSource from './WithImage.vue?raw';
|
6
6
|
import WithCustomContentSource from './WithCustomContent.vue?raw';
|
7
|
-
|
8
|
-
// 转换Vue SFC组件为简化的示例代码(只保留template和setup script)
|
9
|
-
function extractSimpleExample(source: string): string {
|
10
|
-
// 提取模板部分
|
11
|
-
const templateMatch = source.match(/<template>([\s\S]*?)<\/template>/);
|
12
|
-
const template = templateMatch ? templateMatch[1].trim() : '';
|
13
|
-
|
14
|
-
// 提取script setup部分(去除import部分)
|
15
|
-
const scriptMatch = source.match(/<script setup lang="ts">([\s\S]*?)<\/script>/);
|
16
|
-
let script = '';
|
17
|
-
if (scriptMatch) {
|
18
|
-
// 只保留相关变量定义,去除导入语句
|
19
|
-
script = scriptMatch[1]
|
20
|
-
.replace(/import [^;]+;/g, '')
|
21
|
-
.replace(/import SmartHero from '[^']+';/g, "import { SmartHero } from 'cosy-ui';")
|
22
|
-
.trim();
|
23
|
-
}
|
24
|
-
|
25
|
-
// 创建简化版本的代码
|
26
|
-
return `<template>${template}</template>
|
27
|
-
|
28
|
-
<script setup lang="ts">${script}</script>`;
|
29
|
-
}
|
7
|
+
import { extractSimpleExample } from '../../utils/component';
|
30
8
|
|
31
9
|
// 导出主组件
|
32
10
|
export { default as SmartHero } from './SmartHero.vue';
|
@@ -40,7 +18,7 @@ export const SmartHeroExamples = {
|
|
40
18
|
|
41
19
|
// 导出示例组件的源代码(简化版本)
|
42
20
|
export const SmartHeroExampleCodes = {
|
43
|
-
Basic: extractSimpleExample(BasicSource),
|
44
|
-
WithImage: extractSimpleExample(WithImageSource),
|
45
|
-
WithCustomContent: extractSimpleExample(WithCustomContentSource),
|
21
|
+
Basic: extractSimpleExample(BasicSource, 'SmartHero'),
|
22
|
+
WithImage: extractSimpleExample(WithImageSource, 'SmartHero'),
|
23
|
+
WithCustomContent: extractSimpleExample(WithCustomContentSource, 'SmartHero'),
|
46
24
|
};
|