@opendesign-plus/composables 0.0.1-rc.5
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/core/useClipboard.d.ts +16 -0
- package/dist/core/useLocale.d.ts +28 -0
- package/dist/core/useMdRender.d.ts +23 -0
- package/dist/core/useScreen.d.ts +44 -0
- package/dist/core/useTheme.d.ts +19 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3058 -0
- package/dist/index.umd.cjs +26 -0
- package/package.json +39 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 复制文本到剪贴板的工具函数
|
|
3
|
+
* 优先使用现代 Clipboard API, 在不支持的环境中自动降级到传统的 document.execCommand 方法。
|
|
4
|
+
*
|
|
5
|
+
* @param text - 需要复制到剪贴板的文本内容
|
|
6
|
+
* @returns Promise<boolean> - 复制操作是否成功
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const success = await useClipboard('Hello World');
|
|
11
|
+
* if (success) {
|
|
12
|
+
* console.log('文本复制成功');
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function useClipboard(text: string): Promise<boolean>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { WritableComputedRef, ComputedRef } from 'vue';
|
|
2
|
+
import { Composer } from 'vue-i18n';
|
|
3
|
+
export type LocaleT = 'zh' | 'en';
|
|
4
|
+
export interface UseLocaleReturn {
|
|
5
|
+
t: Composer['t'];
|
|
6
|
+
$t: Composer['t'];
|
|
7
|
+
locale: WritableComputedRef<string>;
|
|
8
|
+
isZh: ComputedRef<boolean>;
|
|
9
|
+
isEn: ComputedRef<boolean>;
|
|
10
|
+
changeLocale: (lang?: LocaleT) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 国际化语言切换组合式函数
|
|
14
|
+
*
|
|
15
|
+
* @returns 包含语言相关状态和方法的对象
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { t, locale, isZh, isEn, changeLocale } = useLocale(i18n);
|
|
20
|
+
*
|
|
21
|
+
* // 切换语言
|
|
22
|
+
* changeLocale('en');
|
|
23
|
+
*
|
|
24
|
+
* // 监听当前语言
|
|
25
|
+
* console.log(locale.value); // 'zh' or 'en'
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const useLocale: () => UseLocaleReturn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MarkdownItAsyncOptions } from 'markdown-it-async';
|
|
2
|
+
import { BundledLanguage, BundledTheme } from 'shiki';
|
|
3
|
+
export type * from 'markdown-it-async';
|
|
4
|
+
export type * from 'shiki';
|
|
5
|
+
export interface UseMdOptions extends MarkdownItAsyncOptions {
|
|
6
|
+
anchor?: boolean;
|
|
7
|
+
anchorType?: 'vitepress' | 'github';
|
|
8
|
+
copy?: boolean;
|
|
9
|
+
wrapMarkdownBodyDiv?: boolean;
|
|
10
|
+
theme?: {
|
|
11
|
+
light?: BundledTheme;
|
|
12
|
+
dark?: BundledTheme;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 创建 markdown 渲染实例
|
|
17
|
+
* @param options - 配置选项
|
|
18
|
+
* @returns 返回一个对象可解构出 shiki 实例和 markdown-it 实例
|
|
19
|
+
*/
|
|
20
|
+
export declare function useMdRender(options?: UseMdOptions): Promise<{
|
|
21
|
+
shiki: import('shiki').HighlighterGeneric<BundledLanguage, BundledTheme>;
|
|
22
|
+
markdwon: import('markdown-it-async').MarkdownItAsync;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare enum Size {
|
|
2
|
+
Phone = "phone",
|
|
3
|
+
PadV = "pad_v",
|
|
4
|
+
PadH = "pad_h",
|
|
5
|
+
Laptop = "laptop"
|
|
6
|
+
}
|
|
7
|
+
export type ScreenSizeT = typeof Size.Phone | Size.PadV | Size.PadH | Size.Laptop;
|
|
8
|
+
export declare const ScreenConfig: {
|
|
9
|
+
phone: number;
|
|
10
|
+
pad_v: number;
|
|
11
|
+
pad_h: number;
|
|
12
|
+
laptop: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* lt: less than, 小于 <
|
|
16
|
+
* le: less than or equal to, 小于等于 <=
|
|
17
|
+
* eq: equal to, 等于 =
|
|
18
|
+
* ne: never equal to, 不等于 !=
|
|
19
|
+
* ge: greater than or equal to, 大于等于 >=
|
|
20
|
+
* gt: greater than, 大于 >
|
|
21
|
+
*/
|
|
22
|
+
export type CompareT = 'lt' | 'le' | 'eq' | 'ne' | 'ge' | 'gt';
|
|
23
|
+
export declare const useScreen: () => {
|
|
24
|
+
getSize: (width?: number) => Size;
|
|
25
|
+
current: import('vue').Ref<ScreenSizeT, ScreenSizeT>;
|
|
26
|
+
size: {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
isPhone: import('vue').ComputedRef<boolean>;
|
|
31
|
+
gtPhone: import('vue').ComputedRef<boolean>;
|
|
32
|
+
isPad: import('vue').ComputedRef<boolean>;
|
|
33
|
+
lePad: import('vue').ComputedRef<boolean>;
|
|
34
|
+
gtPad: import('vue').ComputedRef<boolean>;
|
|
35
|
+
isPadV: import('vue').ComputedRef<boolean>;
|
|
36
|
+
lePadV: import('vue').ComputedRef<boolean>;
|
|
37
|
+
gtPadV: import('vue').ComputedRef<boolean>;
|
|
38
|
+
isPadH: import('vue').ComputedRef<boolean>;
|
|
39
|
+
isLaptop: import('vue').ComputedRef<boolean>;
|
|
40
|
+
leLaptop: import('vue').ComputedRef<boolean>;
|
|
41
|
+
gtLaptop: import('vue').ComputedRef<boolean>;
|
|
42
|
+
isPadToLaptop: import('vue').ComputedRef<boolean>;
|
|
43
|
+
isPadVToLaptop: import('vue').ComputedRef<boolean>;
|
|
44
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 初始化主题,建议在 vue 应用初始化前调用
|
|
3
|
+
* @param storageKey - 用于存储主题偏好设置的键名
|
|
4
|
+
* @param cookieDomain - Cookie 的作用域域名
|
|
5
|
+
*/
|
|
6
|
+
export declare function initTheme(storageKey: string, cookieDomain: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* 主题切换组合式函数
|
|
9
|
+
* @param storageKey - 用于存储主题偏好设置的键名,若调用过 initTheme 可不传
|
|
10
|
+
* @param cookieDomain - Cookie 的作用域域名,若调用过 initTheme 可不传
|
|
11
|
+
* @returns 包含当前主题状态和操作方法的对象
|
|
12
|
+
*/
|
|
13
|
+
export declare function useTheme(storageKey?: string, cookieDomain?: string): {
|
|
14
|
+
theme: import('vue').ComputedRef<"light" | "dark">;
|
|
15
|
+
isLight: import('vue').ComputedRef<boolean>;
|
|
16
|
+
isDark: import('vue').ComputedRef<boolean>;
|
|
17
|
+
setTheme: (newTheme: "light" | "dark") => void;
|
|
18
|
+
toggleTheme: () => void;
|
|
19
|
+
};
|