@opendesign-plus-test/composables 0.0.1-rc.4 → 0.0.1-rc.6

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.
@@ -0,0 +1,12 @@
1
+ import { InjectionKey, MaybeRef, WatchSource } from 'vue';
2
+ type BubbleData = Record<string | symbol, any>;
3
+ type DataSource<T = any> = MaybeRef<BubbleData> | ((val?: T | Event, old?: T) => Promise<BubbleData> | BubbleData);
4
+ type ConfigOptions = {
5
+ key?: InjectionKey<any> | string;
6
+ bubble?: boolean;
7
+ catchBubble?: boolean;
8
+ };
9
+ export declare function useWatchAnalytics<T = any>(watchSource: WatchSource<T>, dataSource: DataSource<T>, options?: ConfigOptions): void;
10
+ export declare function useElementEventAnalytics<T = any>(el: MaybeRef<HTMLElement>, event: string, dataSource: DataSource<T>, options?: ConfigOptions): void;
11
+ export declare function useAnalytics<DS = any>(dataSource: DataSource<DS>, options: ConfigOptions): void;
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import { MaybeRefOrGetter } from 'vue';
2
+ export declare const useCheckbox: <T>(datasource: MaybeRefOrGetter<T[]>, cbValueExtractor: (item: T) => string | number) => {
3
+ checkboxes: import('vue').Ref<(string | number)[], (string | number)[]>;
4
+ indeterminate: import('vue').Ref<boolean, boolean>;
5
+ parentCheckbox: import('vue').Ref<(string | number)[], (string | number)[]>;
6
+ isCheckedAll: import('vue').ComputedRef<boolean>;
7
+ clearCheckboxes: () => void;
8
+ checkAll: () => void;
9
+ };
@@ -0,0 +1,65 @@
1
+ import { Ref } from 'vue';
2
+ /**
3
+ * 登录状态枚举
4
+ */
5
+ export declare enum LOGIN_STATUS {
6
+ FAILED = -1,// 登录失败
7
+ NOT = 0,// 未登录
8
+ DOING = 1,// 登录中
9
+ DONE = 2
10
+ }
11
+ /**
12
+ * 设置 CSRF Token 的 Cookie 键名
13
+ * @param key - Cookie 键名,默认为 '_U_T_'
14
+ */
15
+ export declare const setLoginKeys: (key: string) => void;
16
+ /**
17
+ * 获取当前存储的登录凭证
18
+ * @returns 包含 csrfCookie 的对象
19
+ */
20
+ export declare const getUserAuth: () => {
21
+ csrfCookie: string | undefined;
22
+ };
23
+ /**
24
+ * 清除存储的登录凭证
25
+ */
26
+ export declare const clearUserAuth: () => void;
27
+ /**
28
+ * 跳转到登录页面
29
+ * @param loginUrl - 登录页面的 URL
30
+ */
31
+ export declare const doLogin: (loginUrl: string) => void;
32
+ /**
33
+ * 设置登录状态到 store
34
+ * @param status - 登录状态值
35
+ */
36
+ export declare const setStatus: (status: LOGIN_STATUS) => void;
37
+ /**
38
+ * 尝试自动登录并获取用户信息
39
+ * @param getUserInfo - 获取用户信息的异步函数
40
+ * @param noPrivacy - 是否跳过隐私检查,默认为 false
41
+ * @returns 用户信息或 undefined
42
+ */
43
+ export declare const tryLogin: (getUserInfo: () => Promise<{
44
+ data?: any;
45
+ }>, noPrivacy?: boolean) => Promise<any>;
46
+ /**
47
+ * 执行退出登录操作
48
+ * @param logoutUrl - 退出登录后要跳转的 URL
49
+ */
50
+ export declare const doLogout: (logoutUrl: string) => void;
51
+ /**
52
+ * 监听路由变化,自动处理登录状态
53
+ * @param guardList - 需要登录的路由路径数组
54
+ * @param getUserInfo - 获取用户信息的异步函数
55
+ * @param userInfo - 用户信息的响应式引用
56
+ * @param noPrivacy - 是否跳过隐私检查,默认为 false
57
+ *
58
+ * 行为说明:
59
+ * - 监听立即生效(immediate: true)
60
+ * - 若目标路由在 guardList 中,等待 tryLogin 完成后再进入
61
+ * - 其他路由直接进入,同时在后台执行 tryLogin
62
+ */
63
+ export declare const useLoginWatcher: (guardList: string[], getUserInfo: () => Promise<{
64
+ data?: any;
65
+ }>, userInfo: Ref<any>, route: any, noPrivacy?: boolean) => void;
@@ -2,7 +2,7 @@ import { MarkdownItAsyncOptions } from 'markdown-it-async';
2
2
  import { BundledLanguage, BundledTheme } from 'shiki';
