xto-fronted 0.1.9 → 0.2.0

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
@@ -12,6 +12,104 @@
12
12
  - 🌓 亮色/暗色主题切换
13
13
  - 📱 响应式布局
14
14
 
15
+ ## 安装
16
+
17
+ ```bash
18
+ # npm
19
+ npm install xto-fronted
20
+
21
+ # pnpm
22
+ pnpm add xto-fronted
23
+
24
+ # yarn
25
+ yarn add xto-fronted
26
+ ```
27
+
28
+ ## 快速开始
29
+
30
+ ```typescript
31
+ // main.ts
32
+ import { createApp } from 'vue'
33
+ import { createPinia } from 'pinia'
34
+ import App from './App.vue'
35
+ import router from './router'
36
+
37
+ // 初始化 xto-fronted
38
+ import { createXtoApp } from 'xto-fronted'
39
+
40
+ createXtoApp({
41
+ appName: '我的应用',
42
+ baseUrl: 'https://api.example.com',
43
+ appId: 'MY-APP-ID',
44
+ clientId: 'MY-CLIENT-ID',
45
+ indexPath: '/dashboard',
46
+ loginPath: '/login'
47
+ })
48
+
49
+ // 样式
50
+ import 'xto-fronted/style.css'
51
+ import '@xto/base/es/style.css'
52
+ import '@xto/form/es/style.css'
53
+ import '@xto/feedback/es/style.css'
54
+ import '@xto/navigation/es/style.css'
55
+
56
+ const app = createApp(App)
57
+ app.use(createPinia())
58
+ app.use(router)
59
+ app.mount('#app')
60
+ ```
61
+
62
+ ```typescript
63
+ // router/index.ts
64
+ import { createRouter, createLayoutRoute, Login, NotFound } from 'xto-fronted'
65
+
66
+ const businessRoutes = [
67
+ {
68
+ path: '/dashboard',
69
+ name: 'Dashboard',
70
+ component: () => import('@/views/dashboard/index.vue'),
71
+ meta: { title: '仪表盘', icon: 'dashboard' }
72
+ }
73
+ ]
74
+
75
+ const layoutRoute = createLayoutRoute(businessRoutes, { indexPath: '/dashboard' })
76
+
77
+ const routes = [
78
+ { path: '/login', name: 'Login', component: Login },
79
+ layoutRoute,
80
+ { path: '/:pathMatch(.*)*', redirect: '/404' }
81
+ ]
82
+
83
+ export default createRouter(routes)
84
+ ```
85
+
86
+ ```vue
87
+ <!-- App.vue -->
88
+ <script setup>
89
+ import { useAppStore } from 'xto-fronted'
90
+ const appStore = useAppStore()
91
+ </script>
92
+
93
+ <template>
94
+ <div class="app" :class="{ dark: appStore.isDark }">
95
+ <router-view />
96
+ </div>
97
+ </template>
98
+ ```
99
+
100
+ ## 示例项目
101
+
102
+ 查看 [example](./example) 目录获取完整的示例项目。
103
+
104
+ ```bash
105
+ # 在根目录安装依赖(包含 example)
106
+ pnpm install
107
+
108
+ # 运行示例项目
109
+ cd example
110
+ pnpm dev
111
+ ```
112
+
15
113
  ## 项目结构
16
114
 
