jcjy-components 0.0.692 → 0.0.694

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # JCJY Components
2
2
 
3
- Vue 3 组件库,基于 Element Plus Tailwind CSS 构建。
3
+ Vue 3 组件库,基于 Element Plus Tailwind 构建。
4
4
 
5
5
  ## 安装
6
6
 
@@ -16,60 +16,57 @@ yarn add jcjy-components
16
16
 
17
17
  - Vue 3.0+
18
18
  - Element Plus 2.0+
19
- - Tailwind CSS 4.0+ (推荐,用于样式支持)
19
+ - TailwindCSS 3.x(仅支持 TailwindCSS 项目)
20
+
21
+ > 说明:当前版本仅支持已集成 TailwindCSS 的宿主项目;第三方接入时需额外引入 Element Plus 全量样式。
20
22
 
21
23
  ## 使用方法
22
24
 
23
- ### 1. 基本安装
25
+ ### 1. 插件方式(推荐)
24
26
 
25
- ```javascript
27
+ ```ts
26
28
  import { createApp } from 'vue'
29
+ import App from './App.vue'
27
30
  import JcjyComponents from 'jcjy-components'
31
+ import 'element-plus/dist/index.css'
32
+ import 'jcjy-components/style.css'
28
33
 
29
34
  const app = createApp(App)
30
-
31
- // 安装组件库
32
35
  app.use(JcjyComponents)
36
+ app.mount('#app')
33
37
  ```
34
38
 
35
39
  ### 2. 按需导入组件
36
40
 
37
- ```javascript
41
+ ```ts
38
42
  import { AuthGateway } from 'jcjy-components'
43
+ import 'element-plus/dist/index.css'
44
+ import 'jcjy-components/style.css'
39
45
 
40
46
  export default {
41
47
  components: {
42
- AuthGateway
43
- }
48
+ AuthGateway,
49
+ },
44
50
  }
45
51
  ```
46
52
 
47
- ### 3. 样式配置
48
-
49
- **重要**: 本组件库使用 Tailwind CSS,请确保你的项目中已配置 Tailwind CSS。
53
+ ## TypeScript 支持
50
54
 
51
- 在你的 `tailwind.config.js` 中添加组件库路径:
55
+ 本库已内置类型声明,TS 项目可直接获得类型提示。
52
56
 
53
- ```javascript
54
- /** @type {import('tailwindcss').Config} */
55
- export default {
56
- content: [
57
- "./index.html",
58
- "./src/**/*.{vue,js,ts,jsx,tsx}",
59
- // 添加这行以包含组件库的样式
60
- "./node_modules/jcjy-components/**/*.{vue,js,ts,jsx,tsx}",
61
- ],
62
- theme: {
63
- extend: {},
64
- },
65
- plugins: [],
66
- // 禁用 preflight 以避免冲突
67
- corePlugins: {
68
- preflight: false,
69
- },
70
- }
57
+ ```ts
58
+ import type { AuthGatewayConfig } from 'jcjy-components/dist/components/auth-gateway/interface'
71
59
  ```
72
60
 
61
+ ## 样式说明
62
+
63
+ - 请在宿主项目入口显式引入:`import 'jcjy-components/style.css'`
64
+ - 第三方使用时请同时引入 Element Plus 全量样式:`import 'element-plus/dist/index.css'`
65
+ - 仅支持 TailwindCSS 项目接入,宿主项目需已完成 TailwindCSS 配置
66
+ - 组件库默认未打入 Element Plus 全量样式(含 `base.css`),这是为了降低对宿主项目全局样式污染
67
+ - 组件库已关闭 Tailwind 的 `@tailwind base` 与 `@tailwind components`,仅保留 utilities,避免把全局 reset 样式注入到宿主项目
68
+ - 因此宿主项目的原生标签样式(如 `h1`、`p`、`button`)会保持自身样式,不会被组件库覆盖
69
+
73
70
  ## 组件列表
74
71
 
75
72
  ### AuthGateway 认证网关
@@ -79,95 +76,41 @@ export default {
79
76
  ```vue
80
77
  <template>
81
78
  <AuthGateway
82
- mode="default"
83
- @login-success="handleLoginSuccess"
84
- @register-success="handleRegisterSuccess"
79
+ :config="config"
80
+ :binding="binding"
81
+ :login="login"
82
+ :register="register"
83
+ :wechat-config="wechatConfig"
85
84
  />
86
85
  </template>