3
3
  export type * from 'markdown-it-async';
4
4
  export type * from 'shiki';
5
- export interface UseMdOptions extends MarkdownItAsyncOptions {
5
+ export interface UseMdOptionsT extends MarkdownItAsyncOptions {
6
6
  anchor?: boolean;
7
7
  anchorType?: 'vitepress' | 'github';
8
8
  copy?: boolean;
@@ -17,7 +17,7 @@ export interface UseMdOptions extends MarkdownItAsyncOptions {
17
17
  * @param options - 配置选项
18
18
  * @returns 返回一个对象可解构出 shiki 实例和 markdown-it 实例
19
19
  */
20
- export declare function useMdRender(options?: UseMdOptions): Promise<{
20
+ export declare function useMdRender(options?: UseMdOptionsT): Promise<{
21
21
  shiki: import('shiki').HighlighterGeneric<BundledLanguage, BundledTheme>;
22
22
  markdwon: import('markdown-it-async').MarkdownItAsync;
23
23
  }>;
@@ -0,0 +1,4 @@
1
+ import { OScroller } from '@opensig/opendesign';
2
+ import { Ref } from 'vue';
3
+ declare const useScrollBottom: (scrollerRef: Ref<InstanceType<typeof OScroller>>, callback: () => void) => void;
4
+ export default useScrollBottom;
@@ -1,19 +1,37 @@
1
+ import { ComputedRef, Plugin } from 'vue';
1
2
  /**
2
- * 初始化主题,建议在 vue 应用初始化前调用
3
- * @param storageKey - 用于存储主题偏好设置的键名
4
- * @param cookieDomain - Cookie 的作用域域名
3
+ * 创建主题配置项
4
+ * @param options - 配置项
5
+ * @param options.cookieKey - cookie 键名
6
+ * @param options.cookieDomain - cookie 域
7
+ * @param options.lightValue - 浅色主题值
8
+ * @param options.darkValue - 深色主题值
9
+ * @param options.attribute - 属性名
10
+ * @param options.attributeLightValue - 浅色主题属性值
11
+ * @param options.attributeDarkValue - 深色主题属性值
12
+ * @param options.classLightValue - 浅色主题类名
13
+ * @param options.classDarkValue - 深色主题类名
14
+ * @returns theme 插件实例
5
15
  */
6
- export declare function initTheme(storageKey: string, cookieDomain: string): void;
16
+ export declare function createTheme<ThemeValue = 'dark | light'>(options?: {
17
+ cookieKey: string;
18
+ cookieDomain: string;
19
+ lightValue?: string;
20
+ darkValue?: string;
21
+ attribute?: string;
22
+ attributeLightValue?: string;
23
+ attributeDarkValue?: string;
24
+ classLightValue?: string;
25
+ classDarkValue?: string;
26
+ }): Plugin;
7
27
  /**
8
28
  * 主题切换组合式函数
9
- * @param storageKey - 用于存储主题偏好设置的键名,若调用过 initTheme 可不传
10
- * @param cookieDomain - Cookie 的作用域域名,若调用过 initTheme 可不传
11
29
  * @returns 包含当前主题状态和操作方法的对象
12
30
  */
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;
31
+ export declare function useTheme<ThemeValue = 'dark | light'>(): {
32
+ theme: ComputedRef<ThemeValue> | undefined;
33
+ isLight: ComputedRef<boolean> | undefined;
34
+ isDark: ComputedRef<boolean> | undefined;
35
+ setTheme: ((val: ThemeValue) => void) | undefined;
36
+ toggleTheme: (() => void) | undefined;
19
37
  };
package/dist/index.d.ts CHANGED
@@ -3,3 +3,5 @@ export * from './core/useScreen';
3
3
  export * from './core/useLocale';
4
4
  export * from './core/useTheme';
5
5
  export * from './core/useClipboard';
6
+ export * from './analytics/useAnalytics';
7
+ export * from './core/useLogin';