kn-cli 1.0.91 → 1.0.93

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 (143) hide show
  1. package/package.json +1 -1
  2. package/readme.md +3 -0
  3. package/src/.DS_Store +0 -0
  4. package/templates/template_admin/.gitignore +6 -0
  5. package/templates/template_admin/public/index.html +5 -2
  6. package/templates/template_admin/public/src/_antd.less +7 -1
  7. package/templates/template_admin/public/src/components/menu/index.jsx +47 -100
  8. package/templates/template_admin/public/src/components/menu/topMenu/index.jsx +119 -0
  9. package/templates/template_admin/public/src/dictionary/index.js +4 -1
  10. package/templates/template_admin/public/src/hooks/index.jsx +4 -1
  11. package/templates/template_admin/public/src/hooks/useRouteMenu.jsx +232 -0
  12. package/templates/template_admin/public/src/provider/menu.jsx +261 -10
  13. package/templates/template_admin/public/src/route.jsx +18 -9
  14. package/templates/template_app/.gitignore +6 -0
  15. package/templates/template_oa/.gitignore +6 -0
  16. package/templates/template_oa/jsconfig.json +5 -1
  17. package/templates/template_oa/public/src/components/dialog/index.jsx +237 -0
  18. package/templates/template_oa/public/src/components/{Empty → empty}/index.jsx +9 -0
  19. package/templates/{template_oa_jwt/public/src/components/FormRow → template_oa/public/src/components/formRow}/index.jsx +25 -3
  20. package/templates/{template_oa_jwt/public/src/components/FormTable → template_oa/public/src/components/formTable}/index.jsx +39 -1
  21. package/templates/template_oa/public/src/components/iconFont/index.jsx +22 -0
  22. package/templates/template_oa/public/src/components/{IFrame → iframe}/index.jsx +18 -4
  23. package/templates/template_oa/public/src/components/{Layout/Basic → layout/basic}/index.jsx +7 -1
  24. package/templates/{template_oa_jwt/public/src/components/Layout/CenterBody → template_oa/public/src/components/layout/centerBody}/index.jsx +2 -0
  25. package/templates/{template_oa_jwt/public/src/components/Layout/FormBlock → template_oa/public/src/components/layout/formBlock}/index.jsx +3 -1
  26. package/templates/template_oa/public/src/components/{Layout → layout}/index.jsx +12 -6
  27. package/templates/{template_oa_jwt/public/src/components/Layout/Provider → template_oa/public/src/components/layout/provider}/index.jsx +4 -0
  28. package/templates/template_oa/public/src/components/{Link → link}/index.jsx +16 -0
  29. package/templates/template_oa/public/src/components/{Nav → nav}/index.jsx +8 -2
  30. package/templates/{template_oa_jwt/public/src/components/Page/PageLoading → template_oa/public/src/components/page/pageLoading}/index.jsx +25 -4
  31. package/templates/template_oa/public/src/components/{Popup → popup}/index.jsx +13 -0
  32. package/templates/template_oa/public/src/components/{Select/DepSelect → select/depSelect}/index.jsx +15 -0
  33. package/templates/template_oa/public/src/components/{Select/StaffSelect → select/staffSelect}/index.jsx +27 -0
  34. package/templates/template_oa/public/src/components/title/index.jsx +3 -0
  35. package/templates/template_oa/public/src/components/{Toast → toast}/index.jsx +21 -1
  36. package/templates/template_oa/public/src/components/{Upload → upload}/index.jsx +41 -3
  37. package/templates/template_oa/public/src/hooks/index.jsx +1 -0
  38. package/templates/template_oa/public/src/hooks/useDelay.jsx +5 -0
  39. package/templates/template_oa/public/src/hooks/useImageLoader.jsx +1 -2
  40. package/templates/template_oa/public/src/hooks/useLoading.jsx +5 -1
  41. package/templates/template_oa/public/src/hooks/usePreload.jsx +2 -1
  42. package/templates/template_oa/public/src/hooks/useScrollTop.jsx +12 -0
  43. package/templates/template_oa/public/src/hooks/useSearch.jsx +28 -2
  44. package/templates/template_oa/public/src/hooks/useUpdate.jsx +5 -0
  45. package/templates/template_oa/public/src/index.jsx +15 -1
  46. package/templates/template_oa/public/src/pages/video/index.jsx +17 -13
  47. package/templates/template_oa/public/src/provider/app.jsx +33 -2
  48. package/templates/template_oa/public/src/route.jsx +4 -2
  49. package/templates/template_oa/public/src/services/common.js +11 -0
  50. package/templates/template_oa/public/src/services/index.js +44 -2
  51. package/templates/template_oa/public/src/type.js +48 -0
  52. package/templates/template_oa/public/src/utils/index.js +34 -17
  53. package/templates/template_oa_jwt/.gitignore +6 -0
  54. package/templates/template_oa_jwt/jsconfig.json +5 -1
  55. package/templates/template_oa_jwt/public/src/components/dialog/index.jsx +237 -0
  56. package/templates/template_oa_jwt/public/src/components/{Empty → empty}/index.jsx +9 -0
  57. package/templates/{template_oa/public/src/components/FormRow → template_oa_jwt/public/src/components/formRow}/index.jsx +25 -3
  58. package/templates/{template_oa/public/src/components/FormTable → template_oa_jwt/public/src/components/formTable}/index.jsx +41 -2
  59. package/templates/template_oa_jwt/public/src/components/formTable/index.less +18 -0
  60. package/templates/template_oa_jwt/public/src/components/iconFont/index.jsx +22 -0
  61. package/templates/template_oa_jwt/public/src/components/{IFrame → iframe}/index.jsx +15 -0
  62. package/templates/template_oa_jwt/public/src/components/{Layout/Basic → layout/basic}/index.jsx +11 -6
  63. package/templates/{template_oa/public/src/components/Layout/CenterBody → template_oa_jwt/public/src/components/layout/centerBody}/index.jsx +2 -0
  64. package/templates/{template_oa/public/src/components/Layout/FormBlock → template_oa_jwt/public/src/components/layout/formBlock}/index.jsx +3 -1
  65. package/templates/template_oa_jwt/public/src/components/{Layout → layout}/index.jsx +10 -4
  66. package/templates/{template_oa/public/src/components/Layout/Provider → template_oa_jwt/public/src/components/layout/provider}/index.jsx +4 -0
  67. package/templates/template_oa_jwt/public/src/components/{Link → link}/index.jsx +16 -0
  68. package/templates/template_oa_jwt/public/src/components/{Nav → nav}/index.jsx +11 -5
  69. package/templates/{template_oa/public/src/components/Page/PageLoading → template_oa_jwt/public/src/components/page/pageLoading}/index.jsx +25 -4
  70. package/templates/template_oa_jwt/public/src/components/{Popup → popup}/index.jsx +13 -0
  71. package/templates/template_oa_jwt/public/src/components/{Select/DepSelect → select/depSelect}/index.jsx +15 -0
  72. package/templates/template_oa_jwt/public/src/components/{Select/StaffSelect → select/staffSelect}/index.jsx +27 -0
  73. package/templates/template_oa_jwt/public/src/components/title/index.jsx +3 -0
  74. package/templates/template_oa_jwt/public/src/components/{Toast → toast}/index.jsx +21 -1
  75. package/templates/template_oa_jwt/public/src/components/{Upload → upload}/index.jsx +41 -3
  76. package/templates/template_oa_jwt/public/src/dictionary/index.js +2 -0
  77. package/templates/template_oa_jwt/public/src/hooks/index.jsx +2 -2
  78. package/templates/template_oa_jwt/public/src/hooks/useDelay.jsx +5 -0
  79. package/templates/template_oa_jwt/public/src/hooks/useImageLoader.jsx +1 -2
  80. package/templates/template_oa_jwt/public/src/hooks/useLoading.jsx +5 -1
  81. package/templates/template_oa_jwt/public/src/hooks/usePreload.jsx +2 -1
  82. package/templates/template_oa_jwt/public/src/hooks/useScrollTop.jsx +12 -0
  83. package/templates/template_oa_jwt/public/src/hooks/useSearch.jsx +28 -2
  84. package/templates/template_oa_jwt/public/src/hooks/useUpdate.jsx +5 -0
  85. package/templates/template_oa_jwt/public/src/pages/demo/index.jsx +17 -11
  86. package/templates/template_oa_jwt/public/src/provider/app.jsx +30 -1
  87. package/templates/template_oa_jwt/public/src/route.jsx +4 -2
  88. package/templates/template_oa_jwt/public/src/services/common.js +13 -1
  89. package/templates/template_oa_jwt/public/src/services/index.js +52 -8
  90. package/templates/template_oa_jwt/public/src/services/token.js +7 -0
  91. package/templates/template_oa_jwt/public/src/utils/index.js +62 -22
  92. package/templates/template_offcial/.gitignore +6 -0
  93. package/templates/template_admin/public/src/components/topMenu/index.jsx +0 -267
  94. package/templates/template_oa/public/src/components/Alert/index.jsx +0 -0
  95. package/templates/template_oa/public/src/components/Alert/index.less +0 -0
  96. package/templates/template_oa/public/src/components/Auth/index.jsx +0 -44
  97. package/templates/template_oa/public/src/components/Dialog/index.jsx +0 -150
  98. package/templates/template_oa/public/src/components/Footer/index.jsx +0 -17
  99. package/templates/template_oa/public/src/components/Footer/index.less +0 -28
  100. package/templates/template_oa/public/src/components/IconFont/index.jsx +0 -10
  101. package/templates/template_oa/public/src/components/Loading/index.jsx +0 -14
  102. package/templates/template_oa/public/src/components/Loading/index.less +0 -85
  103. package/templates/template_oa_jwt/public/src/components/Alert/index.jsx +0 -0
  104. package/templates/template_oa_jwt/public/src/components/Alert/index.less +0 -0
  105. package/templates/template_oa_jwt/public/src/components/Auth/index.jsx +0 -44
  106. package/templates/template_oa_jwt/public/src/components/Dialog/index.jsx +0 -150
  107. package/templates/template_oa_jwt/public/src/components/Footer/index.jsx +0 -17
  108. package/templates/template_oa_jwt/public/src/components/Footer/index.less +0 -28
  109. package/templates/template_oa_jwt/public/src/components/IconFont/index.jsx +0 -10
  110. package/templates/template_oa_jwt/public/src/components/Loading/index.jsx +0 -16
  111. package/templates/template_oa_jwt/public/src/components/Loading/index.less +0 -96
  112. /package/templates/template_admin/public/src/components/{topMenu → menu/topMenu}/index.less +0 -0
  113. /package/templates/template_oa/public/src/components/{Dialog → dialog}/index.less +0 -0
  114. /package/templates/template_oa/public/src/components/{Empty → empty}/index.less +0 -0
  115. /package/templates/template_oa/public/src/components/{FormRow → formRow}/index.less +0 -0
  116. /package/templates/{template_oa_jwt/public/src/components/FormTable → template_oa/public/src/components/formTable}/index.less +0 -0
  117. /package/templates/template_oa/public/src/components/{IconFont → iconFont}/index.less +0 -0
  118. /package/templates/template_oa/public/src/components/{IFrame → iframe}/index.less +0 -0
  119. /package/templates/template_oa/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
  120. /package/templates/template_oa/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
  121. /package/templates/template_oa/public/src/components/{Layout/FormBlock → layout/formBlock}/index.less +0 -0
  122. /package/templates/template_oa/public/src/components/{Layout → layout}/index.less +0 -0
  123. /package/templates/template_oa/public/src/components/{Link → link}/index.less +0 -0
  124. /package/templates/template_oa/public/src/components/{Nav → nav}/index.less +0 -0
  125. /package/templates/template_oa/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  126. /package/templates/template_oa/public/src/components/{Popup → popup}/index.less +0 -0
  127. /package/templates/template_oa/public/src/components/{Select/StaffSelect → select/staffSelect}/index.less +0 -0
  128. /package/templates/template_oa/public/src/components/{Toast → toast}/index.less +0 -0
  129. /package/templates/template_oa_jwt/public/src/components/{Dialog → dialog}/index.less +0 -0
  130. /package/templates/template_oa_jwt/public/src/components/{Empty → empty}/index.less +0 -0
  131. /package/templates/template_oa_jwt/public/src/components/{FormRow → formRow}/index.less +0 -0
  132. /package/templates/template_oa_jwt/public/src/components/{IconFont → iconFont}/index.less +0 -0
  133. /package/templates/template_oa_jwt/public/src/components/{IFrame → iframe}/index.less +0 -0
  134. /package/templates/template_oa_jwt/public/src/components/{Layout/Basic → layout/basic}/index.less +0 -0
  135. /package/templates/template_oa_jwt/public/src/components/{Layout/CenterBody → layout/centerBody}/index.less +0 -0
  136. /package/templates/template_oa_jwt/public/src/components/{Layout/FormBlock → layout/formBlock}/index.less +0 -0
  137. /package/templates/template_oa_jwt/public/src/components/{Layout → layout}/index.less +0 -0
  138. /package/templates/template_oa_jwt/public/src/components/{Link → link}/index.less +0 -0
  139. /package/templates/template_oa_jwt/public/src/components/{Nav → nav}/index.less +0 -0
  140. /package/templates/template_oa_jwt/public/src/components/{Page/PageLoading → page/pageLoading}/index.less +0 -0
  141. /package/templates/template_oa_jwt/public/src/components/{Popup → popup}/index.less +0 -0
  142. /package/templates/template_oa_jwt/public/src/components/{Select/StaffSelect → select/staffSelect}/index.less +0 -0
  143. /package/templates/template_oa_jwt/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){
12
15
  let mock = require('@/mock');
13
16
  mock;
14
17
  }