17
115
  ```
@@ -1,5 +1,6 @@
1
1
  import { ApiResponse } from '../utils/request';
2
2
  import { LoginResult } from '../types/api';
3
+
3
4
  export interface LoginParams {
4
5
  uid: string;
5
6
  password: string;
@@ -1,3 +1,4 @@
1
1
  import { ApiResponse } from '../utils/request';
2
2
  import { RemoteMenuItem } from '../types/api';
3
+
3
4
  export declare function getUserMenu(): Promise<ApiResponse<RemoteMenuItem[]>>;
@@ -1,5 +1,6 @@
1
1
  import { PageParams, PageResponse } from '../utils/request';
2
2
  import { RoleInfo, MenuItem } from '../types/api';
3
+
3
4
  export declare function getRoleList(params: PageParams & {
4
5
  status?: number;
5
6
  keyword?: string;
@@ -1,3 +1,4 @@
1
1
  import { ApiResponse } from '../utils/request';
2
2
  import { UserInfo } from '../types/api';
3
+
3
4
  export declare function getCurrentUser(): Promise<ApiResponse<UserInfo>>;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,4 +1,15 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
2
- dropdownRef: HTMLDivElement;
3
- }, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
2
+ showCollapse?: boolean;
3
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
4
+ showCollapse?: boolean;
5
+ }>>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
4
6
  export default _default;
7
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
8
+ type __VLS_TypePropsToRuntimeProps<T> = {
9
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
10
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
11
+ } : {
12
+ type: import('vue').PropType<T[K]>;
13
+ required: true;
14
+ };
15
+ };
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
2
  export default _default;
@@ -1,15 +1,25 @@
1
- type __VLS_Props = {
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
2
2
  logo?: string;
3
3
  title?: string;
4
4
  subtitle?: string;
5
- };
6
- declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
7
- error: (error: any) => any;
8
- success: (data: any) => any;
9
- }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
5
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
+ success: (data: any) => void;
7
+ error: (error: any) => void;
8
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
9
+ logo?: string;
10
+ title?: string;
11
+ subtitle?: string;
12
+ }>>> & Readonly<{
10
13
  onError?: ((error: any) => any) | undefined;
11
14
  onSuccess?: ((data: any) => any) | undefined;
12
- }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
13
- formRef: any;
14
- }, HTMLDivElement>;
15
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
15
16
  export default _default;
17
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
18
+ type __VLS_TypePropsToRuntimeProps<T> = {
19
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
20
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
21
+ } : {
22
+ type: import('vue').PropType<T[K]>;
23
+ required: true;
24
+ };
25
+ };
@@ -0,0 +1,19 @@
1
+ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
2
+ visible: boolean;
3
+ }>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
4
+ "update:visible": (val: boolean) => void;
5
+ }, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
6
+ visible: boolean;
7
+ }>>> & Readonly<{
8
+ "onUpdate:visible"?: ((val: boolean) => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
10
+ export default _default;
11
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
12
+ type __VLS_TypePropsToRuntimeProps<T> = {
13
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
14
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
15
+ } : {
16
+ type: import('vue').PropType<T[K]>;
17
+ required: true;
18
+ };
19
+ };
@@ -1,4 +1,5 @@
1
1
  import { UserInfo, LoginResult } from '../types/api';
2
+
2
3
  export declare function useApp(): {
3
4
  loading: import('vue').Ref<boolean, boolean>;
4
5
  isLoggedIn: import('vue').ComputedRef<boolean>;
@@ -1,5 +1,6 @@
1
1
  import { MenuItem } from '../types/api';
2
- export declare function useMenu(iconMap?: Record<string, string>): {
2
+
3
+ export declare function useMenu(): {
3
4
  searchKeyword: import('vue').Ref<string, string>;
4
5
  activeMenu: import('vue').ComputedRef<string>;
5
6
  isCollapsed: import('vue').ComputedRef<boolean>;
@@ -27,7 +28,6 @@ export declare function useMenu(iconMap?: Record<string, string>): {
27
28
  flattenMenus: (menus: MenuItem[], parentTitle?: string) => (MenuItem & {
28
29
  parentTitle: string;
29
30
  })[];
30
- getMenuIcon: (icon?: string) => string;
31
31
  handleMenuSelect: (index: string) => void;
32
32
  handleSearchItemClick: (path: string) => void;
33
33
  clearSearch: () => void;
@@ -1,4 +1,5 @@
1
1
  import { Directive } from 'vue';
2
+
2
3
  declare const permission: Directive;
3
4
  export default permission;
4
5
  export declare function setupPermissionDirective(app: any): void;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { XtoConfig, setConfig, getConfig, getConfigValue } from './config';
2
+
2
3
  export { default as Layout } from './components/Layout/index.vue';
3
4
  export { default as Header } from './components/Layout/Header.vue';
4
5
  export { default as Sidebar } from './components/Layout/Sidebar.vue';
@@ -7,6 +8,7 @@ export { default as Footer } from './components/Layout/Footer.vue';
7
8
  export { default as Login } from './components/Login/index.vue';
8
9
  export { default as NotFound } from './components/Error/404.vue';
9
10
  export { default as Forbidden } from './components/Error/403.vue';
11
+ export { default as SettingDrawer } from './components/SettingDrawer/index.vue';
10
12
  export { useApp } from './composables/useApp';
11
13
  export { useAuth } from './composables/useAuth';
12
14
  export { useMenu } from './composables/useMenu';