87
-
88
- <script setup>
89
- const handleLoginSuccess = (userInfo) => {
90
- console.log('登录成功:', userInfo)
91
- }
92
-
93
- const handleRegisterSuccess = (userInfo) => {
94
- console.log('注册成功:', userInfo)
95
- }
96
- </script>
97
86
  ```
98
87
 
99
- #### Props
100
-
101
- | 属性 | 类型 | 默认值 | 说明 |
102
- | --------------- | ------- | --------- | ------------------------------------- |
103
- | mode | string | 'default' | 显示模式:'default', 'center', 'left' |
104
- | showRegister | boolean | true | 是否显示注册入口 |
105
- | showWechatLogin | boolean | true | 是否显示微信登录 |
106
-
107
- #### Events
108
-
109
- | 事件名 | 参数 | 说明 |
110
- | -------------------- | -------- | ------------------ |
111
- | login-success | userInfo | 登录成功时触发 |
112
- | register-success | userInfo | 注册成功时触发 |
113
- | wechat-login-success | userInfo | 微信登录成功时触发 |
114
-
115
88
  ### 主题工具
116
89
 
117
- 组件库提供主题设置工具:
118
-
119
- ```javascript
90
+ ```ts
120
91
  import { theme } from 'jcjy-components'
121
92
 
122
93
  // 设置主题
123
- theme.setTheme('dark')
94
+ await theme.setTheme('#409EFF')
124
95
 
125
- // 根据URL参数设置主题
126
- theme.setThemeByUrl()
96
+ // 根据 URL 参数设置主题
97
+ await theme.setThemeByUrl()
127
98
  ```
128
99
 
129
- ## Element Plus 依赖
130
-
131
- 本组件库基于 Element Plus 构建,使用组件库时需要自行安装和配置 Element Plus:
132
-
133
- ```javascript
134
- import ElementPlus from 'element-plus'
135
- import 'element-plus/dist/index.css'
136
- import * as ElementPlusIconsVue from '@element-plus/icons-vue'
137
-
138
- const app = createApp(App)
139
-
140
- app.use(ElementPlus)
141
-
142
- // 注册所有图标
143
- for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
144
- app.component(key, component)
145
- }
146
- ```
100
+ ## 产物说明
147
101
 
148
- ## 项目结构
102
+ 发布包默认包含以下关键文件:
149
103
 
150
- ```
151
- jcjy-components/
152
- ├── src/
153
- │ ├── components/
154
- │ │ └── auth-gateway/ # 认证网关组件
155
- │ ├── index.ts # 入口文件
156
- │ └── styles.css # 开发时样式(不打包)
157
- ├── dist/ # 构建输出
158
- │ ├── index.es.js # ES 模块
159
- │ ├── index.umd.js # UMD 模块
160
- │ └── index.d.ts # TypeScript 类型声明
161
- ├── tailwind.config.js # Tailwind 配置
162
- └── vite.config.ts # Vite 构建配置
163
- ```
104
+ - `dist/index.es.js`(ESM)
105
+ - `dist/index.umd.cjs`(CJS)
106
+ - `dist/jcjy-components.css`(样式)
107
+ - `dist/index.d.ts`(类型声明)
164
108
 
165
109
  ## 注意事项
166
110
 
167
- 1. **样式依赖**: 组件库不打包 CSS,依赖宿主项目的 Tailwind CSS
168
- 2. **Element Plus**: 需要在宿主项目中单独安装和配置
169
- 3. **TypeScript**: 提供完整的类型声明支持
170
- 4. **响应式设计**: 组件支持移动端和桌面端响应式布局
111
+ 1. 宿主项目需要自行安装 `vue` `element-plus`(peerDependencies)
112
+ 2. 若你在本库中新增了 Element Plus 组件,请同步补齐 `src/styles.css` 中对应的 `theme-chalk` 样式引入
113
+ 3. 若发布到 npm,请使用:`pnpm push:npm`
171
114
 
172
115
  ## 许可证
173
116
 
