kn-cli 1.0.90 → 1.0.91

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.
Files changed (149) hide show
  1. package/package.json +1 -1
  2. package/readme.md +4 -0
  3. package/src/create.js +22 -2
  4. package/src/utils/index.js +1 -1
  5. package/templates/template_admin/cli.config.js +1 -1
  6. package/templates/template_admin/jsconfig.json +5 -1
  7. package/templates/template_admin/package.json +1 -1
  8. package/templates/template_admin/public/index.html +2 -2
  9. package/templates/template_admin/public/src/components/{Auth → auth}/index.jsx +21 -3
  10. package/templates/template_admin/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
  11. package/templates/template_admin/public/src/components/{Layout/Basic → layout/basic}/index.jsx +13 -3
  12. package/templates/template_admin/public/src/components/layout/centerBody/index.jsx +25 -0
  13. package/templates/template_admin/public/src/components/{Layout → layout}/index.jsx +15 -6
  14. package/templates/{template_offcial/public/src/components/Layout/Provider → template_admin/public/src/components/layout/provider}/index.jsx +8 -1
  15. package/templates/{template_app/public/src/components/Link → template_admin/public/src/components/link}/index.jsx +15 -0
  16. package/templates/template_admin/public/src/components/{Menu → menu}/index.jsx +15 -8
  17. package/templates/template_admin/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +25 -4
  18. package/templates/template_admin/public/src/components/{Popup → popup}/index.jsx +13 -0
  19. package/templates/{template_app/public/src/components/Toast → template_admin/public/src/components/toast}/index.jsx +20 -1
  20. package/templates/template_admin/public/src/components/{TopMenu → topMenu}/index.jsx +13 -8
  21. package/templates/template_admin/public/src/dictionary/index.js +8 -3
  22. package/templates/template_admin/public/src/hooks/index.jsx +1 -0
  23. package/templates/template_admin/public/src/hooks/useDelay.jsx +5 -0
  24. package/templates/template_admin/public/src/hooks/useImageLoader.jsx +1 -2
  25. package/templates/template_admin/public/src/hooks/useLoading.jsx +5 -1
  26. package/templates/template_admin/public/src/hooks/usePreload.jsx +2 -1
  27. package/templates/template_admin/public/src/hooks/useScrollTop.jsx +12 -0
  28. package/templates/template_admin/public/src/hooks/useSearch.jsx +28 -2
  29. package/templates/template_admin/public/src/hooks/useUpdate.jsx +5 -0
  30. package/templates/template_admin/public/src/index.jsx +16 -2
  31. package/templates/template_admin/public/src/pages/material/index.jsx +2 -1
  32. package/templates/template_admin/public/src/pages/user/index.jsx +7 -2
  33. package/templates/template_admin/public/src/provider/app.jsx +39 -4
  34. package/templates/template_admin/public/src/provider/menu.jsx +4 -1
  35. package/templates/template_admin/public/src/route.jsx +8 -5
  36. package/templates/template_admin/public/src/services/index.js +38 -4
  37. package/templates/template_admin/public/src/services/user.js +3 -3
  38. package/templates/template_admin/public/src/type.js +48 -0
  39. package/templates/template_admin/public/src/utils/index.js +34 -18
  40. package/templates/template_app/cli.config.js +1 -1
  41. package/templates/template_app/jsconfig.json +5 -1
  42. package/templates/template_app/package.json +1 -1
  43. package/templates/template_app/public/src/components/{Auth → auth}/index.jsx +20 -2
  44. package/templates/template_app/public/src/components/{Header → header}/index.jsx +25 -1
  45. package/templates/template_app/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
  46. package/templates/template_app/public/src/components/{Layout/App → layout/app}/index.jsx +12 -2
  47. package/templates/template_app/public/src/components/layout/index.jsx +6 -0
  48. package/templates/{template_admin/public/src/components/Layout/Provider → template_app/public/src/components/layout/provider}/index.jsx +3 -0
  49. package/templates/template_app/public/src/components/link/index.jsx +39 -0
  50. package/templates/template_app/public/src/components/{Marquee → marquee}/index.jsx +11 -2
  51. package/templates/template_app/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +23 -3
  52. package/templates/template_app/public/src/components/{Popup → popup}/index.jsx +13 -0
  53. package/templates/{template_offcial/public/src/components/Toast → template_app/public/src/components/toast}/index.jsx +21 -1
  54. package/templates/template_app/public/src/dictionary/index.js +7 -3
  55. package/templates/template_app/public/src/hooks/index.jsx +1 -0
  56. package/templates/template_app/public/src/hooks/useDelay.jsx +5 -0
  57. package/templates/template_app/public/src/hooks/useImageLoader.jsx +1 -2
  58. package/templates/template_app/public/src/hooks/useLoading.jsx +5 -1
  59. package/templates/template_app/public/src/hooks/usePreload.jsx +2 -1
  60. package/templates/template_app/public/src/hooks/useScrollTop.jsx +12 -0
  61. package/templates/template_app/public/src/index.jsx +22 -5
  62. package/templates/template_app/public/src/pages/dictionary/index.jsx +9 -1
  63. package/templates/template_app/public/src/pages/index.jsx +16 -4
  64. package/templates/template_app/public/src/pages/list/index.jsx +7 -1
  65. package/templates/template_app/public/src/pages/login/index.jsx +10 -4
  66. package/templates/template_app/public/src/pages/user/index.jsx +7 -2
  67. package/templates/template_app/public/src/provider/app.jsx +5 -3
  68. package/templates/template_app/public/src/route.jsx +5 -2
  69. package/templates/template_app/public/src/services/index.js +10 -8
  70. package/templates/template_app/public/src/services/user.js +4 -4
  71. package/templates/template_app/public/src/type.js +27 -0
  72. package/templates/template_app/public/src/utils/index.js +6 -0
  73. package/templates/template_oa/cli.config.js +1 -1
  74. package/templates/template_oa/package.json +1 -1
  75. package/templates/template_oa_jwt/cli.config.js +1 -1
  76. package/templates/template_oa_jwt/package.json +1 -1
  77. package/templates/template_offcial/cli.config.js +1 -1
  78. package/templates/template_offcial/jsconfig.json +5 -1
  79. package/templates/template_offcial/package.json +1 -1
  80. package/templates/template_offcial/public/src/components/{Footer → footer}/index.jsx +15 -1
  81. package/templates/template_offcial/public/src/components/{Header → header}/index.jsx +14 -0
  82. package/templates/template_offcial/public/src/components/{IconFont → iconFont}/index.jsx +10 -0
  83. package/templates/template_offcial/public/src/components/{Layout → layout}/index.jsx +10 -3
  84. package/templates/{template_app/public/src/components/Layout/Provider → template_offcial/public/src/components/layout/provider}/index.jsx +7 -0
  85. package/templates/template_offcial/public/src/components/link/index.jsx +39 -0
  86. package/templates/template_offcial/public/src/components/{Page/PageLoading → page/pageLoading}/index.jsx +25 -4
  87. package/templates/template_offcial/public/src/components/{Popup → popup}/index.jsx +13 -0
  88. package/templates/{template_admin/public/src/components/Toast → template_offcial/public/src/components/toast}/index.jsx +20 -1
  89. package/templates/template_offcial/public/src/hooks/index.jsx +1 -0
  90. package/templates/template_offcial/public/src/hooks/useImageLoader.jsx +1 -0
  91. package/templates/template_offcial/public/src/hooks/useInToView.jsx +3 -0
  92. package/templates/template_offcial/public/src/hooks/usePreload.jsx +1 -0
  93. package/templates/template_offcial/public/src/hooks/useScroll.jsx +8 -0
  94. package/templates/template_offcial/public/src/index.jsx +15 -2
  95. package/templates/template_offcial/public/src/pages/index.jsx +8 -1
  96. package/templates/template_offcial/public/src/pages/pc/index.jsx +4 -2
  97. package/templates/template_offcial/public/src/provider/app.jsx +28 -2
  98. package/templates/template_offcial/public/src/route.jsx +4 -2
  99. package/templates/template_offcial/public/src/services/index.js +38 -2
  100. package/templates/template_offcial/public/src/services/user.js +3 -3
  101. package/templates/template_offcial/public/src/type.js +47 -0
  102. package/src/.DS_Store +0 -0
  103. package/templates/template_admin/.gitignore +0 -6
  104. package/templates/template_admin/public/src/components/Alert/index.jsx +0 -0
  105. package/templates/template_admin/public/src/components/Alert/index.less +0 -0
  106. package/templates/template_admin/public/src/components/Header/index.jsx +0 -57
  107. package/templates/template_admin/public/src/components/Layout/CenterBody/index.jsx +0 -15
  108. package/templates/template_admin/public/src/components/Link/index.jsx +0 -24
  109. package/templates/template_admin/public/src/components/Loading/index.jsx +0 -14
  110. package/templates/template_admin/public/src/components/Loading/index.less +0 -85
  111. package/templates/template_admin/public/src/components/mask/index.jsx +0 -47
  112. package/templates/template_admin/public/src/components/mask/index.less +0 -32
  113. package/templates/template_admin/public/src/hooks/useLogin.jsx +0 -33
  114. package/templates/template_app/.gitignore +0 -6
  115. package/templates/template_app/public/src/components/Header/index.less +0 -57
  116. package/templates/template_app/public/src/components/Layout/index.jsx +0 -4
  117. package/templates/template_app/public/src/hooks/useLogin.jsx +0 -33
  118. package/templates/template_oa/.gitignore +0 -6
  119. package/templates/template_oa_jwt/.gitignore +0 -6
  120. package/templates/template_offcial/.gitignore +0 -6
  121. package/templates/template_offcial/public/src/components/Alert/index.jsx +0 -0
  122. package/templates/template_offcial/public/src/components/Alert/index.less +0 -0
  123. package/templates/template_offcial/public/src/components/Link/index.jsx +0 -24
  124. /package/templates/template_admin/public/src/components/{IconFont → iconFont}/index.less +0 -0
  125. /package/templates/template_admin/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
  126. /package/templates/template_admin/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
  127. /package/templates/template_admin/public/src/components/{Layout → layout}/index.less +0 -0
  128. /package/templates/template_admin/public/src/components/{Link → link}/index.less +0 -0
  129. /package/templates/template_admin/public/src/components/{Menu → menu}/index.less +0 -0
  130. /package/templates/template_admin/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  131. /package/templates/template_admin/public/src/components/{Popup → popup}/index.less +0 -0
  132. /package/templates/template_admin/public/src/components/{Toast → toast}/index.less +0 -0
  133. /package/templates/template_admin/public/src/components/{TopMenu → topMenu}/index.less +0 -0
  134. /package/templates/{template_admin/public/src/components/Header → template_app/public/src/components/header}/index.less +0 -0
  135. /package/templates/template_app/public/src/components/{IconFont → iconFont}/index.less +0 -0
  136. /package/templates/template_app/public/src/components/{Layout/App → layout/app}/index.less +0 -0
  137. /package/templates/template_app/public/src/components/{Link → link}/index.less +0 -0
  138. /package/templates/template_app/public/src/components/{Marquee → marquee}/index.less +0 -0
  139. /package/templates/template_app/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  140. /package/templates/template_app/public/src/components/{Popup → popup}/index.less +0 -0
  141. /package/templates/template_app/public/src/components/{Toast → toast}/index.less +0 -0
  142. /package/templates/template_offcial/public/src/components/{Footer → footer}/index.less +0 -0
  143. /package/templates/template_offcial/public/src/components/{Header → header}/index.less +0 -0
  144. /package/templates/template_offcial/public/src/components/{IconFont → iconFont}/index.less +0 -0
  145. /package/templates/template_offcial/public/src/components/{Layout → layout}/index.less +0 -0
  146. /package/templates/template_offcial/public/src/components/{Link → link}/index.less +0 -0
  147. /package/templates/template_offcial/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  148. /package/templates/template_offcial/public/src/components/{Popup → popup}/index.less +0 -0
  149. /package/templates/template_offcial/public/src/components/{Toast → toast}/index.less +0 -0
