ff-ui-plus 2.0.7

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 (319) hide show
  1. package/.nvmrc +1 -0
  2. package/.prettierrc.cjs +41 -0
  3. package/.stylelintignore +5 -0
  4. package/LICENSE +21 -0
  5. package/README.md +265 -0
  6. package/commitlint.config.cjs +162 -0
  7. package/global.d.ts +27 -0
  8. package/index.html +16 -0
  9. package/lib.sh +9 -0
  10. package/lint-staged.config.cjs +8 -0
  11. package/package.json +149 -0
  12. package/packages/components/adaptive-page/index.ts +5 -0
  13. package/packages/components/adaptive-page/src/index.vue +85 -0
  14. package/packages/components/adaptive-page/src/type.ts +9 -0
  15. package/packages/components/adaptive-page/style/css.ts +1 -0
  16. package/packages/components/adaptive-page/style/index.ts +1 -0
  17. package/packages/components/button/index.ts +5 -0
  18. package/packages/components/button/src/index.vue +41 -0
  19. package/packages/components/button/src/type.ts +11 -0
  20. package/packages/components/button/style/css.ts +1 -0
  21. package/packages/components/button/style/index.ts +1 -0
  22. package/packages/components/chart/index.ts +5 -0
  23. package/packages/components/chart/src/index.vue +121 -0
  24. package/packages/components/chart/src/type.ts +7 -0
  25. package/packages/components/chart/style/css.ts +1 -0
  26. package/packages/components/chart/style/index.ts +1 -0
  27. package/packages/components/checkbox/index.ts +3 -0
  28. package/packages/components/checkbox/src/checkbox.d.ts +5 -0
  29. package/packages/components/checkbox/src/index.vue +67 -0
  30. package/packages/components/checkbox/style/css.ts +1 -0
  31. package/packages/components/checkbox/style/index.ts +1 -0
  32. package/packages/components/date-picker/index.ts +5 -0
  33. package/packages/components/date-picker/src/index.vue +228 -0
  34. package/packages/components/date-picker/src/type.ts +22 -0
  35. package/packages/components/date-picker/style/css.ts +1 -0
  36. package/packages/components/date-picker/style/index.ts +1 -0
  37. package/packages/components/detail/index.ts +5 -0
  38. package/packages/components/detail/src/index.vue +102 -0
  39. package/packages/components/detail/src/renderLabel.vue +15 -0
  40. package/packages/components/detail/src/renderTooltip.vue +15 -0
  41. package/packages/components/detail/src/type.ts +28 -0
  42. package/packages/components/detail/style/css.ts +1 -0
  43. package/packages/components/detail/style/index.ts +1 -0
  44. package/packages/components/form/index.ts +5 -0
  45. package/packages/components/form/src/index.vue +407 -0
  46. package/packages/components/form/src/renderBtn.vue +15 -0
  47. package/packages/components/form/src/renderComp.vue +15 -0
  48. package/packages/components/form/src/type.ts +26 -0
  49. package/packages/components/form/style/css.ts +1 -0
  50. package/packages/components/form/style/index.ts +1 -0
  51. package/packages/components/index.ts +20 -0
  52. package/packages/components/input/index.ts +5 -0
  53. package/packages/components/input/src/index.vue +225 -0
  54. package/packages/components/input/src/type.ts +14 -0
  55. package/packages/components/input/style/css.ts +1 -0
  56. package/packages/components/input/style/index.ts +1 -0
  57. package/packages/components/layout-page/index.ts +4 -0
  58. package/packages/components/layout-page/src/index.vue +74 -0
  59. package/packages/components/layout-page/style/css.ts +1 -0
  60. package/packages/components/layout-page/style/index.ts +1 -0
  61. package/packages/components/layout-page-item/index.ts +3 -0
  62. package/packages/components/layout-page-item/src/index.vue +16 -0
  63. package/packages/components/layout-page-item/style/css.ts +1 -0
  64. package/packages/components/layout-page-item/style/index.ts +1 -0
  65. package/packages/components/module-form/index.ts +4 -0
  66. package/packages/components/module-form/src/index.vue +243 -0
  67. package/packages/components/module-form/src/moduleDetail.vue +61 -0
  68. package/packages/components/module-form/src/moduleForm.vue +88 -0
  69. package/packages/components/module-form/src/type.ts +16 -0
  70. package/packages/components/module-form/style/css.ts +1 -0
  71. package/packages/components/module-form/style/index.ts +1 -0
  72. package/packages/components/package.json +9 -0
  73. package/packages/components/query-condition/index.ts +4 -0
  74. package/packages/components/query-condition/src/index.vue +478 -0
  75. package/packages/components/query-condition/src/moreChoose.vue +159 -0
  76. package/packages/components/query-condition/src/renderComp.vue +15 -0
  77. package/packages/components/query-condition/src/type.ts +22 -0
  78. package/packages/components/query-condition/src/useComputed.ts +94 -0
  79. package/packages/components/query-condition/style/css.ts +1 -0
  80. package/packages/components/query-condition/style/index.ts +1 -0
  81. package/packages/components/radio/index.ts +3 -0
  82. package/packages/components/radio/src/index.vue +73 -0
  83. package/packages/components/radio/src/radio.d.ts +12 -0
  84. package/packages/components/radio/style/css.ts +1 -0
  85. package/packages/components/radio/style/index.ts +1 -0
  86. package/packages/components/select/index.ts +4 -0
  87. package/packages/components/select/src/index.vue +240 -0
  88. package/packages/components/select/src/type.ts +43 -0
  89. package/packages/components/select/style/css.ts +1 -0
  90. package/packages/components/select/style/index.ts +1 -0
  91. package/packages/components/select-icon/index.ts +4 -0
  92. package/packages/components/select-icon/src/index.vue +128 -0
  93. package/packages/components/select-icon/style/css.ts +1 -0
  94. package/packages/components/select-icon/style/index.ts +1 -0
  95. package/packages/components/select-table/index.ts +4 -0
  96. package/packages/components/select-table/src/ClickOutside.ts +106 -0
  97. package/packages/components/select-table/src/index.vue +851 -0
  98. package/packages/components/select-table/src/renderCol.vue +20 -0
  99. package/packages/components/select-table/src/type.ts +56 -0
  100. package/packages/components/select-table/src/useVirtualized.ts +86 -0
  101. package/packages/components/select-table/style/css.ts +1 -0
  102. package/packages/components/select-table/style/index.ts +1 -0
  103. package/packages/components/step-wizard/index.ts +4 -0
  104. package/packages/components/step-wizard/src/index.vue +99 -0
  105. package/packages/components/step-wizard/src/type.ts +17 -0
  106. package/packages/components/step-wizard/style/css.ts +1 -0
  107. package/packages/components/step-wizard/style/index.ts +1 -0
  108. package/packages/components/table/index.ts +5 -0
  109. package/packages/components/table/src/ColumnSet.vue +176 -0
  110. package/packages/components/table/src/TTableColumn.vue +100 -0
  111. package/packages/components/table/src/densitySet.vue +91 -0
  112. package/packages/components/table/src/firstColumn.vue +132 -0
  113. package/packages/components/table/src/index.vue +926 -0
  114. package/packages/components/table/src/operator.vue +246 -0
  115. package/packages/components/table/src/renderCol.vue +20 -0
  116. package/packages/components/table/src/renderHeader.vue +18 -0
  117. package/packages/components/table/src/singleEdit.vue +354 -0
  118. package/packages/components/table/src/singleEditCell.vue +303 -0
  119. package/packages/components/table/src/tableProps.ts +162 -0
  120. package/packages/components/table/src/useExpose.ts +74 -0
  121. package/packages/components/table/src/useVirtualized.ts +70 -0
  122. package/packages/components/table/style/css.ts +1 -0
  123. package/packages/components/table/style/index.ts +1 -0
  124. package/packages/components/tabs/index.ts +4 -0
  125. package/packages/components/tabs/src/index.vue +50 -0
  126. package/packages/components/tabs/style/css.ts +1 -0
  127. package/packages/components/tabs/style/index.ts +1 -0
  128. package/packages/components/timer-btn/index.ts +4 -0
  129. package/packages/components/timer-btn/src/index.vue +57 -0
  130. package/packages/components/timer-btn/style/css.ts +1 -0
  131. package/packages/components/timer-btn/style/index.ts +1 -0
  132. package/packages/components/utils/index.ts +142 -0
  133. package/packages/components/utils/install.ts +16 -0
  134. package/packages/eslint-config/build.config.ts +16 -0
  135. package/packages/eslint-config/dist/index.cjs +122 -0
  136. package/packages/eslint-config/dist/index.d.cts +92 -0
  137. package/packages/eslint-config/dist/index.d.mts +92 -0
  138. package/packages/eslint-config/dist/index.d.ts +92 -0
  139. package/packages/eslint-config/dist/index.mjs +120 -0
  140. package/packages/eslint-config/package.json +34 -0
  141. package/packages/eslint-config/src/index.ts +121 -0
  142. package/packages/ff-ui-plus/component.ts +55 -0
  143. package/packages/ff-ui-plus/defaults.ts +4 -0
  144. package/packages/ff-ui-plus/index.ts +9 -0
  145. package/packages/ff-ui-plus/make-installer.ts +10 -0
  146. package/packages/ff-ui-plus/package.json +117 -0
  147. package/packages/ff-ui-plus/version.ts +1 -0
  148. package/packages/hooks/index.ts +1 -0
  149. package/packages/hooks/package.json +9 -0
  150. package/packages/hooks/useLocale.ts +53 -0
  151. package/packages/locale/index.ts +11 -0
  152. package/packages/locale/lang/en.ts +157 -0
  153. package/packages/locale/lang/zh-cn.ts +155 -0
  154. package/packages/locale/package.json +12 -0
  155. package/packages/resolver/package.json +23 -0
  156. package/packages/resolver/src/index.ts +99 -0
  157. package/packages/theme-chalk/build.ts +76 -0
  158. package/packages/theme-chalk/dist/index.css +1 -0
  159. package/packages/theme-chalk/dist/src/adaptive-page.scss +48 -0
  160. package/packages/theme-chalk/dist/src/button.scss +23 -0
  161. package/packages/theme-chalk/dist/src/chart.scss +10 -0
  162. package/packages/theme-chalk/dist/src/checkbox.scss +0 -0
  163. package/packages/theme-chalk/dist/src/date-picker.scss +3 -0
  164. package/packages/theme-chalk/dist/src/detail.scss +7 -0
  165. package/packages/theme-chalk/dist/src/form.scss +104 -0
  166. package/packages/theme-chalk/dist/src/index.scss +19 -0
  167. package/packages/theme-chalk/dist/src/input.scss +0 -0
  168. package/packages/theme-chalk/dist/src/layout-page-item.scss +10 -0
  169. package/packages/theme-chalk/dist/src/layout-page.scss +37 -0
  170. package/packages/theme-chalk/dist/src/module-form.scss +335 -0
  171. package/packages/theme-chalk/dist/src/query-condition.scss +132 -0
  172. package/packages/theme-chalk/dist/src/radio.scss +0 -0
  173. package/packages/theme-chalk/dist/src/select-icon.scss +61 -0
  174. package/packages/theme-chalk/dist/src/select-table.scss +71 -0
  175. package/packages/theme-chalk/dist/src/select.scss +7 -0
  176. package/packages/theme-chalk/dist/src/step-wizard.scss +51 -0
  177. package/packages/theme-chalk/dist/src/table.scss +381 -0
  178. package/packages/theme-chalk/dist/src/tabs.scss +20 -0
  179. package/packages/theme-chalk/dist/src/timer-btn.scss +21 -0
  180. package/packages/theme-chalk/dist/t-adaptive-page.css +1 -0
  181. package/packages/theme-chalk/dist/t-button.css +1 -0
  182. package/packages/theme-chalk/dist/t-chart.css +1 -0
  183. package/packages/theme-chalk/dist/t-checkbox.css +0 -0
  184. package/packages/theme-chalk/dist/t-date-picker.css +1 -0
  185. package/packages/theme-chalk/dist/t-detail.css +1 -0
  186. package/packages/theme-chalk/dist/t-form.css +1 -0
  187. package/packages/theme-chalk/dist/t-input.css +0 -0
  188. package/packages/theme-chalk/dist/t-layout-page-item.css +1 -0
  189. package/packages/theme-chalk/dist/t-layout-page.css +1 -0
  190. package/packages/theme-chalk/dist/t-module-form.css +1 -0
  191. package/packages/theme-chalk/dist/t-query-condition.css +1 -0
  192. package/packages/theme-chalk/dist/t-radio.css +0 -0
  193. package/packages/theme-chalk/dist/t-select-icon.css +1 -0
  194. package/packages/theme-chalk/dist/t-select-table.css +1 -0
  195. package/packages/theme-chalk/dist/t-select.css +1 -0
  196. package/packages/theme-chalk/dist/t-step-wizard.css +1 -0
  197. package/packages/theme-chalk/dist/t-table.css +1 -0
  198. package/packages/theme-chalk/dist/t-tabs.css +1 -0
  199. package/packages/theme-chalk/dist/t-timer-btn.css +1 -0
  200. package/packages/theme-chalk/mixins/config.scss +8 -0
  201. package/packages/theme-chalk/mixins/function.scss +71 -0
  202. package/packages/theme-chalk/mixins/mixins.scss +79 -0
  203. package/packages/theme-chalk/package.json +21 -0
  204. package/packages/theme-chalk/src/adaptive-page.scss +48 -0
  205. package/packages/theme-chalk/src/button.scss +23 -0
  206. package/packages/theme-chalk/src/chart.scss +10 -0
  207. package/packages/theme-chalk/src/checkbox.scss +0 -0
  208. package/packages/theme-chalk/src/date-picker.scss +3 -0
  209. package/packages/theme-chalk/src/detail.scss +7 -0
  210. package/packages/theme-chalk/src/form.scss +104 -0
  211. package/packages/theme-chalk/src/index.scss +19 -0
  212. package/packages/theme-chalk/src/input.scss +0 -0
  213. package/packages/theme-chalk/src/layout-page-item.scss +10 -0
  214. package/packages/theme-chalk/src/layout-page.scss +37 -0
  215. package/packages/theme-chalk/src/module-form.scss +335 -0
  216. package/packages/theme-chalk/src/query-condition.scss +132 -0
  217. package/packages/theme-chalk/src/radio.scss +0 -0
  218. package/packages/theme-chalk/src/select-icon.scss +61 -0
  219. package/packages/theme-chalk/src/select-table.scss +71 -0
  220. package/packages/theme-chalk/src/select.scss +7 -0
  221. package/packages/theme-chalk/src/step-wizard.scss +51 -0
  222. package/packages/theme-chalk/src/table.scss +381 -0
  223. package/packages/theme-chalk/src/tabs.scss +20 -0
  224. package/packages/theme-chalk/src/timer-btn.scss +21 -0
  225. package/packages/types/global.ts +34 -0
  226. package/packages/types/index.ts +1 -0
  227. package/packages/types/package.json +10 -0
  228. package/packages/utils/build.config.ts +23 -0
  229. package/packages/utils/dist/cookie.cjs +1 -0
  230. package/packages/utils/dist/cookie.d.cts +16 -0
  231. package/packages/utils/dist/cookie.d.mts +16 -0
  232. package/packages/utils/dist/cookie.d.ts +16 -0
  233. package/packages/utils/dist/cookie.mjs +1 -0
  234. package/packages/utils/dist/day.cjs +1 -0
  235. package/packages/utils/dist/day.d.cts +37 -0
  236. package/packages/utils/dist/day.d.mts +37 -0
  237. package/packages/utils/dist/day.d.ts +37 -0
  238. package/packages/utils/dist/day.mjs +1 -0
  239. package/packages/utils/dist/file.cjs +1 -0
  240. package/packages/utils/dist/file.d.cts +61 -0
  241. package/packages/utils/dist/file.d.mts +61 -0
  242. package/packages/utils/dist/file.d.ts +61 -0
  243. package/packages/utils/dist/file.mjs +1 -0
  244. package/packages/utils/dist/index.cjs +1 -0
  245. package/packages/utils/dist/index.d.cts +13 -0
  246. package/packages/utils/dist/index.d.mts +13 -0
  247. package/packages/utils/dist/index.d.ts +13 -0
  248. package/packages/utils/dist/index.mjs +1 -0
  249. package/packages/utils/dist/is.cjs +1 -0
  250. package/packages/utils/dist/is.d.cts +117 -0
  251. package/packages/utils/dist/is.d.mts +117 -0
  252. package/packages/utils/dist/is.d.ts +117 -0
  253. package/packages/utils/dist/is.mjs +1 -0
  254. package/packages/utils/dist/letter.cjs +1 -0
  255. package/packages/utils/dist/letter.d.cts +12 -0
  256. package/packages/utils/dist/letter.d.mts +12 -0
  257. package/packages/utils/dist/letter.d.ts +12 -0
  258. package/packages/utils/dist/letter.mjs +1 -0
  259. package/packages/utils/dist/number.cjs +1 -0
  260. package/packages/utils/dist/number.d.cts +23 -0
  261. package/packages/utils/dist/number.d.mts +23 -0
  262. package/packages/utils/dist/number.d.ts +23 -0
  263. package/packages/utils/dist/number.mjs +1 -0
  264. package/packages/utils/dist/openExe.cjs +1 -0
  265. package/packages/utils/dist/openExe.d.cts +9 -0
  266. package/packages/utils/dist/openExe.d.mts +9 -0
  267. package/packages/utils/dist/openExe.d.ts +9 -0
  268. package/packages/utils/dist/openExe.mjs +1 -0
  269. package/packages/utils/dist/storage.cjs +1 -0
  270. package/packages/utils/dist/storage.d.cts +46 -0
  271. package/packages/utils/dist/storage.d.mts +46 -0
  272. package/packages/utils/dist/storage.d.ts +46 -0
  273. package/packages/utils/dist/storage.mjs +1 -0
  274. package/packages/utils/dist/validate.cjs +1 -0
  275. package/packages/utils/dist/validate.d.cts +32 -0
  276. package/packages/utils/dist/validate.d.mts +32 -0
  277. package/packages/utils/dist/validate.d.ts +32 -0
  278. package/packages/utils/dist/validate.mjs +1 -0
  279. package/packages/utils/dist/ws.cjs +1 -0
  280. package/packages/utils/dist/ws.d.cts +86 -0
  281. package/packages/utils/dist/ws.d.mts +86 -0
  282. package/packages/utils/dist/ws.d.ts +86 -0
  283. package/packages/utils/dist/ws.mjs +1 -0
  284. package/packages/utils/package.json +42 -0
  285. package/packages/utils/src/cookie.ts +24 -0
  286. package/packages/utils/src/day.ts +66 -0
  287. package/packages/utils/src/file.ts +173 -0
  288. package/packages/utils/src/index.ts +10 -0
  289. package/packages/utils/src/is.ts +159 -0
  290. package/packages/utils/src/letter.ts +15 -0
  291. package/packages/utils/src/number.ts +37 -0
  292. package/packages/utils/src/openExe.ts +45 -0
  293. package/packages/utils/src/storage.ts +77 -0
  294. package/packages/utils/src/validate.ts +55 -0
  295. package/packages/utils/src/ws.ts +191 -0
  296. package/pnpm-workspace.yaml +3 -0
  297. package/publish.sh +37 -0
  298. package/resolver.sh +9 -0
  299. package/scripts/build/all.ts +152 -0
  300. package/scripts/build/build.config.ts +10 -0
  301. package/scripts/build/dist/index.cjs +7 -0
  302. package/scripts/build/dist/index.d.ts +2 -0
  303. package/scripts/build/dist/index.mjs +12 -0
  304. package/scripts/build/index.ts +63 -0
  305. package/scripts/build/modules.ts +141 -0
  306. package/scripts/build/package.json +14 -0
  307. package/scripts/release/gen-version.ts +12 -0
  308. package/scripts/release/index.ts +209 -0
  309. package/scripts/utils/excludeFiles.ts +14 -0
  310. package/scripts/utils/index.ts +88 -0
  311. package/scripts/utils/main.ts +14 -0
  312. package/scripts/utils/paths.ts +40 -0
  313. package/scripts/utils/plugin.ts +61 -0
  314. package/tsconfig.base.json +23 -0
  315. package/tsconfig.vitest.json +11 -0
  316. package/tsconfig.web.json +18 -0
  317. package/typings/env.d.ts +22 -0
  318. package/typings/index.d.ts +161 -0
  319. package/vitest.config.ts +22 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @desc 校验链接地址
