Compare commits

...
491 Commits
Author SHA1 Message Date
jialin 66e8f83395 fix: did not cache workers and clusters in model files 2025-12-31 10:23:15 +08:00
jialin 41ebceca8f chore: static iconfont files 2025-12-29 15:40:36 +08:00
jialin 632685672c fix: wheel event passive 2025-12-29 15:28:40 +08:00
jialin bd2e4bb633 docs: hygon notes 2025-12-29 09:36:48 +08:00
jialin 835633d44b fix: help menu item clickable area 2025-12-26 18:18:32 +08:00
EVGENY Mandjialin 75773e6b00 Update models.ts 2025-12-26 18:16:33 +08:00
EVGENY Mandjialin a21b9b5244 Update users.ts 2025-12-26 18:16:02 +08:00
EVGENY Mandjialin 38bf76dc14 Update common.ts 2025-12-26 18:15:29 +08:00
EVGENY Mandjialin 9461341104 Update clusters.ts 2025-12-26 18:15:05 +08:00
jialin 5b5b2c6364 fix: chat compare switch model meta 2025-12-26 17:29:36 +08:00
jialin a006263e51 fix: add worker to default cluster 2025-12-26 12:08:30 +08:00
jialin febdd38f7c fix: set submitloading as false in catch 2025-12-26 09:48:10 +08:00
jialin 1b4d335b09 fix: store hideModel value in global session 2025-12-25 20:36:48 +08:00
jialin 725409a576 fix: image seed do no clear 2025-12-25 17:57:11 +08:00
jialin 9b25cc51e4 style: user rank chart 2025-12-25 17:57:11 +08:00
jialin 9dcdb6b6e7 fix: reset userSettings first login 2025-12-25 13:14:59 +08:00
jialin 73b987358f fix(style): cluster options 2025-12-24 20:52:48 +08:00
jialin 84c2bf130c style: cluster selector 2025-12-24 20:37:20 +08:00
jialin b25189feea fix: cancel sorting 2025-12-24 15:40:19 +08:00
jialin a9b58a5564 fix: cluster filter do not work in dashboard 2025-12-24 12:20:56 +08:00
jialin 530b20c633 chore: add resource modal button text 2025-12-24 10:53:53 +08:00
jialin fa0aeac10b fix: remove default sorting status on UI 2025-12-23 20:54:16 +08:00
jialin 1b661bb8cd feat: set default cluster 2025-12-23 20:54:16 +08:00
jialin 530e8f7537 fix: replicas, ready_replicas sorting 2025-12-23 18:35:33 +08:00
jialin 9e019a98f6 fix: click create hide modal 2025-12-23 10:51:58 +08:00
jialin 10c6cf9f7e fix: init image seed 2025-12-23 10:51:58 +08:00
jialin 480b238e44 fix: expand all model clear instances cache 2025-12-23 10:51:58 +08:00
jialin 32bdbc693a fix: onTableChange only handles sorting 2025-12-22 19:41:52 +08:00
jialin ab146b6b6b fix: allow to enter seed 2025-12-22 18:11:46 +08:00
jialin 763929eafc fix: instance backend data ui compatability with old data 2025-12-22 18:11:46 +08:00
jialin 711b3fee98 fix: user guidance when no resource 2025-12-22 18:11:46 +08:00
jialin 0d0592eee9 fix: sorter tooltip 2025-12-22 16:41:44 +08:00
jialin cc7948ba45 fix: update Server as GPUStack Server 2025-12-22 16:19:47 +08:00
jialin 7e25b64689 fix: remove instance from cache after deleting 2025-12-22 16:19:47 +08:00
Yuxing Dengandjialin d844cdadb5 fix: update advertise address title and description 2025-12-22 15:14:29 +08:00
jialin e3b3f51e87 fix: ignore the sort_by when no data 2025-12-22 11:57:57 +08:00
jialin 45efda7f1d fix: single sorted field, remove token 2025-12-22 10:10:35 +08:00
jialin db45c861e4 feat: models filter by state 2025-12-21 21:37:05 +08:00
jialin 42f8e6a6d9 chore: set col order 2025-12-21 21:37:05 +08:00
jialin 23a761226a feat: table list sorter 2025-12-21 21:37:05 +08:00
jialin 6738dfe0d3 fix: anyway submit disabled when no catalog specs 2025-12-19 20:33:25 +08:00
jialin 6e16b2eb0c fix: submit pool data from a validate failed form 2025-12-19 20:33:25 +08:00
jialin 707eb15465 fix: update command of adding worker 2025-12-19 20:33:25 +08:00
jialin 8008099e71 fix: image default seed 2025-12-19 20:33:25 +08:00
jialin 79ccb96c95 fix: edit worker_config 2025-12-19 16:44:52 +08:00
jialin bd76934e40 fix: delete worker pool 2025-12-19 15:19:27 +08:00
jialin bb793a41fc fix: entrypoint do not display in edit 2025-12-19 15:00:10 +08:00
jialin ad048a92ed feat: backend entrypoint 2025-12-19 14:40:20 +08:00
jialin 14d944ad2f style: cluster advanced scroller 2025-12-18 20:03:00 +08:00
jialin e1b8b5696c fix: update instance backend field 2025-12-18 17:29:07 +08:00
jialin 78368e9979 fix: cluster worker config issues 2025-12-18 17:29:07 +08:00
jialin e83bff6923 chore: worker ip 2025-12-18 14:06:32 +08:00
jialin e6c12d81ea fix: edit worker pool miss data 2025-12-18 14:06:32 +08:00
jialin 3a73d0c1b2 style: worker added info status 2025-12-18 12:19:31 +08:00
jialin b524587a9a fix: add worker button do not work 2025-12-18 10:56:45 +08:00
jialin e4bd753355 style: no resource modal 2025-12-17 19:58:28 +08:00
jialin 30536cb04a fix: remove advanced agrs in image 2025-12-17 16:15:34 +08:00
jialin da1efa9270 fix: password length 64 2025-12-17 16:15:34 +08:00
jialin bd6f4b3f76 fix: add worker, create cluster 2025-12-17 14:59:07 +08:00
jialin 5e48d75ead fix: add worker message 2025-12-17 14:59:07 +08:00
jialin bd46fcdc75 fix: container name in add worker 2025-12-17 14:59:07 +08:00
jialin 6968f9fa6b feat: worker_config 2025-12-16 18:43:28 +08:00
jialin 5225fd328d fix: backend framework options 2025-12-16 11:11:24 +08:00
jialin fa42474612 chore: worker added message 2025-12-15 15:13:57 +08:00
jialin d2eda78af0 fix: add worker command container_name 2025-12-15 10:18:16 +08:00
jialin 7a0ee6aac4 style: column wrapper srollable style 2025-12-13 19:47:48 +08:00
jialin b327eedb45 fix: logout error 2025-12-12 17:26:06 +08:00
jialin a68e3ff9da fix: no spec list for catalog 2025-12-12 17:22:28 +08:00
jialin 0500dd2e35 fix: query catalog spec, default_version check 2025-12-12 17:08:30 +08:00
jialin cb43131ccb fix: add worker command 2025-12-12 11:14:57 +08:00
jialin 883e0ab115 feat: get initial password 2025-12-12 11:14:57 +08:00
jialin b189160888 fix: docs for gpu link 404 2025-12-11 18:14:25 +08:00
jialin 3dbb0de683 feat: add resource for first login 2025-12-11 17:50:39 +08:00
jialin b38bc8a207 fix: table sorter 2025-12-11 13:33:41 +08:00
jialin 3328828da6 refactor: card list resize container 2025-12-11 13:33:41 +08:00
jialin 7fdabd90a5 fix: update add worker command 2025-12-10 15:50:53 +08:00
jialin d8452e98f5 style: drawer styles 2025-12-10 15:50:53 +08:00
jialin dda2213593 style: workers page no page container 2025-12-10 15:50:53 +08:00
jialin 04f995b80c style: resize terminal height 2025-12-10 15:50:53 +08:00
jialin a08f1e2512 chore: rename ground-left as ground-llm 2025-12-10 15:50:53 +08:00
jialin af4849d6cc style: terminal panel 2025-12-10 15:50:53 +08:00
jialin 087675889f feat: model cache volume mount, clear gpu selector 2025-12-09 19:07:40 +08:00
jialin daa10617c0 chore: prefetch chunk file 2025-12-05 13:31:56 +08:00
jialin c3b5c13cc5 fix: show info when adding worker error 2025-12-05 11:45:44 +08:00
jialin 1dd83645bd fix: reset first login flag after changing password 2025-12-05 11:26:32 +08:00
jialin 2df7c17bc1 chore: remove experimental from hygon 2025-12-04 22:35:15 +08:00
jialin a274349ace chore: upgrade info 2025-12-04 16:43:33 +08:00
jialin 1c699fe307 chore: tidy code 2025-12-04 16:43:33 +08:00
jialin f0a3e84e4f fix: set default os image 2025-12-04 10:48:34 +08:00
jialin f87989d32e fix: clear os_image when it's not in new image list 2025-12-04 10:12:19 +08:00
jialin 7355be9e3a fix: init cluster id when deploy model 2025-12-03 19:18:07 +08:00
jialin d8f1e95e1a fix: use image label in inputbox 2025-12-03 16:00:59 +08:00
jialin 59eace702b fix: add worker init steps failed 2025-12-03 12:32:04 +08:00
jialin 8a24ba0252 fix: cluster option disabled 2025-12-03 11:50:35 +08:00
jialin 03999a9d2c chore: os image filter 2025-12-03 11:38:16 +08:00
jialin f335cb1775 fix: click icon do not worker on upload 2025-12-02 17:24:14 +08:00
jialin b9c034469b fix: input img url fall back image 2025-12-02 15:58:17 +08:00
jialin ce3a82ddda fix: edit message add image 2025-12-02 14:00:58 +08:00
jialin 5cbb38922c feat: add image from url 2025-12-01 19:01:33 +08:00
jialin 14f0afec08 chore: allow space in backend parameters 2025-12-01 10:06:00 +08:00
jialin 769cc09906 fix: logs are not fully loaded 2025-11-30 20:33:16 +08:00
jialin 306daf7591 chore: amd note for add worker 2025-11-27 19:35:04 +08:00
jialin d1c1132e6e style: button for empty 2025-11-27 15:53:23 +08:00
jialin 962df859f1 chore: get started for add cluster 2025-11-27 11:35:45 +08:00
jialin 97601280d1 fix: model download progress text overflow 2025-11-26 10:28:40 +08:00
jialin ede42e99de fix: do not reset the backend after selecting a gguf file 2025-11-25 17:20:09 +08:00
jialin 47cae0134c feat: display deprecated backend versions group 2025-11-25 16:04:27 +08:00
jialin 33defab7df fix: gpus link 2025-11-25 11:34:11 +08:00
EVGENY Mandjialin 6b402e944b Update Russian translations in models.ts 2025-11-24 09:38:32 +08:00
EVGENY Mandjialin f8a6f4c5e5 Translate cluster messages to Russian 2025-11-24 09:38:14 +08:00
EVGENY Mandjialin adb999d3a9 Update dashboard.ts 2025-11-24 09:37:42 +08:00
jialin f4ea23dd14 fix: set default vllm backend for gguf 2025-11-23 21:08:28 +08:00
jialin 5bd0020e49 fix: check vllm backend for gguf model 2025-11-23 19:57:41 +08:00
jialin 782e81568d fix: check the image and run_command valid when select custom backend 2025-11-23 18:51:01 +08:00
jialin 2ecf83ddae fix: warning message for gguf model 2025-11-23 17:27:42 +08:00
jialin de0982d590 fix: compatibility message for gguf 2025-11-23 15:10:46 +08:00
jialin e5755a2eec chore: adjust ui statements 2025-11-22 13:06:05 +08:00
EVGENY Mandjialin e755c34ab5 Translate health check command tips to Russian 2025-11-22 12:19:10 +08:00
EVGENY Mandjialin 85e4f1a5ed Translate common phrases to Russian 2025-11-22 12:18:40 +08:00
EVGENY Mandjialin 3eb403a2c4 Translate user status messages to Russian 2025-11-22 12:18:15 +08:00
jialin 79442a6a6c fix: apikey form value diff 2025-11-21 20:41:20 +08:00
jialin f49001b742 chore: access setting notes 2025-11-21 20:10:21 +08:00
jialin e80ecfac8d style: table header text-overflow 2025-11-21 16:56:23 +08:00
jialin ff67fba2c9 chore: reset the primary color after logout 2025-11-21 16:56:23 +08:00
jialin 3f63831488 fix: modelscope api incorrect 2025-11-21 13:43:39 +08:00
jialin 19babbc73d style: adjust some styles 2025-11-21 12:16:49 +08:00
jialin 26a4d5474d fix(style): gpu_selector position 2025-11-20 20:49:19 +08:00
jialin af3e03230a fix: rerank api prefix 2025-11-20 17:43:13 +08:00
jialin 551f04011a chore: v1 to v2 2025-11-20 17:31:15 +08:00
jialin ea39a45f31 fix: sglang enable across worker 2025-11-20 15:59:05 +08:00
jialin ebff5695ff chore: consistent UI statement 2025-11-20 14:17:08 +08:00
jialin 9b63c1a515 style: example code title 2025-11-20 12:46:06 +08:00
jialin de882dc62e fix: api info example 2025-11-20 11:47:09 +08:00
jialin 8f9562d6a4 style: adjust some ui statements 2025-11-20 11:47:09 +08:00
jialin 5d383ec39b fix: add worker token do not update 2025-11-20 10:31:27 +08:00
jialin 2687fb187d style: adjust ram prcision 2025-11-19 18:47:55 +08:00
jialin ca43c0b4b2 fix(style): fix some styles 2025-11-19 11:46:18 +08:00
jialin 71bbf59467 style: deploy modal message cover the content 2025-11-19 11:46:18 +08:00
jialin 18f861f771 style: framework options 2025-11-18 20:01:54 +08:00
jialin e85d59dfb0 style: adjust some styles 2025-11-18 13:30:58 +08:00
jialin 78c8b60121 fix: re-request catalog specs after changing cluster 2025-11-18 11:28:37 +08:00
jialin e22b5ed516 chore: small fixes and optimizations 2025-11-17 20:15:26 +08:00
jialin 906f59a566 fix: model source error in catalog 2025-11-17 15:24:22 +08:00
jialin d1c3edfd9b fix: remark field option 2025-11-17 15:24:22 +08:00
jialin e8a0f33bde fix: extra newline character 2025-11-16 11:54:27 +08:00
Christianandjialin 825687f2a8 Fix typo in example-code
Remove obsolet bracket in python-example-code
2025-11-16 09:12:59 +08:00
jialin 2852648a65 fix: run command issue 2025-11-16 09:09:04 +08:00
jialin 0f3f31ef45 refactor: add worker 2025-11-15 22:37:44 +08:00
jialin 864cf76c07 feat: worker maintenance 2025-11-13 21:00:35 +08:00
jialin 98e6c71bf8 fix: model list flicker after page active 2025-11-13 17:25:28 +08:00
jialin aee9566bbb fix: yaml editor do not update when upload same file 2025-11-13 16:53:11 +08:00
jialin b61c0d6dee fix: api access info 2025-11-13 12:22:16 +08:00
jialin f963b3a000 chore: config base url 2025-11-13 12:22:16 +08:00
jialin 03963b736a chore: create, edit image handler 2025-11-12 20:47:34 +08:00
jialin a34c375e2d fix: image response handler 2025-11-12 19:55:31 +08:00
jialin e8eea9573e fix: set response_format as b64_json 2025-11-12 19:18:10 +08:00
jialin b7656d65e7 style: large modal height responsive 2025-11-12 19:18:10 +08:00
jialin d1fa6dd03c fix: pool's label editable 2025-11-12 16:37:01 +08:00
jialin 2045bfaf78 fix: display admin and inactive when view 2025-11-12 16:11:17 +08:00
jialin 653ada5f0f fix: do not evaluate from model files 2025-11-12 15:10:00 +08:00
jialin cbc000d35a fix: playground formref is invalid 2025-11-12 14:57:39 +08:00
jialin 11a676be83 fix: download file error 2025-11-12 11:01:13 +08:00
jialin 7eedea8035 chore: generic_prox ux 2025-11-11 20:06:25 +08:00
EVGENY Mandjialin 2d4ddea915 Update menu.ts 2025-11-11 18:47:08 +08:00
EVGENY Mandjialin 76d7a50fac Update models.ts 2025-11-11 18:46:44 +08:00
jialin 84187eedc4 fix: access control, voices options 2025-11-11 15:47:32 +08:00
jialin ee5c30934b feat: generic_proxy 2025-11-11 15:47:32 +08:00
jialin b4b25d4300 fix: default enter page for user 2025-11-10 20:40:15 +08:00
jialin 9eb1dba4a1 fix: calc scrollheight dynamically for tabs change 2025-11-10 20:40:15 +08:00
jialin 285e274818 fix: display image menu 2025-11-10 10:07:25 +08:00
jialin 0077d109e7 fix: remove page_size 2025-11-07 17:31:39 +08:00
jialin 9cd508a92a fix: draft model change 2025-11-07 16:54:33 +08:00
jialin 9ffd4def64 fix: failed field auto scroll in view 2025-11-07 16:54:33 +08:00
jialin fdb6ac7575 fix: set page to -1 for all data 2025-11-07 16:54:33 +08:00
jialin 64e2cfa35a fix: auto expand the fields group 2025-11-07 11:56:12 +08:00
jialin 39efca0d4c fix: add loading on download button 2025-11-06 19:38:01 +08:00
jialin cd2942405a feat: cluster_count on dashboard 2025-11-06 19:38:01 +08:00
jialin fadff34f5f chore: update description for adding worker 2025-11-06 19:38:01 +08:00
jialin 7334bcdf83 fix: do not paste multiple lines 2025-11-06 15:37:42 +08:00
jialin e1e38f0404 fix: chat stream data too long 2025-11-06 15:37:42 +08:00
EVGENY Mandjialin 38cc179068 Update backends.ts 2025-11-06 10:25:56 +08:00
EVGENY Mandjialin 5147d0d004 Update clusters.ts 2025-11-06 10:24:55 +08:00
EVGENY Mandjialin c237c9dbde Update models.ts 2025-11-06 10:24:15 +08:00
EVGENY Mandjialin 34bd2c3031 Update resources.ts 2025-11-06 10:23:48 +08:00
jialin 6173f3b459 fix: tts request content-type 2025-11-05 17:09:16 +08:00
jialin 333b430b97 fix(style): do not display draft model after done 2025-11-05 10:02:25 +08:00
jialin 4c22d08da5 refactor: page layout 2025-11-05 10:02:25 +08:00
jialin 219f9871a7 feat: add constants config 2025-11-05 10:02:25 +08:00
jialin 80527d5985 fix: distributed_inference always display 2025-11-04 18:57:57 +08:00
jialin 7e5edd6387 fix: backend option format 2025-11-04 18:07:14 +08:00
jialin 4ca6a221e4 fix: do not show draft model downloading progress 2025-11-04 17:19:20 +08:00
jialin e5733a7f6e chore: add worker notes 2025-11-04 17:19:20 +08:00
jialin 23b7936924 fix: custom backend and versions ux 2025-11-04 13:37:53 +08:00
jialin 9be465a8cf chore: update add worker command 2025-11-04 13:37:53 +08:00
jialin 4bbae673dc fix: draft model local path do not search 2025-11-03 14:22:52 +08:00
jialin e66ee5d3f1 fix: catalog kv cache 2025-11-03 11:00:42 +08:00
jialin 20872100d1 fix: kv cache default value 2025-11-03 10:38:41 +08:00
jialin 06f33ded10 fix: algorithm options do not display 2025-11-03 10:29:32 +08:00
jialin adb5cd72b9 chore: show quant in catalog form 2025-11-03 10:14:30 +08:00
jialin 303429c52c chore: clear space onblur 2025-11-03 10:14:30 +08:00
jialin 1a92cc8543 feat: search draft models from remote 2025-11-03 10:14:30 +08:00
jialin d5cc617848 fix: draft download progress should not show 2025-11-03 10:14:30 +08:00
jialin 4af71b5b52 chore: speculative_config init in updating 2025-11-03 10:14:30 +08:00
jialin 2dab89363d chore: draft model downloading 2025-11-03 10:14:30 +08:00
jialin ab9f9a9679 chore: update reference to baseline 2025-11-03 10:14:30 +08:00
jialin c5166f07f1 style: styles 2025-11-03 10:14:30 +08:00
jialin 86c2f8eda1 fix: backend change 2025-11-03 10:14:30 +08:00
jialin 57d41e79c7 fix: fake spec data 2025-11-03 10:14:30 +08:00
jialin 5cd9b8c22f fix: default spec by mode 2025-11-03 10:14:30 +08:00
jialin 56eba0d4fc fix: default spec by mode 2025-11-03 10:14:30 +08:00
jialin 7936d0063d chore: update models locales 2025-11-03 10:14:30 +08:00
jialin 3613fb3f69 feat: add speculative decoding 2025-11-03 10:14:30 +08:00
jialin 608b2e31c7 fix: schdule type gpu_selctor issue 2025-10-31 17:14:38 +08:00
jialin 2006827968 chore: update extended_kv_cache config 2025-10-31 15:03:23 +08:00
jialin f6a3497b0c fix: do not trigger evaluation replica 0 2025-10-31 13:10:52 +08:00
jialin d7ef64746c fix: custom backend version suffix 2025-10-30 19:08:45 +08:00
jialin b733b3615d fix: remove input box for gpus_per_replica 2025-10-30 16:38:55 +08:00
jialin e9fa3e3aa3 fix: gpus_per_replica appears null 2025-10-30 10:52:48 +08:00
jialin b77f796661 feat: add sglang parameters 2025-10-29 18:56:41 +08:00
jialin c077db1129 fix: replicas trigger compatibility 2025-10-29 17:24:26 +08:00
jialin 801c88a3e2 chore: update --token 2025-10-29 12:11:25 +08:00
jialin 646d235c65 fix: adjust gpus_per_replicas ux 2025-10-28 17:21:22 +08:00
jialin a86bed294e fix: gpu selector issues 2025-10-28 11:17:29 +08:00
jialin 697f1f9c25 fix: built-in backend versions endwith -custom 2025-10-27 16:09:09 +08:00
jialin 61065ee0b7 chore: scheduling group 2025-10-27 14:13:47 +08:00
jialin df65d3e2f6 fix: kv cache support in builtin backend 2025-10-27 14:13:47 +08:00
jialin 6969cb0b9c fix: expand model after edting replicas 2025-10-27 14:13:47 +08:00
jialin 7e81871118 fix: miss cluster id in evaluation 2025-10-24 17:55:54 +08:00
jialin ba80ade643 fix: my models status 2025-10-24 16:11:12 +08:00
jialin 0401cf5fb9 fix: no backend options from model files 2025-10-24 10:18:22 +08:00
jialin 53b431f100 fix(style): add backend 2025-10-23 18:41:16 +08:00
jialin 1a082529c6 fix: skip error handler in root path 2025-10-23 17:09:30 +08:00
jialin bf57290197 fix: admin can not delete own 2025-10-23 17:09:30 +08:00
jialin a815e71bfe chore: show existing when add file 2025-10-23 11:52:49 +08:00
jialin cc0580301e fix: do not trigger evaluation after switching model 2025-10-22 14:28:18 +08:00
jialin 5853bd1eeb fix: builtin backend do not submit default_version 2025-10-22 14:28:18 +08:00
jialin ab93c53092 chore: default cluster by state 2025-10-22 12:13:01 +08:00
jialin 818c4fc9a2 style: form tabs header gap 2025-10-22 10:21:27 +08:00
jialin fc7350b7e2 style: scroll to field 2025-10-21 19:59:49 +08:00
jialin 1e4018350f chore: worker selector 2025-10-21 15:59:48 +08:00
jialin f017d609fb fix: skip user api error 2025-10-21 13:26:06 +08:00
jialin ccb6e72057 fix: textarea scroll bar, deactive count message 2025-10-21 13:24:21 +08:00
EVGENY Mandjialin 32ad9525a6 Update apikeys.ts 2025-10-21 09:30:25 +08:00
EVGENY Mandjialin afedd4337b Update backends.ts 2025-10-21 09:30:06 +08:00
EVGENY Mandjialin 1f7acc7cf6 Update clusters.ts 2025-10-21 09:29:47 +08:00
EVGENY Mandjialin e6a5c19f0b Update menu.ts 2025-10-21 09:29:24 +08:00
EVGENY Mandjialin 8e07302ac3 Update models.ts 2025-10-21 09:29:04 +08:00
EVGENY Mandjialin 0238431b96 Update no-result.ts 2025-10-21 09:28:28 +08:00
jialin 3a7a4ccf30 fix: check driver command for adding worker 2025-10-20 19:11:02 +08:00
jialin 9b843151fe feat: add gpus_per_replicas 2025-10-20 14:53:33 +08:00
jialin 19e275a17a chore: update worker locale 2025-10-17 21:11:31 +08:00
jialin 49c6bb71a1 feat: identicon 2025-10-17 10:15:55 +08:00
jialin 005295ac97 style: gguf model ux 2025-10-17 10:15:55 +08:00
jialin 37a3aa75cc chore: cluster locales 2025-10-17 10:15:55 +08:00
jialin 07243b206e feat: enable kv cache 2025-10-16 18:05:30 +08:00
jialin f732f5c390 fix: cluster issues 2025-10-16 15:05:21 +08:00
jialin 1da16a04fe fix: do not set default version 2025-10-16 15:05:21 +08:00
jialin e2da7c5f96 style: ui for no data in table list 2025-10-16 11:11:39 +08:00
jialin ca9ceda2f7 fix: update backend parameters after changing backend 2025-10-15 13:30:58 +08:00
jialin 059416bb47 fix: backend edit format 2025-10-15 12:18:50 +08:00
jialin 4196351e48 fix: backend edit format 2025-10-15 12:18:50 +08:00
jialin f02b972dc0 fix(styles): my models 2025-10-14 20:09:43 +08:00
jialin 8398ac59a1 style: update model modal type 2025-10-14 20:09:43 +08:00
jialin 83403a1a1a feat: add extended_kv_cache 2025-10-14 20:09:43 +08:00
jialin 620c113fae fix(style): cluster state do not display 2025-10-14 13:09:22 +08:00
jialin 903500dcfa chore: infinite scroller 2025-10-13 19:55:08 +08:00
jialin 68d6993acd chore: remove test dir 2025-10-13 19:55:08 +08:00
jialin 2c9f5062a9 refactor: user table list 2025-10-13 19:55:08 +08:00
jialin d3f39ae06b fix: my models 2025-10-13 15:21:17 +08:00
jialin f42f159785 chore: update locales 2025-10-13 15:21:17 +08:00
jialin bb7c8e9c85 chore: model access statement 2025-10-13 15:21:17 +08:00
jialin 663b6c7b4e style: allowed models ux 2025-10-13 15:21:17 +08:00
jialin 1fa2124efd feat: add allowed models 2025-10-13 15:21:17 +08:00
jialin bcd1a339f9 feat: add model access control 2025-10-13 15:21:17 +08:00
jialin c41e5d9c55 chore: update is_built_in 2025-10-13 14:40:26 +08:00
jialin b5fa40047a chore: pluggable locale config 2025-10-13 14:40:26 +08:00
jialin caabeb065a fix: custom versin configs 2025-10-13 14:40:26 +08:00
jialin d393f9ee9e style: versions config 2025-10-13 14:40:26 +08:00
jialin eb509166ee style: backend list styles 2025-10-13 14:40:26 +08:00
jialin 0dfe77df37 chore: built in versions 2025-10-13 14:40:26 +08:00
jialin 46ecc2467b refactor: advance collapse 2025-10-13 14:40:26 +08:00
jialin a5c1b8e15f chore: test by api 2025-10-13 14:40:26 +08:00
jialin 54703c67c1 feat: yaml editor 2025-10-13 14:40:26 +08:00
jialin e863b84016 feat: add backend pages 2025-10-13 14:40:26 +08:00
jialin 1a693f70ac feat: worker terminal 2025-10-13 14:40:26 +08:00
jialin a9de153c00 chore: deploy form context provider 2025-10-13 14:40:26 +08:00
jialin 42217cf079 feat: add awq,gptq filter 2025-10-13 14:40:26 +08:00
jialin bca1e8140e feat: dynamic backends 2025-10-13 14:40:26 +08:00
jialin ee95fabc47 fix: add worker command miss image 2025-10-09 14:31:59 +08:00
jialin 67552c14af style: user activation 2025-10-09 11:07:09 +08:00
Hugo Haldiandjialin 521bf211a2 feat: add user activation control
- Add is_active field to user model
- Create SealCheckbox component with clickable container
- Add activation control to user modal
- Display user status in users table
- Add localization strings for activation features
2025-10-09 10:11:05 +08:00
EVGENY Mandjialin 8e77e19631 UI: Update Russian language menu.ts 2025-09-24 22:22:46 +08:00
EVGENY Mandjialin 8b91a0546c UI: Update Ru common.ts 2025-09-24 22:22:32 +08:00
EVGENY Mandjialin 715c71f9a5 UI: Update ru models.ts 2025-09-24 22:22:16 +08:00
EVGENY Mandjialin 1ec4a949b8 UI: Update ru playground.ts 2025-09-24 22:22:01 +08:00
EVGENY Mandjialin fc2388093d UI: RU language Update clusters.ts 2025-09-24 22:21:46 +08:00
jialin 3a9bf17d7e chore: update worker, cluster status value 2025-09-23 11:15:43 +08:00
jialin a3002ce450 chore: worker resource info adjust 2025-09-23 11:15:43 +08:00
jialin 2515e8f598 chore: update cloud providers 2025-09-22 10:36:34 +08:00
jialin dcc0db35b5 chore: update k8s check env command 2025-09-22 10:22:23 +08:00
jialin 749adb56f8 fix(style): select gpu vendor 2025-09-19 20:07:13 +08:00
jialin f542ebecb4 fix: cluster value setting, volumes setting 2025-09-19 20:00:25 +08:00
jialin b640963f65 fix(style): my models card 2025-09-19 15:46:24 +08:00
jialin 8f5990c537 fix: register cluster modal 2025-09-18 09:45:46 +08:00
jialin bf400547e1 fix: edit gpu_selector failed 2025-09-17 19:53:40 +08:00
jialin 4d9dec8511 refactor: deploy model 2025-09-17 19:53:40 +08:00
jialin 1ac63e36df feat: add baseSelect 2025-09-17 19:53:40 +08:00
jialin f36613227e fix: os image dropdown list 2025-09-17 15:17:31 +08:00
jialin d063dfd652 chore: display available clusters 2025-09-16 20:32:26 +08:00
jialin c9c9401b0b fix: provder disabled click in k8s 2025-09-16 11:26:17 +08:00
jialin 913f2f5077 fix: menu status mismatch 2025-09-16 11:26:17 +08:00
jialin 336bafd6ce chore: cluster docker provider 2025-09-16 11:26:17 +08:00
jialin 5e1a26b743 fix: close modal after editing cluster 2025-09-16 11:26:17 +08:00
jialin d9d5ca95df style: add worker ux 2025-09-16 11:26:17 +08:00
jialin f1bb305cbc fix: add pool not work 2025-09-16 11:26:17 +08:00
jialin c467280170 fix: display instance type spec 2025-09-16 11:26:17 +08:00
jialin deeee70807 feat: add watch api in cluster 2025-09-16 11:26:17 +08:00
jialin 07ade24ea1 refactor: cluster list 2025-09-16 11:26:17 +08:00
jialin 8de272239e refactor: create cluster by steps 2025-09-16 11:26:17 +08:00
jialin 6e5a7035c8 feat: cloud options 2025-09-16 11:26:17 +08:00
jialin 632f206228 fix: cluster apis 2025-09-16 11:26:17 +08:00
jialin f04f1f828f fix: add do cluster 2025-09-16 11:26:17 +08:00
jialin 4f91443957 chore: upgrade antd lib to 5.25.4 2025-09-16 11:26:17 +08:00
jialin 0c1057d554 refactor: credential table columns 2025-09-16 11:26:17 +08:00
jialin 43936e21d9 feat: instances on worker 2025-09-16 11:26:17 +08:00
jialin 949eded4ee refactor: resource table columns 2025-09-16 11:26:17 +08:00
jialin 84859d1b7c style: cluster table list 2025-09-16 11:26:17 +08:00
jialin 553ec724c2 fix: gpu selector by cluster 2025-09-16 11:26:17 +08:00
jialin 207c90e26c feat: terminal 2025-09-16 11:26:17 +08:00
jialin 64bbba7576 feat: add cluster detail page 2025-09-16 11:26:17 +08:00
jialin 62dbd18ef8 chore: create cluster ux 2025-09-16 11:26:17 +08:00
jialin 55b0a20a4a refactor: update scroll modal 2025-09-16 11:26:17 +08:00
jialin 29b74f85c5 chore: adjust deployment modal form 2025-09-16 11:26:17 +08:00
jialin ed49e03802 feat: cluster ux 2025-09-16 11:26:17 +08:00
jialin 4711c848f8 chore: user mdoels 2025-09-16 11:26:17 +08:00
jialin 33df825b73 feat: add card list component 2025-09-16 11:26:17 +08:00
jialin 89001dbb92 feat: add cluster list 2025-09-16 11:26:17 +08:00
jialin 43e1dd0b0e feat: clusters group 2025-09-16 11:26:17 +08:00
jialin f9cf111a86 chore: vllm docs link 2025-08-20 17:21:01 +08:00
jialin 99f8914830 chore: update vllm arguments 2025-08-20 16:43:48 +08:00
jialin 6da877709d style: display title when sso loading 2025-08-20 16:43:48 +08:00
jialin c4948dc11f fix: sso message 2025-08-19 11:08:15 +08:00
jialin 3f243129a4 fix: do not extract the error message from chat chunk 2025-08-18 18:22:46 +08:00
jialin eb2cae7a77 fix: break early while reading stream data 2025-08-15 19:12:12 +08:00
jialin a2bbcd3939 style: side menu 2025-08-15 15:37:51 +08:00
jialin 0650c4bc26 chore: some sso adjustments 2025-08-15 10:26:24 +08:00
jialin 7c32bf97ae chore: auth-config api 2025-08-14 21:50:59 +08:00
jialin 70aecc1f0c fix: keep storing avatar url when edit external user 2025-08-14 20:28:21 +08:00
jialin 5bd5c7d2c5 feat: add user avatar 2025-08-14 16:39:25 +08:00
jialin d6dce4021d fix: filter non-normal gguf files 2025-08-14 11:03:55 +08:00
jialin ccfdb99348 fix: miss global user info 2025-08-13 20:13:46 +08:00
jialin 2ca712435a fix: markdown view \n do not work 2025-08-13 19:50:54 +08:00
jialin 0af8e34a8f fix: external redirect issue 2025-08-13 19:50:54 +08:00
jialin f2583e152a style: login form style 2025-08-13 16:25:26 +08:00
jialin cf70bd2dc1 refactor: login form based on sso auth 2025-08-13 12:15:16 +08:00
forrestzhouandjialin 8f50af917f feat: Change get_config to auth_config to make it more specific 2025-08-12 17:19:04 +08:00
forrestzhouandjialin 4bdde365cf add sso login logic 2025-08-12 17:19:04 +08:00
forrestzhouandjialin 7f1bc33eed first push 0.7 2025-08-12 17:19:04 +08:00
jialin d0d24aba4e fix: markdown viewer white-space: pre-line 2025-08-12 16:45:50 +08:00
EVGENY Mandjialin 0d68c0d683 Update menu.ts 2025-08-12 00:15:14 +08:00
jialin e1ab735823 perf: toggle theme too much render in catalog 2025-08-11 09:35:01 +08:00
jialin bb67a8cbbb chore: display downloading progress in model instance log 2025-08-08 15:51:09 +08:00
jialin c8a7ac7dc6 style: keep text wrap for evalution result 2025-08-05 15:57:35 +08:00
EVGENY Mandjialin 788a294200 Update menu.ts 2025-07-31 09:38:00 +08:00
EVGENY Mandjialin f34935a634 Update models.ts 2025-07-31 09:36:50 +08:00
EVGENY Mandjialin a7331256fc Update dashboard.ts 2025-07-31 09:36:21 +08:00
jialin 8fa3941db9 fix: do not evaluate when local path is null 2025-07-30 11:12:13 +08:00
jialin ada120c1b9 fix: the theme align with the system 2025-07-30 11:12:13 +08:00
jialin 72f7168893 fix: adjust precision for big size 2025-07-29 18:40:29 +08:00
jialin 75b70a26bd fix: download log failed 2025-07-25 11:26:09 +08:00
jialin 4433e5d8e5 chore: move favicon icon to root 2025-07-23 16:02:58 +08:00
jialin 351b2e1417 chore: adjust the evaluation result statement 2025-07-23 11:13:37 +08:00
jialin 3c7dc5a49e fix: update the instance servers field 2025-07-22 19:26:08 +08:00
jialin 9895231696 fix: miss model category、name on catalog page 2025-07-21 19:51:30 +08:00
jialin 3fa3281c51 fix: progress bar default open 2025-07-18 15:12:18 +08:00
jialin bbf11d0374 style: model file status cell size 2025-07-18 10:35:35 +08:00
jialin 04ee696f6a style: playground bold text 2025-07-17 17:26:34 +08:00
jialin ddbbe92a85 chore: show used vram for a second 2025-07-17 12:01:49 +08:00
jialin 32ba5e1802 fix(style): axis tick value too long 2025-07-16 16:33:22 +08:00
jialin a1c6eb177a chore: remove autoplay for audio and video 2025-07-16 14:38:37 +08:00
jialin 14d60264c7 fix: wav format audio, #2317 2025-07-16 13:06:01 +08:00
jialin f4d6abace7 fix: remove insert action for watching, #2504 2025-07-15 19:33:04 +08:00
jialin a5e1717138 chore: update mindie backend parameters 2025-07-15 15:21:26 +08:00
jialin 472a4d400b chore: installer download link 2025-07-14 17:01:11 +08:00
jialin fda4786737 fix: set null to filename for download non-gguf 2025-07-11 11:07:54 +08:00
jialin c3686579b2 chore: add worker statements 2025-07-11 10:09:01 +08:00
jialin f2dfb2f32d style: uniform margin top for resources pages 2025-07-11 10:09:01 +08:00
jialin 60ee9f1a15 fix: catalog jump to deployments route error 2025-07-10 17:50:21 +08:00
jialin f43d1af6a7 fix(style): menu item text wrap 2025-07-10 15:24:55 +08:00
jialin b631b4c7b7 chore: remove menu data render 2025-07-10 14:52:08 +08:00
jialin e3aba0529f chore: update iconfont files 2025-07-10 10:02:10 +08:00
jialin cf682feae9 fix: menu items for user role 2025-07-10 10:02:10 +08:00
jialin 03d798760c chore: add worker guide 2025-07-10 09:47:12 +08:00
jialin 51450c2b02 style: flatten menu items 2025-07-10 09:47:12 +08:00
EVGENY Mandjialin 751ddbb3f3 Update resources.ts 2025-07-10 09:44:00 +08:00
EVGENY Mandjialin 36b3620d0c Update common.ts 2025-07-10 09:43:16 +08:00
jialin fd3eb513ff chore: update the guide for adding worker 2025-07-09 16:03:07 +08:00
jialin af0aaddbfd fix: update the requestId when switch model 2025-07-09 16:03:07 +08:00
jialin b167170aa9 style: tag tooltip content width 2025-07-09 16:03:07 +08:00
jialin 642ac3ebc4 fix: reset form after switch model 2025-07-07 17:40:09 +08:00
jialin 69cceb4fc7 refactor: update user guide for add worker
chore: update resource locales
2025-07-07 17:40:09 +08:00
jialin ac32e23e87 fix: distributed inference across workers disabled for vox-box 2025-07-04 20:57:57 +08:00
jialin 04de4ff606 fix: enable distributed inference field for mindie 2025-07-04 19:56:47 +08:00
jialin 27761566c9 fix: collpase instance error 2025-07-04 17:49:17 +08:00
jialin 3d93eda92d fix: distribution downloading data do not show 2025-07-04 16:45:15 +08:00
jialin 6943571a6d fix: images did not get cleared after clicking stop 2025-07-04 15:42:03 +08:00
jialin 28994cb9da chore: add iluvatar corex in add worker 2025-07-04 15:42:03 +08:00
jialin 5866634b3f chore: update iconfont files 2025-07-03 11:38:19 +08:00
jialin e3d91f1cc7 style: source icon in model result list 2025-07-03 11:38:19 +08:00
jialin 8ac06259f5 fix: do nothing when clicking the selected model or file 2025-07-03 10:41:22 +08:00
jialin c8933a6669 fix: update form values when switching model、size, #2191 2025-07-02 20:34:48 +08:00
jialin 6c2da264db fix: image generating flickering, #1415 2025-07-02 19:33:33 +08:00
jialin 993f01a301 fix: multiple select ux 2025-07-02 11:39:54 +08:00
jialin 9e29e7283c feat: add simple select component 2025-07-01 20:20:50 +08:00
jialin 7da106798d fix: some fields value do not be updated from default spec 2025-06-30 20:10:20 +08:00
jialin b2e9cbb44a chore: update backend parameters and logs reading frequency 2025-06-30 18:57:13 +08:00
jialin 143f6df2c1 perf: do not handle ansi sequence for parsing logs 2025-06-30 17:07:29 +08:00
jialin a64505fcc1 chore: update mindie parameters 2025-06-29 16:43:03 +08:00
jialin 0aaf919827 fix: switch model clear backend_parameters, env, backend_version 2025-06-27 18:07:30 +08:00
jialin bf8e988488 style: top users chart compact 2025-06-27 17:26:34 +08:00
jialin d26ea28028 fix(style): top users bar name too long 2025-06-27 16:42:24 +08:00
jialin abdd5e08a6 fix(style): top users bar name too long 2025-06-27 16:38:19 +08:00
jialin 47a5ef915b fix: pick backend_parameter, env, backend_version from spec in catalog 2025-06-27 16:38:19 +08:00
jialin 5861508153 fix(style): imgs overflow style on chat 2025-06-27 13:43:40 +08:00
jialin 85754ccfb5 fix(style): chart grid right margin 2025-06-27 10:53:51 +08:00
jialin cbeea23295 style: keep the logs pagination visible 2025-06-27 10:15:11 +08:00
jialin e2d79a6802 style: multiple selection tag 2025-06-26 20:39:07 +08:00
jialin c68d85096b fix(style): usage reponse size 2025-06-26 15:54:59 +08:00
jialin fcafa83111 fix: split line align for two yAxis chart 2025-06-26 15:54:59 +08:00
jialin 47d7418eb1 fix: usage: datepicker item disabled issue 2025-06-26 12:15:09 +08:00
jialin 8751400ae3 fix: distributed servers info 2025-06-25 20:29:48 +08:00
jialin 3889c1fa71 fix: reranker item uid updated, chat image size issue, #2280 2025-06-25 16:49:46 +08:00
jialin a4d1d3b16c style: skeleton for search result 2025-06-25 14:35:00 +08:00
jialin adfdf41e85 fix: do not check the required fields for evaluation, #2191 2025-06-25 14:35:00 +08:00
jialin a6825f7ee3 feat: clean markdown content 2025-06-25 14:35:00 +08:00
jialin 830ee45161 fix: update evaluation result issue 2025-06-24 20:47:27 +08:00
jialin 5f7df3f871 chore: update usage api 2025-06-24 16:54:03 +08:00
jialin 34af730934 feat: model usage 2025-06-24 16:54:03 +08:00
jialin 645801fe86 chore: mindle multiple support 2025-06-23 20:23:05 +08:00
jialin 547f49a978 fix: audio uploader has cache issue 2025-06-23 16:25:22 +08:00
jialin fd3d7a6f29 style: side menu style 2025-06-23 15:13:49 +08:00
jialin 6be7140a47 fix: #2227, #2263 2025-06-20 19:34:04 +08:00
jialin ca7dc02d88 revert: markdown katex parse 2025-06-20 11:18:18 +08:00
jialin 1924c45358 fix: chat request payload error, #2163 2025-06-20 11:18:18 +08:00
jialin be92f92991 fix: for gguf ref not be created, #2227 2025-06-19 15:25:21 +08:00
jialin a9b909cca1 fix: upload a audio will clear imgs, #2163 2025-06-19 13:36:49 +08:00
jialin 175b83dd68 fix: #2191,#2227 2025-06-19 13:36:49 +08:00
jialin df85284a60 style: audio player, usage chart 2025-06-19 13:36:49 +08:00
jialin 17ffa93393 fix: do not modify the custom name 2025-06-18 17:56:19 +08:00
jialin 73c525127f fix(style): simple audio player 2025-06-18 17:45:58 +08:00
jialin 3e76d7c321 fix: embedding params escape 2025-06-18 15:03:35 +08:00
jialin 9295f9cef3 fix: sync and update the evaluation result 2025-06-18 11:48:09 +08:00
jialin 9d1e6df8f0 chore: date ranger picker presets 2025-06-18 11:48:09 +08:00
jialin 0805d70c07 style: usage download button 2025-06-17 16:17:26 +08:00
jialin 0133524f09 fix: debounce for page change in search models 2025-06-17 11:50:33 +08:00
EVGENY Mandjialin 2c5100b2ed Update common.ts 2025-06-17 09:50:38 +08:00
EVGENY Mandjialin 51296cdc15 Update dashboard.ts 2025-06-17 09:50:14 +08:00
EVGENY Mandjialin f261bec248 Update users.ts 2025-06-17 09:49:54 +08:00
jialin 97c7087f6c fix(style): esc hint flickering 2025-06-16 19:54:23 +08:00
jialin 109906d083 fix: usage chart y axis ticks, add esc hint for drawer 2025-06-16 19:28:02 +08:00
jialin 81833c4938 fix: update gpus state by polling 2025-06-12 17:26:34 +08:00
jialin 1b6cfdbdc4 fix: evaluate status add lock state 2025-06-12 09:57:25 +08:00
jialin 281d8bddc1 feat: add pagination for searching models 2025-06-10 19:24:13 +08:00
jialin 0eaa3aeeb7 fix: do not undo when is inverting 2025-06-09 19:39:27 +08:00
jialin 4dcb0bcfed fix: image editor fit view incorrect, do not query gguf files when gguf unchecked 2025-06-09 18:45:47 +08:00
jialin e69b7dfd6a Revert "fix: normaliza embedding data"
This reverts commit 2bfb93a063.
2025-06-09 18:45:47 +08:00
jialin 38d63c71ee fix: normaliza embedding data 2025-06-09 18:45:47 +08:00
jialin 6880fd3f5f fix: user settings locales 2025-06-09 18:45:47 +08:00
jialin 1771ca363a fix: show embedding token usage 2025-06-09 18:45:47 +08:00
jialin c896c88c23 chore: remove ollama model source 2025-06-09 18:45:47 +08:00
jialin 5ef733729b fix: ui conflicts in update of multiple evalute result 2025-06-09 18:45:47 +08:00
jialin f73e29937c chore: export table title 2025-06-09 18:45:47 +08:00
jialin 8383547943 style: simple audio player 2025-06-09 18:45:47 +08:00
jialin 8070d3f1e6 style: usage chart style 2025-06-09 18:45:47 +08:00
jialin a161fa953e feat: usage export data 2025-06-09 18:45:47 +08:00
jialin 471e1ae96f feat: upload audio file in chat 2025-06-03 19:58:08 +08:00
jialin ed28bcdfb0 fix: set default spec to form 2025-06-03 15:16:52 +08:00
gitlawr 31ea81c211 ci: publish v*-dev branches 2025-05-30 14:02:56 +08:00
jialin 283189a17c fix: model instances always update by cache 2025-05-30 11:23:25 +08:00
jialin 40020df865 fix: clear backend parameters when change model file 2025-05-29 11:32:23 +08:00
jialin aa6b5ec24f fix: refresh model list manually 2025-05-28 17:25:23 +08:00
jialin f53fe042a9 fix: update allChildren after stop or start 2025-05-28 14:41:35 +08:00
jialin 034a54bf4b chore: model file components for updating 2025-05-27 19:45:24 +08:00
jialin 894dd1e353 chore: update mindie parameters 2025-05-27 16:50:08 +08:00
jialin ca99db5a97 chore: show llm code with common component 2025-05-27 16:50:08 +08:00
jialin 61e506010c fix: pca calculating takes a long time 2025-05-26 19:56:51 +08:00
jialin 4b4343a9fd chore: add watch for worker and gpu updating 2025-05-26 16:17:17 +08:00
jialin 9efacefba3 fix: remove worker-loader 2025-05-25 19:45:57 +08:00
jialin f288c9a9ad perf: embedding calc in worker process 2025-05-25 11:15:50 +08:00
jialin ec45f23485 chore: adjust the delay for scroller 2025-05-20 19:33:10 +08:00
jialin 1c11e73ff8 fix: playground parameters area resizable 2025-05-20 19:33:10 +08:00
603 changed files with 45465 additions and 21192 deletions
+1
View File
@@ -1,3 +1,4 @@
PORT=9000 PORT=9000
UMI_DEV_SERVER_COMPRESS=none UMI_DEV_SERVER_COMPRESS=none
DID_YOU_KNOW=none
+18 -8
View File
@@ -4,11 +4,13 @@ on:
push: push:
branches: branches:
- 'main' - 'main'
- 'v*-dev'
tags: tags:
- '*.*.*' - '*.*.*'
pull_request: pull_request:
branches: branches:
- 'main' - 'main'
- 'v*-dev'
env: env:
NODE_VERSION: '21' NODE_VERSION: '21'
@@ -72,11 +74,6 @@ jobs:
if: github.event_name == 'push' if: github.event_name == 'push'
timeout-minutes: 30 timeout-minutes: 30
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
strategy:
matrix:
version: ['latest', '${{ github.ref_name }}']
exclude:
- version: 'main'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -92,10 +89,23 @@ jobs:
${{ github.workspace }}/node_modules ${{ github.workspace }}/node_modules
- name: Build - name: Build
run: scripts/build run: scripts/build
- name: Determine Version
id: version
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "version=latest" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF}" == refs/heads/v*-dev ]]; then
echo "version=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
else
echo "Not a publish target"
exit 1
fi
- name: Package - name: Package
run: scripts/package run: scripts/package
env: env:
VERSION: '${{ matrix.version }}' VERSION: '${{ steps.version.outputs.version }}'
- name: Release - name: Release
uses: TencentCloud/cos-action@b0aa648235fb35a1bdd6a77f529eb0ac4c2f1c25 uses: TencentCloud/cos-action@b0aa648235fb35a1bdd6a77f529eb0ac4c2f1c25
with: with:
@@ -103,7 +113,7 @@ jobs:
secret_key: ${{ secrets.CI_TECENTCOS_SECRET_KEY }} secret_key: ${{ secrets.CI_TECENTCOS_SECRET_KEY }}
cos_bucket: ${{ secrets.COS_BUCKET }} cos_bucket: ${{ secrets.COS_BUCKET }}
cos_region: ${{ secrets.COS_REGION }} cos_region: ${{ secrets.COS_REGION }}
local_path: dist/${{ matrix.version }}.tar.gz local_path: dist/${{ steps.version.outputs.version }}.tar.gz
remote_path: releases/${{ matrix.version }}.tar.gz remote_path: releases/${{ steps.version.outputs.version }}.tar.gz
accelerate: true accelerate: true
clean: false clean: false
-2
View File
@@ -1,4 +1,2 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged npx lint-staged
+14 -19
View File
@@ -1,9 +1,9 @@
import { defineConfig } from '@umijs/max'; import { defineConfig } from '@umijs/max';
import keepAlive from './keep-alive'; import keepAlive from './keep-alive';
import { compressionPluginConfig, monacoPluginConfig } from './plugins';
import proxy from './proxy'; import proxy from './proxy';
import routes from './routes'; import routes from './routes';
import { getBranchInfo } from './utils'; import { getBranchInfo } from './utils';
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const versionInfo = getBranchInfo(); const versionInfo = getBranchInfo();
process.env.VERSION = JSON.stringify(versionInfo); process.env.VERSION = JSON.stringify(versionInfo);
@@ -28,6 +28,9 @@ export default defineConfig({
logLevel: 'info', logLevel: 'info',
defaultSizes: 'parsed' // stat // gzip defaultSizes: 'parsed' // stat // gzip
}, },
mfsu: {
exclude: ['lodash', 'ml-pca', 'monaco-editor']
},
base: process.env.npm_config_base || '/', base: process.env.npm_config_base || '/',
...(isProduction ...(isProduction
? { ? {
@@ -50,29 +53,18 @@ export default defineConfig({
chunkFilename: `css/[name].${t}.chunk.css` chunkFilename: `css/[name].${t}.chunk.css`
} }
]); ]);
config.module
.rule('worker')
.test(/\.worker\.js$/)
.use('worker-loader')
.loader('worker-loader');
config.output config.output
.filename(`js/[name].${t}.js`) .filename(`js/[name].${t}.js`)
.chunkFilename(`js/[name].${t}.chunk.js`); .chunkFilename(`js/[name].${t}.chunk.js`);
config compressionPluginConfig(config);
.plugin('compression-webpack-plugin') monacoPluginConfig(config);
.use(CompressionWebpackPlugin, [
{
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
}
]);
} }
} }
: {}), : {
chainWebpack(config) {
monacoPluginConfig(config);
}
}),
favicons: ['/static/favicon.png'], favicons: ['/static/favicon.png'],
jsMinifier: 'terser', jsMinifier: 'terser',
cssMinifier: 'cssnano', cssMinifier: 'cssnano',
@@ -86,6 +78,9 @@ export default defineConfig({
model: {}, model: {},
initialState: {}, initialState: {},
request: {}, request: {},
routePrefetch: {
defaultPrefetch: 'intent'
},
keepalive: keepAlive, keepalive: keepAlive,
locale: { locale: {
antd: true, antd: true,
+36
View File
@@ -0,0 +1,36 @@
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin';
const CompressionWebpackPlugin = require('compression-webpack-plugin');
export function monacoPluginConfig(config: any) {
return config
.plugin('monaco-editor-webpack-plugin')
.use(MonacoWebpackPlugin, [
{
languages: ['yaml'],
customLanguages: [
{
label: 'yaml',
entry: 'monaco-yaml',
worker: {
id: 'monaco-yaml/yamlWorker',
entry: 'monaco-yaml/yaml.worker'
}
}
]
}
]);
}
export function compressionPluginConfig(config: any) {
return config
.plugin('compression-webpack-plugin')
.use(CompressionWebpackPlugin, [
{
filename: '[path][base].gz',
algorithm: 'gzip',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
}
]);
}
+1 -6
View File
@@ -1,6 +1,7 @@
const proxyTableList = [ const proxyTableList = [
'cli', 'cli',
'v1', 'v1',
'v2',
'auth', 'auth',
'v1-openai', 'v1-openai',
'version', 'version',
@@ -20,12 +21,6 @@ export default function createProxyTable(target?: string) {
ws: true, ws: true,
log: 'debug', log: 'debug',
pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`), pathRewrite: (pth: string) => pth.replace(`/^/${api}`, `/${api}`),
// onProxyRes: (proxyRes: any, req: any, res: any) => {
// console.log('headers=========', {
// res: proxyRes.headers,
// req: req.headers
// });
// },
headers: { headers: {
origin: newTarget, origin: newTarget,
Connection: 'keep-alive' Connection: 'keep-alive'
+196 -45
View File
@@ -5,13 +5,18 @@ export default [
name: 'dashboard', name: 'dashboard',
path: '/dashboard', path: '/dashboard',
key: 'dashboard', key: 'dashboard',
icon: 'AppstoreOutlined', icon: 'icon-dashboard',
selectedIcon: 'icon-dashboard-filled',
defaultIcon: 'icon-dashboard',
access: 'canSeeAdmin', access: 'canSeeAdmin',
component: './dashboard' component: './dashboard',
routes: []
}, },
{ {
name: 'playground', name: 'playground',
icon: 'ExperimentOutlined', icon: 'icon-experiment',
selectedIcon: 'icon-experiment-filled',
defaultIcon: 'icon-experiment',
path: '/playground', path: '/playground',
key: 'playground', key: 'playground',
routes: [ routes: [
@@ -24,31 +29,19 @@ export default [
title: 'Chat', title: 'Chat',
path: '/playground/chat', path: '/playground/chat',
key: 'chat', key: 'chat',
icon: 'Comment', icon: 'icon-chat',
selectedIcon: 'icon-chat-filled',
defaultIcon: 'icon-chat',
component: './playground/index' component: './playground/index'
}, },
{
name: 'text2images',
title: 'Text2Images',
path: keepAliveRoutes.text2images,
key: 'text2images',
icon: 'Comment',
component: './playground/images'
},
{
name: 'speech',
title: 'Speech',
path: keepAliveRoutes.speech,
key: 'speech',
icon: 'Comment',
component: './playground/speech'
},
{ {
name: 'embedding', name: 'embedding',
title: 'embedding', title: 'embedding',
path: '/playground/embedding', path: '/playground/embedding',
key: 'embedding', key: 'embedding',
icon: 'Comment', icon: 'icon-embedding',
selectedIcon: 'icon-embedding-filled',
defaultIcon: 'icon-embedding',
component: './playground/embedding' component: './playground/embedding'
}, },
{ {
@@ -56,50 +49,208 @@ export default [
title: 'Rerank', title: 'Rerank',
path: '/playground/rerank', path: '/playground/rerank',
key: 'rerank', key: 'rerank',
icon: 'Comment', icon: 'icon-reranker',
selectedIcon: 'icon-reranker-filled',
defaultIcon: 'icon-reranker',
component: './playground/rerank' component: './playground/rerank'
},
{
name: 'text2images',
title: 'Text2Images',
path: keepAliveRoutes.text2images,
key: 'text2images',
icon: 'icon-image1',
selectedIcon: 'icon-image-filled',
defaultIcon: 'icon-image1',
component: './playground/images'
},
{
name: 'speech',
title: 'Speech',
path: keepAliveRoutes.speech,
key: 'speech',
icon: 'icon-audio1',
selectedIcon: 'icon-audio-filled',
defaultIcon: 'icon-audio1',
component: './playground/speech'
} }
] ]
}, },
{
name: 'modelCatalog',
path: '/models/catalog',
key: 'modelsCatalog',
icon: 'icon-catalog',
access: 'canSeeAdmin',
component: './llmodels/catalog'
},
{ {
name: 'models', name: 'models',
path: '/models/list', path: '/models',
key: 'models', key: 'models',
icon: 'Block', routes: [
access: 'canSeeAdmin', {
component: './llmodels/index' path: '/models',
redirect: '/models/deployments'
},
{
name: 'modelCatalog',
path: '/models/catalog',
key: 'modelsCatalog',
icon: 'icon-layers',
selectedIcon: 'icon-layers-filled',
defaultIcon: 'icon-layers',
access: 'canSeeAdmin',
component: './llmodels/catalog'
},
{
name: 'deployment',
path: '/models/deployments',
key: 'modelDeployments',
icon: 'icon-rocket-launch1',
selectedIcon: 'icon-rocket-launch-fill',
defaultIcon: 'icon-rocket-launch1',
access: 'canSeeAdmin',
component: './llmodels/index'
},
{
name: 'userModels',
path: '/models/user-models',
key: 'userModels',
icon: 'icon-models',
selectedIcon: 'icon-models-filled',
defaultIcon: 'icon-models',
access: 'canSeeUser',
component: './llmodels/user-models'
}
]
}, },
{ {
name: 'resources', name: 'resources',
path: '/resources', path: '/resources',
key: 'resources', key: 'resources',
icon: 'CloudServer',
access: 'canSeeAdmin', access: 'canSeeAdmin',
component: './resources' routes: [
{
path: '/resources',
redirect: '/resources/workers'
},
{
name: 'workers',
path: '/resources/workers',
key: 'workers',
icon: 'icon-resources',
selectedIcon: 'icon-resources-filled',
defaultIcon: 'icon-resources',
component: './resources/components/workers'
},
{
name: 'gpus',
path: '/resources/gpus',
key: 'gpus',
icon: 'icon-gpu1',
selectedIcon: 'icon-gpu-filled',
defaultIcon: 'icon-gpu1',
component: './resources/components/gpus'
},
{
name: 'backendsList',
path: '/resources/backends',
key: 'backendsList',
icon: 'icon-backend',
selectedIcon: 'icon-backend-filled',
defaultIcon: 'icon-backend',
access: 'canSeeAdmin',
component: './backends/index'
},
{
name: 'modelfiles',
path: '/resources/modelfiles',
key: 'modelfiles',
icon: 'icon-files',
selectedIcon: 'icon-files-filled',
defaultIcon: 'icon-files',
component: './resources/components/model-files'
}
]
},
{
name: 'clusterManagement',
path: '/cluster-management',
key: 'clusterManagement',
access: 'canSeeAdmin',
routes: [
{
path: '/cluster-management',
redirect: '/cluster-management/clusters/list'
},
{
name: 'clusters',
path: '/cluster-management/clusters/list',
key: 'clusters',
icon: 'icon-cluster2-outline',
selectedIcon: 'icon-cluster2-filled',
defaultIcon: 'icon-cluster2-outline',
component: './cluster-management/clusters',
subMenu: [
'/cluster-management/clusters/detail',
'/cluster-management/clusters/create'
]
},
{
name: 'clusterDetail',
path: '/cluster-management/clusters/detail',
key: 'clusterDetail',
icon: 'icon-cluster2-outline',
selectedIcon: 'icon-cluster2-filled',
defaultIcon: 'icon-cluster2-outline',
hideInMenu: true,
component: './cluster-management/cluster-detail'
},
{
name: 'clusterCreate',
path: '/cluster-management/clusters/create',
key: 'clusterCreate',
icon: 'icon-cluster2-outline',
selectedIcon: 'icon-cluster2-filled',
defaultIcon: 'icon-cluster2-outline',
hideInMenu: true,
component: './cluster-management/cluster-create'
},
{
name: 'credentials',
path: '/cluster-management/credentials',
key: 'credentials',
icon: 'icon-credential-outline',
selectedIcon: 'icon-credential-filled',
defaultIcon: 'icon-credential-outline',
component: './cluster-management/credentials'
}
]
},
{
name: 'accessControl',
path: '/access-control',
key: 'accessControl',
access: 'canSeeAdmin',
routes: [
{
path: '/access-control',
redirect: '/access-control/users'
},
{
name: 'users',
path: '/access-control/users',
key: 'users',
icon: 'icon-users',
selectedIcon: 'icon-users-filled',
defaultIcon: 'icon-users',
component: './users'
}
]
}, },
{ {
name: 'apikeys', name: 'apikeys',
path: '/api-keys', path: '/api-keys',
key: 'apikeys', key: 'apikeys',
icon: 'KeyOutlined', hideInMenu: true,
selectedIcon: 'icon-key-filled',
icon: 'icon-key',
defaultIcon: 'icon-key',
component: './api-keys' component: './api-keys'
}, },
{
name: 'users',
path: '/users',
key: 'users',
icon: 'Team',
access: 'canSeeAdmin',
component: './users'
},
{ {
name: 'profile', name: 'profile',
path: '/profile', path: '/profile',
+21 -4
View File
@@ -29,20 +29,25 @@
"@umijs/max": "^4.2.11", "@umijs/max": "^4.2.11",
"@xterm/addon-fit": "^0.10.0", "@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0", "@xterm/xterm": "^5.5.0",
"ahooks": "^3.8.5",
"ansi-to-html": "^0.7.2", "ansi-to-html": "^0.7.2",
"antd": "^5.21.6", "antd": "^5.25.4",
"antd-style": "^3.6.2", "antd-style": "^3.6.2",
"axios": "^1.7.2", "axios": "^1.8.2",
"classnames": "^2.5.1", "classnames": "^2.5.1",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
"dayjs": "^1.11.11", "dayjs": "^1.11.11",
"dompurify": "^3.2.6",
"driver.js": "^1.3.1", "driver.js": "^1.3.1",
"echarts": "^5.5.1", "echarts": "^5.5.1",
"epubjs": "^0.3.93", "epubjs": "^0.3.93",
"file-saver": "^2.0.5",
"has-ansi": "^5.0.1", "has-ansi": "^5.0.1",
"highlight.js": "^11.10.0", "highlight.js": "^11.10.0",
"jdenticon": "^3.3.0",
"jotai": "^2.8.4", "jotai": "^2.8.4",
"js-yaml": "^4.1.0",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"katex": "^0.16.21", "katex": "^0.16.21",
"lamejs": "github:zhuker/lamejs", "lamejs": "github:zhuker/lamejs",
@@ -50,34 +55,41 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mammoth": "^1.8.0", "mammoth": "^1.8.0",
"marked": "^14.1.0", "marked": "^14.1.0",
"minimatch": "^10.0.3",
"ml-dataset-iris": "^1.2.1", "ml-dataset-iris": "^1.2.1",
"ml-pca": "^4.1.1", "ml-pca": "^4.1.1",
"monaco-editor": "^0.53.0",
"monaco-editor-webpack-plugin": "^7.1.0",
"monaco-yaml": "^5.4.0",
"numeral": "^2.0.6", "numeral": "^2.0.6",
"overlayscrollbars": "^2.10.0", "overlayscrollbars": "^2.10.0",
"overlayscrollbars-react": "^0.5.6", "overlayscrollbars-react": "^0.5.6",
"pdfjs-dist": "^4.7.76", "pdfjs-dist": "^4.7.76",
"query-string": "^9.0.0", "query-string": "^9.0.0",
"rc-resize-observer": "^1.4.0", "rc-resize-observer": "^1.4.3",
"rc-virtual-list": "^3.14.8", "rc-virtual-list": "^3.14.8",
"re-resizable": "^6.10.1", "re-resizable": "^6.10.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hotkeys-hook": "^4.5.0", "react-hotkeys-hook": "^4.5.0",
"react-intersection-observer": "^9.16.0",
"react-markdown": "^9.0.3", "react-markdown": "^9.0.3",
"rehype-katex": "^7.0.1", "rehype-katex": "^7.0.1",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1", "remark-gfm": "^4.0.1",
"remark-math": "^6.0.0", "remark-math": "^6.0.0",
"simplebar-react": "^3.2.6", "simplebar-react": "^3.2.6",
"styled-components": "^6.1.15", "styled-components": "^6.1.15",
"tinycolor2": "^1.6.0",
"umi-presets-pro": "^2.0.3", "umi-presets-pro": "^2.0.3",
"wavesurfer.js": "^7.8.8", "wavesurfer.js": "^7.8.8",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" "xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
}, },
"devDependencies": { "devDependencies": {
"@types/marked": "^6.0.0",
"@types/react": "^18.3.1", "@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1", "@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
"@umijs/plugins": "^4.4.11",
"babel-plugin-named-asset-import": "^0.3.8", "babel-plugin-named-asset-import": "^0.3.8",
"case-sensitive-paths-webpack-plugin": "^2.4.0", "case-sensitive-paths-webpack-plugin": "^2.4.0",
"compression-webpack-plugin": "^11.1.0", "compression-webpack-plugin": "^11.1.0",
@@ -99,5 +111,10 @@
"url-loader": "^4.1.1", "url-loader": "^4.1.1",
"webpack-bundle-analyzer": "^4.10.2", "webpack-bundle-analyzer": "^4.10.2",
"worker-loader": "^3.0.8" "worker-loader": "^3.0.8"
},
"pnpm": {
"overrides": {
"elliptic": "^6.6.1"
}
} }
} }
+5334 -9171
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+7
View File
@@ -4,8 +4,15 @@ export default (initialState: { currentUser?: Global.UserInfo }) => {
initialState.currentUser && initialState.currentUser &&
initialState.currentUser.is_admin initialState.currentUser.is_admin
); );
const canSeeUser = !!(
initialState &&
initialState.currentUser &&
!initialState.currentUser.is_admin
);
return { return {
canSeeAdmin, canSeeAdmin,
canSeeUser,
canDelete: true, canDelete: true,
canLogin: true canLogin: true
}; };
+28 -10
View File
@@ -1,5 +1,6 @@
import { GPUStackVersionAtom, UpdateCheckAtom } from '@/atoms/user'; import { GPUStackVersionAtom, UpdateCheckAtom } from '@/atoms/user';
import { setAtomStorage } from '@/atoms/utils'; import { setAtomStorage } from '@/atoms/utils';
import { DEFAULT_ENTER_PAGE, GPUSTACK_API_BASE_URL } from '@/config/settings';
import { requestConfig } from '@/request-config'; import { requestConfig } from '@/request-config';
import { import {
queryCurrentUserState, queryCurrentUserState,
@@ -13,8 +14,7 @@ import {
writeState writeState
} from '@/utils/localstore/index'; } from '@/utils/localstore/index';
import { RequestConfig, history } from '@umijs/max'; import { RequestConfig, history } from '@umijs/max';
import { message } from 'antd';
const loginPath = '/login';
// only for the first login and access from http://localhost // only for the first login and access from http://localhost
@@ -23,7 +23,7 @@ const checkDefaultPage = async (userInfo: any) => {
if (isFirstLogin === null && isOnline()) { if (isFirstLogin === null && isOnline()) {
writeState(IS_FIRST_LOGIN, true); writeState(IS_FIRST_LOGIN, true);
if (userInfo && userInfo?.is_admin) { if (userInfo && userInfo?.is_admin) {
history.push('/models/list'); history.push(DEFAULT_ENTER_PAGE.adminForFirst);
} }
} }
}; };
@@ -48,7 +48,9 @@ export async function getInitialState(): Promise<{
} }
}; };
const fetchUserInfo = async (): Promise<Global.UserInfo> => { const fetchUserInfo = async (config?: {
skipErrorHandler?: boolean;
}): Promise<Global.UserInfo> => {
try { try {
const data = await queryCurrentUserState({ const data = await queryCurrentUserState({
skipErrorHandler: true skipErrorHandler: true
@@ -57,8 +59,19 @@ export async function getInitialState(): Promise<{
getUpdateCheck(); getUpdateCheck();
} }
return data; return data;
} catch (error) { } catch (error: any) {
history.push(loginPath); const data = error?.response?.data;
if (data?.code === 401 && data?.message.includes('deactivate')) {
message.error({
content: (
<div>
<span>{data?.message}</span>
</div>
),
duration: 5
});
}
history.push(DEFAULT_ENTER_PAGE.login);
} }
return {} as Global.UserInfo; return {} as Global.UserInfo;
}; };
@@ -66,10 +79,15 @@ export async function getInitialState(): Promise<{
const getAppVersionInfo = async () => { const getAppVersionInfo = async () => {
try { try {
const data = await queryVersionInfo(); const data = await queryVersionInfo();
const isProduction = data.version?.indexOf('0.0.0') === -1;
const isDev = data.version?.indexOf('0.0.0') > -1;
const isRc = data.version?.indexOf('rc') > -1;
setAtomStorage(GPUStackVersionAtom, { setAtomStorage(GPUStackVersionAtom, {
...data, ...data,
isProduction isProd: !isDev && !isRc,
isDev,
isRc
}); });
} catch (error) { } catch (error) {
console.error('queryVersionInfo error', error); console.error('queryVersionInfo error', error);
@@ -78,7 +96,7 @@ export async function getInitialState(): Promise<{
getAppVersionInfo(); getAppVersionInfo();
if (![loginPath].includes(location.pathname)) { if (![DEFAULT_ENTER_PAGE.login].includes(location.pathname)) {
const userInfo = await fetchUserInfo(); const userInfo = await fetchUserInfo();
checkDefaultPage(userInfo); checkDefaultPage(userInfo);
return { return {
@@ -92,6 +110,6 @@ export async function getInitialState(): Promise<{
} }
export const request: RequestConfig = { export const request: RequestConfig = {
baseURL: ' /v1', baseURL: `/${GPUSTACK_API_BASE_URL}`,
...requestConfig ...requestConfig
}; };
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 27 KiB

+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1755020187776" class="icon" viewBox="0 0 1105 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7392" xmlns:xlink="http://www.w3.org/1999/xlink" width="138.125" height="128"><path d="M507.2896 133.44768l130.98496-71.4496v820.9408l-130.97984 69.71392V133.44768z" fill="#F38019" p-id="7393"></path><path d="M479.39072 323.968a724.30592 724.30592 0 0 0-77.056 16.6144C118.35904 417.01376 37.77536 603.8016 67.95776 701.696c30.11584 97.8944 161.03424 263.2192 439.2704 250.19904 0.13824-27.41248 0.13824-57.73824 0-90.89536-200.49408-26.37824-302.67904-88.82688-306.55488-187.40736-5.74464-147.74272 134.1696-216.90368 217.87136-229.0176 16.82432-2.49344 37.66272-5.67808 61.19936-8.6528l-0.27648-111.9488h-0.07168z m185.12384 107.65312c52.1984 5.6832 103.57248 18.69312 147.0464 44.44672-10.65984 5.19168-34.26816 19.73248-70.82496 43.47904l290.49344 66.39104-16.54272-206.58176-78.37184 44.30336c-116.10112-57.8048-205.19936-91.0336-267.29984-99.6864l-4.50048 107.648z" fill="#ADAFB3" p-id="7394"></path></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#1f1f1f"><path d="M140-180v-88.92q0-29.39 15.96-54.43 15.96-25.03 42.66-38.49 59.3-29.08 119.65-43.62Q378.62-420 440-420q21.06 0 42.12 1.89 21.05 1.88 42.11 5.65-1.69 51.46 20.81 96.81Q567.54-270.31 609-240v60H140ZM753.85-72.31l-53.35-53.14v-164.73q-39.11-11.51-63.85-43.97-24.73-32.46-24.73-74.7 0-51.46 36.38-87.84t87.85-36.38q51.46 0 87.66 36.39Q860-460.28 860-408.79q0 39.94-22.42 70.71-22.43 30.77-57.2 44.23l44.23 44.23-53.07 53.2 53.07 53.19-70.76 70.92ZM440-484.62q-57.75 0-98.87-41.12Q300-566.86 300-624.61q0-57.75 41.13-98.88 41.12-41.12 98.87-41.12 57.75 0 98.87 41.12Q580-682.36 580-624.61q0 57.75-41.13 98.87-41.12 41.12-98.87 41.12Zm296.15 93.47q14.7 0 25.04-10.54 10.35-10.54 10.35-25.23 0-14.69-10.35-25.04-10.34-10.35-25.04-10.35-14.69 0-25.23 10.35-10.54 10.35-10.54 25.04t10.54 25.23q10.54 10.54 25.23 10.54Z"/></svg>

After

Width:  |  Height:  |  Size: 934 B

+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none">
<g fill="#C22E33">
<path d="M7.754 2l.463.41c.343.304.687.607 1.026.915C11.44 5.32 13.3 7.565 14.7 10.149c.072.132.137.268.202.403l.098.203-.108.057-.081-.115-.21-.299-.147-.214c-1.019-1.479-2.04-2.96-3.442-4.145a6.563 6.563 0 00-1.393-.904c-1.014-.485-1.916-.291-2.69.505-.736.757-1.118 1.697-1.463 2.653-.045.123-.092.245-.139.367l-.082.215-.172-.055c.1-.348.192-.698.284-1.049.21-.795.42-1.59.712-2.356.31-.816.702-1.603 1.093-2.39.169-.341.338-.682.5-1.025h.092z"/>
<path d="M8.448 11.822c-1.626.77-5.56 1.564-7.426 1.36C.717 11.576 3.71 4.05 5.18 2.91l-.095.218a4.638 4.638 0 01-.138.303l-.066.129c-.76 1.462-1.519 2.926-1.908 4.53a7.482 7.482 0 00-.228 1.689c-.01 1.34.824 2.252 2.217 2.309.67.027 1.347-.043 2.023-.114.294-.03.587-.061.88-.084.108-.008.214-.021.352-.039l.231-.028z"/>
<path d="M3.825 14.781c-.445.034-.89.068-1.333.108 4.097.39 8.03-.277 11.91-1.644-1.265-2.23-2.97-3.991-4.952-5.522.026.098.084.169.141.239l.048.06c.17.226.348.448.527.67.409.509.818 1.018 1.126 1.578.778 1.42.356 2.648-1.168 3.296-1.002.427-2.097.718-3.18.892-1.03.164-2.075.243-3.119.323z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+42
View File
@@ -104,6 +104,11 @@
justify-content: space-between; justify-content: space-between;
} }
.justify-between {
display: flex;
justify-content: space-between;
}
.justify-center { .justify-center {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -164,6 +169,10 @@
gap: 8px; gap: 8px;
} }
.gap-4 {
gap: 4px;
}
.gap-20 { .gap-20 {
gap: 20px; gap: 20px;
} }
@@ -204,6 +213,10 @@
font-size: 20px; font-size: 20px;
} }
.font-size-18 {
font-size: 18px;
}
.font-size-24 { .font-size-24 {
font-size: 24px; font-size: 24px;
} }
@@ -216,6 +229,10 @@
margin-bottom: 0; margin-bottom: 0;
} }
.m-t-0 {
margin-top: 0;
}
.m-b-16 { .m-b-16 {
margin-bottom: 16px; margin-bottom: 16px;
} }
@@ -240,6 +257,10 @@
font-weight: var(--font-weight-bold); font-weight: var(--font-weight-bold);
} }
.text-primary {
color: var(--ant-color-text);
}
.text-secondary { .text-secondary {
color: var(--ant-color-text-secondary); color: var(--ant-color-text-secondary);
} }
@@ -248,6 +269,10 @@
color: var(--ant-color-text-tertiary); color: var(--ant-color-text-tertiary);
} }
.text-quaternary {
color: var(--ant-color-text-quaternary);
}
.tips-desc-list { .tips-desc-list {
list-style-type: decimal; list-style-type: decimal;
padding-left: 16px; padding-left: 16px;
@@ -315,3 +340,20 @@ textarea:hover {
.ant-result-extra { .ant-result-extra {
color: var(--ant-color-text-secondary); color: var(--ant-color-text-secondary);
} }
.text-success {
color: var(--ant-color-success);
}
.desc-fill {
font-weight: 600;
color: var(--ant-color-text);
background-color: var(--ant-color-fill-content);
line-height: 1.5;
padding: 2px 6px;
border-radius: 4px;
}
.line-6 {
line-height: 24px;
}
+1 -2
View File
@@ -3,8 +3,7 @@
.ant-layout-sider-children { .ant-layout-sider-children {
border-inline: none; border-inline: none;
border-radius: 0; border-radius: 0;
// padding-inline: 16px; padding-block-end: 8px;
padding-block-end: 12px;
} }
.umi-plugin-layout-right { .umi-plugin-layout-right {
+65
View File
@@ -0,0 +1,65 @@
import { atom } from 'jotai';
// models expand keys: create, update , delete,
export const expandKeysAtom = atom<string[]>([]);
export const regionListAtom = atom<
{
datacenter: string;
label: string;
value: string;
icon: string;
sizes: string[];
}[]
>([]);
export const regionInstanceTypeListAtom = atom<
{
label: string;
value: string;
description: string;
specInfo: Record<string, any>;
vendor: string;
available: boolean;
regions: string[];
}[]
>([]);
export const regionOSImageListAtom = atom<
{
label: string;
value: string;
os_image: string;
name: string;
description: string;
vendor: string;
specInfo: Record<string, any>;
regions: string[];
}[]
>([]);
export const allRegionOSImageListAtom = atom<
{
label: string;
value: string;
regions: string[];
}[]
>([]);
export const allRegionInstanceTypeListAtom = atom<
{
label: string;
value: string;
regions: string[];
}[]
>([]);
export const fromClusterCreationAtom = atom(false);
/**
* for temporary cluster session storage during creation/editing
*/
export const clusterSessionAtom = atom<{
firstAddWorker: boolean;
firstAddCluster: boolean;
} | null>(null);
+49 -1
View File
@@ -1,4 +1,52 @@
import { atom } from 'jotai'; import { BackendOption } from '@/pages/llmodels/config/types';
import { atom, getDefaultStore } from 'jotai';
// models expand keys: create, update , delete, // models expand keys: create, update , delete,
export const modelsExpandKeysAtom = atom<string[]>([]); export const modelsExpandKeysAtom = atom<string[]>([]);
export const modelsSessionAtom = atom<Record<string, any>>({});
export const requestIdAtom = atom<number>(0);
export const setRquestId = () => {
const store = getDefaultStore();
const id = Date.now();
store.set(requestIdAtom, id);
return id;
};
export const getRequestId = () => {
const store = getDefaultStore();
return store.get(requestIdAtom);
};
// store for cluster list: res.items from api
export const clusterListAtom = atom<
{
label: string;
value: number;
provider: string;
state: string;
is_default: boolean;
workers: number;
ready_workers: number;
gpus: number;
}[]
>([]);
// store for worker list: res.items from api
export const workerListAtom = atom<
{
label: string;
value: number;
cluster_id: number;
state: string;
id: number;
labels: Record<string, any>;
name: string;
}[]
>([]);
export const backendOptionsAtom = atom<BackendOption[]>([]);
export const resourceOverviewAtom = atom<Record<string, any>>({});
+12 -8
View File
@@ -1,4 +1,4 @@
import { colorPrimary } from '@/config/theme'; import { COLOR_PRIMARY } from '@/config/theme';
import { atom } from 'jotai'; import { atom } from 'jotai';
import { atomWithStorage } from 'jotai/utils'; import { atomWithStorage } from 'jotai/utils';
@@ -7,13 +7,17 @@ type UserSettings = {
mode: 'light' | 'realDark' | 'auto'; mode: 'light' | 'realDark' | 'auto';
colorPrimary: string; colorPrimary: string;
isDarkTheme: boolean; isDarkTheme: boolean;
collapsed: boolean;
hideAddResourceModal?: boolean;
}; };
const defaultSettings: UserSettings = { export const defaultSettings: UserSettings = {
theme: 'light', theme: 'light',
mode: 'auto', mode: 'auto',
isDarkTheme: false, isDarkTheme: false,
colorPrimary: colorPrimary colorPrimary: COLOR_PRIMARY,
collapsed: false,
hideAddResourceModal: false
}; };
export const getStorageUserSettings = () => { export const getStorageUserSettings = () => {
@@ -31,10 +35,9 @@ export const getStorageUserSettings = () => {
} }
}; };
export const userSettingsAtom = atomWithStorage<UserSettings>( export const userSettingsAtom = atomWithStorage<UserSettings>('userSettings', {
'userSettings', ...getStorageUserSettings()
defaultSettings });
);
export const userSettingsHelperAtom = atom( export const userSettingsHelperAtom = atom(
(get) => get(userSettingsAtom), (get) => get(userSettingsAtom),
@@ -46,8 +49,9 @@ export const userSettingsHelperAtom = atom(
}; };
set(userSettingsAtom, { set(userSettingsAtom, {
...newSettings, ...newSettings,
colorPrimary: newSettings.colorPrimary || colorPrimary, colorPrimary: newSettings.colorPrimary || COLOR_PRIMARY,
isDarkTheme: newSettings.theme === 'realDark' isDarkTheme: newSettings.theme === 'realDark'
}); });
} }
); );
export const hideModalTemporarilyAtom = atom<boolean>(false);
+6 -2
View File
@@ -6,11 +6,15 @@ export const userAtom = atomWithStorage<any>('userInfo', null);
export const GPUStackVersionAtom = atom<{ export const GPUStackVersionAtom = atom<{
version: string; version: string;
git_commit: string; git_commit: string;
isProduction: boolean; isProd: boolean;
isDev?: boolean;
isRc?: boolean;
}>({ }>({
version: '', version: '',
git_commit: '', git_commit: '',
isProduction: false isProd: false,
isDev: false,
isRc: false
}); });
export const UpdateCheckAtom = atom<{ export const UpdateCheckAtom = atom<{
+33
View File
@@ -1,5 +1,38 @@
import { defaultSettings } from '@/atoms/settings';
import { getDefaultStore } from 'jotai'; import { getDefaultStore } from 'jotai';
export const clearStorageUserSettings = () => {
try {
const savedSettings = JSON.parse(
localStorage.getItem('userSettings') || '{}'
);
localStorage.setItem(
'userSettings',
JSON.stringify({
...savedSettings,
hideAddResourceModal: false,
colorPrimary: undefined
})
);
} catch (error) {
console.log('Error clearing user settings:', error);
}
};
export const resetStorageUserSettings = () => {
try {
localStorage.setItem(
'userSettings',
JSON.stringify({
...defaultSettings,
colorPrimary: undefined
})
);
} catch (error) {
console.log('Error clearing user settings:', error);
}
};
export const clearAtomStorage = (atom: any) => { export const clearAtomStorage = (atom: any) => {
if (!atom) { if (!atom) {
return; return;
-72
View File
@@ -1,72 +0,0 @@
.alert-info-block {
padding-block: 6px;
padding-inline: 10px 16px;
position: relative;
padding-left: 32px;
text-align: left;
border-radius: var(--border-radius-base);
margin: 0;
border: 1px solid transparent;
.ant-typography {
margin-bottom: 0;
}
&.danger {
border-color: var(--ant-color-error-border);
background-color: var(--ant-color-error-bg);
}
&.warning {
border-color: var(--ant-color-warning-border);
background-color: var(--ant-color-warning-bg);
}
&.transition {
color: var(--ant-geekblue-7);
background: var(--ant-geekblue-1);
border-color: var(--ant-geekblue-3);
}
&.success {
border: 1px solid var(--ant-color-success);
color: var(--ant-color-success);
background: var(--ant-color-success-bg);
.content.success {
font-weight: var(--font-weight-normal);
}
}
.title {
position: absolute;
left: 0;
top: 0;
display: flex;
height: 32px;
padding: 5px 10px;
border-radius: var(--border-radius-base) var(--border-radius-base) 0 0;
.info-icon {
&.danger {
color: var(--ant-color-error);
}
&.warning {
color: var(--ant-color-warning);
}
&.transition {
color: var(--ant-geekblue-7);
}
&.success {
color: var(--ant-color-success);
}
}
.text {
font-weight: var(--font-weight-bold);
}
}
}
+105 -8
View File
@@ -1,10 +1,14 @@
import { WarningFilled } from '@ant-design/icons'; import {
CheckCircleFilled,
LoadingOutlined,
WarningFilled
} from '@ant-design/icons';
import { Typography } from 'antd'; import { Typography } from 'antd';
import { createStyles } from 'antd-style';
import classNames from 'classnames'; import classNames from 'classnames';
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import OverlayScroller from '../overlay-scroller'; import OverlayScroller, { OverlayScrollerOptions } from '../overlay-scroller';
import './block.less';
interface AlertInfoProps { interface AlertInfoProps {
type: Global.MessageType; type: Global.MessageType;
message: React.ReactNode; message: React.ReactNode;
@@ -15,8 +19,84 @@ interface AlertInfoProps {
contentStyle?: React.CSSProperties; contentStyle?: React.CSSProperties;
title?: React.ReactNode; title?: React.ReactNode;
maxHeight?: number; maxHeight?: number;
overlayScrollerProps?: OverlayScrollerOptions;
} }
const useStyles = createStyles(({ token, css }) => {
return {
alertBlockInfo: css`
padding-block: 6px;
padding-inline: 10px 16px;
position: relative;
padding-left: 32px;
text-align: left;
border-radius: ${token.borderRadius}px;
margin: 0;
border: 1px solid transparent;
.ant-typography {
margin-bottom: 0;
}
&.danger {
border-color: ${token.colorErrorBorder};
background-color: ${token.colorErrorBg};
}
&.warning {
border-color: ${token.colorWarningBorder};
background-color: ${token.colorWarningBg};
}
&.transition {
color: ${token.geekblue7};
background: ${token.geekblue1};
border-color: ${token.geekblue3};
}
&.success {
border: 1px solid ${token.colorSuccess};
color: ${token.colorSuccessText};
background: ${token.colorSuccessBg};
.content.success {
font-weight: var(--font-weight-normal);
}
}
.title {
position: absolute;
left: 0;
top: 0;
display: flex;
height: 32px;
padding: 5px 10px;
border-radius: ${token.borderRadius}px ${token.borderRadius}px 0 0;
.info-icon {
&.danger {
color: ${token.colorErrorText};
}
&.warning {
color: ${token.colorWarningText};
}
&.transition {
color: ${token.geekblue7};
}
&.success {
color: ${token.colorSuccessText};
}
}
.text {
font-weight: var(--font-weight-bold);
}
}
`
};
});
const TitleWrapper = styled.div` const TitleWrapper = styled.div`
font-weight: 700; font-weight: 700;
color: var(--ant-color-text); color: var(--ant-color-text);
@@ -29,6 +109,7 @@ const ContentWrapper = styled.div<{ $hasTitle: boolean }>`
? 'var(--ant-color-text-secondary)' ? 'var(--ant-color-text-secondary)'
: 'var(--ant-color-text)'}; : 'var(--ant-color-text)'};
font-weight: var(--font-weight-500); font-weight: var(--font-weight-500);
white-space: pre-line;
`; `;
const AlertInfo: React.FC<AlertInfoProps> = (props) => { const AlertInfo: React.FC<AlertInfoProps> = (props) => {
@@ -41,14 +122,26 @@ const AlertInfo: React.FC<AlertInfoProps> = (props) => {
title, title,
contentStyle, contentStyle,
icon, icon,
maxHeight = 86 maxHeight = 86,
overlayScrollerProps = {}
} = props; } = props;
const { styles } = useStyles();
const renderIcon = () => {
if (type === 'transition') {
return <LoadingOutlined />;
}
if (type === 'success') {
return <CheckCircleFilled />;
}
return <WarningFilled />;
};
return ( return (
<> <>
{message ? ( {message ? (
<div <div
className={classNames('alert-info-block', type)} className={classNames(styles.alertBlockInfo, type)}
style={{ ...style }} style={{ ...style }}
> >
<Typography.Paragraph <Typography.Paragraph
@@ -61,13 +154,17 @@ const AlertInfo: React.FC<AlertInfoProps> = (props) => {
> >
<div className={classNames('title', type)}> <div className={classNames('title', type)}>
<span className={classNames('info-icon', type)}> <span className={classNames('info-icon', type)}>
{icon ?? <WarningFilled />} {icon ?? renderIcon()}
</span> </span>
</div> </div>
{title && ( {title && (
<TitleWrapper className="title-text">{title}</TitleWrapper> <TitleWrapper className="title-text">{title}</TitleWrapper>
)} )}
<OverlayScroller maxHeight={maxHeight} style={{ ...contentStyle }}> <OverlayScroller
maxHeight={maxHeight}
style={{ ...contentStyle }}
{...overlayScrollerProps}
>
<ContentWrapper <ContentWrapper
$hasTitle={!!title} $hasTitle={!!title}
className={classNames('content', type)} className={classNames('content', type)}
@@ -82,4 +179,4 @@ const AlertInfo: React.FC<AlertInfoProps> = (props) => {
); );
}; };
export default React.memo(AlertInfo); export default AlertInfo;
+2
View File
@@ -28,6 +28,8 @@ const AlertInfo: React.FC<AlertInfoProps> = (props) => {
} }
} }
style={{ style={{
fontWeight: 400,
whiteSpace: 'pre-line',
textAlign: 'center', textAlign: 'center',
padding: '2px 5px', padding: '2px 5px',
borderRadius: 'var(--border-radius-base)', borderRadius: 'var(--border-radius-base)',
@@ -0,0 +1,22 @@
import React from 'react';
import styled from 'styled-components';
const AudioWrapper = styled.div`
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
`;
const AudioElement: React.FC<any> = (props) => {
return (
<div>
<AudioWrapper>
<audio {...props} controls></audio>
</AudioWrapper>
</div>
);
};
export default AudioElement;
@@ -0,0 +1,406 @@
import { formatTime } from '@/utils/index';
import { DeleteOutlined, DownloadOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Dropdown, Slider, type MenuProps } from 'antd';
import { createStyles } from 'antd-style';
import { round } from 'lodash';
import React, {
forwardRef,
useCallback,
useEffect,
useImperativeHandle,
useMemo
} from 'react';
import styled from 'styled-components';
import AutoTooltip from '../auto-tooltip';
import IconFont from '../icon-font';
type ActionItem = 'download' | 'delete' | 'speed';
interface AudioPlayerProps {
autoplay?: boolean;
url: string;
speed?: number;
ref?: any;
name: string;
height?: number;
width?: number;
duration?: number;
actions?: ActionItem[];
onDelete?: () => void;
}
const SliderWrapper = styled.div`
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
gap: 8px;
.ant-slider {
flex: 1;
}
.time {
color: var(--ant-color-text-tertiary);
}
`;
const useStyles = createStyles(({ css, token }) => {
// @ts-ignore
const isDarkMode = token.darkMode as boolean;
return {
wrapper: css`
position: relative;
min-width: 360px;
height: 54px;
display: flex;
align-items: center;
justify-content: flex-start;
padding: 8px 10px;
background-color: ${isDarkMode
? 'var(--ant-color-fill-secondary)'
: '#F1F3F4'};
border-radius: 28px;
.inner {
width: 100%;
display: flex;
align-items: center;
justify-content: flex-start;
flex: 1;
gap: 8px;
.slider {
display: flex;
flex-direction: column;
justify-content: center;
flex: 1;
.ant-slider {
margin: 0;
}
&:hover {
.ant-slider-handle {
opacity: 1;
transition: opacity 0.3s ease-in-out;
}
}
&:focus-within {
.ant-slider-handle {
opacity: 1;
}
}
}
.ant-slider-handle {
opacity: 0;
&::before {
background-color: var(--ant-color-bg-spotlight);
border-radius: 50%;
}
&::after {
display: none;
}
}
}
`
};
});
const sliderStyles = {
rail: {
borderRadius: '4px',
backgroundColor: 'var(--ant-color-fill-secondary)'
},
track: {
borderRadius: '4px',
backgroundColor: 'var(--ant-color-bg-spotlight)'
}
};
const speedOptions = [
{ label: '1x', value: 1 },
{ label: '2x', value: 2 },
{ label: '3x', value: 3 },
{ label: '4x', value: 4 }
];
const speedConfig = {
min: 0.5,
max: 2,
step: 0.25
};
const AudioPlayer: React.FC<AudioPlayerProps> = forwardRef((props, ref) => {
const intl = useIntl();
const { styles } = useStyles();
const {
autoplay = false,
speed: defaultSpeed = 1,
actions = ['delete'],
name,
onDelete
} = props;
const audioRef = React.useRef<HTMLAudioElement>(null);
const [audioState, setAudioState] = React.useState<{
currentTime: number;
duration: number;
}>({
currentTime: 0,
duration: 0
});
console.log('audioState', name);
const [playOn, setPlayOn] = React.useState<boolean>(false);
const [speakerOn, setSpeakerOn] = React.useState<boolean>(false);
const [volume, setVolume] = React.useState<number>(1);
const [speed, setSpeed] = React.useState<number>(defaultSpeed);
const timer = React.useRef<any>(null);
useImperativeHandle(ref, () => ({
play: () => {
audioRef.current?.play();
},
pause: () => {
audioRef.current?.pause();
}
}));
const handleShowVolume = useCallback(() => {
setSpeakerOn(!speakerOn);
}, [speakerOn]);
const handleSeepdChange = useCallback((value: number | string) => {
setSpeed(value as number);
audioRef.current!.playbackRate = value as number;
}, []);
const handleAudioOnPlay = useCallback(() => {
timer.current = setInterval(() => {
setAudioState((prestate) => {
return {
currentTime: Math.ceil(audioRef.current?.currentTime || 0),
duration:
prestate.duration || Math.ceil(audioRef.current?.duration || 0)
};
});
if (audioRef.current?.paused || audioRef.current?.ended) {
clearInterval(timer.current);
setPlayOn(false);
setAudioState((prestate: any) => {
return {
currentTime: audioRef.current?.ended ? 0 : prestate.currentTime,
duration: prestate.duration
};
});
}
}, 500);
}, []);
const handlePlay = useCallback(() => {
setPlayOn(!playOn);
if (playOn) {
audioRef.current?.pause();
} else {
audioRef.current?.play();
}
}, [playOn]);
const handleFormatVolume = (val?: number) => {
if (val === undefined) {
return `${round(volume * 100)}%`;
}
return `${round(val * 100)}%`;
};
const handleVolumeChange = useCallback((value: number) => {
audioRef.current!.volume = round(value, 2);
setVolume(round(value, 2));
}, []);
const initPlayerConfig = () => {
if (audioRef.current) {
audioRef.current!.volume = volume;
audioRef.current!.playbackRate = speed;
}
};
const handleLoadedMetadata = useCallback(
(data: any) => {
const duration = Math.ceil(audioRef.current?.duration || 0);
setAudioState({
currentTime: 0,
duration:
duration && duration !== Infinity ? duration : props.duration || 0
});
setPlayOn(autoplay);
},
[autoplay, props.duration]
);
const handleCurrentChange = useCallback((val: number) => {
audioRef.current!.currentTime = val;
setAudioState((prestate) => {
return {
currentTime: val,
duration: prestate.duration
};
});
}, []);
const handleReduceSpeed = () => {
setSpeed((pre) => {
if (pre - speedConfig.step < speedConfig.min) {
return speedConfig.min;
}
const next = pre - speedConfig.step;
audioRef.current!.playbackRate = next;
return next;
});
};
const handleAddSpeed = () => {
setSpeed((pre) => {
if (pre + speedConfig.step > speedConfig.max) {
return speedConfig.max;
}
const next = pre + speedConfig.step;
audioRef.current!.playbackRate = next;
return next;
});
};
const handleOnLoad = (e: any) => {
console.log('onload', e);
};
const onDownload = useCallback(() => {
const url = props.url || '';
const filename = props.name;
const link = document.createElement('a');
link.href = url;
link.download = filename || 'audio.mp3'; // Default filename
document.body.appendChild(link);
link.click();
link.remove();
}, [props.url, props.name]);
const items: MenuProps['items'] = useMemo(() => {
return [
{
key: 'download',
label: intl.formatMessage({ id: 'common.button.download' }),
icon: <DownloadOutlined />,
onClick: onDownload
},
{
key: 'speed',
label: intl.formatMessage({ id: 'playground.params.speed' }),
icon: <IconFont type="icon-play-speed"></IconFont>,
children: speedOptions.map((item) => ({
key: item.value,
label: item.label,
onClick: () => handleSeepdChange(item.value)
}))
},
{
key: 'delete',
label: intl.formatMessage({ id: 'common.button.delete' }),
icon: <DeleteOutlined />,
danger: true,
onClick: () => {
if (audioRef.current) {
audioRef.current.pause();
audioRef.current.src = '';
audioRef.current.load();
}
setAudioState({ currentTime: 0, duration: 0 });
setPlayOn(false);
onDelete?.();
}
}
].filter((item) => actions.includes(item.key as ActionItem));
}, [actions, intl, onDownload, onDelete, handleSeepdChange]);
useEffect(() => {
if (audioRef.current) {
initPlayerConfig();
}
}, [audioRef.current]);
useEffect(() => {
return () => {
clearInterval(timer.current);
};
}, []);
return (
<div
className={styles.wrapper}
style={{
width: props.width || '100%',
height: props.height || '60px',
position: 'relative'
}}
>
<div className="inner">
<Button
size="middle"
type="text"
onClick={handlePlay}
shape="circle"
disabled={!audioState?.duration}
icon={
!playOn ? (
<IconFont
type="icon-playcircle-fill"
style={{ fontSize: '24px' }}
></IconFont>
) : (
<IconFont
type="icon-stopcircle-fill"
style={{ fontSize: '24px' }}
></IconFont>
)
}
></Button>
<div className="slider">
<div className="flex-center flex-between file-name">
<AutoTooltip ghost maxWidth={200}>
<span>{name}</span>
</AutoTooltip>
</div>
<SliderWrapper>
<span className="time">{formatTime(audioState.currentTime)}</span>
<Slider
tooltip={{ open: false }}
min={0}
step={1}
styles={sliderStyles}
max={audioState.duration}
value={audioState.currentTime}
onChange={handleCurrentChange}
/>
</SliderWrapper>
</div>
<Dropdown menu={{ items }} trigger={['click']}>
<Button
icon={<IconFont type="icon-more"></IconFont>}
type="text"
size="middle"
shape="circle"
></Button>
</Dropdown>
</div>
<audio
crossOrigin="anonymous"
autoPlay={autoplay}
src={props.url}
ref={audioRef}
preload="metadata"
style={{ opacity: 0, position: 'absolute', left: '-9999px' }}
onPlay={handleAudioOnPlay}
onLoadedMetadata={handleLoadedMetadata}
></audio>
</div>
);
});
export default React.memo(AudioPlayer);
+3 -2
View File
@@ -70,8 +70,9 @@ const AutoImage: React.FC<
setIsError(false); setIsError(false);
}, [props.onLoad]); }, [props.onLoad]);
const handleOnError = useCallback(() => { const handleOnError = useCallback((e: any) => {
setIsError(true); setIsError(true);
e.target.src = fallbackImg;
}, []); }, []);
useEffect(() => { useEffect(() => {
@@ -127,4 +128,4 @@ const AutoImage: React.FC<
); );
}; };
export default React.memo(AutoImage); export default AutoImage;
+1 -1
View File
@@ -87,7 +87,7 @@
} }
.single-image { .single-image {
height: 100%; // height: 100%;
width: inherit; width: inherit;
display: flex; display: flex;
justify-content: center; justify-content: center;
+15 -11
View File
@@ -1,5 +1,5 @@
import { CloseCircleOutlined } from '@ant-design/icons'; import { CloseCircleOutlined, LoadingOutlined } from '@ant-design/icons';
import { Progress, ProgressProps } from 'antd'; import { Progress, ProgressProps, Spin } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import { round } from 'lodash'; import { round } from 'lodash';
import ResizeObserver from 'rc-resize-observer'; import ResizeObserver from 'rc-resize-observer';
@@ -94,6 +94,17 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
const handleOnLoad = React.useCallback(async () => {}, []); const handleOnLoad = React.useCallback(async () => {}, []);
const renderProgress = () => {
<Progress
percent={round(progress, 0)}
type="dashboard"
size={loadingSize}
steps={{ count: 50, gap: 2 }}
format={() => <span className="font-size-20">{round(progress, 0)}%</span>}
trailColor="var(--ant-color-fill-secondary)"
/>;
};
return ( return (
<ResizeObserver onResize={handleResize}> <ResizeObserver onResize={handleResize}>
<div <div
@@ -135,15 +146,8 @@ const SingleImage: React.FC<SingleImageProps> = (props) => {
overflow: 'hidden' overflow: 'hidden'
}} }}
> >
<Progress <Spin
percent={round(progress, 0)} indicator={<LoadingOutlined style={{ fontSize: 32 }} spin />}
type="dashboard"
size={loadingSize}
steps={{ count: 50, gap: 2 }}
format={() => (
<span className="font-size-20">{round(progress, 0)}%</span>
)}
trailColor="var(--ant-color-fill-secondary)"
/> />
</span> </span>
) : ( ) : (
+21 -6
View File
@@ -8,6 +8,7 @@ import React, {
useRef, useRef,
useState useState
} from 'react'; } from 'react';
import styled from 'styled-components';
import { TooltipOverlayScroller } from '../overlay-scroller'; import { TooltipOverlayScroller } from '../overlay-scroller';
// type TagProps = React.ComponentProps<typeof Tag>; // type TagProps = React.ComponentProps<typeof Tag>;
@@ -22,9 +23,19 @@ interface AutoTooltipProps extends Omit<TagProps, 'title'> {
title?: React.ReactNode; title?: React.ReactNode;
showTitle?: boolean; showTitle?: boolean;
closable?: boolean; closable?: boolean;
radius?: number | string;
filled?: boolean;
tooltipProps?: React.ComponentProps<typeof Tooltip>; tooltipProps?: React.ComponentProps<typeof Tooltip>;
} }
const StyledTag = styled(Tag)`
margin: 0;
&.tag-filled {
border: none;
background-color: var(--ant-color-fill-secondary);
}
`;
const AutoTooltip: React.FC<AutoTooltipProps> = ({ const AutoTooltip: React.FC<AutoTooltipProps> = ({
children, children,
maxWidth = '100%', maxWidth = '100%',
@@ -33,6 +44,8 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
title, title,
showTitle = false, showTitle = false,
tooltipProps, tooltipProps,
radius = 12,
filled = false,
...tagProps ...tagProps
}) => { }) => {
const contentRef = useRef<HTMLDivElement>(null); const contentRef = useRef<HTMLDivElement>(null);
@@ -94,7 +107,7 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
<TooltipOverlayScroller <TooltipOverlayScroller
toolTipProps={{ toolTipProps={{
...tooltipProps, ...tooltipProps,
destroyTooltipOnHide: false destroyOnHidden: false
}} }}
title={isOverflowing || showTitle ? title || children : false} title={isOverflowing || showTitle ? title || children : false}
> >
@@ -103,13 +116,14 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
{children} {children}
</div> </div>
) : ( ) : (
<Tag <StyledTag
{...tagProps} {...tagProps}
className={`${tagProps.className || ''} ${filled ? 'tag-filled' : ''}`}
ref={contentRef} ref={contentRef}
style={{ style={{
...tagStyle,
paddingInline: tagProps.closable ? '8px 22px' : 8, paddingInline: tagProps.closable ? '8px 22px' : 8,
borderRadius: 12 borderRadius: radius,
...tagStyle
}} }}
closeIcon={ closeIcon={
tagProps.closable ? ( tagProps.closable ? (
@@ -117,7 +131,8 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
style={{ style={{
position: 'absolute', position: 'absolute',
right: 8, right: 8,
top: 6 top: '50%',
transform: 'translateY(-50%)'
}} }}
/> />
) : ( ) : (
@@ -126,7 +141,7 @@ const AutoTooltip: React.FC<AutoTooltipProps> = ({
} }
> >
{children} {children}
</Tag> </StyledTag>
)} )}
</TooltipOverlayScroller> </TooltipOverlayScroller>
); );
+1 -1
View File
@@ -2,6 +2,6 @@
border-radius: var(--border-radius-small); border-radius: var(--border-radius-small);
background-color: var(--color-white-1); background-color: var(--color-white-1);
box-shadow: none; box-shadow: none;
padding: 10px; padding: 10px 16px;
border: 1px solid var(--ant-color-border); border: 1px solid var(--ant-color-border);
} }
+109
View File
@@ -0,0 +1,109 @@
import { createStyles } from 'antd-style';
import React from 'react';
import styled from 'styled-components';
const SimpleCardItemWrapper = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
gap: 16px;
`;
const useStyles = createStyles(({ css, token }) => ({
wrapper: css`
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
background: ${token.colorBgContainer};
border-radius: ${token.borderRadius}px;
padding: ${token.padding}px;
justify-content: center;
align-items: center;
gap: ${token.padding}px;
&.bordered {
border: 1px solid ${token.colorBorder};
}
.title {
font-size: ${token.fontSize}px;
font-weight: var(--font-weight-medium);
}
.content {
display: flex;
justify-content: center;
align-items: center;
font-size: ${token.fontSize}px;
color: ${token.colorTextSecondary};
gap: 8px;
.icon {
display: inline-block;
width: 10px;
height: 10px;
gap: 10px;
&.roundRect {
border-radius: 2px;
}
&.circle {
border-radius: 50%;
}
}
}
`
}));
export const SimpleCardItem: React.FC<{
title?: string;
content?: React.ReactNode;
style?: React.CSSProperties;
bordered?: boolean;
color?: string;
iconType?: string;
}> = (props) => {
const { styles, cx } = useStyles();
const { title, content, style, bordered, iconType, color } = props;
return (
<div className={cx({ bordered: bordered }, styles.wrapper)} style={style}>
<div className="title">{title}</div>
<div className="content">
<span
className={cx([iconType], 'icon')}
style={{
backgroundColor: color || 'transparent'
}}
></span>
<span>{content}</span>
</div>
</div>
);
};
export const SimpleCard: React.FC<{
dataList: {
label: string;
value: React.ReactNode;
color: string;
iconType: string;
}[];
height?: string | number;
bordered?: boolean;
}> = (props) => {
const { dataList, bordered } = props;
return (
<SimpleCardItemWrapper style={{ height: props.height || '100%' }}>
{dataList.map((item, index) => (
<SimpleCardItem
key={index}
title={item.label}
content={item.value}
bordered={bordered}
color={item.color}
iconType={item.iconType}
></SimpleCardItem>
))}
</SimpleCardItemWrapper>
);
};
+208
View File
@@ -0,0 +1,208 @@
import IconFont from '@/components/icon-font';
import { Card } from 'antd';
import { createStyles } from 'antd-style';
import classNames from 'classnames';
import React, { useEffect, useRef, useState } from 'react';
import styled from 'styled-components';
const CardStyled = styled(Card)`
box-shadow: none !important;
&.isOpen {
.ant-card-head {
border-bottom: 1px solid var(--ant-color-border-secondary);
border-radius: var(--ant-border-radius) var(--ant-border-radius) 0 0;
}
}
.ant-card-head {
cursor: pointer;
background-color: var(--ant-color-fill-quaternary);
border-bottom: none;
border-radius: var(--ant-border-radius);
padding: 0 16px;
&:hover {
background-color: var(--ant-color-fill-secondary);
.del-btn {
display: block;
}
}
}
`;
const useStyles = createStyles(({ css, token }) => {
return {
title: css`
font-weight: 400;
height: 56px;
font-size: var(--font-size-base);
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
`,
expandIcon: css`
display: flex;
align-items: center;
gap: 8px;
`,
subtitle: css`
font-size: 14px;
color: ${token.colorTextSecondary};
`,
content: css`
padding-top: 8px;
`,
left: css`
flex: 1;
`,
right: css`
display: flex;
align-items: center;
gap: 8px;
.del-btn {
display: none;
}
`
};
});
export interface CollapsibleContainerProps {
title?: React.ReactNode;
subtitle?: React.ReactNode;
right?: React.ReactNode;
deleteBtn?: React.ReactNode;
defaultOpen?: boolean;
open?: boolean;
collapsible?: boolean;
showExpandIcon?: boolean;
onToggle?: (open: boolean) => void;
disabled?: boolean;
variant?: 'outlined' | 'borderless' | undefined;
iconPosition?: 'left' | 'right';
className?: string;
children?: React.ReactNode;
styles?: {
body?: React.CSSProperties;
header?: React.CSSProperties;
content?: React.CSSProperties;
};
}
export default function CollapsibleContainer({
title,
subtitle,
right,
deleteBtn,
defaultOpen = true,
open,
onToggle,
disabled = false,
showExpandIcon = true,
variant = 'borderless',
className = '',
collapsible,
iconPosition = 'left',
styles: cardStyles,
children
}: CollapsibleContainerProps) {
const { styles } = useStyles();
const isControlled = typeof open === 'boolean';
const [internalOpen, setInternalOpen] = useState(defaultOpen);
const isOpen = collapsible
? isControlled
? (open as boolean)
: internalOpen
: true;
const toggle = () => {
if (disabled || !collapsible) return;
const next = !isOpen;
if (!isControlled) setInternalOpen(next);
onToggle?.(next);
};
const contentRef = useRef<HTMLDivElement>(null);
const [height, setHeight] = useState(isOpen ? 'auto' : '0px');
const renderIcon = () => {
if (showExpandIcon) {
return (
<IconFont
rotate={isOpen ? 180 : 0}
type="icon-down"
style={{
cursor: disabled ? 'not-allowed' : 'pointer',
fontSize: 12
}}
/>
);
}
return null;
};
const renderTitle = () => {
if (!collapsible) {
return null;
}
return (
<div className={styles.title} onClick={toggle}>
<div className={styles.left}>
<div className={styles.expandIcon}>
{iconPosition === 'left' && renderIcon()}
{title && <div>{title}</div>}
</div>
{subtitle && <div className={styles.subtitle}>{subtitle}</div>}
</div>
<div className={styles.right}>
{right && <span>{right}</span>}
{deleteBtn && <span className="del-btn">{deleteBtn}</span>}
{iconPosition === 'right' && renderIcon()}
</div>
</div>
);
};
useEffect(() => {
if (!collapsible) {
setHeight('auto');
return;
}
if (isOpen) {
const scrollHeight = contentRef.current?.scrollHeight || 0;
setHeight(scrollHeight + 'px');
const timer = setTimeout(() => setHeight('auto'), 200);
return () => clearTimeout(timer);
} else {
const scrollHeight = contentRef.current?.scrollHeight || 0;
setHeight(scrollHeight + 'px');
requestAnimationFrame(() => setHeight('0px'));
return () => {};
}
}, [isOpen, collapsible]);
return (
<CardStyled
className={classNames(className, { collapsible, disabled, isOpen })}
variant={variant}
styles={{
body: {
padding: 0,
...cardStyles?.body
},
header: {
...cardStyles?.header
}
}}
title={renderTitle()}
>
<div
ref={contentRef}
style={{
height: height,
overflow: 'hidden'
}}
>
<div style={{ paddingTop: 8, ...cardStyles?.content }}>{children}</div>
</div>
</CardStyled>
);
}
+1 -3
View File
@@ -55,9 +55,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
}); });
clipboardRef.current.on('error', (e: any) => { clipboardRef.current.on('error', (e: any) => {
message.success( message.error(intl.formatMessage({ id: 'common.copy.fail' }) as string);
intl.formatMessage({ id: 'common.copy.fail' }) as string
);
e.clearSelection(); e.clearSelection();
}); });
} }
+3 -3
View File
@@ -15,7 +15,7 @@ const fadeOut = keyframes`
} }
`; `;
const Mask = styled.div<{ isHiding: boolean }>` const Mask = styled.div<{ $isHiding: boolean }>`
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
@@ -26,7 +26,7 @@ const Mask = styled.div<{ isHiding: boolean }>`
height: 100vh; height: 100vh;
background-color: rgba(59, 59, 59, 1); background-color: rgba(59, 59, 59, 1);
z-index: 9999; z-index: 9999;
animation: ${({ isHiding }) => (isHiding ? fadeOut : 'none')} ${duration}s animation: ${({ $isHiding }) => ($isHiding ? fadeOut : 'none')} ${duration}s
ease forwards; ease forwards;
`; `;
@@ -79,7 +79,7 @@ const DarkModeMask = () => {
return () => el.removeEventListener('animationend', handleAnimationEnd); return () => el.removeEventListener('animationend', handleAnimationEnd);
}, [visible]); }, [visible]);
return visible ? <Mask ref={maskRef} isHiding={isHiding}></Mask> : null; return visible ? <Mask ref={maskRef} $isHiding={isHiding}></Mask> : null;
}; };
export default DarkModeMask; export default DarkModeMask;
-22
View File
@@ -1,22 +0,0 @@
:local(.delete-modal-content) {
display: flex;
font-size: var(--font-size-middle);
:global {
.anticon {
font-size: 20px;
margin-right: 10px;
color: var(--ant-color-warning);
}
.title {
display: flex;
align-items: center;
}
}
}
:local(.content) {
padding-top: 15px;
padding-left: 30px;
}
+86 -42
View File
@@ -9,9 +9,38 @@ import {
message, message,
type ModalFuncProps type ModalFuncProps
} from 'antd'; } from 'antd';
import { FC, forwardRef, useImperativeHandle, useState } from 'react'; import { createStyles } from 'antd-style';
import { forwardRef, useImperativeHandle, useState } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import Styles from './index.less';
const useStyles = createStyles(({ css }) => ({
'delete-modal-content': css`
display: flex;
font-size: var(--font-size-middle);
.anticon {
font-size: 20px;
margin-right: 10px;
color: var(--ant-color-warning);
}
.title {
display: flex;
align-items: center;
font-weight: var(--font-weight-500);
}
`,
content: css`
padding-top: 15px;
padding-left: 30px;
color: var(--ant-color-text-secondary);
white-space: pre-line;
word-break: break-all;
span {
color: var(--ant-color-text);
display: flex;
margin-top: 8px;
}
`
}));
const CheckboxWrapper = styled.div` const CheckboxWrapper = styled.div`
margin-top: 20px; margin-top: 20px;
@@ -25,12 +54,8 @@ const CheckboxWrapper = styled.div`
} }
`; `;
interface DeleteModalProps {
ref: any;
}
interface DataOptions { interface DataOptions {
content: string; content?: string;
selection?: boolean; selection?: boolean;
name?: string; name?: string;
okText?: string; okText?: string;
@@ -43,28 +68,33 @@ interface DataOptions {
}; };
} }
const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => { interface Configuration {
checked: boolean;
}
const DeleteModal = forwardRef((props, ref) => {
const intl = useIntl(); const intl = useIntl();
const { styles } = useStyles();
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll(); const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [checked, setChecked] = useState(false); const [configuration, setConfiguration] = useState<Configuration>({
checked: false
});
const [config, setConfig] = useState<ModalFuncProps & DataOptions>({} as any); const [config, setConfig] = useState<ModalFuncProps & DataOptions>({} as any);
useImperativeHandle(ref, () => ({ const show = (data: ModalFuncProps & DataOptions) => {
show: (data: ModalFuncProps & DataOptions) => { saveScrollHeight();
saveScrollHeight(); setConfig(data);
setConfig(data); setConfiguration({
setChecked(data.checkConfig?.defautlChecked || false); checked: data.checkConfig?.defautlChecked || false
setVisible(true); });
}, setVisible(true);
hide: () => { };
setVisible(false);
restoreScrollHeight(); const hide = () => {
}, setVisible(false);
configuration: { restoreScrollHeight();
checked: checked };
}
}));
const handleCancel = () => { const handleCancel = () => {
setVisible(false); setVisible(false);
@@ -94,6 +124,12 @@ const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => {
} }
}; };
useImperativeHandle(ref, () => ({
show,
hide,
configuration
}));
return ( return (
<Modal <Modal
style={{ style={{
@@ -102,12 +138,16 @@ const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => {
open={visible} open={visible}
onOk={handleOk} onOk={handleOk}
onCancel={handleCancel} onCancel={handleCancel}
destroyOnClose={true} destroyOnHidden={false}
closeIcon={false} closeIcon={false}
maskClosable={false} maskClosable={false}
keyboard={false} keyboard={false}
width={460} width={460}
styles={{}} styles={{
footer: {
marginTop: '20px'
}
}}
footer={ footer={
<Space size={20}> <Space size={20}>
<Button onClick={handleCancel} size="middle"> <Button onClick={handleCancel} size="middle">
@@ -115,7 +155,7 @@ const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => {
? intl.formatMessage({ id: config.cancelText }) ? intl.formatMessage({ id: config.cancelText })
: intl.formatMessage({ id: 'common.button.cancel' })} : intl.formatMessage({ id: 'common.button.cancel' })}
</Button> </Button>
<Button type="primary" onClick={handleOk} size="middle"> <Button type="primary" onClick={handleOk} size="middle" danger>
{config.okText {config.okText
? intl.formatMessage({ id: config.okText }) ? intl.formatMessage({ id: config.okText })
: intl.formatMessage({ id: 'common.button.delete' })} : intl.formatMessage({ id: 'common.button.delete' })}
@@ -123,7 +163,7 @@ const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => {
</Space> </Space>
} }
> >
<div className={Styles['delete-modal-content']}> <div className={styles['delete-modal-content']}>
<span className="title"> <span className="title">
<ExclamationCircleFilled /> <ExclamationCircleFilled />
<span> <span>
@@ -134,26 +174,30 @@ const DeleteModal: FC<DeleteModalProps> = forwardRef((props, ref) => {
</span> </span>
</div> </div>
<div <div
className={Styles['content']} className={styles['content']}
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: __html: config.content
config.content && ? intl.formatMessage(
intl.formatMessage( {
{ id: config.operation || ''
id: config.operation || '' },
}, {
{ type: intl.formatMessage({ id: config.content }),
type: intl.formatMessage({ id: config.content }), name: config.name
name: config.name }
} )
) : ''
}} }}
></div> ></div>
{config.checkConfig && ( {config.checkConfig && (
<CheckboxWrapper> <CheckboxWrapper>
<Checkbox <Checkbox
checked={checked} checked={configuration.checked}
onChange={(e) => setChecked(e.target.checked)} onChange={(e) =>
setConfiguration({
checked: e.target.checked
})
}
> >
<span className="check-text"> <span className="check-text">
{intl.formatMessage({ id: config.checkConfig?.checkText })} {intl.formatMessage({ id: config.checkConfig?.checkText })}
@@ -16,6 +16,9 @@ const DropDownActions: React.FC<DropDownProps> = (props) => {
const items = useMemo(() => { const items = useMemo(() => {
return menu?.items?.map((item: any) => ({ return menu?.items?.map((item: any) => ({
..._.omit(item, 'locale'), ..._.omit(item, 'locale'),
icon: item.icon
? React.cloneElement(item.icon, { style: { fontSize: 14 } })
: null,
label: item.locale ? intl.formatMessage({ id: item.label }) : item.label label: item.locale ? intl.formatMessage({ id: item.label }) : item.label
})); }));
}, [menu?.items, intl]); }, [menu?.items, intl]);
+20 -13
View File
@@ -4,6 +4,7 @@ import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React from 'react';
import styled from 'styled-components';
import './index.less'; import './index.less';
type Trigger = 'click' | 'hover'; type Trigger = 'click' | 'hover';
@@ -19,6 +20,17 @@ interface DropdownButtonsProps {
onSelect: (val: any, item?: any) => void; onSelect: (val: any, item?: any) => void;
} }
const DropdownWrapper = styled.div`
display: flex;
flex-direction: column;
background-color: var(--ant-color-bg-elevated);
padding: 5px;
align-items: flex-start;
border-radius: var(--border-radius-base);
box-shadow: var(--ant-box-shadow-secondary);
min-width: 160px;
`;
const DropdownButtons: React.FC<DropdownButtonsProps> = ({ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
items, items,
size = 'middle', size = 'middle',
@@ -64,18 +76,9 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
disabled={disabled} disabled={disabled}
trigger={trigger} trigger={trigger}
type="primary" type="primary"
dropdownRender={(menus: any) => { popupRender={(menus: any) => {
return ( return (
<div <DropdownWrapper>
className="flex flex-column "
style={{
backgroundColor: 'var(--ant-color-bg-elevated)',
padding: 5,
alignItems: 'flex-start',
borderRadius: 'var(--border-radius-base)',
boxShadow: 'var(--ant-box-shadow-secondary)'
}}
>
{_.map(_.tail(items), (item: any) => { {_.map(_.tail(items), (item: any) => {
return ( return (
<Button <Button
@@ -86,13 +89,17 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
key={item.key} key={item.key}
disabled={item.disabled} disabled={item.disabled}
onClick={() => handleMenuClick(item)} onClick={() => handleMenuClick(item)}
style={{ width: '100%', justifyContent: 'flex-start' }} style={{
width: '100%',
justifyContent: 'flex-start',
paddingInline: 10
}}
> >
{intl.formatMessage({ id: item.label })} {intl.formatMessage({ id: item.label })}
</Button> </Button>
); );
})} })}
</div> </DropdownWrapper>
); );
}} }}
buttonsRender={([leftButton, rightButton]) => [ buttonsRender={([leftButton, rightButton]) => [
@@ -0,0 +1,19 @@
import ComponentsMap from '@/components/seal-form/config/components';
import { SealFormItemProps } from '@/components/seal-form/types';
import { Form } from 'antd';
import React from 'react';
interface FieldItemProps extends SealFormItemProps {
widget: keyof typeof ComponentsMap;
name: string;
}
const FieldItem: React.FC<FieldItemProps> = (props) => {
const { name, widget, required = [], ...rest } = props;
const Component = ComponentsMap[widget];
return <Form.Item name={name}></Form.Item>;
};
export default FieldItem;
@@ -0,0 +1,59 @@
import ComponentsMap from '@/components/seal-form/config/components';
import { FormWidgetProps } from '../config/types';
const FormWidget: React.FC<
FormWidgetProps & {
onChange?: (data: any) => void;
disabled?: boolean;
}
> = ({
widget,
title: label,
required,
placeholder,
options,
description,
enum: enumValues,
style,
value,
min,
max,
status,
checked,
isInFormItems,
disabled,
onChange
}) => {
const Component = ComponentsMap[widget];
const optionList = enumValues?.map((item: string | number) => ({
label: item,
value: item
}));
return Component ? (
<Component
{...{
label,
required,
placeholder,
description,
min,
max
}}
status={status}
isInFormItems={isInFormItems}
disabled={disabled}
options={options || optionList}
value={value}
checked={checked}
style={{
width: '100%',
...style
}}
onChange={onChange}
/>
) : null;
};
export default FormWidget;
@@ -0,0 +1,175 @@
import Wrapper from '@/components/label-selector/wrapper';
import { MinusOutlined } from '@ant-design/icons';
import { Button } from 'antd';
import React, { useEffect, useMemo } from 'react';
import styled from 'styled-components';
import { statusType } from '../config/types';
import FormWidget from './form-widget';
const RowWrapper = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
`;
const WidgetBox = styled.div`
display: flex;
align-items: center;
gap: 8px;
width: 100%;
`;
interface ListMapProps {
minItems?: number;
dataList: any[];
label?: React.ReactNode;
btnText?: string;
requiredFields?: string[];
validateStatusList?: Record<string, statusType>[];
properties: Record<string, any>;
disabled?: boolean;
onAdd?: (data: any[]) => void;
onDelete?: (deletedItem: any, data: any[]) => void;
onChange?: (data: any) => void;
}
interface ListItemProps {
schemaList: any[];
data: Record<string, any>;
disabled?: boolean;
validateStatus?: Record<string, statusType>;
onChange?: (data: any) => void;
}
const ListItem: React.FC<ListItemProps> = ({
schemaList,
data,
onChange,
validateStatus,
disabled
}) => {
const handleValueChange = (name: string, target: any) => {
if (target?.target?.type === 'checkbox') {
const checked = target.target?.checked;
onChange?.({ [name]: checked });
} else {
const value = target?.target ? target.target.value : target;
onChange?.({ [name]: value });
}
};
return (
<>
{schemaList.map((schema: any) => (
<FormWidget
status={validateStatus?.[schema.name]}
widget={schema.type}
{...schema}
disabled={disabled || schema.readOnly}
key={schema.name}
value={data?.[schema.name]}
checked={data?.[schema.name]}
isInFormItems={false}
onChange={(target) => handleValueChange(schema.name, target)}
/>
))}
</>
);
};
const ListMap: React.FC<ListMapProps> = ({
dataList = [],
label,
btnText,
properties = {},
requiredFields = [],
minItems = 0,
validateStatusList = [],
disabled,
onAdd,
onDelete,
onChange
}) => {
const [items, setItems] = React.useState(dataList || []);
const schemaList = useMemo(() => {
const list = Object.entries(properties).map(([key, value]) => ({
...value,
required: requiredFields.includes(key),
name: key
}));
return list;
}, [properties, requiredFields]);
const handleOnAdd = () => {
const keys = Object.keys(properties);
const newItems = [
...items,
{ ...keys.reduce((acc, key) => ({ ...acc, [key]: '' }), {}) }
];
setItems(newItems);
onAdd?.(newItems);
};
const handleDelete = (index: number) => {
const deleteItem = items[index];
const newItems = items.filter((_, i) => i !== index);
setItems(newItems);
onDelete?.(deleteItem, newItems);
};
const handleItemChange = (index: number, data: { [key: string]: any }) => {
const newItems = [...items];
newItems[index] = { ...newItems[index], ...data };
setItems(newItems);
onChange?.(newItems);
};
useEffect(() => {
if (!dataList.length && minItems > 0) {
handleOnAdd();
}
}, []);
useEffect(() => {
setItems(dataList);
}, [dataList]);
return (
<Wrapper
label={label}
btnText={btnText}
onAdd={handleOnAdd}
disabled={disabled}
>
{items.map((item, index) => (
<RowWrapper key={index}>
<WidgetBox>
<ListItem
schemaList={schemaList}
data={item}
validateStatus={validateStatusList?.[index]}
disabled={disabled}
onChange={(value) => handleItemChange(index, value)}
/>
</WidgetBox>
{!disabled && (
<Button
size="small"
type="default"
shape="circle"
style={{
width: 24,
marginLeft: 10,
flex: 'none'
}}
icon={<MinusOutlined />}
onClick={() => handleDelete(index)}
/>
)}
</RowWrapper>
))}
</Wrapper>
);
};
export default ListMap;
@@ -0,0 +1,39 @@
import React from 'react';
// refer to json schema
export interface FieldSchema {
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
title?: string;
name: string;
description?: string;
properties?: Record<string, FieldSchema>;
default?: any;
enum?: string[];
minItems?: number;
maxItems?: number;
items?: FieldSchema[];
widget?: string;
min?: number;
style?: React.CSSProperties;
required?: string[];
}
export type statusType = 'error' | 'warning' | '' | undefined;
export interface FormWidgetProps {
status?: statusType;
isInFormItems?: boolean;
widget: 'Input' | 'Select' | 'Checkbox' | 'InputNumber';
name: string;
title?: string;
required?: boolean;
placeholder?: string;
readOnly?: boolean;
options?: { label: string; value: string | number }[];
description?: string;
enum?: (string | number)[];
style?: React.CSSProperties;
value?: any;
checked?: boolean;
min?: number;
max?: number;
}
@@ -0,0 +1,33 @@
import { useMemo } from 'react';
import { FieldSchema } from '../config/types';
interface ParsedField {
name: (string | number)[];
schema: FieldSchema;
}
const parseSchema = (
schema: Record<string, FieldSchema>,
parentName: (string | number)[] = []
): ParsedField[] => {
const fields: ParsedField[] = [];
Object.entries(schema).forEach(([key, fieldSchema]) => {
const currentName = [...parentName, key];
if (fieldSchema.type === 'object' && fieldSchema.properties) {
fields.push(...parseSchema(fieldSchema.properties, currentName));
} else if (fieldSchema.type === 'array' && fieldSchema.items) {
fields.push({ name: currentName, schema: fieldSchema });
} else {
fields.push({ name: currentName, schema: fieldSchema });
}
});
return fields;
};
const useParsedFields = (schema: Record<string, FieldSchema>) => {
return useMemo(() => parseSchema(schema), [schema]);
};
export default useParsedFields;
@@ -0,0 +1,61 @@
import { useRef } from 'react';
import { statusType } from '../config/types';
export default function useValidateFields(params: {
requiredFields?: string[];
setValidateStatusList: (statusList: { [key: string]: statusType }[]) => void;
}) {
const { requiredFields, setValidateStatusList } = params;
const validationEnabled = useRef(false);
const isEmptyValue = (value: any, key: string) => {
return !value;
};
const validateRule = (value: any, key: string) => {
return true;
};
const listMapValidator = async (_: any, valueList: any) => {
if (!validationEnabled.current) {
return Promise.resolve();
}
const fields = new Set<string>();
const statusList: { [key: string]: statusType }[] = [];
(valueList || []).forEach((item: any, index: number) => {
const status: { [key: string]: statusType } = {};
Object.entries(item || {}).forEach(([key, value]) => {
if (isEmptyValue(value, key)) {
fields.add(key);
if (requiredFields?.includes(key)) {
status[key] = 'error';
} else {
status[key] = '';
}
} else if (validateRule(value, key)) {
status[key] = '';
}
});
statusList.push(status);
});
setValidateStatusList(statusList);
if (fields.size > 0) {
return Promise.reject(`${Array.from(fields).join(', ')} is required`);
}
return Promise.resolve();
};
const toggleValidation = (enabled: boolean) => {
validationEnabled.current = enabled;
};
return {
listMapValidator,
toggleValidation
};
}
+26
View File
@@ -0,0 +1,26 @@
import { Form } from 'antd';
import React from 'react';
import { FieldSchema } from './config/types';
interface DynamicFormProps {
schema: FieldSchema;
onSubmit: (values: any) => void;
}
const DynamicForm: React.FC<DynamicFormProps> = ({ schema, onSubmit }) => {
const form = Form.useFormInstance();
const handleFinish = (values: any) => {
onSubmit(values);
};
return (
<>
<Form form={form} onFinish={handleFinish}>
{/* Render form fields based on schema */}
</Form>
</>
);
};
export default DynamicForm;
+84 -26
View File
@@ -1,7 +1,6 @@
import { throttle } from 'lodash'; import _, { throttle } from 'lodash';
import React, { import React, {
forwardRef, forwardRef,
useCallback,
useEffect, useEffect,
useImperativeHandle, useImperativeHandle,
useRef useRef
@@ -10,14 +9,16 @@ import echarts, { ECOption } from '.';
const Chart: React.FC<{ const Chart: React.FC<{
options: ECOption; options: ECOption;
chartHeight?: number;
height: number | string; height: number | string;
width: number | string; width: number | string;
ref?: any; ref?: any;
}> = forwardRef(({ options, width, height }, ref) => { }> = forwardRef(({ options, width, height, chartHeight }, ref) => {
const container = useRef<HTMLDivElement>(null); const container = useRef<HTMLDivElement>(null);
const chart = useRef<echarts.EChartsType>(); const chart = useRef<echarts.EChartsType>();
const resizeable = useRef(false); const resizeable = useRef(false);
const resizeObserver = useRef<ResizeObserver>(); const resizeObserver = useRef<ResizeObserver>();
const finished = useRef(false);
useImperativeHandle(ref, () => { useImperativeHandle(ref, () => {
return { return {
@@ -25,40 +26,96 @@ const Chart: React.FC<{
}; };
}); });
const init = useCallback(() => { const init = () => {
if (container.current) { if (container.current) {
chart.current?.clear(); chart.current?.clear();
chart.current = echarts.init(container.current); chart.current = echarts.init(container.current);
} }
}, []); };
const resize = useCallback(() => { const setOption = (options: ECOption) => {
chart.current?.resize(); if (!chart.current) return;
}, []); chart.current?.clear();
chart.current?.setOption(options, {
const setOption = useCallback( notMerge: true,
(options: ECOption) => { lazyUpdate: true
chart.current?.clear(); });
chart.current?.setOption(options, { if (Array.isArray(options.yAxis) && options.yAxis.length > 1) {
notMerge: true, chart.current?.resize();
lazyUpdate: true }
}); };
},
[options]
);
useEffect(() => { useEffect(() => {
const handleOnFinished = () => {
if (!chart.current || finished.current) return;
const currentChart = chart.current;
const optionsYAxis = currentChart.getOption()?.yAxis;
if (
!optionsYAxis ||
!Array.isArray(optionsYAxis) ||
optionsYAxis.length < 2
)
return;
// @ts-ignore
const model = currentChart.getModel();
const yAxisModels = [
model.getComponent('yAxis', 0),
model.getComponent('yAxis', 1)
];
if (!yAxisModels[0] || !yAxisModels[1]) return;
const axes = yAxisModels.map((m) => m.axis);
const intervals = axes.map((axis) => axis.scale.getInterval());
const ticksList = axes.map((axis) => axis.scale.getTicks());
const counts = ticksList.map((t) => t.length);
const unifiedCount = Math.max(counts[0], counts[1]);
const newMax0 = intervals[0] * (unifiedCount - 1);
const newMax1 = intervals[1] * (unifiedCount - 1);
// if newMax0 equal to maxValue0, and newMax1 equal to maxValue1, do not update yAxis
if (counts[0] === counts[1]) return;
const yAxis: any[] = [{}, {}];
if (counts[0] < unifiedCount) {
yAxis[0].max = _.round(newMax0, 2);
yAxis[0].interval = intervals[0];
yAxis[0].splitNumber = unifiedCount;
}
if (counts[1] < unifiedCount) {
yAxis[1].max = _.round(newMax1, 2);
yAxis[1].interval = intervals[1];
yAxis[1].splitNumber = unifiedCount;
}
finished.current = true;
currentChart.setOption({
yAxis: yAxis
});
};
if (container.current) { if (container.current) {
init(); init();
chart.current?.on('finished', handleOnFinished);
} }
return () => { return () => {
chart.current?.off('finished', handleOnFinished);
chart.current?.dispose(); chart.current?.dispose();
}; };
}, [init]); }, []);
useEffect(() => { useEffect(() => {
resizeable.current = false; resizeable.current = false;
resize(); finished.current = false;
setOption(options); setOption(options);
resizeable.current = true; resizeable.current = true;
}, [options]); }, [options]);
@@ -72,19 +129,20 @@ const Chart: React.FC<{
if (container.current) { if (container.current) {
resizeObserver.current = new ResizeObserver(handleResize); resizeObserver.current = new ResizeObserver(handleResize);
resizeObserver.current.observe(container.current); resizeObserver.current.observe(container.current);
} }
return () => { return () => {
if (container.current) { resizeObserver.current?.disconnect();
resizeObserver.current?.unobserve(container.current); resizeObserver.current = undefined;
}
}; };
}, []); }, []);
return ( return (
<div className="chart-wrapper" style={{ width: width, height }}> <div className="chart-wrapper" style={{ width: width, height }}>
<div ref={container} style={{ width: width, height }}></div> <div
ref={container}
style={{ width: width, height: chartHeight || height }}
></div>
</div> </div>
); );
}); });
+18 -29
View File
@@ -1,27 +1,12 @@
import useUserSettings from '@/hooks/use-user-settings'; import useUserSettings from '@/hooks/use-user-settings';
import { formatLargeNumber } from '@/utils';
import { theme } from 'antd'; import { theme } from 'antd';
import { isFunction } from 'lodash'; import { isFunction } from 'lodash';
import { useMemo } from 'react'; import { useMemo } from 'react';
const formatLargeNumber = (value: number) => {
if (typeof value !== 'number' || isNaN(value)) {
return value;
}
if (value >= 1e9) {
return (value / 1e9).toFixed(1).replace(/\.0$/, '') + 'B';
} else if (value >= 1e6) {
return (value / 1e6).toFixed(1).replace(/\.0$/, '') + 'M';
} else if (value >= 1e3) {
return (value / 1e3).toFixed(1).replace(/\.0$/, '') + 'K';
} else {
return value;
}
};
export const grid = { export const grid = {
left: 0, left: 0,
right: 20, right: 0,
bottom: 20, bottom: 20,
containLabel: true containLabel: true
}; };
@@ -31,14 +16,14 @@ export default function useChartConfig() {
const { useToken } = theme; const { useToken } = theme;
const { token } = useToken(); const { token } = useToken();
console.log('token:', token);
const chartColorMap = useMemo(() => { const chartColorMap = useMemo(() => {
return { return {
titleColor: token.colorText, titleColor: token.colorText,
splitLineColor: token.colorBorder, splitLineColor: token.colorBorder,
tickLineColor: token.colorSplit, tickLineColor: token.colorSplit,
axislabelColor: token.colorTextTertiary, axislabelColor: token.colorTextTertiary,
colorSecondary: token.colorTextSecondary,
colorTertiary: token.colorTextTertiary,
gaugeBgColor: token.colorFillSecondary, gaugeBgColor: token.colorFillSecondary,
gaugeSplitLineColor: isDarkTheme gaugeSplitLineColor: isDarkTheme
? 'rgba(255,255,255,.3)' ? 'rgba(255,255,255,.3)'
@@ -56,18 +41,23 @@ export default function useChartConfig() {
borderColor: 'transparent', borderColor: 'transparent',
formatter(params: any, callback?: (val: any) => any) { formatter(params: any, callback?: (val: any) => any) {
let result = `<span class="tooltip-x-name">${params[0].axisValue}</span>`; let result = `<span class="tooltip-x-name">${params[0].axisValue}</span>`;
params.forEach((item: any) => { params.forEach((item: any) => {
let value = isFunction(callback) let value = isFunction(callback)
? callback?.(item.data.value) ? callback?.(item.data.value)
: item.data.value; : item.data.value;
const borderRadius = item.seriesType === 'bar' ? '2px' : '8px';
result += `<span class="tooltip-item"> result += `<span class="tooltip-item">
<span class="tooltip-item-name"> <span class="tooltip-item-name">
<span style="display:inline-block;margin-right:5px;border-radius:8px;width:8px;height:8px;background-color:${item.color};"></span> <span style="display:inline-block;margin-right:5px;border-radius:${borderRadius};width:8px;height:8px;background-color:${item.color};"></span>
<span class="tooltip-title">${item.seriesName}</span>: <span class="tooltip-title">${item.seriesName}</span>:
</span> </span>
<span class="tooltip-value">${value}</span> <span class="tooltip-value">${value}</span>
</span>`; </span>`;
}); });
return `<div class="tooltip-wrapper">${result}</div>`; return `<div class="tooltip-wrapper">${result}</div>`;
} }
}; };
@@ -75,6 +65,7 @@ export default function useChartConfig() {
const legend = { const legend = {
itemWidth: 8, itemWidth: 8,
itemHeight: 8, itemHeight: 8,
itemGap: 12,
textStyle: { textStyle: {
color: chartColorMap.axislabelColor color: chartColorMap.axislabelColor
} }
@@ -98,8 +89,6 @@ export default function useChartConfig() {
}; };
const yAxis = { const yAxis = {
// max: 100,
// min: 0,
nameTextStyle: { nameTextStyle: {
padding: [0, 0, 0, -20] padding: [0, 0, 0, -20]
}, },
@@ -135,7 +124,6 @@ export default function useChartConfig() {
type: 'bar', type: 'bar',
barMaxWidth: 20, barMaxWidth: 20,
barMinWidth: 8, barMinWidth: 8,
// stack: 'total',
barGap: '30%', barGap: '30%',
barCategoryGap: '50%' barCategoryGap: '50%'
}; };
@@ -218,13 +206,13 @@ export default function useChartConfig() {
rich: { rich: {
value: { value: {
fontSize: 16, fontSize: 16,
fontWeight: '500', fontWeight: 500,
color: chartColorMap.titleColor color: chartColorMap.titleColor
}, },
unit: { unit: {
fontSize: 14, fontSize: 14,
color: chartColorMap.titleColor, color: chartColorMap.titleColor,
fontWeight: '500', fontWeight: 500,
padding: [0, 0, 0, 2] padding: [0, 0, 0, 2]
} }
} }
@@ -232,6 +220,7 @@ export default function useChartConfig() {
}; };
return { return {
token,
tooltip, tooltip,
grid, grid,
legend, legend,
+44 -12
View File
@@ -1,9 +1,19 @@
import Chart from '@/components/echarts/chart'; import Chart from '@/components/echarts/chart';
import useChartConfig from '@/components/echarts/config'; import useChartConfig from '@/components/echarts/config';
import EmptyData from '@/components/empty-data'; import EmptyData from '@/components/empty-data';
import React, { memo } from 'react'; import React from 'react';
import { ChartProps } from './types'; import { ChartProps } from './types';
const strokeColorFunc = (percent: number) => {
if (percent <= 50 || percent === undefined) {
return 'rgb(84, 204, 152, 80%)';
}
if (percent <= 80) {
return 'rgba(250, 173, 20, 80%)';
}
return 'rgba(255, 77, 79, 80%)';
};
const GaugeChart: React.FC<Omit<ChartProps, 'seriesData' | 'xAxisData'>> = ( const GaugeChart: React.FC<Omit<ChartProps, 'seriesData' | 'xAxisData'>> = (
props props
) => { ) => {
@@ -12,28 +22,46 @@ const GaugeChart: React.FC<Omit<ChartProps, 'seriesData' | 'xAxisData'>> = (
title: titleConfig, title: titleConfig,
chartColorMap chartColorMap
} = useChartConfig(); } = useChartConfig();
const { value, height, width, labelFormatter, title, color } = props; const { value, height, width, labelFormatter, title, color, gaugeConfig } =
props;
const titleText = typeof title === 'string' ? title : title?.text;
if (!value && value !== 0) { if (!value && value !== 0) {
return <EmptyData height={height} title={title}></EmptyData>; return <EmptyData height={height} title={titleText}></EmptyData>;
} }
const setDataOptions = () => { const setDataOptions = () => {
const colorValue = color || strokeColorFunc(value);
const combineGaugeConfig = {
...gaugeItemConfig,
...gaugeConfig
};
combineGaugeConfig.detail.rich.value.color = colorValue;
combineGaugeConfig.detail.rich.unit.color = colorValue;
return { return {
title: { title: {
...titleConfig, ...titleConfig,
text: title, text: titleText,
top: '0', textStyle: {
left: 'center' fontSize: 12,
color: chartColorMap.colorSecondary,
fontWeight: 400
},
top: 10,
left: 'center',
...(typeof title === 'object' ? title : {})
}, },
series: [ series: [
{ {
...gaugeItemConfig, ...combineGaugeConfig,
axisLine: { axisLine: {
...gaugeItemConfig.axisLine, ...combineGaugeConfig.axisLine,
lineStyle: { lineStyle: {
...gaugeItemConfig.axisLine.lineStyle, ...combineGaugeConfig.axisLine.lineStyle,
color: [ color: [
[value / 100, color], [value / 100, colorValue],
[1, chartColorMap.gaugeBgColor] [1, chartColorMap.gaugeBgColor]
] ]
} }
@@ -42,7 +70,11 @@ const GaugeChart: React.FC<Omit<ChartProps, 'seriesData' | 'xAxisData'>> = (
color: 'transparent' color: 'transparent'
}, },
detail: { detail: {
...gaugeItemConfig.detail, ...combineGaugeConfig.detail,
borderColor: colorValue,
lineHeight: 20,
height: 18,
width: 50,
formatter: labelFormatter || gaugeItemConfig.detail.formatter formatter: labelFormatter || gaugeItemConfig.detail.formatter
}, },
data: [{ value }] data: [{ value }]
@@ -62,4 +94,4 @@ const GaugeChart: React.FC<Omit<ChartProps, 'seriesData' | 'xAxisData'>> = (
); );
}; };
export default memo(GaugeChart); export default GaugeChart;
+61 -10
View File
@@ -2,10 +2,10 @@ import Chart from '@/components/echarts/chart';
import useChartConfig from '@/components/echarts/config'; import useChartConfig from '@/components/echarts/config';
import EmptyData from '@/components/empty-data'; import EmptyData from '@/components/empty-data';
import _ from 'lodash'; import _ from 'lodash';
import React, { memo, useMemo } from 'react'; import React, { useMemo } from 'react';
import { ChartProps } from './types'; import { ChartProps } from './types';
const BarChart: React.FC<ChartProps> = (props) => { const BarChart: React.FC<ChartProps & { maxItems?: number }> = (props) => {
const { const {
seriesData, seriesData,
xAxisData, xAxisData,
@@ -13,9 +13,11 @@ const BarChart: React.FC<ChartProps> = (props) => {
width, width,
labelFormatter, labelFormatter,
legendData, legendData,
maxItems,
title title
} = props; } = props;
const { const {
token,
grid, grid,
legend, legend,
title: titleConfig, title: titleConfig,
@@ -30,18 +32,42 @@ const BarChart: React.FC<ChartProps> = (props) => {
...titleConfig, ...titleConfig,
left: 'start' left: 'start'
}, },
grid, grid: {
...grid,
top: 0,
bottom: maxItems
? `${(1 / maxItems) * (maxItems - xAxisData.length) * 100}%`
: 0
},
tooltip: { tooltip: {
...tooltip ...tooltip
}, },
xAxis: { xAxis: {
...xAxis, ...xAxis,
axisLabel: { axisLabel: {
...xAxis.axisLabel, ...xAxis.axisLabel
formatter: labelFormatter }
},
yAxis: {
...yAxis,
axisLabel: {
...yAxis.axisLabel,
show: true,
overflow: 'truncate',
width: 75,
ellipsis: '...'
// formatter(value: string, index: number) {
// return `{a|${index + 1}}`;
// },
// rich: {
// a: {
// fontWeight: 500,
// fontSize: 14,
// color: token?.colorTextSecondary
// }
// }
} }
}, },
yAxis,
legend: { legend: {
...legend, ...legend,
data: [] data: []
@@ -57,7 +83,23 @@ const BarChart: React.FC<ChartProps> = (props) => {
stack: 'Ad', stack: 'Ad',
barGap: '30%', barGap: '30%',
label: { label: {
show: false show: false,
formatter(params: any) {
if (params.seriesIndex === 0) {
return `{value|${params.name}}`;
}
return '';
},
position: 'left',
align: 'left',
offset: [5, 18],
rich: {
value: {
textBorderWidth: 0,
fontSize: 11,
color: token?.colorTextTertiary
}
}
}, },
itemStyle: { itemStyle: {
color: item.color color: item.color
@@ -114,10 +156,19 @@ const BarChart: React.FC<ChartProps> = (props) => {
legend legend
]); ]);
const isEmpty = useMemo(() => {
return seriesData?.every?.((item: any) => {
return !item?.data?.length;
});
}, [seriesData]);
return ( return (
<> <>
{!seriesData.length ? ( {isEmpty ? (
<EmptyData height={height} title={title}></EmptyData> <EmptyData
height={height}
title={_.get(title, 'text', title || '')}
></EmptyData>
) : ( ) : (
<Chart <Chart
height={height} height={height}
@@ -129,4 +180,4 @@ const BarChart: React.FC<ChartProps> = (props) => {
); );
}; };
export default memo(BarChart); export default BarChart;
+61 -8
View File
@@ -1,10 +1,13 @@
import Chart from '@/components/echarts/chart'; import Chart from '@/components/echarts/chart';
import useChartConfig from '@/components/echarts/config'; import useChartConfig from '@/components/echarts/config';
import EmptyData from '@/components/empty-data'; import EmptyData from '@/components/empty-data';
import { genColors } from '@/utils';
import _ from 'lodash'; import _ from 'lodash';
import React, { memo, useMemo } from 'react'; import React, { useMemo } from 'react';
import echarts from '.';
import { ChartProps } from './types'; import { ChartProps } from './types';
const LinearGradient = echarts.graphic.LinearGradient;
const LineChart: React.FC<ChartProps> = (props) => { const LineChart: React.FC<ChartProps> = (props) => {
const { const {
seriesData, seriesData,
@@ -16,7 +19,11 @@ const LineChart: React.FC<ChartProps> = (props) => {
tooltipValueFormatter = null, tooltipValueFormatter = null,
legendData = [], legendData = [],
smooth, smooth,
title title,
legendOptions,
gridOptions,
titleOptions,
showArea
} = props; } = props;
const { const {
grid, grid,
@@ -28,11 +35,24 @@ const LineChart: React.FC<ChartProps> = (props) => {
yAxis yAxis
} = useChartConfig(); } = useChartConfig();
const axisLabelFormatter = (value: string, index: number) => {
if (labelFormatter) {
return labelFormatter(value, index);
}
if (index === xAxisData.length - 1) {
return '';
}
return value;
};
const options = { const options = {
title: { title: {
text: '' text: ''
}, },
grid, grid: {
...grid,
...gridOptions
},
tooltip: { tooltip: {
...tooltip, ...tooltip,
formatter(params: any) { formatter(params: any) {
@@ -45,12 +65,13 @@ const LineChart: React.FC<ChartProps> = (props) => {
...xAxis, ...xAxis,
axisLabel: { axisLabel: {
...xAxis.axisLabel, ...xAxis.axisLabel,
formatter: labelFormatter formatter: axisLabelFormatter
} }
}, },
yAxis, yAxis,
legend: { legend: {
...legend, ...legend,
...legendOptions,
data: legendData.map((item: any) => { data: legendData.map((item: any) => {
return { return {
name: item, name: item,
@@ -64,6 +85,11 @@ const LineChart: React.FC<ChartProps> = (props) => {
const dataOptions = useMemo((): any => { const dataOptions = useMemo((): any => {
const data = _.map(seriesData, (item: any) => { const data = _.map(seriesData, (item: any) => {
const colors = genColors({
color: item.color,
alpha1: 0.25,
alpha2: 0.1
});
return { return {
...item, ...item,
...lineItemConfig, ...lineItemConfig,
@@ -75,7 +101,21 @@ const LineChart: React.FC<ChartProps> = (props) => {
lineStyle: { lineStyle: {
...lineItemConfig.lineStyle, ...lineItemConfig.lineStyle,
color: item.color color: item.color
} },
areaStyle: showArea
? {
color: new LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: colors[0]
},
{
offset: 1,
color: colors[1]
}
])
}
: null
}; };
}); });
return { return {
@@ -83,6 +123,7 @@ const LineChart: React.FC<ChartProps> = (props) => {
animation: false, animation: false,
title: { title: {
...titleConfig, ...titleConfig,
...titleOptions,
text: title text: title
}, },
yAxis: { yAxis: {
@@ -99,12 +140,24 @@ const LineChart: React.FC<ChartProps> = (props) => {
}, },
series: data series: data
}; };
}, [seriesData, xAxisData, yAxisName, title, smooth, legendData, options]); }, [
seriesData,
xAxisData,
yAxisName,
title,
smooth,
titleOptions,
legendData,
options
]);
return ( return (
<> <>
{!seriesData.length ? ( {!seriesData.length ? (
<EmptyData height={height} title={title}></EmptyData> <EmptyData
height={height}
title={_.get(title, 'text', title || '')}
></EmptyData>
) : ( ) : (
<Chart <Chart
height={height} height={height}
@@ -116,4 +169,4 @@ const LineChart: React.FC<ChartProps> = (props) => {
); );
}; };
export default memo(LineChart); export default LineChart;
+176
View File
@@ -0,0 +1,176 @@
import Chart from '@/components/echarts/chart';
import useChartConfig from '@/components/echarts/config';
import EmptyData from '@/components/empty-data';
import { genColors } from '@/utils';
import _ from 'lodash';
import React, { useMemo } from 'react';
import echarts from '.';
import { ChartProps } from './types';
const LinearGradient = echarts.graphic.LinearGradient;
const MixLineBarChart: React.FC<
ChartProps & {
chartData: {
line: any[];
bar: any[];
};
}
> = (props) => {
const {
seriesData,
xAxisData,
yAxisName,
height,
width,
labelFormatter,
tooltipValueFormatter = null,
legendData = [],
smooth,
title,
chartData
} = props;
const {
grid,
legend,
lineItemConfig,
barItemConfig,
title: titleConfig,
tooltip,
xAxis,
yAxis
} = useChartConfig();
const { line: lineSeriesData, bar: barSeriesData } = chartData;
const options = {
title: {
text: ''
},
grid: {
...grid,
right: 0,
top: 20,
bottom: 10
},
tooltip: {
...tooltip,
formatter(params: any) {
return tooltipValueFormatter
? tooltip.formatter(params, tooltipValueFormatter)
: tooltip.formatter(params);
}
},
xAxis: {
...xAxis,
axisLabel: {
...xAxis.axisLabel,
formatter: labelFormatter
}
},
yAxis,
legend: {
...legend,
data: legendData,
itemGap: 20,
bottom: 5,
show: false
},
series: []
};
const dataOptions = useMemo((): any => {
const linedata = _.map(lineSeriesData, (item: any) => {
const colors = genColors({
color: item.color,
alpha1: 0.5,
alpha2: 0.1
});
return {
...item,
...lineItemConfig,
smooth: smooth,
itemStyle: {
...lineItemConfig.itemStyle,
color: item.color
},
yAxisIndex: 1,
lineStyle: {
...lineItemConfig.lineStyle,
color: item.color
}
// areaStyle: {
// color: new LinearGradient(0, 0, 0, 1, [
// {
// offset: 0,
// color: colors[0]
// },
// {
// offset: 1,
// color: colors[1]
// }
// ])
// }
};
});
const barData = _.map(barSeriesData, (item: any) => {
return {
...item,
...barItemConfig,
stack: 'total',
yAxisIndex: 0,
itemStyle: {
...item.itemStyle,
color: item.color
}
};
});
return {
...options,
animation: false,
title: {
...titleConfig,
text: title
},
yAxis: [
{
...options.yAxis
},
{
...options.yAxis,
nameTextStyle: {
fontSize: 12,
align: 'right'
}
}
],
xAxis: {
...options.xAxis,
data: xAxisData
},
series: [...barData, ...linedata]
};
}, [seriesData, xAxisData, yAxisName, title, smooth, legendData, options]);
return (
<>
{!lineSeriesData.length && !barSeriesData.length ? (
<EmptyData
height={height}
title={_.get(title, 'text', title || '')}
></EmptyData>
) : (
<Chart
height={height}
options={dataOptions}
width={width || '100%'}
></Chart>
)}
</>
);
};
export default MixLineBarChart;
+1 -1
View File
@@ -181,7 +181,7 @@ const Scatter: React.FC<ChartProps> = (props) => {
<span class="tooltip-value">${item.text}</span> <span class="tooltip-value">${item.text}</span>
</span>`; </span>`;
}); });
return `<div class="tooltip-wrapper">${result}</div>`; return `<div class="tooltip-wrapper scatter">${result}</div>`;
} }
}, },
title: { title: {
+26 -3
View File
@@ -1,17 +1,40 @@
import type {
LegendComponentOption,
TitleComponentOption
} from 'echarts/components';
export interface ChartProps { export interface ChartProps {
seriesData: any[]; seriesData: any[];
showEmpty?: boolean; showEmpty?: boolean;
showArea?: boolean;
xAxisData: string[]; xAxisData: string[];
legendData?: string[]; legendData?: LegendComponentOption['data'];
labelFormatter?: (val?: any) => string; legendOptions?: {
[K in keyof LegendComponentOption]?: LegendComponentOption[K];
};
gridOptions?: {
left?: string | number;
right?: string | number;
top?: string | number;
bottom?: string | number;
};
labelFormatter?: (val?: any, index?: number) => string;
tooltipValueFormatter?: (val: any) => string; tooltipValueFormatter?: (val: any) => string;
height: string | number; height: string | number;
width?: string | number; width?: string | number;
title?: string; title?: string | TitleComponentOption;
titleOptions?: {
[K in keyof TitleComponentOption]?: TitleComponentOption[K];
};
value?: number; value?: number;
smooth?: boolean; smooth?: boolean;
color?: string; color?: string;
yAxisName?: string; yAxisName?: string;
gaugeConfig?: {
radius?: string;
center?: string[];
startAngle?: number;
endAngle?: number;
};
} }
export interface AreaChartItemProps { export interface AreaChartItemProps {
+41 -49
View File
@@ -1,74 +1,66 @@
import classNames from 'classnames';
import React from 'react'; import React from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import CopyButton from '../copy-button';
import SegmentLine from '../segment-line';
import './index.less'; import './index.less';
const Wrapper = styled.div<{ $height: number }>` const HeaderWrapper = styled.div<{ $height?: number }>`
height: ${(props) => props.$height}px; height: ${(props) => (props.$height ? `${props.$height}px` : 'auto')};
display: flex;
padding-block: 0;
justify-content: space-between;
align-items: center;
`;
const Wrapper = styled.div`
border-radius: var(--border-radius-mini);
overflow: hidden;
&.bordered {
border: 1px solid var(--ant-color-border);
}
&.borderless {
border: none;
}
.code-pre {
margin-bottom: 0;
}
.scrollbar {
.slider {
border-radius: 6px;
}
}
`; `;
interface EditorwrapProps { interface EditorwrapProps {
headerHeight?: number; headerHeight?: number;
header?: React.ReactNode; header?: React.ReactNode;
children: React.ReactNode; children: React.ReactNode;
showHeader?: boolean; variant?: 'bordered' | 'borderless';
copyText: string;
defaultValue?: string;
langOptions?: Global.BaseOption<string | number>[];
styles?: { styles?: {
wrapper?: React.CSSProperties; wrapper?: React.CSSProperties;
header?: React.CSSProperties; header?: React.CSSProperties;
content?: React.CSSProperties; content?: React.CSSProperties;
}; };
onChangeLang?: (value: string | number) => void;
} }
const EditorWrap: React.FC<EditorwrapProps> = ({ const EditorWrap: React.FC<EditorwrapProps> = ({
headerHeight = 40, headerHeight = 40,
header, header,
children, children,
copyText, variant = 'borderless',
langOptions = [], styles = {}
onChangeLang,
defaultValue,
styles = {},
showHeader = true
}) => { }) => {
const handleChangeLang = (value: string | number) => {
onChangeLang?.(value);
};
const renderHeader = () => {
if (header) {
return <div className="editor-header">{header}</div>;
}
if (showHeader) {
return (
<Wrapper className="editor-header" $height={headerHeight}>
<SegmentLine
height={headerHeight}
defaultValue={defaultValue}
size="small"
options={langOptions}
onChange={handleChangeLang}
></SegmentLine>
<CopyButton
text={copyText}
size="small"
style={{
color: 'rgba(255,255,255,.7)'
}}
/>
</Wrapper>
);
}
return null;
};
return ( return (
<div className="editor-wrap" style={{ ...styles.wrapper }}> <Wrapper
{renderHeader()} style={{ ...styles.wrapper }}
<div className="editor-content">{children}</div> className={classNames({
</div> bordered: variant === 'bordered',
borderless: variant === 'borderless'
})}
>
{header && <HeaderWrapper $height={headerHeight}>{header}</HeaderWrapper>}
<div>{children}</div>
</Wrapper>
); );
}; };
export default React.memo(EditorWrap); export default EditorWrap;
@@ -1,30 +1,39 @@
import { LoadingOutlined } from '@ant-design/icons';
import Editor from '@monaco-editor/react'; import Editor from '@monaco-editor/react';
import React, { useEffect, useRef, useState } from 'react'; import React, {
forwardRef,
useEffect,
useImperativeHandle,
useRef
} from 'react';
import EditorWrap from '../editor-wrap'; import EditorWrap from '../editor-wrap';
interface ViewerProps { interface ViewerProps {
ref?: any;
lang: string; lang: string;
defaultLang?: string; defaultLang?: string;
langOptions?: Global.BaseOption<string>[];
config?: any; config?: any;
value: string; value: string;
height?: string | number; height?: string | number;
theme?: string; theme?: string;
showHeader?: boolean; header?: React.ReactNode;
placeholder?: string;
variant?: 'bordered' | 'borderless';
} }
const ViewerEditor: React.FC<ViewerProps> = (props) => { const ViewerEditor: React.FC<ViewerProps> = forwardRef((props, ref) => {
const editorRef = useRef<any>(null);
const { const {
lang, lang,
value, value,
config, config,
langOptions,
defaultLang, defaultLang,
height = 380, height = 380,
showHeader theme = 'vs-dark',
header,
variant = 'borderless',
placeholder
} = props; } = props;
const [langType, setLangType] = useState(defaultLang);
const editorRef = useRef<any>(null);
const handleBeforeMount = (monaco: any) => { const handleBeforeMount = (monaco: any) => {
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({ monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
@@ -36,12 +45,8 @@ const ViewerEditor: React.FC<ViewerProps> = (props) => {
const handleEditorDidMount = (editor: any, monaco: any) => { const handleEditorDidMount = (editor: any, monaco: any) => {
editorRef.current = editor; editorRef.current = editor;
console.log('loaded====', editor, monaco);
}; };
const handleOnChangeLang = (value: string) => {
setLangType(value);
};
const formatCode = () => { const formatCode = () => {
if (editorRef.current) { if (editorRef.current) {
setTimeout(() => { setTimeout(() => {
@@ -55,35 +60,50 @@ const ViewerEditor: React.FC<ViewerProps> = (props) => {
} }
}; };
useImperativeHandle(ref, () => ({
format: () => {
formatCode();
},
getValue: () => {
return editorRef.current?.getValue?.();
},
setValue: (val: string) => {
editorRef.current?.setValue?.(val);
},
editor: editorRef.current
}));
useEffect(() => { useEffect(() => {
formatCode(); formatCode();
setTimeout(() => { setTimeout(() => {
const lineCount = editorRef.current?.getModel().getLineCount(); // 获取总行数 const lineCount = editorRef.current?.getModel().getLineCount();
editorRef.current?.revealLine(lineCount); // 滚动到最后一行 editorRef.current?.revealLine(lineCount);
}, 100); // 可以调整延时,确保编辑器完全加载 }, 100);
}, [value]); }, [value]);
return ( return (
<EditorWrap <EditorWrap header={header} variant={variant}>
copyText={value}
langOptions={langOptions}
defaultValue={lang}
showHeader={showHeader}
onChangeLang={handleOnChangeLang}
>
<Editor <Editor
height={height} height={height}
theme="vs-dark" theme={theme}
className="monaco-editor" className="monaco-editor"
defaultLanguage={defaultLang} defaultLanguage={defaultLang}
language={langType} language={lang}
value={value} value={value}
options={config} options={{
minimap: { enabled: false },
scrollbar: {
verticalScrollbarSize: 6,
horizontalScrollbarSize: 6
},
placeholder: placeholder
}}
loading={<LoadingOutlined style={{ fontSize: 24 }}></LoadingOutlined>}
beforeMount={handleBeforeMount} beforeMount={handleBeforeMount}
onMount={handleEditorDidMount} onMount={handleEditorDidMount}
/> />
</EditorWrap> </EditorWrap>
); );
}; });
export default React.memo(ViewerEditor); export default ViewerEditor;
@@ -1,4 +1,3 @@
import { memo } from 'react';
import CodeViewer from './code-viewer'; import CodeViewer from './code-viewer';
import './styles/dark.less'; import './styles/dark.less';
@@ -38,4 +37,4 @@ const DarkViewer: React.FC<CodeViewerProps> = (props) => {
); );
}; };
export default memo(DarkViewer); export default DarkViewer;
@@ -1,4 +1,3 @@
import { memo } from 'react';
import CodeViewer from './code-viewer'; import CodeViewer from './code-viewer';
import './styles/light.less'; import './styles/light.less';
@@ -39,4 +38,4 @@ const LightViewer: React.FC<CodeViewerProps> = (props) => {
); );
}; };
export default memo(LightViewer); export default LightViewer;
@@ -1,6 +1,6 @@
import classNames from 'classnames'; import classNames from 'classnames';
import hljs from 'highlight.js'; import hljs from 'highlight.js';
import { memo, useMemo } from 'react'; import { useMemo } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import CopyButton from '../copy-button'; import CopyButton from '../copy-button';
import { escapeHtml } from './utils'; import { escapeHtml } from './utils';
@@ -155,4 +155,4 @@ const CodeViewer: React.FC<CodeViewerProps> = (props) => {
); );
}; };
export default memo(CodeViewer); export default CodeViewer;
+1 -1
View File
@@ -56,4 +56,4 @@ const HighlightCode: React.FC<{
); );
}; };
export default React.memo(HighlightCode); export default HighlightCode;
@@ -46,7 +46,7 @@
white-space: pre-wrap; white-space: pre-wrap;
code { code {
line-height: 1.5; line-height: 1.6;
} }
&.copyable { &.copyable {
+431 -11
View File
@@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: iconfont; /* Project id 4613488 */ font-family: iconfont; /* Project id 4613488 */
src: url('iconfont.woff2?t=1747231573342') format('woff2'), src: url('iconfont.woff2?t=1766993792323') format('woff2'),
url('iconfont.woff?t=1747231573342') format('woff'), url('iconfont.woff?t=1766993792323') format('woff'),
url('iconfont.ttf?t=1747231573342') format('truetype'); url('iconfont.ttf?t=1766993792323') format('truetype');
} }
.iconfont { .iconfont {
@@ -13,6 +13,434 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icon-cloud::before {
content: "\e6bc";
}
.icon-server02::before {
content: "\e6bd";
}
.icon-drag_handle::before {
content: "\e6b9";
}
.icon-basic::before {
content: "\e6bb";
}
.icon-settings::before {
content: "\e6b8";
}
.icon-speed::before {
content: "\e6ba";
}
.icon-permission::before {
content: "\e6b6";
}
.icon-captive_portal::before {
content: "\e6b7";
}
.icon-lock_open_right::before {
content: "\e6b3";
}
.icon-lock_person::before {
content: "\e6b4";
}
.icon-lock_open::before {
content: "\e6b5";
}
.icon-question::before {
content: "\e6b2";
}
.icon-aws::before {
content: "\e616";
}
.icon-aws1::before {
content: "\e62f";
}
.icon-manage_user::before {
content: "\e6b1";
}
.icon-private::before {
content: "\e6b0";
}
.icon-stop3::before {
content: "\e6af";
}
.icon-version::before {
content: "\e6ae";
}
.icon-edit-content::before {
content: "\e6ab";
}
.icon-code_block::before {
content: "\e6ac";
}
.icon-parameters::before {
content: "\e6ad";
}
.icon-backend-filled::before {
content: "\e6a9";
}
.icon-backend::before {
content: "\e6aa";
}
.icon-down2::before {
content: "\e6a7";
}
.icon-nvidia2::before {
content: "\e60d";
}
.icon-centos::before {
content: "\e6cd";
}
.icon-redhat::before {
content: "\ec7b";
}
.icon-ubuntu::before {
content: "\edd3";
}
.icon-debian::before {
content: "\eb74";
}
.icon-alma-linux::before {
content: "\e6a8";
}
.icon-fedora::before {
content: "\e61a";
}
.icon-rocky-linux::before {
content: "\e620";
}
.icon-nvidia1::before {
content: "\e980";
}
.icon-nvidia::before {
content: "\e60c";
}
.icon-amd::before {
content: "\e6a6";
}
.icon-huawei::before {
content: "\e615";
}
.icon-metax::before {
content: "\e6a4";
}
.icon-ascend::before {
content: "\e6a3";
}
.icon-huaweicloud::before {
content: "\e614";
}
.icon-alicloud::before {
content: "\e784";
}
.icon-tencentcloud::before {
content: "\e609";
}
.icon-cluster2-outline::before {
content: "\e6a1";
}
.icon-cluster2-filled::before {
content: "\e6a2";
}
.icon-cluster-filled::before {
content: "\e69f";
}
.icon-cluster-outline::before {
content: "\e6a0";
}
.icon-admin-user::before {
content: "\e69d";
}
.icon-user::before {
content: "\e69e";
}
.icon-detail-info::before {
content: "\e69b";
}
.icon-docker::before {
content: "\e69c";
}
.icon-digitalocean::before {
content: "\eb79";
}
.icon-rocket-launch1::before {
content: "\e699";
}
.icon-rocket-launch-fill::before {
content: "\e69a";
}
.icon-credential-filled::before {
content: "\e697";
}
.icon-credential-outline::before {
content: "\e698";
}
.icon-k8s-filled::before {
content: "\e63e";
}
.icon-k8s-outline::before {
content: "\e64b";
}
.icon-huggingface1::before {
content: "\e605";
}
.icon-modelscope_light::before {
content: "\e696";
}
.icon-catalog1::before {
content: "\e691";
}
.icon-chat-filled::before {
content: "\e692";
}
.icon-chat::before {
content: "\e693";
}
.icon-files-filled::before {
content: "\e694";
}
.icon-files::before {
content: "\e695";
}
.icon-models-filled::before {
content: "\e682";
}
.icon-image-filled::before {
content: "\e683";
}
.icon-audio1::before {
content: "\e684";
}
.icon-image1::before {
content: "\e685";
}
.icon-audio-filled::before {
content: "\e686";
}
.icon-reranker-filled::before {
content: "\e687";
}
.icon-embedding-filled::before {
content: "\e68a";
}
.icon-models::before {
content: "\e68b";
}
.icon-reranker::before {
content: "\e68c";
}
.icon-embedding::before {
content: "\e68d";
}
.icon-gpu-filled::before {
content: "\e68e";
}
.icon-catalog-filled::before {
content: "\e68f";
}
.icon-gpu1::before {
content: "\e690";
}
.icon-language::before {
content: "\e679";
}
.icon-help::before {
content: "\e67a";
}
.icon-key-filled::before {
content: "\e67b";
}
.icon-key::before {
content: "\e67d";
}
.icon-resources::before {
content: "\e67e";
}
.icon-users::before {
content: "\e67f";
}
.icon-resources-filled::before {
content: "\e680";
}
.icon-users-filled::before {
content: "\e681";
}
.icon-model::before {
content: "\e676";
}
.icon-model-filled::before {
content: "\e678";
}
.icon-layers-filled::before {
content: "\e671";
}
.icon-layers::before {
content: "\e673";
}
.icon-experiment::before {
content: "\e674";
}
.icon-experiment-filled::before {
content: "\e675";
}
.icon-dashboard::before {
content: "\e66d";
}
.icon-dashboard-filled::before {
content: "\e66e";
}
.icon-expand-left::before {
content: "\ea48";
}
.icon-expand-right::before {
content: "\ea49";
}
.icon-users-fill::before {
content: "\e677";
}
.icon-layers-fill::before {
content: "\e89d";
}
.icon-key-fill::before {
content: "\e80e";
}
.icon-server-fill::before {
content: "\e7a3";
}
.icon-model-fill::before {
content: "\e7b7";
}
.icon-left_panel_close::before {
content: "\e668";
}
.icon-left_panel_open::before {
content: "\e669";
}
.icon-playcircle-fill::before {
content: "\e665";
}
.icon-stopcircle-fill::before {
content: "\e666";
}
.icon-play-speed::before {
content: "\e856";
}
.icon-more::before {
content: "\e62e";
}
.icon-play::before {
content: "\e9f9";
}
.icon-pause::before {
content: "\e713";
}
.icon-dark_theme::before { .icon-dark_theme::before {
content: "\e646"; content: "\e646";
} }
@@ -237,14 +665,6 @@
content: "\e62c"; content: "\e62c";
} }
.icon-stopcircle-fill::before {
content: "\e7cc";
}
.icon-playcircle-fill::before {
content: "\e7cd";
}
.icon-SpeakerSlash::before { .icon-SpeakerSlash::before {
content: "\e661"; content: "\e661";
} }
File diff suppressed because one or more lines are too long
+749 -14
View File
@@ -5,6 +5,755 @@
"css_prefix_text": "icon-", "css_prefix_text": "icon-",
"description": "", "description": "",
"glyphs": [ "glyphs": [
{
"icon_id": "46296038",
"name": "cloud",
"font_class": "cloud",
"unicode": "e6bc",
"unicode_decimal": 59068
},
{
"icon_id": "46296037",
"name": "server",
"font_class": "server02",
"unicode": "e6bd",
"unicode_decimal": 59069
},
{
"icon_id": "46272083",
"name": "drag_handle",
"font_class": "drag_handle",
"unicode": "e6b9",
"unicode_decimal": 59065
},
{
"icon_id": "46055620",
"name": "basic",
"font_class": "basic",
"unicode": "e6bb",
"unicode_decimal": 59067
},
{
"icon_id": "46055265",
"name": "settings",
"font_class": "settings",
"unicode": "e6b8",
"unicode_decimal": 59064
},
{
"icon_id": "46055263",
"name": "speed",
"font_class": "speed",
"unicode": "e6ba",
"unicode_decimal": 59066
},
{
"icon_id": "46039838",
"name": "permission",
"font_class": "permission",
"unicode": "e6b6",
"unicode_decimal": 59062
},
{
"icon_id": "46039837",
"name": "captive_portal",
"font_class": "captive_portal",
"unicode": "e6b7",
"unicode_decimal": 59063
},
{
"icon_id": "46001737",
"name": "lock_open_right",
"font_class": "lock_open_right",
"unicode": "e6b3",
"unicode_decimal": 59059
},
{
"icon_id": "46001736",
"name": "lock_person",
"font_class": "lock_person",
"unicode": "e6b4",
"unicode_decimal": 59060
},
{
"icon_id": "46001735",
"name": "lock_open",
"font_class": "lock_open",
"unicode": "e6b5",
"unicode_decimal": 59061
},
{
"icon_id": "45937227",
"name": "question_mark_24dp_1F1F1F_FILL0_wght300_GRAD0_opsz",
"font_class": "question",
"unicode": "e6b2",
"unicode_decimal": 59058
},
{
"icon_id": "10786885",
"name": "aws",
"font_class": "aws",
"unicode": "e616",
"unicode_decimal": 58902
},
{
"icon_id": "12014352",
"name": "aws",
"font_class": "aws1",
"unicode": "e62f",
"unicode_decimal": 58927
},
{
"icon_id": "45704693",
"name": "manage_accounts_24dp_1F1F1F_FILL1_wght300_GRAD0_op",
"font_class": "manage_user",
"unicode": "e6b1",
"unicode_decimal": 59057
},
{
"icon_id": "45702717",
"name": "private",
"font_class": "private",
"unicode": "e6b0",
"unicode_decimal": 59056
},
{
"icon_id": "45702697",
"name": "stop",
"font_class": "stop3",
"unicode": "e6af",
"unicode_decimal": 59055
},
{
"icon_id": "45688107",
"name": "version",
"font_class": "version",
"unicode": "e6ae",
"unicode_decimal": 59054
},
{
"icon_id": "45631011",
"name": "contract_edit_24dp_1F1F1F_FILL0_wght300_GRAD0_opsz",
"font_class": "edit-content",
"unicode": "e6ab",
"unicode_decimal": 59051
},
{
"icon_id": "45631010",
"name": "code_blocks_24dp_1F1F1F_FILL0_wght300_GRAD0_opsz24",
"font_class": "code_block",
"unicode": "e6ac",
"unicode_decimal": 59052
},
{
"icon_id": "45631009",
"name": "settings_applications_24dp_1F1F1F_FILL0_wght300_GR",
"font_class": "parameters",
"unicode": "e6ad",
"unicode_decimal": 59053
},
{
"icon_id": "45623375",
"name": "bolt_24dp_1F1F1F_FILL1_wght300_GRAD0_opsz24",
"font_class": "backend-filled",
"unicode": "e6a9",
"unicode_decimal": 59049
},
{
"icon_id": "45623374",
"name": "bolt_24dp_1F1F1F_FILL0_wght300_GRAD0_opsz24",
"font_class": "backend",
"unicode": "e6aa",
"unicode_decimal": 59050
},
{
"icon_id": "45554217",
"name": "arrow_down",
"font_class": "down2",
"unicode": "e6a7",
"unicode_decimal": 59047
},
{
"icon_id": "11155543",
"name": "nvidia",
"font_class": "nvidia2",
"unicode": "e60d",
"unicode_decimal": 58893
},
{
"icon_id": "11425971",
"name": "centos",
"font_class": "centos",
"unicode": "e6cd",
"unicode_decimal": 59085
},
{
"icon_id": "15378743",
"name": "redhat",
"font_class": "redhat",
"unicode": "ec7b",
"unicode_decimal": 60539
},
{
"icon_id": "6808499",
"name": "Ubuntu",
"font_class": "ubuntu",
"unicode": "edd3",
"unicode_decimal": 60883
},
{
"icon_id": "15378275",
"name": "debian",
"font_class": "debian",
"unicode": "eb74",
"unicode_decimal": 60276
},
{
"icon_id": "38395859",
"name": "almalinux",
"font_class": "alma-linux",
"unicode": "e6a8",
"unicode_decimal": 59048
},
{
"icon_id": "43280042",
"name": "linux-fedora",
"font_class": "fedora",
"unicode": "e61a",
"unicode_decimal": 58906
},
{
"icon_id": "43280143",
"name": "linux-rocky_linux",
"font_class": "rocky-linux",
"unicode": "e620",
"unicode_decimal": 58912
},
{
"icon_id": "36227448",
"name": "nvidia",
"font_class": "nvidia1",
"unicode": "e980",
"unicode_decimal": 59776
},
{
"icon_id": "40723469",
"name": "nvidia",
"font_class": "nvidia",
"unicode": "e60c",
"unicode_decimal": 58892
},
{
"icon_id": "45463937",
"name": "amd",
"font_class": "amd",
"unicode": "e6a6",
"unicode_decimal": 59046
},
{
"icon_id": "24164616",
"name": "华为",
"font_class": "huawei",
"unicode": "e615",
"unicode_decimal": 58901
},
{
"icon_id": "45461362",
"name": "metax",
"font_class": "metax",
"unicode": "e6a4",
"unicode_decimal": 59044
},
{
"icon_id": "45459906",
"name": "ascend",
"font_class": "ascend",
"unicode": "e6a3",
"unicode_decimal": 59043
},
{
"icon_id": "8152996",
"name": "HUAWEI",
"font_class": "huaweicloud",
"unicode": "e614",
"unicode_decimal": 58900
},
{
"icon_id": "34290284",
"name": "alicloud",
"font_class": "alicloud",
"unicode": "e784",
"unicode_decimal": 59268
},
{
"icon_id": "36654764",
"name": "tencent",
"font_class": "tencentcloud",
"unicode": "e609",
"unicode_decimal": 58889
},
{
"icon_id": "45310241",
"name": "cluster2-outline",
"font_class": "cluster2-outline",
"unicode": "e6a1",
"unicode_decimal": 59041
},
{
"icon_id": "45310242",
"name": "cluster2-filled",
"font_class": "cluster2-filled",
"unicode": "e6a2",
"unicode_decimal": 59042
},
{
"icon_id": "45310070",
"name": "cluster-filled",
"font_class": "cluster-filled",
"unicode": "e69f",
"unicode_decimal": 59039
},
{
"icon_id": "45310069",
"name": "cluster-outline",
"font_class": "cluster-outline",
"unicode": "e6a0",
"unicode_decimal": 59040
},
{
"icon_id": "45240470",
"name": "admin-user",
"font_class": "admin-user",
"unicode": "e69d",
"unicode_decimal": 59037
},
{
"icon_id": "45240469",
"name": "user",
"font_class": "user",
"unicode": "e69e",
"unicode_decimal": 59038
},
{
"icon_id": "45221182",
"name": "detail-info",
"font_class": "detail-info",
"unicode": "e69b",
"unicode_decimal": 59035
},
{
"icon_id": "45102077",
"name": "Docker",
"font_class": "docker",
"unicode": "e69c",
"unicode_decimal": 59036
},
{
"icon_id": "15378290",
"name": "digitalocean",
"font_class": "digitalocean",
"unicode": "eb79",
"unicode_decimal": 60281
},
{
"icon_id": "45040302",
"name": "rocket-launch",
"font_class": "rocket-launch1",
"unicode": "e699",
"unicode_decimal": 59033
},
{
"icon_id": "45040301",
"name": "rocket-launch-fill",
"font_class": "rocket-launch-fill",
"unicode": "e69a",
"unicode_decimal": 59034
},
{
"icon_id": "45028316",
"name": "credential",
"font_class": "credential-filled",
"unicode": "e697",
"unicode_decimal": 59031
},
{
"icon_id": "45028315",
"name": "credential",
"font_class": "credential-outline",
"unicode": "e698",
"unicode_decimal": 59032
},
{
"icon_id": "37601405",
"name": "k8s",
"font_class": "k8s-filled",
"unicode": "e63e",
"unicode_decimal": 58942
},
{
"icon_id": "41673174",
"name": "k8s",
"font_class": "k8s-outline",
"unicode": "e64b",
"unicode_decimal": 58955
},
{
"icon_id": "40865292",
"name": "huggingface",
"font_class": "huggingface1",
"unicode": "e605",
"unicode_decimal": 58885
},
{
"icon_id": "43616582",
"name": "modelscope_light",
"font_class": "modelscope_light",
"unicode": "e696",
"unicode_decimal": 59030
},
{
"icon_id": "44776845",
"name": "catalog",
"font_class": "catalog1",
"unicode": "e691",
"unicode_decimal": 59025
},
{
"icon_id": "44776848",
"name": "chat-filled",
"font_class": "chat-filled",
"unicode": "e692",
"unicode_decimal": 59026
},
{
"icon_id": "44776846",
"name": "chat",
"font_class": "chat",
"unicode": "e693",
"unicode_decimal": 59027
},
{
"icon_id": "44776841",
"name": "files-filled",
"font_class": "files-filled",
"unicode": "e694",
"unicode_decimal": 59028
},
{
"icon_id": "44776840",
"name": "files",
"font_class": "files",
"unicode": "e695",
"unicode_decimal": 59029
},
{
"icon_id": "44776851",
"name": "models-filled",
"font_class": "models-filled",
"unicode": "e682",
"unicode_decimal": 59010
},
{
"icon_id": "44776857",
"name": "image-filled",
"font_class": "image-filled",
"unicode": "e683",
"unicode_decimal": 59011
},
{
"icon_id": "44776856",
"name": "audio",
"font_class": "audio1",
"unicode": "e684",
"unicode_decimal": 59012
},
{
"icon_id": "44776855",
"name": "image",
"font_class": "image1",
"unicode": "e685",
"unicode_decimal": 59013
},
{
"icon_id": "44776850",
"name": "audio-filled",
"font_class": "audio-filled",
"unicode": "e686",
"unicode_decimal": 59014
},
{
"icon_id": "44776849",
"name": "reranker-filled",
"font_class": "reranker-filled",
"unicode": "e687",
"unicode_decimal": 59015
},
{
"icon_id": "44776852",
"name": "embedding-filled",
"font_class": "embedding-filled",
"unicode": "e68a",
"unicode_decimal": 59018
},
{
"icon_id": "44776853",
"name": "models",
"font_class": "models",
"unicode": "e68b",
"unicode_decimal": 59019
},
{
"icon_id": "44776844",
"name": "reranker",
"font_class": "reranker",
"unicode": "e68c",
"unicode_decimal": 59020
},
{
"icon_id": "44776854",
"name": "embedding",
"font_class": "embedding",
"unicode": "e68d",
"unicode_decimal": 59021
},
{
"icon_id": "44776843",
"name": "gpu-filled",
"font_class": "gpu-filled",
"unicode": "e68e",
"unicode_decimal": 59022
},
{
"icon_id": "44776847",
"name": "catalog-filled",
"font_class": "catalog-filled",
"unicode": "e68f",
"unicode_decimal": 59023
},
{
"icon_id": "44776842",
"name": "gpu",
"font_class": "gpu1",
"unicode": "e690",
"unicode_decimal": 59024
},
{
"icon_id": "44685190",
"name": "language",
"font_class": "language",
"unicode": "e679",
"unicode_decimal": 59001
},
{
"icon_id": "44685189",
"name": "help",
"font_class": "help",
"unicode": "e67a",
"unicode_decimal": 59002
},
{
"icon_id": "44684306",
"name": "key-filled",
"font_class": "key-filled",
"unicode": "e67b",
"unicode_decimal": 59003
},
{
"icon_id": "44684302",
"name": "key",
"font_class": "key",
"unicode": "e67d",
"unicode_decimal": 59005
},
{
"icon_id": "44684304",
"name": "resources",
"font_class": "resources",
"unicode": "e67e",
"unicode_decimal": 59006
},
{
"icon_id": "44684305",
"name": "users",
"font_class": "users",
"unicode": "e67f",
"unicode_decimal": 59007
},
{
"icon_id": "44684303",
"name": "resources-filled",
"font_class": "resources-filled",
"unicode": "e680",
"unicode_decimal": 59008
},
{
"icon_id": "44684301",
"name": "users-filled",
"font_class": "users-filled",
"unicode": "e681",
"unicode_decimal": 59009
},
{
"icon_id": "44684150",
"name": "model",
"font_class": "model",
"unicode": "e676",
"unicode_decimal": 58998
},
{
"icon_id": "44684149",
"name": "model-filled",
"font_class": "model-filled",
"unicode": "e678",
"unicode_decimal": 59000
},
{
"icon_id": "44684090",
"name": "layers-filled",
"font_class": "layers-filled",
"unicode": "e671",
"unicode_decimal": 58993
},
{
"icon_id": "44684091",
"name": "layers",
"font_class": "layers",
"unicode": "e673",
"unicode_decimal": 58995
},
{
"icon_id": "44684086",
"name": "experiment",
"font_class": "experiment",
"unicode": "e674",
"unicode_decimal": 58996
},
{
"icon_id": "44684085",
"name": "experiment",
"font_class": "experiment-filled",
"unicode": "e675",
"unicode_decimal": 58997
},
{
"icon_id": "44684021",
"name": "dashboard",
"font_class": "dashboard",
"unicode": "e66d",
"unicode_decimal": 58989
},
{
"icon_id": "44684020",
"name": "dashboard-filled",
"font_class": "dashboard-filled",
"unicode": "e66e",
"unicode_decimal": 58990
},
{
"icon_id": "40068272",
"name": "expand-left",
"font_class": "expand-left",
"unicode": "ea48",
"unicode_decimal": 59976
},
{
"icon_id": "40068278",
"name": "expand-right",
"font_class": "expand-right",
"unicode": "ea49",
"unicode_decimal": 59977
},
{
"icon_id": "1350497",
"name": "sq-users",
"font_class": "users-fill",
"unicode": "e677",
"unicode_decimal": 58999
},
{
"icon_id": "13691715",
"name": "layers",
"font_class": "layers-fill",
"unicode": "e89d",
"unicode_decimal": 59549
},
{
"icon_id": "14267903",
"name": "key-skeleton-alt",
"font_class": "key-fill",
"unicode": "e80e",
"unicode_decimal": 59406
},
{
"icon_id": "14341823",
"name": "cloud-server-solid",
"font_class": "server-fill",
"unicode": "e7a3",
"unicode_decimal": 59299
},
{
"icon_id": "40764011",
"name": "icon-model-selected",
"font_class": "model-fill",
"unicode": "e7b7",
"unicode_decimal": 59319
},
{
"icon_id": "44668359",
"name": "left_panel_close_36dp_1F1F1F_FILL0_wght400_GRAD0_o",
"font_class": "left_panel_close",
"unicode": "e668",
"unicode_decimal": 58984
},
{
"icon_id": "44668360",
"name": "left_panel_open_36dp_1F1F1F_FILL0_wght400_GRAD0_op",
"font_class": "left_panel_open",
"unicode": "e669",
"unicode_decimal": 58985
},
{
"icon_id": "44650419",
"name": "play circle-fill",
"font_class": "playcircle-fill",
"unicode": "e665",
"unicode_decimal": 58981
},
{
"icon_id": "44650418",
"name": "stop circle-fill",
"font_class": "stopcircle-fill",
"unicode": "e666",
"unicode_decimal": 58982
},
{
"icon_id": "8592899",
"name": "play-speed",
"font_class": "play-speed",
"unicode": "e856",
"unicode_decimal": 59478
},
{
"icon_id": "10941162",
"name": "more",
"font_class": "more",
"unicode": "e62e",
"unicode_decimal": 58926
},
{
"icon_id": "703373",
"name": "play",
"font_class": "play",
"unicode": "e9f9",
"unicode_decimal": 59897
},
{
"icon_id": "736882",
"name": "pause",
"font_class": "pause",
"unicode": "e713",
"unicode_decimal": 59155
},
{ {
"icon_id": "44028047", "icon_id": "44028047",
"name": "dark_theme", "name": "dark_theme",
@@ -397,20 +1146,6 @@
"unicode": "e62c", "unicode": "e62c",
"unicode_decimal": 58924 "unicode_decimal": 58924
}, },
{
"icon_id": "6151140",
"name": "stop circle-fill",
"font_class": "stopcircle-fill",
"unicode": "e7cc",
"unicode_decimal": 59340
},
{
"icon_id": "6151141",
"name": "play circle-fill",
"font_class": "playcircle-fill",
"unicode": "e7cd",
"unicode_decimal": 59341
},
{ {
"icon_id": "23563264", "icon_id": "23563264",
"name": "SpeakerSlash", "name": "SpeakerSlash",
Binary file not shown.
Binary file not shown.
Binary file not shown.
+66
View File
@@ -0,0 +1,66 @@
import IconFont from '@/components/icon-font';
import {
ApiOutlined,
DeleteOutlined,
DockerOutlined,
DownloadOutlined,
EditOutlined,
ExperimentOutlined,
FileTextOutlined,
KubernetesOutlined,
ProfileOutlined,
RetweetOutlined,
StarOutlined,
ThunderboltOutlined
} from '@ant-design/icons';
import React from 'react';
const icons = {
EditOutlined: React.createElement(EditOutlined),
ExperimentOutlined: React.createElement(ExperimentOutlined),
DeleteOutlined: React.createElement(DeleteOutlined),
ThunderboltOutlined: React.createElement(ThunderboltOutlined),
RetweetOutlined: React.createElement(RetweetOutlined),
DownloadOutlined: React.createElement(DownloadOutlined),
FileTextOutlined: React.createElement(FileTextOutlined),
ApiOutlined: React.createElement(ApiOutlined),
KubernetesOutlined: React.createElement(KubernetesOutlined),
ProfileOutlined: React.createElement(ProfileOutlined),
DockerOutlined: React.createElement(DockerOutlined),
Stop: React.createElement(IconFont, { type: 'icon-stop1' }),
Play: React.createElement(IconFont, { type: 'icon-outline-play' }),
Catalog: React.createElement(IconFont, { type: 'icon-catalog' }),
HF: React.createElement(IconFont, { type: 'icon-huggingface' }),
Ollama: React.createElement(IconFont, { type: 'icon-ollama' }),
ModelScope: React.createElement(IconFont, { type: 'icon-tu2' }),
LocalPath: React.createElement(IconFont, { type: 'icon-hard-disk' }),
Launch: React.createElement(IconFont, { type: 'icon-rocket-launch' }),
Deployment: React.createElement(IconFont, { type: 'icon-rocket-launch1' }),
Docker: React.createElement(IconFont, { type: 'icon-docker' }),
DigitalOcean: React.createElement(IconFont, { type: 'icon-digitalocean' }),
DetailInfo: React.createElement(IconFont, { type: 'icon-detail-info' }),
HuaweiCloud: React.createElement(IconFont, { type: 'icon-huaweicloud' }),
AliCloud: React.createElement(IconFont, { type: 'icon-alicloud' }),
TencentCloud: React.createElement(IconFont, { type: 'icon-tencentcloud' }),
Nvidia: React.createElement(IconFont, { type: 'icon-nvidia' }),
Ascend: React.createElement(IconFont, { type: 'icon-ascend' }),
Catalog1: React.createElement(IconFont, { type: 'icon-catalog1' }),
AMD: React.createElement(IconFont, { type: 'icon-amd' }),
KubernetesFilled: React.createElement(IconFont, { type: 'icon-k8s-filled' }),
EditContent: React.createElement(IconFont, { type: 'icon-edit-content' }),
Yaml: React.createElement(IconFont, { type: 'icon-code_block' }),
Version: React.createElement(IconFont, { type: 'icon-version' }),
Parameter: React.createElement(IconFont, { type: 'icon-parameters' }),
Private: React.createElement(IconFont, { type: 'icon-private' }),
AWS: React.createElement(IconFont, { type: 'icon-aws' }),
LockOpenRight: React.createElement(IconFont, {
type: 'icon-lock_open_right'
}),
LockPerson: React.createElement(IconFont, { type: 'icon-lock_person' }),
LockOpen: React.createElement(IconFont, { type: 'icon-lock_open' }),
Permission: React.createElement(IconFont, { type: 'icon-permission' }),
CaptivePortal: React.createElement(IconFont, { type: 'icon-captive_portal' }),
StarOutlined: React.createElement(StarOutlined)
};
export default icons;
@@ -107,7 +107,6 @@ export default function useZoom(props: {
if (isLoadingMaskRef.current) { if (isLoadingMaskRef.current) {
return; return;
} }
event.preventDefault();
// stop // stop
handleZoom(event); handleZoom(event);
updateCursorSize(); updateCursorSize();
+13 -4
View File
@@ -433,7 +433,6 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
fitView(); fitView();
setActiveScale(autoScale.current); setActiveScale(autoScale.current);
updateCursorSize(); updateCursorSize();
redrawStrokes(strokesRef.current);
}; };
const handleBrushSizeChange = (value: number) => { const handleBrushSizeChange = (value: number) => {
@@ -454,11 +453,22 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
useEffect(() => { useEffect(() => {
const handleUndoShortcut = (e: KeyboardEvent) => { const handleUndoShortcut = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'z') { if (
(e.ctrlKey || e.metaKey) &&
e.key === 'z' &&
!negativeMaskRef.current
) {
undo(); undo();
} }
}; };
window.addEventListener('keydown', handleUndoShortcut);
return () => {
window.removeEventListener('keydown', handleUndoShortcut);
};
}, []);
useEffect(() => {
const handleMouseDown = (e: MouseEvent) => { const handleMouseDown = (e: MouseEvent) => {
mouseDownState.current = true; mouseDownState.current = true;
}; };
@@ -467,7 +477,6 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
mouseDownState.current = false; mouseDownState.current = false;
}; };
window.addEventListener('keydown', handleUndoShortcut);
// mouse down // mouse down
window.addEventListener('mousedown', handleMouseDown); window.addEventListener('mousedown', handleMouseDown);
@@ -475,7 +484,7 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = forwardRef(
window.addEventListener('mouseup', handleMouseUp); window.addEventListener('mouseup', handleMouseUp);
return () => { return () => {
clearTimeout(timer.current); clearTimeout(timer.current);
window.removeEventListener('keydown', handleUndoShortcut);
window.removeEventListener('mousedown', handleMouseDown); window.removeEventListener('mousedown', handleMouseDown);
window.removeEventListener('mouseup', handleMouseUp); window.removeEventListener('mouseup', handleMouseUp);
}; };
+8 -6
View File
@@ -48,12 +48,14 @@ const ToolsBar: React.FC<ToolsBarProps> = (props) => {
<Tooltip <Tooltip
placement="bottomLeft" placement="bottomLeft"
arrow={false} arrow={false}
overlayInnerStyle={{ styles={{
background: 'var(--color-white-1)', body: {
display: 'flex', background: 'var(--color-white-1)',
alignItems: 'center', display: 'flex',
justifyContent: 'flex-start', alignItems: 'center',
width: 160 justifyContent: 'flex-start',
width: 160
}
}} }}
title={ title={
<div className="flex-column" style={{ width: '100%' }}> <div className="flex-column" style={{ width: '100%' }}>
+32
View File
@@ -0,0 +1,32 @@
import AutoTooltip from '@/components/auto-tooltip';
import _ from 'lodash';
import React from 'react';
import styled from 'styled-components';
const LabelsWrapper = styled.div`
display: flex;
flex-wrap: wrap;
gap: 6px;
`;
interface LabelCellProps {
labels: Record<string, any>;
}
const LabelsCell: React.FC<LabelCellProps> = ({ labels }) => (
<LabelsWrapper>
{_.map(labels, (value: string, key: string) => (
<AutoTooltip
key={key}
className="m-r-0"
maxWidth={155}
style={{ paddingInline: 8, borderRadius: 12 }}
>
<span>{key}</span>
<span>:{value}</span>
</AutoTooltip>
))}
</LabelsWrapper>
);
export default LabelsCell;
@@ -0,0 +1,138 @@
import AutoComplete from '@/components/seal-form/auto-complete';
import { MinusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button, Tooltip } from 'antd';
import _ from 'lodash';
import React, { useMemo, useState } from 'react';
import { useLabelSelectorContext } from './context';
import './styles/label-item.less';
interface LabelItemProps {
label: {
key: string;
value: string;
};
labels?: Record<string, any>;
labelKey?: string;
labelValue?: string;
keyAddon?: React.ReactNode;
valueAddon?: React.ReactNode;
seperator?: string;
labelList: { key: string; value: string }[];
disabled?: boolean;
onDelete?: () => void;
onChange?: (params: { key: string; value: string }) => void;
onPaste?: (e: any) => void;
onBlur?: (e: any, type: string) => void;
}
const LabelItem: React.FC<LabelItemProps> = ({
labels,
label,
labelList,
seperator,
keyAddon,
valueAddon,
disabled,
onChange,
onDelete,
onBlur
}) => {
const intl = useIntl();
const [open, setOpen] = useState(false);
const { options } = useLabelSelectorContext();
const keyOptions = useMemo(() => {
return options?.filter(
(item) => !_.has(labels, item.value) || item.value === label.key
);
}, [labels, options]);
const valueOptions = useMemo(() => {
return options?.find((item) => item.value === label.key)?.children || [];
}, [label.key, options]);
const handleOnValueChange = (value: string) => {
onChange?.({
key: label.key,
value: value
});
};
const handleOnKeyChange = (key: any) => {
onChange?.({
key,
value: label.value
});
};
const handleKeyOnBlur = (e: any, type: string) => {
const val = e.target.value;
// has duplicate key
const duplicates = _.filter(
labelList,
(item: Global.BaseListItem<string>) => val && val === item.key
);
if (duplicates.length > 1) {
setOpen(true);
onChange?.({
key: '',
value: label.value
});
setTimeout(() => {
setOpen(false);
}, 1000);
} else {
setOpen(false);
}
onBlur?.(e, type);
};
return (
<div className="label-item">
<div className="label-key">
{keyAddon ?? (
<Tooltip
open={open}
title={intl.formatMessage({ id: 'resources.table.key.tips' })}
>
<AutoComplete
options={keyOptions}
disabled={disabled}
checkStatus="success"
label={intl.formatMessage({ id: 'common.input.key' })}
value={label.key}
onChange={handleOnKeyChange}
onBlur={(e: any) => handleKeyOnBlur(e, 'key')}
></AutoComplete>
</Tooltip>
)}
</div>
{seperator && <span className="seprator">{seperator}</span>}
<div className="label-value">
{valueAddon ?? (
<AutoComplete
options={valueOptions}
disabled={disabled}
checkStatus={label.value ? 'success' : ''}
label={intl.formatMessage({ id: 'common.input.value' })}
value={label.value}
onChange={handleOnValueChange}
onBlur={(e: any) => onBlur?.(e, 'value')}
></AutoComplete>
)}
</div>
{!disabled && (
<Button
size="small"
className="btn"
type="default"
shape="circle"
onClick={onDelete}
>
<MinusOutlined />
</Button>
)}
</div>
);
};
export default LabelItem;
+25
View File
@@ -0,0 +1,25 @@
import React from 'react';
interface LabelSelectorContextProps {
options?: Array<{
label: string;
value: string | number;
children?: { label: string; value: string | number }[];
}>;
currentData?: Record<string, any>;
}
export const LabelSelectorContext =
React.createContext<LabelSelectorContextProps>(
{} as LabelSelectorContextProps
);
export const useLabelSelectorContext = () => {
const context = React.useContext(LabelSelectorContext);
if (!context) {
throw new Error(
'useLabelSelectorContext must be used within a LabelSelectorProvider'
);
}
return context;
};
+32 -15
View File
@@ -1,6 +1,6 @@
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import _ from 'lodash'; import _ from 'lodash';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import Inner from './inner'; import Inner from './inner';
interface LabelSelectorProps { interface LabelSelectorProps {
@@ -8,6 +8,8 @@ interface LabelSelectorProps {
label?: string; label?: string;
btnText?: string; btnText?: string;
description?: React.ReactNode; description?: React.ReactNode;
disabled?: boolean;
isAutoComplete?: boolean;
onChange?: (labels: Record<string, any>) => void; onChange?: (labels: Record<string, any>) => void;
onBlur?: (e: any, type: string, index: number) => void; onBlur?: (e: any, type: string, index: number) => void;
onDelete?: (index: number) => void; onDelete?: (index: number) => void;
@@ -18,9 +20,11 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
onChange, onChange,
onBlur, onBlur,
onDelete, onDelete,
disabled,
label, label,
btnText, btnText,
description description,
isAutoComplete
}) => { }) => {
const intl = useIntl(); const intl = useIntl();
const [labelsData, setLabelsData] = useState({}); const [labelsData, setLabelsData] = useState({});
@@ -41,18 +45,30 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
} }
}, [labels]); }, [labels]);
const handleLabelListChange = useCallback( const handleLabelListChange = (list: { key: string; value: string }[]) => {
(list: { key: string; value: string }[]) => { setLabelList(list);
setLabelList(list); };
},
[setLabelList]
);
const handleLabelsChange = (data: Record<string, any>) => { const handleLabelsChange = (data: Record<string, any>) => {
console.log('handleLabelsChange', data); console.log('handleLabelsChange', data);
setLabelsData(data); setLabelsData(data);
onChange?.(data); onChange?.(data);
}; };
const updateLabels = (list: { key: string; value: string }[]) => {
const newLabels = _.reduce(
list,
(result: any, item: any) => {
if (item.key) {
result[item.key] = item.value;
}
return result;
},
{}
);
onChange?.(newLabels);
};
const handleOnPaste = ( const handleOnPaste = (
e: React.ClipboardEvent<HTMLTextAreaElement>, e: React.ClipboardEvent<HTMLTextAreaElement>,
index: number index: number
@@ -70,22 +86,23 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
const [key, value] = line.split('=').map((part) => part.trim()); const [key, value] = line.split('=').map((part) => part.trim());
return { key, value }; return { key, value };
}); });
console.log(lines, parsedData);
setLabelList((prevPairs) => { const newPairs = [...labelList];
const newPairs = [...prevPairs]; newPairs.splice(index, 1, ...parsedData);
newPairs.splice(index, 1, ...parsedData);
return newPairs; updateLabels(newPairs);
}); setLabelList(newPairs);
}; };
return ( return (
<Inner <Inner
disabled={disabled}
label={label} label={label}
btnText={btnText} btnText={btnText}
description={ description={
description ?? intl.formatMessage({ id: 'models.form.keyvalue.paste' }) description ?? intl.formatMessage({ id: 'models.form.keyvalue.paste' })
} }
isAutoComplete={isAutoComplete}
labels={labelsData} labels={labelsData}
labelList={labelList} labelList={labelList}
onChange={handleLabelsChange} onChange={handleLabelsChange}
@@ -97,4 +114,4 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
); );
}; };
export default React.memo(LabelSelector); export default LabelSelector;
+50 -38
View File
@@ -1,14 +1,14 @@
import { PlusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Button } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import React, { useRef } from 'react'; import React, { useEffect } from 'react';
import AutoCompleteItem from './autocomplete-item';
import LabelItem from './label-item'; import LabelItem from './label-item';
import Wrapper from './wrapper'; import Wrapper from './wrapper';
interface LabelSelectorProps { interface LabelSelectorProps {
labels: Record<string, any>; labels: Record<string, any>;
label?: string; label?: string;
btnText?: string; btnText?: string;
isAutoComplete?: boolean;
labelList: Array<{ key: string; value: string }>; labelList: Array<{ key: string; value: string }>;
onLabelListChange: (list: { key: string; value: string }[]) => void; onLabelListChange: (list: { key: string; value: string }[]) => void;
onChange?: (labels: Record<string, any>) => void; onChange?: (labels: Record<string, any>) => void;
@@ -16,6 +16,7 @@ interface LabelSelectorProps {
onBlur?: (e: any, type: string, index: number) => void; onBlur?: (e: any, type: string, index: number) => void;
onDelete?: (index: number) => void; onDelete?: (index: number) => void;
description?: React.ReactNode; description?: React.ReactNode;
disabled?: boolean;
} }
const Inner: React.FC<LabelSelectorProps> = ({ const Inner: React.FC<LabelSelectorProps> = ({
@@ -26,13 +27,17 @@ const Inner: React.FC<LabelSelectorProps> = ({
onPaste, onPaste,
onBlur, onBlur,
onDelete, onDelete,
disabled,
label, label,
btnText, btnText,
description description,
isAutoComplete
}) => { }) => {
const intl = useIntl(); const intl = useIntl();
const buttonRef = useRef<HTMLButtonElement>(null);
const boxRef = useRef<HTMLDivElement>(null); useEffect(() => {
console.log('labels changed in Inner', labels);
}, [labels]);
const updateLabels = (list: { key: string; value: string }[]) => { const updateLabels = (list: { key: string; value: string }[]) => {
const newLabels = _.reduce( const newLabels = _.reduce(
@@ -75,42 +80,49 @@ const Inner: React.FC<LabelSelectorProps> = ({
}; };
return ( return (
<Wrapper label={label} description={description}> <Wrapper
label={label}
description={description}
onAdd={handleAddLabel}
disabled={disabled}
btnText={btnText}
>
<> <>
{labelList?.map((item: any, index: number) => { {isAutoComplete
return ( ? labelList?.map((item: any, index: number) => {
<LabelItem return (
key={index} <AutoCompleteItem
label={item} disabled={disabled}
seperator=":" key={index}
labelList={labelList} label={item}
onDelete={() => handleOnDelete(index)} seperator=":"
onChange={(obj) => handleOnChange(index, obj)} labels={labels}
onPaste={(e) => onPaste?.(e, index)} labelList={labelList}
onBlur={(e: any, type: string) => onBlur?.(e, type, index)} onDelete={() => handleOnDelete(index)}
/> onChange={(obj) => handleOnChange(index, obj)}
); onPaste={(e) => onPaste?.(e, index)}
})} onBlur={(e: any, type: string) => onBlur?.(e, type, index)}
<div className="flex justify-center"> />
<Button );
ref={buttonRef} })
type="text" : labelList?.map((item: any, index: number) => {
block return (
style={{ <LabelItem
marginTop: 16, disabled={disabled}
backgroundColor: 'var(--ant-color-fill-secondary)' key={index}
}} label={item}
onClick={handleAddLabel} seperator=":"
> labelList={labelList}
<PlusOutlined className="font-size-14" />{' '} onDelete={() => handleOnDelete(index)}
{intl.formatMessage({ onChange={(obj) => handleOnChange(index, obj)}
id: btnText || 'common.button.addSelector' onPaste={(e) => onPaste?.(e, index)}
onBlur={(e: any, type: string) => onBlur?.(e, type, index)}
/>
);
})} })}
</Button>
</div>
</> </>
</Wrapper> </Wrapper>
); );
}; };
export default React.memo(Inner); export default Inner;
+19 -11
View File
@@ -1,4 +1,5 @@
import SealInput from '@/components/seal-form/seal-input'; import SealInput from '@/components/seal-form/seal-input';
import { Global } from '@/config/global';
import { MinusOutlined } from '@ant-design/icons'; import { MinusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Button, Tooltip } from 'antd'; import { Button, Tooltip } from 'antd';
@@ -15,8 +16,9 @@ interface LabelItemProps {
keyAddon?: React.ReactNode; keyAddon?: React.ReactNode;
valueAddon?: React.ReactNode; valueAddon?: React.ReactNode;
seperator?: string; seperator?: string;
onDelete?: () => void;
labelList: { key: string; value: string }[]; labelList: { key: string; value: string }[];
disabled?: boolean;
onDelete?: () => void;
onChange?: (params: { key: string; value: string }) => void; onChange?: (params: { key: string; value: string }) => void;
onPaste?: (e: any) => void; onPaste?: (e: any) => void;
onBlur?: (e: any, type: string) => void; onBlur?: (e: any, type: string) => void;
@@ -27,6 +29,7 @@ const LabelItem: React.FC<LabelItemProps> = ({
seperator, seperator,
keyAddon, keyAddon,
valueAddon, valueAddon,
disabled,
onChange, onChange,
onDelete, onDelete,
onPaste, onPaste,
@@ -82,6 +85,7 @@ const LabelItem: React.FC<LabelItemProps> = ({
title={intl.formatMessage({ id: 'resources.table.key.tips' })} title={intl.formatMessage({ id: 'resources.table.key.tips' })}
> >
<SealInput.Input <SealInput.Input
disabled={disabled}
checkStatus="success" checkStatus="success"
label={intl.formatMessage({ id: 'common.input.key' })} label={intl.formatMessage({ id: 'common.input.key' })}
value={label.key} value={label.key}
@@ -96,6 +100,8 @@ const LabelItem: React.FC<LabelItemProps> = ({
<div className="label-value"> <div className="label-value">
{valueAddon ?? ( {valueAddon ?? (
<SealInput.Input <SealInput.Input
trim={false}
disabled={disabled}
checkStatus={label.value ? 'success' : ''} checkStatus={label.value ? 'success' : ''}
label={intl.formatMessage({ id: 'common.input.value' })} label={intl.formatMessage({ id: 'common.input.value' })}
value={label.value} value={label.value}
@@ -104,17 +110,19 @@ const LabelItem: React.FC<LabelItemProps> = ({
></SealInput.Input> ></SealInput.Input>
)} )}
</div> </div>
<Button {!disabled && (
size="small" <Button
className="btn" size="small"
type="default" className="btn"
shape="circle" type="default"
onClick={onDelete} shape="circle"
> onClick={onDelete}
<MinusOutlined /> >
</Button> <MinusOutlined />
</Button>
)}
</div> </div>
); );
}; };
export default React.memo(LabelItem); export default LabelItem;
@@ -1,20 +0,0 @@
.wrapper {
position: relative;
padding: 14px;
padding-top: 34px;
border: 1px solid var(--ant-color-border);
border-radius: var(--border-radius-base);
display: flex;
width: 100%;
flex-direction: column;
:global {
.label {
position: absolute;
left: 16px;
line-height: 1;
top: 12px;
color: var(--ant-color-text-tertiary);
}
}
}
+60 -8
View File
@@ -1,15 +1,56 @@
import LabelInfo from '@/components/seal-form/components/label-info'; import LabelInfo from '@/components/seal-form/components/label-info';
import { PlusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button } from 'antd';
import React from 'react'; import React from 'react';
import styles from './styles/wrapper.less'; import styled from 'styled-components';
const Wrapper: React.FC<{ interface WrapperProps {
label?: React.ReactNode; label?: React.ReactNode;
description?: React.ReactNode; description?: React.ReactNode;
labelExtra?: React.ReactNode; labelExtra?: React.ReactNode;
children: React.ReactNode; children: React.ReactNode;
}> = ({ children, label, description, labelExtra, ...rest }) => { btnText?: string;
disabled?: boolean;
onAdd?: () => void;
button?: React.ReactNode;
}
const Container = styled.div`
position: relative;
padding: 14px;
padding-top: 34px;
border: 1px solid var(--ant-color-border);
border-radius: var(--border-radius-base);
display: flex;
width: 100%;
flex-direction: column;
.label {
position: absolute;
left: 16px;
line-height: 1;
top: 12px;
color: var(--ant-color-text-tertiary);
}
`;
const ButtonWrapper = styled.div`
margin-top: 16px;
`;
const Wrapper: React.FC<WrapperProps> = ({
children,
label,
description,
labelExtra,
onAdd,
btnText,
disabled,
button
}) => {
const intl = useIntl();
return ( return (
<div className={styles['wrapper']}> <Container>
{label && ( {label && (
<span className="label"> <span className="label">
<LabelInfo <LabelInfo
@@ -19,10 +60,21 @@ const Wrapper: React.FC<{
></LabelInfo> ></LabelInfo>
</span> </span>
)} )}
{React.isValidElement(children) {children}
? React.cloneElement(children, { ...rest }) {!disabled && (
: children} <ButtonWrapper>
</div> {button || (
<Button variant="filled" color="default" block onClick={onAdd}>
<PlusOutlined className="font-size-14" />
{btnText ||
intl.formatMessage({
id: 'common.button.addSelector'
})}
</Button>
)}
</ButtonWrapper>
)}
</Container>
); );
}; };
+19 -1
View File
@@ -2,9 +2,27 @@ import langConfigMap from '@/locales/lang-config-map';
import { GlobalOutlined } from '@ant-design/icons'; import { GlobalOutlined } from '@ant-design/icons';
import { getAllLocales, setLocale } from '@umijs/max'; import { getAllLocales, setLocale } from '@umijs/max';
import { Dropdown } from 'antd'; import { Dropdown } from 'antd';
import { createStyles } from 'antd-style';
import { get } from 'lodash'; import { get } from 'lodash';
const useStyles = createStyles(({ token, css }) => ({
button: css`
color: ${token.colorText};
padding: 0 12px;
cursor: pointer;
.anticon {
color: ${token.colorText};
}
&:hover {
.anticon {
color: ${token.colorTextTertiary};
}
}
`
}));
const LangSelect = () => { const LangSelect = () => {
const { styles } = useStyles();
const allLocals = getAllLocales(); const allLocals = getAllLocales();
const items = allLocals.map((key) => { const items = allLocals.map((key) => {
return { return {
@@ -25,7 +43,7 @@ const LangSelect = () => {
return ( return (
<Dropdown menu={{ items }}> <Dropdown menu={{ items }}>
<span style={{ padding: '0 12px', cursor: 'pointer' }}> <span className={styles.button}>
<GlobalOutlined /> <GlobalOutlined />
</span> </span>
</Dropdown> </Dropdown>
+5 -7
View File
@@ -8,13 +8,14 @@ interface HintInputProps {
onChange: (value: string) => void; onChange: (value: string) => void;
onBlur?: (e: any) => void; onBlur?: (e: any) => void;
placeholder?: string; placeholder?: string;
trim?: boolean;
sourceOptions?: Global.HintOptions[]; sourceOptions?: Global.HintOptions[];
} }
const matchReg = /[^=]+=[^=]*$/; const matchReg = /[^=]+=[^=]*$/;
const HintInput: React.FC<HintInputProps> = (props) => { const HintInput: React.FC<HintInputProps> = (props) => {
const { value, label, onChange, onBlur, sourceOptions } = props; const { value, label, onChange, onBlur, sourceOptions, trim = true } = props;
const cursorPosRef = React.useRef(0); const cursorPosRef = React.useRef(0);
const contextBeforeCursorRef = React.useRef(''); const contextBeforeCursorRef = React.useRef('');
const [options, setOptions] = React.useState< const [options, setOptions] = React.useState<
@@ -70,11 +71,7 @@ const HintInput: React.FC<HintInputProps> = (props) => {
const handleInput = (e: any) => { const handleInput = (e: any) => {
getContextBeforeCursor(e); getContextBeforeCursor(e);
onChange(e.target.value?.trim()); onChange(e.target.value);
};
const handleOnChange = (value: string) => {
onChange(value?.trim());
}; };
const handleOnSelect = (value: string) => { const handleOnSelect = (value: string) => {
@@ -93,9 +90,10 @@ const HintInput: React.FC<HintInputProps> = (props) => {
onBlur={onBlur} onBlur={onBlur}
label={label} label={label}
options={options} options={options}
trim={trim}
style={{ width: '100%' }} style={{ width: '100%' }}
/> />
); );
}; };
export default React.memo(HintInput); export default HintInput;
+13 -29
View File
@@ -1,6 +1,3 @@
import { PlusOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { Button } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import React from 'react'; import React from 'react';
import Wrapper from '../label-selector/wrapper'; import Wrapper from '../label-selector/wrapper';
@@ -8,19 +5,19 @@ import ListItem from './list-item';
interface ListInputProps { interface ListInputProps {
dataList: string[]; dataList: string[];
label: React.ReactNode; label?: React.ReactNode;
description?: React.ReactNode; description?: React.ReactNode;
btnText?: string; btnText?: string;
options?: Global.HintOptions[]; options?: Global.HintOptions[];
placeholder?: string; placeholder?: string;
labelExtra?: React.ReactNode; labelExtra?: React.ReactNode;
trim?: boolean;
onChange: (data: string[]) => void; onChange: (data: string[]) => void;
onBlur?: (e: any, index: number) => void; onBlur?: (e: any, index: number) => void;
onDelete?: (index: number) => void; onDelete?: (index: number) => void;
} }
const ListInput: React.FC<ListInputProps> = (props) => { const ListInput: React.FC<ListInputProps> = (props) => {
const intl = useIntl();
const { const {
dataList, dataList,
label, label,
@@ -30,11 +27,11 @@ const ListInput: React.FC<ListInputProps> = (props) => {
onDelete, onDelete,
btnText, btnText,
options, options,
labelExtra labelExtra,
trim = true
} = props; } = props;
const [list, setList] = React.useState<{ value: string; uid: number }[]>([]); const [list, setList] = React.useState<{ value: string; uid: number }[]>([]);
const countRef = React.useRef(0); const countRef = React.useRef(0);
const buttonRef = React.useRef<HTMLButtonElement>(null);
const updateCountRef = () => { const updateCountRef = () => {
countRef.current = countRef.current + 1; countRef.current = countRef.current + 1;
@@ -65,9 +62,6 @@ const ListInput: React.FC<ListInputProps> = (props) => {
uid: countRef.current uid: countRef.current
}); });
setList(values); setList(values);
// setTimeout(() => {
// buttonRef.current?.scrollIntoView?.({ behavior: 'smooth' });
// }, 100);
}; };
React.useEffect(() => { React.useEffect(() => {
@@ -85,7 +79,13 @@ const ListInput: React.FC<ListInputProps> = (props) => {
}, [dataList]); }, [dataList]);
return ( return (
<Wrapper label={label} description={description} labelExtra={labelExtra}> <Wrapper
label={label}
description={description}
labelExtra={labelExtra}
onAdd={handleOnAdd}
btnText={btnText}
>
<> <>
{_.map(list, (item: any, index: number) => { {_.map(list, (item: any, index: number) => {
return ( return (
@@ -97,29 +97,13 @@ const ListInput: React.FC<ListInputProps> = (props) => {
onBlur={(e) => onBlur?.(e, index)} onBlur={(e) => onBlur?.(e, index)}
onRemove={() => handleOnRemove(index)} onRemove={() => handleOnRemove(index)}
onChange={(val) => handleOnChange(val, index)} onChange={(val) => handleOnChange(val, index)}
trim={trim}
/> />
); );
})} })}
<div className="flex justify-center">
<Button
ref={buttonRef}
variant="filled"
color="default"
block
style={{
marginTop: 16
}}
onClick={handleOnAdd}
>
<PlusOutlined className="font-size-14" />{' '}
{intl.formatMessage({
id: btnText
})}
</Button>
</div>
</> </>
</Wrapper> </Wrapper>
); );
}; };
export default React.memo(ListInput); export default ListInput;
+12 -2
View File
@@ -13,10 +13,19 @@ interface LabelItemProps {
label?: string; label?: string;
placeholder?: string; placeholder?: string;
options?: Global.HintOptions[]; options?: Global.HintOptions[];
trim?: boolean;
} }
const ListItem: React.FC<LabelItemProps> = (props) => { const ListItem: React.FC<LabelItemProps> = (props) => {
const { onRemove, onChange, onBlur, label, value, options } = props; const {
onRemove,
onChange,
onBlur,
label,
value,
options,
trim = true
} = props;
const handleOnChange = (value: any) => { const handleOnChange = (value: any) => {
onChange(value); onChange(value);
@@ -30,6 +39,7 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
onBlur={onBlur} onBlur={onBlur}
label={label} label={label}
sourceOptions={options} sourceOptions={options}
trim={trim}
placeholder={props.placeholder} placeholder={props.placeholder}
/> />
<Button <Button
@@ -44,4 +54,4 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
); );
}; };
export default React.memo(ListItem); export default ListItem;

Some files were not shown because too many files have changed in this diff Show More