15
18
 
19
+ // @ts-ignore
16
20
  window.appLog=(txt)=>{
17
21
  console.log(txt);
18
22
  }
19
23
 
20
24
  /* eslint-disable */
25
+ // @ts-ignore
21
26
  if(BUILD_ENV!='prod'){
27
+ // @ts-ignore
22
28
  let VConsole = require('vconsole');
29
+ // @ts-ignore
23
30
  const vConsole = new VConsole();
24
31
  setTimeout(() => {
25
32
  vConsole.setSwitchPosition(70, 10);
26
33
  }, 2000);
27
34
  }
28
35
 
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,25 +1,29 @@
1
+ // @ts-ignore
1
2
  import React, { useEffect, useState, useRef } from 'react';
2
- import { useParams, useSearchParams,useNavigate } from 'react-router-dom';
3
+ // @ts-ignore
4
+ import { useNavigate } from 'react-router-dom';
5
+ // @ts-ignore
6
+ import { Table, Input, Button, Form,Checkbox,Radio } from 'antd';
3
7
 
4
8
  import {usePaginationWithForm} from '@/hooks';
5
9
  import {GET_LIST} from '@/services/video';
6
10
  import {GET_STAFF_LIST,GET_DEP_LIST} from '@/services/common';
7
-
8
- import { Table, Input, Button, Form,Checkbox,Radio } from 'antd';
9
- import {FormBlockByTitle} from '@/components/Layout/FormBlock';
10
- import styles from './index.less';
11
+ import {FormBlockByTitle} from '@/components/layout/formBlock';
11
12
  import PageTitle from '@/pages/components/pageTitle';