@@ -1,7 +1,32 @@
1
- import { useRef,useState,useMemo, useEffect } from 'react';
1
+ // @ts-ignore
2
+ import React,{ useState } from 'react';
3
+
4
+
5
+ /**
6
+ * @typedef {object} UseSearch
7
+ * @property {(pageInfo:Pagination,sorterInfo:any)=>Promise} onPaginationChange - 监听分页信息发生变更
8
+ * @property {Pagination} pagination - 当前分页信息
9
+ * @property {object} search - 当前分页查询参数
10
+ * @property {()=>Promise} btnSearch - 出发查询
11
+ * @property {(object)=>void} setSearch - 设置查询参数
12
+ * @property {(object)=>Promise<ServicesResponse>} refresh - 设置查询参数
13
+ * @property {()=>void} btnReset - 重置查询参数
14
+ * @property {(sorter:object)=>void} onSorter - 监听排序变更
15
+ *
16
+ */
17
+
2
18
 
3
19
  /**
4
20
  * 管理表格数据的查询搜索及分页
21
+ * @param {object} props
22
+ * @param {object} [props.initSearch={}] - 初始的分页搜索参数
23
+ * @param {(params)=>Promise} [props.service] - 分页接口提交方法
24
+ * @param {(params:any)=>object} [props.beforeSearch] - 参数拦截器
25
+ * @param {(params:any)=>object} [props.beforeService] - 提交接口前的参数拦截器
26
+ * @param {(response:any)=>void} [props.updateData] - 接口返回后的回调
27
+ * @param {Pagination} [props.pagination] - 接口返回后的回调
28
+ *
29
+ * @returns {UseSearch}
5
30
  */