@@ -0,0 +1,12 @@
1
+ declare function open(): void;
2
+ declare function close(): void;
3
+ declare const __VLS_export: import("vue").DefineComponent<{}, {
4
+ open: typeof open;
5
+ close: typeof close;
6
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
+ confirm: (v: any) => any;
8
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
9
+ onConfirm?: ((v: any) => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { type AuthGatewayProps } from "./interface";
2
+ declare const __VLS_export: import("vue").DefineComponent<AuthGatewayProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ success: (v: any) => any;
4
+ }, string, import("vue").PublicProps, Readonly<AuthGatewayProps> & Readonly<{
5
+ onSuccess?: ((v: any) => any) | undefined;
6
+ }>, {
7
+ strictRegister: boolean;
8
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,50 @@
1
+ export declare const TabKey: {
2
+ readonly LOGIN: 0;
3
+ readonly REGISTER: 1;
4
+ readonly WECHAT: 2;
5
+ readonly WECHAT_SCAN: 3;
6
+ };
7
+ export type TabKey = (typeof TabKey)[keyof typeof TabKey];
8
+ export interface AuthGatewayProps {
9
+ config: AuthGatewayConfig;
10
+ strictRegister?: boolean;
11
+ binding: (v: {
12
+ orgName: string;
13
+ name: string;
14
+ code: string;
15
+ }, headers: {
16
+ token: string;
17
+ }) => Promise<any>;
18
+ register: (params: {
19
+ userName: string;
20
+ passwd: string;
21
+ weChatOpenId?: string;
22
+ }) => Promise<any>;
23
+ login: (params: {
24
+ weChatCode?: string;
25
+ userName?: string;
26
+ passwd?: string;
27
+ weChatOpenId?: string;
28
+ }) => Promise<{
29
+ err: number;
30
+ msg: string;
31
+ weChatUserDetail: any;
32
+ } | any>;
33
+ wechatConfig?: {
34
+ appId: string;
35
+ redirectUrl: string;
36
+ };
37
+ }
38
+ export interface AuthGatewayConfig {
39
+ title?: string;
40
+ favicon?: string;
41
+ loginBackground?: string;
42
+ skipBind?: '0' | '1';
43
+ hf?: '0' | '1';
44
+ nb?: '0' | '1';
45
+ cf?: string;
46
+ from?: 'inline';
47
+ hideWx?: string;
48
+ layout?: 'default' | 'center' | 'left';
49
+ }
50
+ export declare const DEFAULT_CONFIG: AuthGatewayConfig;
@@ -0,0 +1,14 @@
1
+ import { TabKey } from "./interface";
2
+ type __VLS_Props = {
3
+ confirmText?: string;
4
+ hideLoginMethods?: boolean;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
+ toggle: (v: TabKey) => any;
8
+ submit: (v: any) => any;
9
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
10
+ onToggle?: ((v: TabKey) => any) | undefined;
11
+ onSubmit?: ((v: any) => any) | undefined;
12
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
+ declare const _default: typeof __VLS_export;
14
+ export default _default;
@@ -0,0 +1,12 @@
1
+ type __VLS_Props = {
2
+ confirmText?: string;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
5
+ submit: (v: any) => any;
6
+ back: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
8
+ onSubmit?: ((v: any) => any) | undefined;
9
+ onBack?: (() => any) | undefined;
10
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,17 @@
1
+ export declare function transformModel(v: {
2
+ email: string;
3
+ password: string;
4
+ }): {
5
+ userName: string;
6
+ passwd: string | Int32Array<ArrayBufferLike>;
7
+ };
8
+ export declare function setThemeByUrl(src?: string): Promise<void>;
9
+ export declare function setTheme(colors: any[]): void;
10
+ export declare function setTitle(title?: string, favicon?: string): void;
11
+ export declare const passwordValidator: (config?: Partial<{
12
+ minLength: number;
13
+ lowercase: number;
14
+ uppercase: number;
15
+ numbers: number;
16
+ symbols: number;
17
+ }>) => (_rule: any, value: string, callback: any) => any;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ info: any;
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
5
+ back: () => any;
6
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
7
+ onBack?: (() => any) | undefined;
8
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,13 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
2
+ submit: (v: {
3
+ weChatCode: string;
4
+ }) => any;
5
+ back: () => any;
6
+ }, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
7
+ onSubmit?: ((v: {
8
+ weChatCode: string;
9
+ }) => any) | undefined;
10
+ onBack?: (() => any) | undefined;
11
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import type { App } from 'vue';
2
+ import AuthGateway from './components/auth-gateway/index.vue';
3
+ import { setTheme, setThemeByUrl } from './components/auth-gateway/util';
4
+ import './styles.css';
5
+ export declare const theme: {
6
+ setTheme: typeof setTheme;
7
+ setThemeByUrl: typeof setThemeByUrl;
8
+ };
9
+ export { AuthGateway };
10
+ export type { AuthGatewayConfig } from './components/auth-gateway/interface';
11
+ declare const _default: {
12
+ install(app: App): void;
13
+ };
14
+ export default _default;