3
+ * @param url
4
+ * @returns
5
+ */
6
+ export function validateRegexUrl(url: string) {
7
+ const regex = new RegExp(
8
+ "^(https?:\\/\\/)?" + // protocol
9
+ "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // domain name
10
+ "((\\d{1,3}\\.){3}\\d{1,3}))" + // OR ip (v4) address
11
+ "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // port and path
12
+ "(\\?[;&a-z\\d%_.~+=-]*)?" + // query string
13
+ "(\\#[-a-z\\d_]*)?$",
14
+ "i"
15
+ )
16
+ return regex.test(url)
17
+ }
18
+
19
+ /**
20
+ * @desc 检验电话
21
+ * @param phone
22
+ * @returns
23
+ */
24
+ export const validatePhone = (phone: string) => {
25
+ const reg = /^1(3[0-9]|4[0-1,4-9]|5[0-3,5-9]|6[2567]|7[0-8]|8[0-9]|9[0-3,5-9])\d{8}$/
26
+ return reg.test(phone)
27
+ }
28
+
29
+ /**
30
+ * @desc 检验固定电话
31
+ * @param localPhone
32
+ * @returns
33
+ */
34
+ export const validateLocalPhone = (localPhone: string) => {
35
+ const reg = /^\d{3}-\d{7,8}|\d{4}-\d{7,8}$/
36
+ return reg.test(localPhone)
37
+ }
38
+
39
+ /**
40
+ * @desc 检验邮箱
41
+ * @param mail
42
+ * @returns
43
+ */
44
+ export const validateEmail = (mail: string) => {
45
+ // eslint-disable-next-line no-useless-escape
46
+ const reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
47
+ return reg.test(mail)
48
+ }
49
+
50
+ /**
51
+ * @desc 判断是否是可跳转URL
52
+ * @param {string} path
53
+ * @returns
54
+ */
55
+ export const validateExternal = (path: string) => /^(https?:|mailto:|tel:)/.test(path)
@@ -0,0 +1,191 @@
1
+ import qs from "qs"
2
+
3
+ /**
4
+ * setTimeout 类型
5
+ */
6
+ type Timeout = ReturnType<typeof setTimeout>
7
+
8
+ /**
9
+ * setInterval 类型
10
+ */
11
+ type Interval = ReturnType<typeof setInterval>
12
+
13
+ /**
14
+ * 允许null的泛型
15
+ */
16
+ type Nullable<T> = T | null
17
+
18
+ /**
19
+ * 默认重连次数
20
+ */
21
+ const reconnectMaxCount = 3
22
+ /**
23
+ * 默认心跳信息
24
+ */
25
+ const message = "ping"
26
+ /**
27
+ * 默认心跳间隔
28
+ */
29
+ const interval = 3000
30
+
31
+ /**
32
+ * 默认延时时间
33
+ */
34
+ const timeout = 1000
35
+
36
+ type AutoReconnect = {
37
+ /**
38
+ *重连尝试次数 默认 3
39
+ */
40
+ reconnectMaxCount?: number
41
+ }
42
+
43
+ type Heartbeat = {
44
+ /**
45
+ * 心跳信息 默认`ping`
46
+ */
47
+ message: string
48
+ /**
49
+ * 心跳间隔时间 默认 `3000` 毫秒
50
+ */
51
+ interval: number
52
+ }
53
+
54
+ export interface WSOptions {
55
+ /**
56
+ * 是否自动重连 默认`true`
57
+ */
58
+ autoReconnect: boolean | AutoReconnect
59
+ /**
60
+ * 心跳 默认`false`
61
+ */
62
+ heartbeat: boolean | Heartbeat
63
+ /**
64
+ * url 携带的参数
65
+ */
66
+ query: Record<string, string>
67
+ }
68
+
69
+ class WS {
70
+ url: string
71
+ socket: WebSocket | null = null
72
+ reconnectCount = 0
73
+ delay: Nullable<Timeout> = null
74
+ timer: Nullable<Interval> = null
75
+ autoReconnect: WSOptions["autoReconnect"]
76
+ heartbeat: WSOptions["heartbeat"]
77
+ query: WSOptions["query"]
78
+
79
+ constructor(url?: string, options?: WSOptions) {
80
+ const { autoReconnect = true, query = {}, heartbeat = false } = options || {}
81
+ this.autoReconnect = autoReconnect
82
+ this.heartbeat = heartbeat
83
+ this.query = query
84
+
85
+ this.url = `${url}` + qs.stringify({ ...this.query }, { addQueryPrefix: true })
86
+
87
+ // 开启连接
88
+ this.connect()
89
+ }
90
+
91
+ /**
92
+ * 连接
93
+ */
94
+ connect(): void {
95
+ this.close()
96
+ this.socket = new WebSocket(this.url)
97
+ this.onError()
98
+ this.onOpen()
99
+ }
100
+
101
+ /**
102
+ * 监听连接
103
+ */
104
+ onOpen(): void {
105
+ if (this.socket) {
106
+ this.socket.onopen = () => {
107
+ this.send("ping")
108
+ // 开启心跳
109
+ this.heartbeat && this.startHeartbeat()
110
+ }
111
+ }
112
+ }
113
+
114
+ /**
115
+ * 开启心跳
116
+ */
117
+ startHeartbeat(): void {
118
+ const msg = (this.heartbeat as Heartbeat)?.message || message
119
+ const int = (this.heartbeat as Heartbeat)?.interval || interval
120
+ this.timer = setInterval(() => {
121
+ this.send(msg)
122
+ }, int)
123
+ }
124
+
125
+ /**
126
+ * 监听错误
127
+ */
128
+ onError(): void {
129
+ if (this.socket) {
130
+ this.socket.onerror = () => {
131
+ const count = (this.autoReconnect as AutoReconnect)?.reconnectMaxCount || reconnectMaxCount
132
+ if (this.autoReconnect && this.reconnectCount < count) {
133
+ this.reconnectCount++
134
+ this.connect()
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ /**
141
+ * 关闭连接
142
+ */
143
+ close(): void {
144
+ this.socket && this.socket.close()
145
+ this.delay && clearTimeout(this.delay)
146
+ this.timer && clearInterval(this.timer)
147
+ this.socket = null
148
+ }
149
+
150
+ /**
151
+ * 监听消息
152
+ * @param callback
153
+ */
154
+ onMessage(callback: (...data: any[]) => any): void {
155
+ if (this.socket) {
156
+ this.socket.onmessage = data => {
157
+ try {
158
+ const res = JSON.parse(data.data)
159
+ callback(res)
160
+ } catch (err) {
161
+ callback(data)
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ /**
168
+ * 发送消息
169
+ * @param data
170
+ */
171
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void {
172
+ if (!this.socket) return
173
+ // 状态为 `1-开启状态` 直接发送
174
+ if (this.socket.readyState === this.socket.OPEN) {
175
+ this.socket.send(JSON.stringify(data))
176
+ // 状态为 `0-开启状态` 则延后调用
177
+ } else if (this.socket.readyState === this.socket.CONNECTING) {
178
+ this.delay = setTimeout(() => {
179
+ this.socket?.send(data)
180
+ }, timeout)
181
+ // 状态为 `2-关闭中 3-关闭状态` 则重新连接
182
+ } else {
183
+ this.connect()
184
+ this.delay = setTimeout(() => {
185
+ this.socket?.send(data)
186
+ }, timeout)
187
+ }
188
+ }
189
+ }
190
+
191
+ export { WS }
@@ -0,0 +1,3 @@
1
+ packages:
2
+ - packages/*
3
+ - docs
package/publish.sh ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ npm run clean
5
+
6
+ npm run build
7
+ cd dist/ff-ui-plus
8
+ npm publish --registry=https://registry.npmjs.org/
9
+ echo "Successfully published ff-ui-plus"
10
+ cd -
11
+
12
+ cd packages/utils
13
+ echo "build utils..."
14
+ npm run build
15
+ echo "publish utils..."
16
+ npm publish --registry=https://registry.npmjs.org/
17
+ echo "Successfully published utils"
18
+ cd -
19
+
20
+ cd packages/resolver
21
+ echo "build resolver..."
22
+ npm run build
23
+ echo "publish resolver..."
24
+ npm publish --registry=https://registry.npmjs.org/
25
+ echo "Successfully published resolver"
26
+ cd -
27
+
28
+ cd packages/eslint-config
29
+ echo "build eslint-config..."
30
+ npm run build
31
+ echo "publish eslint-config..."
32
+ npm publish --registry=https://registry.npmjs.org/
33
+ echo "Successfully published eslint-config"
34
+ cd -
35
+
36
+ echo "✅ Publish completed"
37
+ exit
package/resolver.sh ADDED
@@ -0,0 +1,9 @@
1
+ set -e
2
+
3
+ cd packages/resolver
4
+ echo "build resolver..."
5
+ npm run build
6
+ echo "publish resolver..."
7
+ npm publish --registry=https://registry.npmjs.org/
8
+ echo "Successfully published resolver"
9
+ cd -
@@ -0,0 +1,152 @@
1
+ import { resolve, basename } from "path"
2
+ import vuePlugin from "@vitejs/plugin-vue"
3
+ import postcss from "rollup-plugin-postcss"
4
+ import autoprefixer from "autoprefixer"
5
+ import fs from "fs"
6
+ import cssnano from "cssnano"
7
+ import { rollup, Plugin } from "rollup"
8
+ import consola from "consola"
9
+ import { nodeResolve } from "@rollup/plugin-node-resolve"
10
+ import commonjs from "@rollup/plugin-commonjs"
11
+ import esbuild, { minify as minifyPlugin } from "rollup-plugin-esbuild"
12
+ import glob from 'fast-glob'
13
+ import { camelCase, upperFirst } from 'lodash'
14
+ import { pcOutput, pcRoot, projPackage, localesRoot } from '../utils/paths'
15
+ // import { pcOutput, pcRoot, projPackage } from "../utils/paths"
16
+ import {
17
+ writeBundles,
18
+ formatBundleFilename,
19
+ PKG_CAMEL_CASE_NAME,
20
+ PKG_NAME,
21
+ PKG_CAMEL_CASE_LOCAL_NAME,
22
+ target
23
+ } from "../utils"
24
+ import { external } from "../utils/main"
25
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26
+ // @ts-ignore
27
+ import banner2 from "rollup-plugin-banner2"
28
+ import { TuiPlusAlias, TuiPlusClearConsole } from "../utils/plugin"
29
+
30
+ const pkg = JSON.parse(fs.readFileSync(projPackage, "utf-8"))
31
+
32
+ const banner = `/*! ${PKG_NAME} v${pkg.version} */\n`
33
+
34
+ const buildAll = async (minify?: boolean) => {
35
+ const plugins = [
36
+ TuiPlusClearConsole(),
37
+ TuiPlusAlias(),
38
+ vuePlugin({ isProduction: true }) as Plugin,
39
+ nodeResolve({
40
+ extensions: [".mjs", ".js", ".json", ".ts"]
41
+ }),
42
+ commonjs(),
43
+ banner2(() => banner),
44
+ esbuild({
45
+ sourceMap: false,
46
+ target: target,
47
+ loaders: {
48
+ ".vue": "ts"
49
+ }
50
+ })
51
+ ]
52
+
53
+ if (minify) {
54
+ plugins.push(
55
+ minifyPlugin({
56
+ target: target,
57
+ sourceMap: false
58
+ })
59
+ )
60
+ plugins.push(
61
+ postcss({
62
+ extract: true,
63
+ plugins: [autoprefixer(), cssnano()]
64
+ })
65
+ )
66
+ } else {
67
+ plugins.push(
68
+ postcss({
69
+ extract: true,
70
+ plugins: [autoprefixer()]
71
+ })
72
+ )
73
+ }
74
+
75
+ const bundle = await rollup({
76
+ input: resolve(pcRoot, "index.ts"),
77
+ plugins,
78
+ external: external,
79
+ treeshake: true
80
+ })
81
+
82
+ await writeBundles(bundle, [
83
+ {
84
+ format: "umd",
85
+ file: resolve(pcOutput, formatBundleFilename("index", minify, "js")),
86
+ exports: "named",
87
+ name: PKG_CAMEL_CASE_NAME,
88
+ globals: {
89
+ vue: "Vue",
90
+ "element-plus": "ElementPlus"
91
+ },
92
+ sourcemap: false
93
+ },
94
+ {
95
+ format: "esm",
96
+ file: resolve(pcOutput, formatBundleFilename("index", minify, "mjs")),
97
+ sourcemap: false
98
+ }
99
+ ])
100
+ const msg = minify
101
+ ? "Successfully build compressed umd and esm!"
102
+ : "Successfully build into umd and esm!"
103
+ consola.success(msg)
104
+ }
105
+
106
+ async function buildLocale(minify: boolean) {
107
+ const files = await glob(`**/*.ts`, {
108
+ cwd: resolve(localesRoot, 'lang'),
109
+ absolute: true
110
+ })
111
+ return Promise.all(
112
+ files.map(async file => {
113
+ const filename = basename(file, '.ts')
114
+ const name = upperFirst(camelCase(filename))
115
+
116
+ const bundle = await rollup({
117
+ input: file,
118
+ plugins: [
119
+ esbuild({
120
+ minify,
121
+ sourceMap: false,
122
+ target
123
+ })
124
+ ]
125
+ })
126
+ await writeBundles(bundle, [
127
+ {
128
+ format: 'umd',
129
+ file: resolve(pcOutput, 'locale', formatBundleFilename(filename, minify, 'js')),
130
+ exports: 'default',
131
+ name: `${PKG_CAMEL_CASE_LOCAL_NAME}${name}`,
132
+ sourcemap: false,
133
+ banner
134
+ },
135
+ {
136
+ format: 'esm',
137
+ file: resolve(pcOutput, 'locale', formatBundleFilename(filename, minify, 'mjs')),
138
+ sourcemap: false,
139
+ banner
140
+ }
141
+ ])
142
+ })
143
+ ).then(() => {
144
+ const msg = minify ? 'Successfully build compressed locale!' : 'Successfully build into locale!'
145
+ consola.success(msg)
146
+ })
147
+ }
148
+
149
+ const task = [buildAll(false), buildAll(true), buildLocale(false), buildLocale(true)]
150
+ // const task = [buildAll(false), buildAll(true)]
151
+
152
+ export default task
@@ -0,0 +1,10 @@
1
+ import { defineBuildConfig } from 'unbuild'
2
+
3
+ export default defineBuildConfig({
4
+ entries: ['index'],
5
+ clean: true,
6
+ declaration: true,
7
+ rollup: {
8
+ emitCJS: true
9
+ }
10
+ })
@@ -0,0 +1,7 @@
1
+ module.exports = require("D:/zl/ai大模型/t-ui-plus-master/node_modules/.pnpm/jiti@1.21.7/node_modules/jiti/lib/index.js")(null, {
2
+ "esmResolve": true,
3
+ "interopDefault": true,
4
+ "alias": {
5
+ "@ff-ui-plus/build": "D:/zl/ai大模型/t-ui-plus-master/scripts/build"
6
+ }
7
+ })("D:/zl/ai大模型/t-ui-plus-master/scripts/build/index.ts")
@@ -0,0 +1,2 @@
1
+ export * from "D:/zl/ai大模型/t-ui-plus-master/scripts/build/index";
2
+ export { default } from "D:/zl/ai大模型/t-ui-plus-master/scripts/build/index";
@@ -0,0 +1,12 @@
1
+ import jiti from "file:///D:/zl/ai%E5%A4%A7%E6%A8%A1%E5%9E%8B/t-ui-plus-master/node_modules/.pnpm/jiti@1.21.7/node_modules/jiti/lib/index.js";
2
+
3
+ /** @type {import("D:/zl/ai大模型/t-ui-plus-master/scripts/build/index")} */
4
+ const _module = jiti(null, {
5
+ "esmResolve": true,
6
+ "interopDefault": true,
7
+ "alias": {
8
+ "@ff-ui-plus/build": "D:/zl/ai大模型/t-ui-plus-master/scripts/build"
9
+ }
10
+ })("D:/zl/ai大模型/t-ui-plus-master/scripts/build/index.ts");
11
+
12
+ export default _module;
@@ -0,0 +1,63 @@
1
+ import { resolve } from 'path'
2
+ import { copyFile, readFile, writeFile } from 'fs/promises'
3
+ import consola from 'consola'
4
+ import { buildOutput, pcOutput, projRoot, pcPackage } from '../utils/paths'
5
+ import { copy } from 'fs-extra'
6
+ import all from './all'
7
+ import modules from './modules'
8
+
9
+ const copyFiles = () =>
10
+ Promise.all([
11
+ copyFile(pcPackage, resolve(pcOutput, 'package.json')),
12
+ copyFile(resolve(projRoot, 'README.md'), resolve(pcOutput, 'README.md')),
13
+ copyFile(resolve(projRoot, 'global.d.ts'), resolve(pcOutput, 'global.d.ts')),
14
+ copyFile(resolve(projRoot, 'typings/index.d.ts'), resolve(pcOutput, 'index.d.ts'))
15
+ ])
16
+
17
+ const copyDts = async () => {
18
+ const src = resolve(buildOutput, 'types')
19
+
20
+ /**
21
+ * copy es dts
22
+ */
23
+ const targetES = resolve(pcOutput, 'es')
24
+ await copy(src, targetES)
25
+
26
+ /**
27
+ * copy lib dts
28
+ */
29
+ const targetLib = resolve(pcOutput, 'lib')
30
+ await copy(src, targetLib)
31
+
32
+ /**
33
+ * copy lang dts
34
+ */
35
+ const lang = resolve(src, 'locale', 'lang')
36
+ const targetLocale = resolve(pcOutput, 'locale')
37
+ await copy(lang, targetLocale)
38
+ }
39
+
40
+ const updateVersion = async () => {
41
+ const pcOutputPkg = resolve(pcOutput, 'package.json')
42
+ const mainPackageInfo = await readFile(pcOutputPkg, 'utf-8')
43
+ const packageInfo = await readFile(resolve(projRoot, 'package.json'), 'utf-8')
44
+ const mainPkg = JSON.parse(mainPackageInfo)
45
+ const pkg = JSON.parse(packageInfo)
46
+ mainPkg.version = pkg.version
47
+ await writeFile(pcOutputPkg, JSON.stringify(mainPkg, null, 2) + '\n')
48
+ }
49
+
50
+ const task = [...all, ...modules]
51
+
52
+ Promise.all(task)
53
+ .then(async () => {
54
+ await copyDts()
55
+ consola.success('Successfully copied definition file!')
56
+ await copyFiles()
57
+ consola.success('Successfully copied package.json and README.md and global.d.ts!')
58
+ await updateVersion()
59
+ consola.success('Successfully updated version!')
60
+ })
61
+ .catch(err => {
62
+ console.log(err)
63
+ })
@@ -0,0 +1,141 @@
1
+ import { resolve } from 'path'
2
+ import consola from 'consola'
3
+ import { rollup, Plugin } from 'rollup'
4
+ import { nodeResolve } from '@rollup/plugin-node-resolve'
5
+ import commonjs from '@rollup/plugin-commonjs'
6
+ import esbuild from 'rollup-plugin-esbuild'
7
+ import glob from 'fast-glob'
8
+ import vuePlugin from '@vitejs/plugin-vue'
9
+ import postcss from 'rollup-plugin-postcss'
10
+ import autoprefixer from 'autoprefixer'
11
+ import dts from 'vite-plugin-dts'
12
+ import cssnano from 'cssnano'
13
+ import type { OutputOptions, ModuleFormat } from 'rollup'
14
+ import { pcOutput, pcRoot, pkgRoot, TSCONFIG_PATH, DTS_OUT_DIR } from '../utils/paths'
15
+ import { target, writeBundlesFunction, pathRewriter, cssResolver } from '../utils'
16
+ import { externalModules, excludeFiles } from '../utils/main'
17
+ import {
18
+ TuiPlusAlias,
19
+ TuiPlusExternal,
20
+ TuiPlusClearConsole
21
+ } from '../utils/plugin'
22
+
23
+ const buildConfig = {
24
+ esm: {
25
+ module: 'ESNext',
26
+ format: 'esm',
27
+ ext: 'mjs',
28
+ output: {
29
+ name: 'es',
30
+ path: resolve(pcOutput, 'es')
31
+ }
32
+ },
33
+ cjs: {
34
+ module: 'CommonJS',
35
+ format: 'cjs',
36
+ ext: 'js',
37
+ output: {
38
+ name: 'lib',
39
+ path: resolve(pcOutput, 'lib')
40
+ }
41
+ }
42
+ }
43
+ const buildConfigEntries = Object.entries(buildConfig)
44
+
45
+ const buildModules = async () => {
46
+ const input = excludeFiles(
47
+ await glob('**/*.{js,ts,vue}', {
48
+ cwd: pkgRoot,
49
+ absolute: true,
50
+ onlyFiles: true
51
+ })
52
+ )
53
+
54
+ const getBundle = async (options: OutputOptions) => {
55
+ const plugins = [
56
+ TuiPlusClearConsole(),
57
+ TuiPlusExternal(options),
58
+ TuiPlusAlias(),
59
+ vuePlugin({ isProduction: true }) as Plugin,
60
+ nodeResolve({
61
+ extensions: ['.mjs', '.js', '.json', '.ts']
62
+ }),
63
+ commonjs(),
64
+ esbuild({
65
+ sourceMap: false,
66
+ target: target,
67
+ loaders: {
68
+ '.vue': 'ts'
69
+ }
70
+ }),
71
+ postcss({
72
+ namedExports: true,
73
+ extract: true,
74
+ plugins: [autoprefixer(), cssnano()]
75
+ })
76
+ ]
77
+
78
+ const config = {
79
+ input,
80
+ external: externalModules,
81
+ plugins:
82
+ options.format === 'esm'
83
+ ? [
84
+ ...plugins,
85
+ dts({
86
+ entryRoot: pkgRoot,
87
+ tsconfigPath: TSCONFIG_PATH,
88
+ outDir: DTS_OUT_DIR,
89
+ staticImport: true,
90
+ insertTypesEntry: false,
91
+ cleanVueFileName: false,
92
+ copyDtsFiles: false,
93
+ strictOutput: true,
94
+ exclude: [
95
+ resolve(pkgRoot, 'eslint-config'),
96
+ resolve(pkgRoot, 'utils'),
97
+ resolve(pkgRoot, 'resolver'),
98
+ resolve(pkgRoot, 'theme-chalk')
99
+ ],
100
+ resolvers: [cssResolver],
101
+ beforeWriteFile: (filePath: string, content: string) => {
102
+ let tempPath = filePath
103
+ let code = pathRewriter(content)
104
+ if (filePath.includes('dist/types/ff-ui-plus')) {
105
+ tempPath = filePath.replace('dist/types/ff-ui-plus', 'dist/types')
106
+ }
107
+ // */style/index */style/css
108
+ if (filePath.includes('style/index') || filePath.includes('style/css')) {
109
+ code = JSON.parse(content)
110
+ }
111
+ return {
112
+ filePath: tempPath,
113
+ content: code
114
+ }
115
+ }
116
+ })
117
+ ]
118
+ : plugins,
119
+ treeshake: false
120
+ }
121
+ return await rollup(config)
122
+ }
123
+
124
+ await writeBundlesFunction(
125
+ getBundle,
126
+ buildConfigEntries.map(([module, config]): OutputOptions => {
127
+ return {
128
+ format: config.format as ModuleFormat,
129
+ dir: config.output.path,
130
+ exports: module === 'cjs' ? 'named' : undefined,
131
+ preserveModules: true,
132
+ preserveModulesRoot: pcRoot,
133
+ sourcemap: false,
134
+ entryFileNames: `[name].${config.ext}`
135
+ }
136
+ })
137
+ )
138
+ consola.success('Successfully build into modules!')
139
+ }
140
+
141
+ export default [buildModules()]