6
31
  const useSearch=(props)=>{
7
32
  const [search,setSearch] = useState(props.initSearch||{});
@@ -80,10 +105,11 @@ const useSearch=(props)=>{
80
105
  }
81
106
  }
82
107
  const btnReset=()=>{
108
+ // @ts-ignore
83
109
  formRef.resetFields();
84
110
  }
85
111
 
86
- const refresh= async ({searchValue,pageValue,orderValue}={})=>{
112
+ const refresh= async ({searchValue=null,pageValue=null,orderValue=null}={})=>{
87
113
  searchValue = searchValue || search;
88
114
  pageValue = pageValue || pagination;
89
115
 
@@ -1,5 +1,10 @@
1
+ // @ts-ignore
1
2
  import { useState, useMemo } from 'react';
2
3
 
4
+
5
+ /**
6
+ * 更新计数器
7
+ */
3
8
  const useUpdate=()=>{
4
9
  const [count,setCount] = useState(1);
5
10
  const action = useMemo(()=>{
@@ -1,5 +1,8 @@
1
+ // @ts-ignore
1
2
  import React from 'react';
3
+ // @ts-ignore
2
4
  import ReactDOM from 'react-dom';
5
+ // @ts-ignore
3
6
  import {HashRouter} from 'react-router-dom';
4
7
  // import {createRoot} from 'react-dom/client';
5
8
  // import { createHashRouter,RouterProvider } from 'react-router-dom';
@@ -7,33 +10,44 @@ import './_antd.less';
7
10
  import './_reset.less';
8
11
  import {RouteList} from './route';
9
12
 
10
-
13
+ // @ts-ignore
11
14
  if(MOCK){
15
+ // @ts-ignore
12
16
  let mock = require('@/mock');
13
17
  mock;
14
18
  }
15
19
 
20
+ // @ts-ignore
16
21
  window.appLog=(txt)=>{
17
22
  console.log(txt);
18
23
  }
19
24
 
20
25
  /* eslint-disable */
26
+ // @ts-ignore
21
27
  if(BUILD_ENV!='prod'){
28
+ // @ts-ignore
22
29
  let VConsole = require('vconsole');
30
+ // @ts-ignore
23
31
  const vConsole = new VConsole();
24
32
  setTimeout(() => {
25
33
  vConsole.setSwitchPosition(70, 10);
26
34
  }, 2000);
27
35
  }
28
-
36
+ // @ts-ignore
29
37
  if(BUILD_ENV){
38
+ // @ts-ignore
30
39
  window.appLog(`代码环境类型:${BUILD_ENV}`);
31
40
  }
41
+ // @ts-ignore
32
42
  if (VERSION_HASH) {
43
+ // @ts-ignore
33
44
  window.appLog(`VERSION_HASH:${VERSION_HASH}`);
34
45
  }
46
+ // @ts-ignore
35
47
  window.appLog(`log init`);
48
+ // @ts-ignore
36
49
  window.appLog(`${location.href}`);
50
+ // @ts-ignore
37
51
  window.appLog(`ua:${navigator.userAgent}`);
38
52
  /* eslint-enable */
39
53
 
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
- import {usePaginationWithForm} from '@/hooks';
2
+ import {usePaginationWithForm} from '@/hooks/index';
3
3
  import {GET_LIST} from '@/services/video';
4
+ // @ts-ignore
4
5
  import {Table,Pagination,Form,Input,Button} from 'antd';
5
6
 
6
7
  const Page = () => {
@@ -1,6 +1,11 @@
1
- import React, { useEffect, useState, useRef } from 'react';
2
- import Link from '@/components/Link';
1
+ // @ts-ignore
2
+ import React from 'react';
3
3
 
4
+ import Link from '@/components/link';
5
+
6
+ /**
7
+ * @returns {JSX.Element}
8
+ */
4
9
  const Page = () => {
5
10
  return (
6
11
  <div>
@@ -1,12 +1,36 @@
1
- import { useState,useMemo, useEffect } from 'react';
1
+ // @ts-ignore
2
+ import { useState,useMemo } from 'react';
3
+ // @ts-ignore
2
4
  import { useSearchParams,useNavigate } from 'react-router-dom';
3
-
4
- import { createContainer } from "unstated-next"
5
- import {useDelay} from '@/hooks';
5
+ // @ts-ignore
6
+ import { createContainer } from "unstated-next";
7
+ // @ts-ignore
8
+ import {useDelay} from '@/hooks/index';
6
9
  import {setJwt,setLogout} from '@/services';
7
10
  import {KSSO_LOGIN,LOGIN,LOGOUT} from '@/services/auth';
8
11
  import {jumpUrl} from '@/utils';
9
12
 
13
+
14
+ /**
15
+ * @typedef AppContaniner
16
+ * @property {boolean} loading - 当前是否是加载状态
17
+ * @property {(open:boolean)=>void} setLoading - 设置加载状态
18
+ * @property {()=>Promise<boolean>} isLogin - 检查是否已登录状态
19
+ * @property {(username:string,password:string)=>Promise<boolean>} login - 触发登录
20
+ * @property {object} nav - 导航栏配置
21
+ * @property {(option:object)=>void} setNav - 设置导航栏配置
22
+ * @property {()=>Promise} logout - 注销病退回登录界面
23
+ * @property {(user:object)=>void} setUser - 注销病退回登录界面
24
+ * @property {object} user - 注销病退回登录界面
25
+ * @property {()=>Promise<boolean>} kssoLogin - 触发ksso登录
26
+ *
27
+ */
28
+
29
+
30
+ /**
31
+ * 应用全局Provider
32
+ * @returns
33
+ */
10
34
  const useApp=() =>{
11
35
  const [search] = useSearchParams();
12
36
  const navigate= useNavigate();
@@ -25,6 +49,7 @@ const useApp=() =>{
25
49
  userData= JSON.parse(userData);
26
50
  if(userData){
27
51
  setUser(userData);
52
+ // @ts-ignore
28
53
  setJwt(userData.token);
29
54
  return true;
30
55
  }
@@ -114,6 +139,16 @@ const useApp=() =>{
114
139
  return action
115
140
  }
116
141
 
142
+
143
+ /**
144
+ * @typedef {object} AppProvider
145
+ * @property {function():AppContaniner} useContainer
146
+ * @property {React.ComponentType<any>} Provider
147
+ */
148
+
149
+ /**
150
+ * @type {AppProvider}
151
+ */
117
152
  const App = createContainer(useApp);
118
153
 
119
154
  export default App;
@@ -1,5 +1,8 @@
1
- import { useState,useMemo } from 'react';
1
+ // @ts-ignore
2
+ import React,{ useState,useMemo } from 'react';
3
+ // @ts-ignore
2
4
  import { createContainer } from "unstated-next"
5
+
3
6
  import {GET_MENU} from '@/services/auth';
4
7
 
5
8
  const useProvider=() =>{
@@ -1,13 +1,16 @@
1
+
2
+ // @ts-ignore
1
3
  import React,{Suspense} from 'react';
4
+ // @ts-ignore
2
5
  import { Routes, Route, Navigate } from 'react-router-dom';
3
6
 
4
- import { LayoutBasic, Layout } from '@/components/Layout';
5
- import PageLoading from '@/components/Page/PageLoading';
7
+ import { LayoutBasic, Layout } from '@/components/layout';
8
+ import PageLoading from '@/components/page/pageLoading';
6
9
 
7
10
  import Login from '@/pages/login';
8
- import {AuthLogin} from '@/components/Auth';
9
- import LeftMenu from '@/components/Menu';
10
- import TopMenu from '@/components/TopMenu';
11
+ import {AuthLogin} from '@/components/auth';
12
+ import LeftMenu from '@/components/menu';
13
+ import TopMenu from '@/components/topMenu';
11
14
 
12
15
  import ProviderMenu from '@/provider/menu';
13
16
 
@@ -1,9 +1,14 @@
1
+ // @ts-ignore
1
2
  import Axios from 'axios';
3
+ // @ts-ignore
2
4
  import qs from 'qs';
5
+ // @ts-ignore
3
6
  import { message } from 'antd';
7
+
4
8
  const axios = Axios.create();
9
+ // @ts-ignore
5
10
  console.log(`========API_ROOT:${API_HOST}========`);
6
-
11
+ // @ts-ignore
7
12
  export const API_ROOT = API_HOST;
8
13
  const tokenMode='header';//header,cookie
9
14
  const tokenName='Authorization';
@@ -27,7 +32,7 @@ export const setJwt = (value) => {
27
32
  localStorage.setItem('jwt', value);
28
33
  jwt = value;
29
34
  };
30
-
35
+ // @ts-ignore
31
36
  window.setJwt=setJwt;
32
37
  export const setLogout=(fn)=>{
33
38
  logout=fn;
@@ -95,6 +100,13 @@ axios.interceptors.response.use(
95
100
 
96
101
 
97
102
  let buffer = {};
103
+ /**
104
+ * GET请求
105
+ * @param {string} url - 接口地址
106
+ * @param {Object} [param] - 接口参数
107
+ * @param {Object} [options] - 扩展参数
108
+ * @returns Promise<ServicesResponse>
109
+ */
98
110
  export async function GET_DEFAULT(url, param, options) {
99
111
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
100
112
  let now = Date.now();
@@ -127,6 +139,12 @@ export async function GET_DEFAULT(url, param, options) {
127
139
  return response && response.data ? response.data : null;
128
140
  }
129
141
 
142
+ /**
143
+ * GET请求
144
+ * @param {string} url - 接口地址
145
+ * @param {Object} [param] - 接口参数
146
+ * @returns Promise<ServicesResponse>
147
+ */
130
148
  export async function GET_DEFAULT_CROSS(url, param) {
131
149
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
132
150
 
@@ -140,7 +158,15 @@ export async function GET_DEFAULT_CROSS(url, param) {
140
158
  return response && response.data ? response.data : null;
141
159
  }
142
160
 
143
- export async function POST_DEFAULT(url, params, method, options) {
161
+ /**
162
+ * POST请求
163
+ * @param {string} url - 接口地址
164
+ * @param {Object} [params] - 接口参数
165
+ * @param {Object} [options] - 特殊参数
166
+ *
167
+ * @returns Promise<ServicesResponse>
168
+ */
169
+ export async function POST_DEFAULT(url, params, options) {
144
170
  let data = params;
145
171
  // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
146
172
  // if (typeof params === 'string') {
@@ -150,7 +176,7 @@ export async function POST_DEFAULT(url, params, method, options) {
150
176
  // }
151
177
 
152
178
  let response = await axios({
153
- method: method || 'POST',
179
+ method: 'POST',
154
180
  url: url,
155
181
  data,
156
182
  ...options,
@@ -159,6 +185,14 @@ export async function POST_DEFAULT(url, params, method, options) {
159
185
  return response && response.data ? response.data : null;
160
186
  }
161
187
 
188
+
189
+ /**
190
+ * POST请求
191
+ * @param {string} url - 接口地址
192
+ * @param {Object} [params] - 接口参数
193
+ *
194
+ * @returns Promise<ServicesResponse>
195
+ */
162
196
  export async function POST_DEFAULT_CROSS(url, params) {
163
197
  let data = {};
164
198
  // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
@@ -1,16 +1,16 @@
1
- import {GET_DEFAULT,PUT_DEFAULT,POST_DEFAULT,API_ROOT} from './index.js';
1
+ import {GET_DEFAULT,POST_DEFAULT,API_ROOT} from './index.js';
2
2
 
3
3
 
4
4
 
5
5
  export function GET_USER(){
6
- return GET_DEFAULT(`${HOST}/user`);
6
+ return GET_DEFAULT(`${API_ROOT}/user`);
7
7
  }
8
8
 
9
9
  export function SET_USER(params={
10
10
  name:'',
11
11
  age:''
12
12
  }){
13
- return POST_DEFAULT(`${HOST}/user`,params)
13
+ return POST_DEFAULT(`${API_ROOT}/user`,params)
14
14
  }
15
15
 
16
16
 
@@ -0,0 +1,48 @@
1
+
2
+ /**
3
+ * 可自行扩展任意数量的属性
4
+ * @typedef {Object<string, any>} OtherAny
5
+ */
6
+
7
+ /**
8
+ * 指向DOM节点的ref
9
+ * @typedef {object} RefDomElement
10
+ * @property {HTMLElement} current - DOM节点
11
+ */
12
+
13
+
14
+
15
+ /**
16
+ * @typedef {object} FormDataInfo
17
+ * @property {string} btnControl
18
+ */
19
+
20
+ /**
21
+ * @typedef {[FormDataInfo,Function]} UseStateFormData
22
+ */
23
+
24
+
25
+ /**
26
+ * @typedef {FormDataInfo & OtherAny} TableContentData
27
+ */
28
+
29
+
30
+ /**
31
+ * 分页
32
+ * @typedef {object} Pagination
33
+ * @property {number} current - 当前页码,1~N
34
+ * @property {number} pageSize=10 - 分页大小
35
+ * @property {number} total - 总记录条数
36
+ * @property {number} startIdx - 当前页面第一条的数据索引起始值
37
+ *
38
+ */
39
+
40
+
41
+ /**
42
+ * 接口response数据
43
+ * @typedef {object} ServicesResponse
44
+ * @property {number} code - 接口处理结果,0为成功
45
+ * @property {object} data - 接口返回的数据
46
+ * @property {Pagination} page - 分页数据
47
+ *
48
+ */
@@ -1,10 +1,16 @@
1
1
 
2
-
2
+ /**
3
+ * 打开一个第三方链接
4
+ * @param {string} link - 链接地址
5
+ * @param {string} [target='_blank'] - 打开方式,_blank:新窗口打开
6
+ */
3
7
  export const openLink = (link, target = '_blank') => {
4
8
  let domLink = document.createElement('a');
5
9
  domLink.href = link;
6
10
  domLink.setAttribute('target', target);
11
+ // @ts-ignore
7
12
  domLink.style.opacity = 0;
13
+ // @ts-ignore
8
14
  domLink.style.zIndex = -999;
9
15
  document.body.appendChild(domLink);
10
16
  domLink.click();
@@ -13,30 +19,38 @@ export const openLink = (link, target = '_blank') => {
13
19
  }, 200);
14
20
  }
15
21
 
22
+ /**
23
+ * 判断当前是否为移动端
24
+ * @returns {boolean}
25
+ */
16
26
  export const isMobile = () => {
17
27
  return navigator.userAgent.match(
18
28
  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
19
- )
29
+ )?true:false
20
30
  }
21
31
 
22
- export const toHref = (url, replace, newWindow) => {
23
- if(window.knFeishu){
24
- window.knFeishu.ToHref(url,replace,newWindow);
25
- return;
26
- }
27
- if (newWindow) {
28
- window.open(url);
29
- return;
30
- }
31
- if (replace) {
32
- location.replace(url);
33
- return;
34
- }
35
- location.href = url;
36
- };
37
32
 
33
+ /**
34
+ * 跳转URL-兼容飞书
35
+ * @param {string} url - 链接地址
36
+ * @param {object} [options] - 参数
37
+ * @param {boolean} [options.replace] - 是否要覆盖当前URL记录
38
+ * @param {boolean} [options.newWindow] - 是否新窗口中打开
39
+ * @param {boolean} [options.reload] - 是否重载当前页面
40
+ *
41
+ *
42
+ */
38
43
  export const jumpUrl=(url,options={})=>{
39
- const {replace,newWindow,reload}= options;
44
+ const {replace=false,newWindow=false,reload=false}= options;
45
+ if(!reload){
46
+ // @ts-ignore
47
+ if(window.knFeishu){
48
+ // @ts-ignore
49
+ window.knFeishu.ToHref(url,replace,newWindow);
50
+ return;
51
+ }
52
+ }
53
+
40
54
  if(reload){
41
55
  location.reload();
42
56
  return;
@@ -56,7 +70,9 @@ export const jumpUrl=(url,options={})=>{
56
70
 
57
71
  // 关闭页面
58
72
  export const closeWindow = () => {
73
+ // @ts-ignore
59
74
  if (window.knFeishu && window.knFeishu.closeWindow) {
75
+ // @ts-ignore
60
76
  window.knFeishu.closeWindow();
61
77
  } else {
62
78
  if (window.close) {
@@ -1,6 +1,6 @@
1
1
 
2
2
  module.exports = {
3
- name:'template-app',
3
+ name:'projectName',
4
4
  registryType:'npm',//npm镜像源,taobao|npm
5
5
  less:{
6
6
  javascriptEnabled:false,//是否开启less js
@@ -3,8 +3,12 @@
3
3
  "baseUrl": ".",
4
4
  "emitDecoratorMetadata": true,
5
5
  "experimentalDecorators": true,
6
+ "lib": ["dom", "ES2021"],
7
+ "allowJs":true,
8
+ "checkJs": true,
9
+ "jsx": "react",
6
10
  "paths": {
7
11
  "@/*": ["./public/src/*"]
8
- }
12
+ },
9
13
  }
10
14
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "template_app",
2
+ "name": "projectName",
3
3
  "version": "1.0.0",
4
4
  "main": "lib/index",
5
5
  "scripts": {
@@ -1,8 +1,19 @@
1
+ // @ts-ignore
1
2
  import React, { useEffect, useState } from 'react';
2
- import ProviderApp from '@/provider/app';
3
+ // @ts-ignore
3
4
  import { useNavigate } from 'react-router-dom';
5
+
6
+ import ProviderApp from '@/provider/app';
4
7
  import {useLoading} from '@/hooks';
5
8
 
9
+ /**
10
+ * 检查用户是否带有某个权限
11
+ * @param {object} props
12
+ * @param {string} [props.name] - 权限的名称
13
+ * @param {JSX.Element} [props.children] - 子组件
14
+ *
15
+ * @returns {JSX.Element}
16
+ */
6
17
  export const AuthShow=(props)=>{
7
18
  const {name} = props;
8
19
  const app = ProviderApp.useContainer();
@@ -12,6 +23,13 @@ export const AuthShow=(props)=>{
12
23
  return <></>
13
24
  }
14
25
 
26
+ /**
27
+ * 用户登录态校验
28
+ * @param {object} props
29
+ * @param {JSX.Element} [props.children] - 当登录校验合法后显示的子组件
30
+ *
31
+ * @returns {JSX.Element}
32
+ */
15
33
  export const AuthLogin=(props)=>{
16
34
  const navigate = useNavigate();
17
35
  const [pass,setPass] = useState(false)
@@ -32,7 +50,7 @@ export const AuthLogin=(props)=>{
32
50
  navigate('/login');
33
51
  }
34
52
  }
35
- useEffect(check,[]);
53
+ useEffect(()=>{check()},[]);
36
54
 
37
55
  if(pass){
38
56
  return props.children;
@@ -1,7 +1,31 @@
1
+ // @ts-ignore
1
2
  import React, { useEffect } from 'react';
2
- import IconFont from '../IconFont';
3
+ // @ts-ignore
4
+ import IconFont from '../iconFont';
5
+
6
+ // @ts-ignore
3
7
  import styles from './index.less';
4
8
 
9
+ /**
10
+ * 头部导航栏
11
+ * @param {object} props
12
+ * @param {string} [props.visible=true] - 是否显示
13
+ * @param {string} [props.className] - 扩展类样式名称
14
+ * @param {string} [props.title] - 标题
15
+ * @param {string} [props.subTitle] - 副标题
16
+ * @param {string} [props.leftLabel] - 左侧操作按钮文案
17
+ * @param {string} [props.rightLabel] - 右侧操作按钮文案
18
+ * @param {JSX.Element|string} [props.left] - 左侧操作按钮组件
19
+ * @param {JSX.Element|string} [props.right] - 左侧操作按钮组件
20
+ * @param {JSX.Element|string} [props.syncDocumentTitle=false] - 是否将标题同步到网页<title>标签内
21
+ * @param {Function} [props.onLeftLabel] - 左侧操作按钮文案点击回调
22
+ * @param {Function} [props.onRight] - 右侧操作按钮ICON点击回调
23
+ * @param {Function} [props.onRightLabel] - 右侧操作按钮文案点击回调
24
+ * @param {Function} [props.onTitle] - 点击导航栏标题回调
25
+ *
26
+ *
27
+ * @returns {JSX.Element}
28
+ */
5
29
  const Header=(props)=>{
6
30
  const {
7
31
  visible=true,
@@ -1,6 +1,16 @@
1
+ // @ts-ignore
1
2
  import React from "react";
3
+ // @ts-ignore
2
4
  import styles from'./index.less';
3
5
 
6
+ /**
7
+ * iconFont图标
8
+ * @param {object} props
9
+ * @param {string} [props.icon] - 图标名称
10
+ * @param {string} [props.className] - 扩展类名
11
+ *
12
+ * @returns {JSX.Element}
13
+ */
4
14
  const IconFont=(props)=>{
5
15
  const {icon,className,...others} = props;
6
16
  return (
@@ -1,10 +1,20 @@
1
+ // @ts-ignore
1
2
  import React from 'react';
3
+ // @ts-ignore
2
4
  import {Outlet} from 'react-router-dom';
3
- import Header from '@/components/Header';
5
+
6
+ import Header from '@/components/header';
4
7
  import ProviderApp from '@/provider/app';
5
- import styles from './index.less';
6
8
 
9
+ // @ts-ignore
10
+ import styles from './index.less';
7
11
 
12
+ /**
13
+ * APP框架layout
14
+ * @param {object} [props]
15
+ *
16
+ * @returns {JSX.Element}
17
+ */
8
18
  const LayoutApp=(props)=>{
9
19
  const providerApp = ProviderApp.useContainer();
10
20
  console.log('layoutApp.nav',providerApp.nav)
@@ -0,0 +1,6 @@
1
+ // @ts-ignore
2
+ import React from 'react';
3
+
4
+ import LayoutApp from './app';
5
+ import LayoutProvider from './provider';
6
+ export { LayoutApp ,LayoutProvider};
@@ -1,5 +1,8 @@
1
+ // @ts-ignore
1
2
  import React from 'react';
3
+ // @ts-ignore
2
4
  import {Outlet} from 'react-router-dom';
5
+
3
6
  import ProviderApp from '@/provider/app';
4
7
 
5
8
  const LayoutProvider=(props)=>{