12
13
  import TotalRecord from '@/pages/components/totalRecord';
13
- import {ShowErrorAlert,ShowAlert,ShowConfirm} from '@/components/Dialog';
14
- import ShowToast from '@/components/Toast';
15
- import Empty from '@/components/Empty';
16
- import FormRow from '@/components/FormRow';
17
- import FormTable from '@/components/FormTable';
18
- import UploadHelper from '@/components/Upload';
19
- import StaffSelect from '@/components/Select/StaffSelect';
20
- import DepSelect from '@/components/Select/DepSelect';
14
+ import {ShowErrorAlert,ShowAlert,ShowConfirm} from '@/components/dialog';
15
+ import ShowToast from '@/components/toast';
16
+ import Empty from '@/components/empty';
17
+ import FormRow from '@/components/formRow';
18
+ import FormTable from '@/components/formTable';
19
+ import UploadHelper from '@/components/upload';
20
+ import StaffSelect from '@/components/select/staffSelect';
21
+ import DepSelect from '@/components/select/depSelect';
21
22
  import ProviderApp from '@/provider/app';
22
23
 
24
+ // @ts-ignore
25
+ import styles from './index.less';
26
+
23
27
  const Page = () => {
24
28
  const providerApp = ProviderApp.useContainer();
25
29
  const navigate= useNavigate();
@@ -1,8 +1,27 @@
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';
5
+ // @ts-ignore
6
+ import { createContainer } from "unstated-next"
7
+
3
8
  import {setLogout} from '@/services';
4
9
 
5
- import { createContainer } from "unstated-next"
10
+
11
+
12
+ /**
13
+ * @typedef AppContaniner
14
+ * @property {boolean} loading - 当前是否是加载状态
15
+ * @property {(open:boolean)=>void} setLoading - 设置加载状态
16
+ * @property {object} nav - 导航栏配置
17
+ * @property {(option:object)=>void} setNav - 设置导航栏配置
18
+ * @property {()=>Promise} logout - 注销病退回登录界面
19
+ * @property {(user:object)=>void} setUser - 注销病退回登录界面
20
+ * @property {object} user - 注销病退回登录界面
21
+ *
22
+ */
23
+
24
+
6
25
 
7
26
  const useApp=() =>{
8
27
  const [search] = useSearchParams();
@@ -17,11 +36,14 @@ const useApp=() =>{
17
36
  }
18
37
 
19
38
  const logout=async ()=>{
39
+ // @ts-ignore
20
40
  if(BUILD_ENV=='localdebug'){
21
41
  navigate('/login');
22
42
  }else{
23
43
  let url = window.btoa(location.href);
44
+ // @ts-ignore
24
45
  let redirect=`${OA_HOST}/login?url=${url}`;
46
+ // @ts-ignore
25
47
  if(BUILD_ENV!='prod'){
26
48
  redirect+='&debug=1';
27
49
  }
@@ -47,6 +69,15 @@ const useApp=() =>{
47
69
  return action
48
70
  }
49
71
 
72
+ /**
73
+ * @typedef {object} AppProvider
74
+ * @property {function():AppContaniner} useContainer
75
+ * @property {React.ComponentType<any>} Provider
76
+ */
77
+
78
+ /**
79
+ * @type {AppProvider}
80
+ */
50
81
  const App = createContainer(useApp);
51
82
 
52
83
  export default App;
@@ -1,8 +1,10 @@
1
+ // @ts-ignore
1
2
  import React,{Suspense} from 'react';
3
+ // @ts-ignore
2
4
  import { Routes, Route, Navigate } from 'react-router-dom';
3
5
 
4
- import { LayoutBasic, Layout } from '@/components/Layout';
5
- import PageLoading from '@/components/Page/PageLoading';
6
+ import { LayoutBasic, Layout } from '@/components/layout';
7
+ import PageLoading from '@/components/page/pageLoading';
6
8
 
7
9
  import Login from '@/pages/login';
8
10
  // import {AuthLogin} from '@/components/Auth';
@@ -1,11 +1,13 @@
1
1
 
2
2
  import {GET_TOKEN,GET_DEFAULT_CROSS} from '@/services';
3
+ // @ts-ignore
3
4
  import axios from 'axios';
4
5
 
5
6
  /**
6
7
  * 获取员工列表
7
8
  */
8
9
  export async function GET_STAFF_LIST() {
10
+ // @ts-ignore
9
11
  let ret = await GET_DEFAULT_CROSS(`${OA_HOST}/common/getNewUserList`);
10
12
  return ret;
11
13
  // let response = await axios({
@@ -23,6 +25,7 @@ export async function GET_STAFF_LIST() {
23
25
  * 所有部门信息
24
26
  */
25
27
  export async function GET_DEP_LIST() {
28
+ // @ts-ignore
26
29
  return GET_DEFAULT_CROSS(`${OA_HOST}/common/getBenefitDept`);
27
30
  }
28
31
 
@@ -31,6 +34,7 @@ export async function GET_DEP_LIST() {
31
34
  * @returns
32
35
  */
33
36
  export function GET_COMPANY_LIST(){
37
+ // @ts-ignore
34
38
  return GET_DEFAULT_CROSS(`${OA_HOST}/filestore/list?status=1`);
35
39
  }
36
40
 
@@ -50,6 +54,7 @@ export async function POST_IMPORT_EXCEL(url, file, onProgress) {
50
54
  url: url,
51
55
  data: formdata,
52
56
  onUploadProgress: (e) => {
57
+ // @ts-ignore
53
58
  onProgress({ percent: `${e.loaded}/${e.total}` * 100 });
54
59
  },
55
60
  });
@@ -60,6 +65,7 @@ export async function POST_IMPORT_EXCEL(url, file, onProgress) {
60
65
  * 获取下载文件的url路径
61
66
  */
62
67
  export function GET_DOWNLOAD_FILE(s_name) {
68
+ // @ts-ignore
63
69
  return `${OA_HOST}/file/download?name=${s_name}`;
64
70
  }
65
71
 
@@ -80,6 +86,7 @@ export async function UPLOAD_FILE(file, param, onProgress) {
80
86
 
81
87
  let response = await axios({
82
88
  method: 'post',
89
+ // @ts-ignore
83
90
  url: `${OA_HOST}/file/upload`,
84
91
  data: formdata,
85
92
  xsrfCookieName: '',
@@ -87,6 +94,7 @@ export async function UPLOAD_FILE(file, param, onProgress) {
87
94
  withCredentials: true,
88
95
 
89
96
  onUploadProgress: (e) => {
97
+ // @ts-ignore
90
98
  let per = parseFloat((e.loaded / e.total) * 100).toFixed(0);
91
99
  onProgress({ percent: per });
92
100
  },
@@ -110,6 +118,9 @@ export async function UPLOAD_FILE(file, param, onProgress) {
110
118
  * types:array|string,['png','gif']|'png' 类型
111
119
  */
112
120
  export function CHECK_FILE_TYPE(types, filename) {
121
+ /**
122
+ * @type RegExp|string
123
+ */
113
124
  let reg = '';
114
125
 
115
126
  if (types.constructor === Array) {
@@ -1,9 +1,16 @@
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
+
8
+
4
9
  const axios = Axios.create();
10
+ // @ts-ignore
5
11
  console.log(`========API_ROOT:${API_HOST}========`);
6
12
 
13
+ // @ts-ignore
7
14
  export const API_ROOT = API_HOST;
8
15
  const tokenMode='header';//header,cookie
9
16
  const tokenName='Authorization';
@@ -29,6 +36,7 @@ export const setJwt = (value) => {
29
36
  jwt = value;
30
37
  };
31
38
 
39
+ // @ts-ignore
32
40
  window.setJwt=setJwt;
33
41
  export const setLogout=(fn)=>{
34
42
  logout=fn;
@@ -93,9 +101,23 @@ axios.interceptors.response.use(
93
101
  );
94
102
 
95
103
 
104
+ /**
105
+ * @typedef RequestOptions 发送请求的扩展信息
106
+ * @property {number|boolean} ttl=false - 接口缓存周期,开启后默认为2秒,ttl单位为毫秒
107
+ * @property {string|boolean} noInterceptors=false - 关闭拦截类型,'all'为关闭包括401、403在内的所有异常,默认情况下只拦截response.code不为0的情况
108
+ *
109
+ */
96
110
 
97
111
 
98
112
  let buffer = {};
113
+ /**
114
+ * @function
115
+ * @description 发送一个GET请求
116
+ * @param {string} url - 请求地址
117
+ * @param {Object} [param] - 请求的参数
118
+ * @param {RequestOptions} [options] - 扩展参数
119
+ * @returns {Promise<Object>}
120
+ */
99
121
  export async function GET_DEFAULT(url, param, options) {
100
122
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
101
123
  let now = Date.now();
@@ -128,6 +150,13 @@ export async function GET_DEFAULT(url, param, options) {
128
150
  return response && response.data ? response.data : null;
129
151
  }
130
152
 
153
+ /**
154
+ * @function
155
+ * @description 发送一个GET请求
156
+ * @param {string} url - 请求地址
157
+ * @param {Object} [param] - 请求的参数
158
+ * @returns {Promise<Object>}
159
+ */
131
160
  export async function GET_DEFAULT_CROSS(url, param) {
132
161
  if (param) param = qs.stringify(param, { arrayFormat: 'indices' });
133
162
 
@@ -141,7 +170,14 @@ export async function GET_DEFAULT_CROSS(url, param) {
141
170
  return response && response.data ? response.data : null;
142
171
  }
143
172
 
144
- export async function POST_DEFAULT(url, params, method, options) {
173
+ /**
174
+ * 发送一个POST请求
175
+ * @param {string} url - 请求地址
176
+ * @param {Object} [params] - 请求的参数
177
+ * @param {RequestOptions} [options] - 扩展参数
178
+ * @returns {Promise<Object>}
179
+ */
180
+ export async function POST_DEFAULT(url, params, options) {
145
181
  let data = params;
146
182
  // if (params) params = qs.stringify(params, { arrayFormat: 'indices' });
147
183
  // if (typeof params === 'string') {
@@ -151,7 +187,7 @@ export async function POST_DEFAULT(url, params, method, options) {
151
187
  // }
152
188
  let token= await GET_TOKEN();
153
189
  let response = await axios({
154
- method: method || 'POST',
190
+ method: 'POST',
155
191
  url: url,
156
192
  data:{
157
193
  _token:token,
@@ -163,6 +199,12 @@ export async function POST_DEFAULT(url, params, method, options) {
163
199
  return response && response.data ? response.data : null;
164
200
  }
165
201
 
202
+ /**
203
+ * 发送一个POST请求
204
+ * @param {string} url - 请求地址
205
+ * @param {Object} [params] - 请求的参数
206
+ * @returns {Promise<Object>}
207
+ */
166
208
  export async function POST_DEFAULT_CROSS(url, params) {
167
209
  let token= await GET_TOKEN();
168
210
 
@@ -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,17 @@
1
1
 
2
2
 
3
+ /**
4
+ * 打开一个第三方链接
5
+ * @param {string} link - 链接地址
6
+ * @param {string} [target='_blank'] - 打开方式,_blank:新窗口打开
7
+ */
3
8
  export const openLink = (link, target = '_blank') => {
4
9
  let domLink = document.createElement('a');
5
10
  domLink.href = link;
6
11
  domLink.setAttribute('target', target);
12
+ // @ts-ignore
7
13
  domLink.style.opacity = 0;
14
+ // @ts-ignore
8
15
  domLink.style.zIndex = -999;
9
16
  document.body.appendChild(domLink);
10
17
  domLink.click();
@@ -13,30 +20,38 @@ export const openLink = (link, target = '_blank') => {
13
20
  }, 200);
14
21
  }
15
22
 
23
+ /**
24
+ * 判断当前是否为移动端
25
+ * @returns {boolean}
26
+ */
16
27
  export const isMobile = () => {
17
28
  return navigator.userAgent.match(
18
29
  /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
19
- )
30
+ )?true:false
20
31
  }
21
32
 
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
33
 
34
+ /**
35
+ * 跳转URL-兼容飞书
36
+ * @param {string} url - 链接地址
37
+ * @param {object} [options] - 参数
38
+ * @param {boolean} [options.replace] - 是否要覆盖当前URL记录
39
+ * @param {boolean} [options.newWindow] - 是否新窗口中打开
40
+ * @param {boolean} [options.reload] - 是否重载当前页面
41
+ *
42
+ *
43
+ */
38
44
  export const jumpUrl=(url,options={})=>{
39
- const {replace,newWindow,reload}= options;
45
+ const {replace=false,newWindow=false,reload=false}= options;
46
+ if(!reload){
47
+ // @ts-ignore
48
+ if(window.knFeishu){
49
+ // @ts-ignore
50
+ window.knFeishu.ToHref(url,replace,newWindow);
51
+ return;
52
+ }
53
+ }
54
+
40
55
  if(reload){
41
56
  location.reload();
42
57
  return;
@@ -56,7 +71,9 @@ export const jumpUrl=(url,options={})=>{
56
71
 
57
72
  // 关闭页面
58
73
  export const closeWindow = () => {
74
+ // @ts-ignore
59
75
  if (window.knFeishu && window.knFeishu.closeWindow) {
76
+ // @ts-ignore
60
77
  window.knFeishu.closeWindow();
61
78
  } else {
62
79
  if (window.close) {
@@ -0,0 +1,6 @@
1
+ **/node_modules
2
+ **/package-lock.json
3
+ **/.DS_Store
4
+ **/dist
5
+ **/release
6
+
@@ -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
  }