mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
Compare commits
1190 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9617ddc02c | |||
| 8083090414 | |||
| 60296bf3c9 | |||
| 77d0d9bfb8 | |||
| 6e0c66d982 | |||
| 07b49030a2 | |||
| 203c3e4c4b | |||
| e434c7867f | |||
| f3059f8df8 | |||
| 0b0cd25d2c | |||
| 4e0239d282 | |||
| 2574b2814b | |||
| 1564bd977e | |||
| 92e47812bd | |||
| 2e867da093 | |||
| da85269c9f | |||
| 15f803a511 | |||
| 7eca309eac | |||
| 414308802c | |||
| 7333e4fda3 | |||
| 1cdaa29764 | |||
| 9d270b7b0e | |||
| 31abd609e6 | |||
| fdd1cd32a8 | |||
| 6210a06d43 | |||
| 807132014a | |||
| 041817cc3c | |||
| acb0ceb9a9 | |||
| 417dab7ddc | |||
| 3a9a07c109 | |||
| a02d505e2e | |||
| bcee9315d5 | |||
| a0266b061f | |||
| 0e19f37a68 | |||
| c70aeaa3cd | |||
| f22738ec2b | |||
| f69f304ebf | |||
| 111877a1e4 | |||
| c924b0ce1d | |||
| fed8e62965 | |||
| 987488c928 | |||
| 8efa20e03a | |||
| ced2143a6e | |||
| a58e2c4e67 | |||
| d26f3a8082 | |||
| 0337c3a2a2 | |||
| 67c4eea64f | |||
| 64c59e4886 | |||
| 3392abaf4b | |||
| 29da1c441a | |||
| 53735cff61 | |||
| 80d59f5856 | |||
| fb5203c356 | |||
| 49f353033c | |||
| 1fd3e5689d | |||
| 021ec6fbee | |||
| eb7b9acb26 | |||
| 1042f8808c | |||
| 093c698cf0 | |||
| 9ebf8e217b | |||
| 3f4b6865fe | |||
| 977665fac7 | |||
| e16a7f6705 | |||
| ab642000d4 | |||
| efdb5eebbe | |||
| 6872ef74ca | |||
| 55d649e56e | |||
| 43c3e7a818 | |||
| 158008d836 | |||
| 7d7e9581d4 | |||
| b25b4075cd | |||
| 1f0c467e8e | |||
| a153bfef02 | |||
| 941690038b | |||
| a8a6b8278a | |||
| b13eb59396 | |||
| fde94b2851 | |||
| ccca43f3dc | |||
| 60e33a0305 | |||
| 933cf44839 | |||
| dda842d468 | |||
| 98b65ed437 | |||
| bde2cca414 | |||
| 20657f22d6 | |||
| 762b604e60 | |||
| d29d198c88 | |||
| a9168c7b91 | |||
| cfafd043e9 | |||
| bf6c62a57f | |||
| 9831730b28 | |||
| 02fa2dc086 | |||
| 3cd3794cf1 | |||
| 4723114bf5 | |||
| 7aa2512ad9 | |||
| 11e74fd08e | |||
| ba115f7a3c | |||
| f03f5f81d1 | |||
| afc8fe4167 | |||
| 0ed51b28ab | |||
| f1333b68b6 | |||
| c8bd6f63a3 | |||
| 61598b49ef | |||
| 69bbdb3d02 | |||
| 6598b6fc9e | |||
| bd7008d8c3 | |||
| 7645134b35 | |||
| 3e9e83cd03 | |||
| 0250e65959 | |||
| 2c4a22e921 | |||
| fecfea5dad | |||
| ff157fbdd3 | |||
| 402a3c2d15 | |||
| cac95019b6 | |||
| e247972624 | |||
| 88022a8edd | |||
| e5bdadc016 | |||
| 68bf7081e6 | |||
| 85e530a122 | |||
| 7a7569a63f | |||
| b6ededa2c4 | |||
| 22b1b50429 | |||
| b098a09425 | |||
| 35f018544d | |||
| a1dcbd23b7 | |||
| 3a6ad62cad | |||
| 80adb6b62f | |||
| b71615597b | |||
| 80b388bfc6 | |||
| 32b5f90e86 | |||
| 79b40ced37 | |||
| 7ff4b77505 | |||
| d979eb7c2a | |||
| 75a5416fad | |||
| 7d3d9605cb | |||
| 77b4a8e9d4 | |||
| 4c415a47f8 | |||
| 56289058fc | |||
| 954c7f2192 | |||
| 2065126bcb | |||
| b8e9b87c88 | |||
| 1aa95fb972 | |||
| 00061bbf19 | |||
| f95f28cd67 | |||
| eca864a80b | |||
| 5d71a8d7c5 | |||
| 78a892dcda | |||
| 4f7ca8018c | |||
| 4fe55593b7 | |||
| 9b8a3256bd | |||
| c167712b0e | |||
| c7f561a55d | |||
| 30bead497e | |||
| 34ecd56cc4 | |||
| e4b46ea2e2 | |||
| 9e520be8b5 | |||
| 2f7db1c871 | |||
| 0aa526b6d4 | |||
| a8b4599c4f | |||
| 9c54fec65e | |||
| 9315a5de4c | |||
| e09d35ec53 | |||
| 07c904be75 | |||
| c2c6f2b3f6 | |||
| 0a3fdd61c8 | |||
| 25ad26ad55 | |||
| d424b68b2b | |||
| 3c29a0a5c6 | |||
| cf27da94a7 | |||
| 6eaa946be6 | |||
| 06aa17d0c3 | |||
| a43880fbcc | |||
| 94503a4ab6 | |||
| 718f37e0da | |||
| e04282e3a4 | |||
| 587eec4f15 | |||
| e760ce953b | |||
| 98bde0a1c0 | |||
| 5759195b23 | |||
| dcf18705da | |||
| 61ae37d3d9 | |||
| 10488a6308 | |||
| 3e3227755b | |||
| bd4ad2bac8 | |||
| 5c58283264 | |||
| b55d68ed39 | |||
| 2c7680bedc | |||
| 6b9df8c5e9 | |||
| db2e05889d | |||
| 273f9ace58 | |||
| 517ac1eeac | |||
| bb1371090c | |||
| 63fbd35c63 | |||
| e8887c1454 | |||
| 7cc4a92015 | |||
| 6d55676aa9 | |||
| 4c35a51f64 | |||
| 2a977b37d4 | |||
| 48f8bc0c8e | |||
| 0b6aa6b343 | |||
| 463f063932 | |||
| 1218ac43f8 | |||
| 11bc0331cf | |||
| 04a5da862f | |||
| 6af33ee5b7 | |||
| 66d0653dc6 | |||
| f356df7f74 | |||
| e289537fd9 | |||
| 4390e9767c | |||
| 7adbbc31c2 | |||
| e9b40d8b27 | |||
| 3b1c9d9f67 | |||
| 1011302721 | |||
| 55e9744321 | |||
| 0481d42929 | |||
| c10fa95cb3 | |||
| 2e383282c8 | |||
| 7c913a4cb6 | |||
| 3140589299 | |||
| 42e3384ebb | |||
| 8610cd5770 | |||
| 3132d48813 | |||
| 1f240581d2 | |||
| ecf259a9e7 | |||
| a0b2148b65 | |||
| 4371715b32 | |||
| 2619493362 | |||
| 50faa4af80 | |||
| 267e019864 | |||
| 9b35281d04 | |||
| da37970a43 | |||
| 27ba933099 | |||
| 6879a97e36 | |||
| 0fa8f6e6e4 | |||
| dd7f9c9f5f | |||
| 5ee4f34624 | |||
| 04fd862b11 | |||
| 31a1703ba8 | |||
| e74b022986 | |||
| 6419cdaf13 | |||
| 4b03c56315 | |||
| 3e50895af2 | |||
| 81a9c35cda | |||
| 620bd4cd49 | |||
| bd9e99890d | |||
| eaecc5c80a | |||
| fe30521c24 | |||
| ed8c2f286c | |||
| 06e7d96f67 | |||
| 3c807cfdcf | |||
| 1d3d4e2075 | |||
| 666acb6241 | |||
| 7243684977 | |||
| 1c499ae805 | |||
| 0dabe4d0e5 | |||
| f7f802639e | |||
| 0153612020 | |||
| 6d03f67ffd | |||
| d27f7eba4d | |||
| 7b2356f8f3 | |||
| 4c60acb5bb | |||
| 6ddd2f2389 | |||
| 3de5221b4a | |||
| 4e98b09fa4 | |||
| 3e0070db80 | |||
| 10f852803a | |||
| b347d8f08c | |||
| e786393523 | |||
| 11ae2969b4 | |||
| 4a2995b533 | |||
| b6d2abaa64 | |||
| 1495451901 | |||
| 3e79f117a3 | |||
| 7489a8f601 | |||
| 13517c835c | |||
| 70cab89511 | |||
| 8ec82bc9ba | |||
| d4ef5a7516 | |||
| 5205764fae | |||
| 23c36cc68b | |||
| 16d1e8f3d7 | |||
| ee0f45a6e1 | |||
| f402bcaae9 | |||
| e6684244d1 | |||
| 044e31dd8a | |||
| 976f3505bf | |||
| bd33dff2f3 | |||
| f91b83385f | |||
| 80bcc6a058 | |||
| 6797ff023d | |||
| 24a26f3394 | |||
| 528bb727ad | |||
| edf30ac61f | |||
| e0c482efbc | |||
| c67964045d | |||
| cf285f0637 | |||
| 28cc30b8a7 | |||
| 286387440c | |||
| d4c697d680 | |||
| 92a6f777ed | |||
| d90dc847ef | |||
| a6d3fd807a | |||
| 8707a01fd3 | |||
| 815cc61607 | |||
| 2c95e440d1 | |||
| 12ed7aafee | |||
| b06c880a9c | |||
| 3becd8a0a7 | |||
| b7efd2e5c5 | |||
| b5d70ca524 | |||
| 3b5195a6ba | |||
| d41afdd2da | |||
| d94fc09d07 | |||
| 5253a62f9a | |||
| 818436c946 | |||
| 125f59b1e1 | |||
| 50d0923bce | |||
| b41152f4d9 | |||
| e18a6ef1c6 | |||
| d0813e8595 | |||
| eef14f36a1 | |||
| 47cdc6bf18 | |||
| f65a908661 | |||
| 3c0140f3b8 | |||
| 93f1a76efb | |||
| 8d415fa273 | |||
| 244a3c784f | |||
| c36ff21b91 | |||
| f8fad4caf4 | |||
| 3b54c03027 | |||
| a5f46a930f | |||
| 6157a9d1fa | |||
| f910fc84e5 | |||
| 9cb09905f9 | |||
| eeb2fbcad6 | |||
| 400faf92c0 | |||
| fb023a039b | |||
| 95b5d848f7 | |||
| ded5e064e6 | |||
| 7ea50ec380 | |||
| 901bef1463 | |||
| 8d44d796b4 | |||
| 5a10ad478e | |||
| fd6680d615 | |||
| e03cdfc42b | |||
| 945d53fcfd | |||
| ac7045b724 | |||
| c907bdc4a5 | |||
| 733ed9ac2f | |||
| 1d8e579a10 | |||
| 567cac9c95 | |||
| 095c09c8c0 | |||
| e9c949822d | |||
| 3482d5416c | |||
| d8cb4a0c94 | |||
| 59acfa7a47 | |||
| 2eb2e690d1 | |||
| f7801261c3 | |||
| 7e7be7f040 | |||
| 0187fd16b2 | |||
| ba0bdb5e99 | |||
| 9d3e4f07bf | |||
| bd81d7584d | |||
| 9577339e14 | |||
| 5c292ef1cb | |||
| 4f3de85068 | |||
| 07a25c9643 | |||
| 8f60426b4c | |||
| 37f87615bd | |||
| 3f96de660b | |||
| e86999770f | |||
| a8bb0c24ec | |||
| 6ba2a08b62 | |||
| d232269416 | |||
| 9d2208e14d | |||
| 8d69d45d1d | |||
| b0c37918b5 | |||
| d5af1c8da3 | |||
| a6105cfc3c | |||
| 0aa5ffd2c2 | |||
| 968f5b986f | |||
| 014a7e0362 | |||
| a92baf09d9 | |||
| 46e2edbe13 | |||
| 5aba86965e | |||
| 5924208aaa | |||
| 526390816b | |||
| d7e28c9704 | |||
| 7c827804f4 | |||
| b0dacbda0d | |||
| d5abde2593 | |||
| bc3290de3b | |||
| 7f438bf776 | |||
| 13cfe24b2f | |||
| 9cf1cd99c2 | |||
| f5cfd77550 | |||
| f27abbd454 | |||
| 6a7a11a811 | |||
| 4a8f5152b3 | |||
| 599ee6b9b8 | |||
| 83ac747cb1 | |||
| 09b98c6c0d | |||
| 13eac21609 | |||
| d0d9e2a9a8 | |||
| b047c93965 | |||
| d5eedd1dd2 | |||
| 9cc6696340 | |||
| 86758383c4 | |||
| 150a0264c5 | |||
| 558a2d8aad | |||
| fa327114f7 | |||
| 6ce3e0bfac | |||
| 4f7dee570a | |||
| e4eadf863e | |||
| 7a70a6ce01 | |||
| ca328e784c | |||
| 9871e252bc | |||
| d40eb6c4e1 | |||
| a7b0e6d0bf | |||
| f4f546e654 | |||
| 1fcbb3ecbc | |||
| 98e3cc973b | |||
| 220ab53ef2 | |||
| 9ba70063d2 | |||
| 076277d0a9 | |||
| bcd2ba1ec9 | |||
| 5827afd09c | |||
| 4a3e49f4e3 | |||
| 95d24aca41 | |||
| 345e37bd81 | |||
| 91b2fabf10 | |||
| bae1803157 | |||
| 911d16de31 | |||
| 1efe924221 | |||
| 0230235427 | |||
| 58e737ee28 | |||
| 78c98f121d | |||
| 2e3b86741b | |||
| fcd9869caa | |||
| f60579b735 | |||
| 6574f36c73 | |||
| 246ce245b9 | |||
| fa0a211db9 | |||
| 1c536df3c8 | |||
| 82fa1b5b1c | |||
| dacce748a1 | |||
| b59088c598 | |||
| 26dbce9dbf | |||
| 9b6d07dc4c | |||
| 00e21c8000 | |||
| 8c5f5326d5 | |||
| 3ebafcbc03 | |||
| 9777859f42 | |||
| 54f76d6576 | |||
| 3bb8293478 | |||
| 16e899cab7 | |||
| b4b9469284 | |||
| e0896864c2 | |||
| c7b16e0ea9 | |||
| f6d6920cfb | |||
| 8b4059a249 | |||
| 94b19e7589 | |||
| a090bb7caa | |||
| 101e97dfec | |||
| 31054a2df7 | |||
| 58231eb19c | |||
| 8f8b5d2684 | |||
| ca5e497dbb | |||
| 13aabcacd2 | |||
| 3afd0bb609 | |||
| e250a8b57f | |||
| 051fa7647d | |||
| 9c4c794d0f | |||
| 9211a28675 | |||
| 8d660ec7c0 | |||
| ed8109fc30 | |||
| 37fc63def8 | |||
| 8c1a8f67d8 | |||
| 94ed7581bb | |||
| 4a84a69fe7 | |||
| 1ebf6c9319 | |||
| d0fc353d0b | |||
| 977919fdb1 | |||
| ae2e37cedb | |||
| 02e5394924 | |||
| cdc9bb73bb | |||
| 3a2c0c744c | |||
| ffeb76f608 | |||
| 3748cb39b2 | |||
| 543ea52bb3 | |||
| 2ad508ec60 | |||
| f9501d6f60 | |||
| 6bbdf9600d | |||
| c554c010c5 | |||
| 075c976d19 | |||
| 6da49e78ee | |||
| 59ce2e0623 | |||
| 09b2a7f1a4 | |||
| bd466ac420 | |||
| 96183eb5df | |||
| 21164859cf | |||
| 9b50fe68c9 | |||
| d8576e4dc6 | |||
| 9fc23ad4be | |||
| 6c997c0b51 | |||
| 9b10421882 | |||
| e5bc98cac0 | |||
| e98f320f41 | |||
| d0ef35fb92 | |||
| 8c512f3163 | |||
| 8cc0fc9987 | |||
| 604200e1db | |||
| 2a1581acdb | |||
| 39e3198821 | |||
| b4c2b3614b | |||
| 5ea0cc7838 | |||
| a9b7fc525a | |||
| b05874fb0a | |||
| 5fdd142a17 | |||
| 243e1da716 | |||
| 772217258c | |||
| 57cc9c9db7 | |||
| e6f6560f3a | |||
| cbce30b4d7 | |||
| 23c8a84b4c | |||
| a521bff1f1 | |||
| 986784b128 | |||
| 238c2b8cd3 | |||
| c6a418e00c | |||
| e59ea1f84d | |||
| a1acde5df0 | |||
| 3ec61165ca | |||
| cc823a18d4 | |||
| b6aa865a67 | |||
| 86f83d995b | |||
| e314e09fdb | |||
| 4aa4238943 | |||
| 5d638b8bf4 | |||
| 5027d817c5 | |||
| 40b92330eb | |||
| b990447226 | |||
| 482019f514 | |||
| 2027af3a3f | |||
| c1a55385d3 | |||
| 8be47c99dd | |||
| 10d11f5b99 | |||
| 3db2c66f12 | |||
| e8614c0072 | |||
| 11b4c43845 | |||
| 36fec4ddbe | |||
| bb64039a0d | |||
| 7b43b0b300 | |||
| fd270c80f5 | |||
| 12b5801b1b | |||
| 23a6b38a7d | |||
| 296118470c | |||
| 6d4dccc6b7 | |||
| e449f86c01 | |||
| a1bdc048a7 | |||
| b5be78416f | |||
| 89d1fe2c49 | |||
| 0a1b08157d | |||
| 61503f4146 | |||
| d36c66371f | |||
| 34b259562d | |||
| b7bb409e96 | |||
| 517007c941 | |||
| 4c685a9ec6 | |||
| 1aca2099de | |||
| a93e5b4ff8 | |||
| 85d25bebe2 | |||
| 9fa43ccc00 | |||
| c2a11050dd | |||
| 080bfc3a44 | |||
| f6956ddeca | |||
| 9f56fa5e14 | |||
| ccc39b95de | |||
| 9a2782e54b | |||
| 22455e2301 | |||
| 8ed2c84b68 | |||
| ccd2a209e2 | |||
| baf8ed4830 | |||
| dedb586daf | |||
| 21cd823791 | |||
| c8ab65ef1b | |||
| f1c16fd992 | |||
| 52035341f6 | |||
| aa62d44717 | |||
| a072d1fc8d | |||
| 38a00570d0 | |||
| 43283b9da3 | |||
| ef82cdbed6 | |||
| 2bafe6f31f | |||
| 3eb4f98fd8 | |||
| bb5acad033 | |||
| b8308a446b | |||
| c86f99ce45 | |||
| 952c519e45 | |||
| 07d97fa0bf | |||
| b0defedf04 | |||
| edc2fccdeb | |||
| a75b8a3f13 | |||
| 5aab5f7913 | |||
| 9ab7989c8b | |||
| e3e11d740a | |||
| 4bae2edc49 | |||
| 4eaa47ca25 | |||
| e01f596525 | |||
| 912e8d0d04 | |||
| 570c80af91 | |||
| 7aa0ec0d67 | |||
| 2fea6cb622 | |||
| 2195ff900f | |||
| 836c7699b8 | |||
| 72ed6c814e | |||
| c33b070509 | |||
| de12d5686c | |||
| c55a8ac805 | |||
| df3626f3f0 | |||
| 28bef97faa | |||
| 9897b6e9dc | |||
| 9af6963901 | |||
| c2d3ebecda | |||
| ba543311fc | |||
| 87b8dda97b | |||
| e7facf5686 | |||
| 4dd57837c5 | |||
| d4ebc68e30 | |||
| 1f8e089e51 | |||
| ce6f463fe8 | |||
| a37fe1d794 | |||
| 818d1ec6bf | |||
| fc4a5f7e28 | |||
| 0e3568b584 | |||
| 3617e4fe29 | |||
| f2fddc1727 | |||
| 3b7204f1a6 | |||
| 6646bb1e56 | |||
| c27533f802 | |||
| 613a47c181 | |||
| 90138a142b | |||
| 4bf8db4898 | |||
| 4f887f7204 | |||
| 14e17ccf2c | |||
| 5975670b8c | |||
| dbc4bc3343 | |||
| ada7635703 | |||
| 943a77f718 | |||
| ef02c11efa | |||
| 8c166dae9b | |||
| b23da78c26 | |||
| 93ac7310e8 | |||
| 9376acc456 | |||
| b70a1f9a51 | |||
| ac90a134b4 | |||
| 96bd1cf9f6 | |||
| 960e37a81a | |||
| 044bd550c9 | |||
| 0a9a903d1b | |||
| 84d7606e12 | |||
| febb64b8bb | |||
| 932e433c46 | |||
| b7307cd36d | |||
| 7a0f3efd83 | |||
| 28af1f691c | |||
| 796bc7bc15 | |||
| 8f06073783 | |||
| 7d6251b191 | |||
| e13fff633e | |||
| d984be4b85 | |||
| 213bdbd9d5 | |||
| 6a59d27b84 | |||
| ad45ab2e82 | |||
| 8982a63283 | |||
| 1b1515a8bd | |||
| df50e13db0 | |||
| 89d91c14c9 | |||
| 3a57c609f7 | |||
| 2cd331ec50 | |||
| 3fa02ec65c | |||
| f33f1965b4 | |||
| a70ecea02b | |||
| 8e68eb35f3 | |||
| 2893331ff5 | |||
| 1a3d14cdd6 | |||
| dce9a7addb | |||
| f3e7487482 | |||
| 86c39237dc | |||
| b5ad739b93 | |||
| 0b7f0405d5 | |||
| 1ab56708a5 | |||
| 522489c9e9 | |||
| a9eb2a790f | |||
| a092ed1108 | |||
| 503515281d | |||
| 2326d4dfb5 | |||
| 42e8030cf7 | |||
| 17b4ede566 | |||
| bbc3fea848 | |||
| 82e46b872b | |||
| 0f6a091c73 | |||
| 4e87adb4b3 | |||
| 320a2b6cf8 | |||
| b216556867 | |||
| 7fbb98a2a9 | |||
| 461a8edbea | |||
| cdef179bed | |||
| a067388d79 | |||
| 2d5e541593 | |||
| be40186ad3 | |||
| c9ae05b22e | |||
| 2b874fe59f | |||
| 9da5e5d6c0 | |||
| a6bfce2a5f | |||
| 8cbeabe917 | |||
| 1db354077f | |||
| e31d41a276 | |||
| 21d2abf716 | |||
| 3a86a88870 | |||
| 6117a840e1 | |||
| 0e20987fb8 | |||
| 65e7cab772 | |||
| 935f2ac766 | |||
| 3e12d7eb9c | |||
| d6095269b7 | |||
| 0c415b4e32 | |||
| bc1819b368 | |||
| a9be016c87 | |||
| 11da5e9d26 | |||
| 2c6c194821 | |||
| aedd8b4cc6 | |||
| fa2607e9b8 | |||
| 3783e5ee5d | |||
| fd56b8ffed | |||
| 07e288be16 | |||
| 46143c3fe0 | |||
| 83e3cc85f2 | |||
| a4b50ae60a | |||
| a30d0c37eb | |||
| 64fdf59905 | |||
| 1aa3f2fb05 | |||
| 68e8cb72d3 | |||
| a86d3cd65a | |||
| a4b4cbf60f | |||
| 2dcb7ebd74 | |||
| ad6b64ca74 | |||
| d27a2b8cf3 | |||
| 8fa1985feb | |||
| 451efb8d3e | |||
| d6bf3139ff | |||
| 309b9ea937 | |||
| 554bff38c6 | |||
| d5e6062ec9 | |||
| bcb68d552f | |||
| 3de87723ae | |||
| 535d70ac5a | |||
| d588d43aa1 | |||
| f455cecb54 | |||
| b88c0a9305 | |||
| 9030cff8ba | |||
| 98f73f799a | |||
| d2e428ada8 | |||
| 74156ec84c | |||
| f9e6bc92d7 | |||
| 9884586cc9 | |||
| ac717a6efb | |||
| 2b7c1ded15 | |||
| daac27712d | |||
| 1080f33282 | |||
| cc5c0a0a89 | |||
| 85971447e1 | |||
| 256e8ef275 | |||
| c07e54ec03 | |||
| 70f834e1cf | |||
| c320c6f2a2 | |||
| 256eb60df8 | |||
| 5f03973bf2 | |||
| ab2a0d8ae2 | |||
| 7e48402591 | |||
| aa85f6fcd1 | |||
| cd441ccfe7 | |||
| 47f6519006 | |||
| 9679376cb2 | |||
| efa97c3bbc | |||
| 087e598be0 | |||
| 31aa8243ee | |||
| d3d05ef539 | |||
| d6062ea4e7 | |||
| 7949748951 | |||
| 94f7392060 | |||
| 0d737bad57 | |||
| 1225db50c9 | |||
| e5d85bb3df | |||
| 0f09e5c236 | |||
| 0f0204b647 | |||
| 94421d2622 | |||
| 44f0b70461 | |||
| f58768237b | |||
| 588cf839e3 | |||
| 76872b3a97 | |||
| d253d68a12 | |||
| 4de0d29f30 | |||
| 0f0480db63 | |||
| aa40b62e0a | |||
| 68309ac582 | |||
| 522183eb4d | |||
| 4f6fee4d73 | |||
| c5fecf73c8 | |||
| ee8e93d1e8 | |||
| 9d0fa5ea4a | |||
| b0b9affbe7 | |||
| 1d1c7c78e8 | |||
| d7f5b87e70 | |||
| 1048666972 | |||
| 217f5d61c7 | |||
| 2f1677f581 | |||
| afd7ea6a1c | |||
| 7155e14e64 | |||
| 68e5b49f46 | |||
| c01e95c716 | |||
| ffa7e5130e | |||
| 7ce33bfd4c | |||
| 0c64fa9986 | |||
| 07e8b347e1 | |||
| 38a402adef | |||
| 7ab2e29101 | |||
| b96796793b | |||
| baa073b05d | |||
| c944f9de52 | |||
| 5567a65e4b | |||
| c6c775f436 | |||
| c0c43be6b9 | |||
| 9b6074318a | |||
| ada121015d | |||
| 9d7b6c4bc6 | |||
| c262fc4f4d | |||
| 335317bd86 | |||
| 396464c573 | |||
| d93c76ca36 | |||
| 60ad6007e5 | |||
| ceee520102 | |||
| a053557000 | |||
| e7c14b0817 | |||
| 727fd0bd36 | |||
| 885cec57db | |||
| 4ba2b0c9ab | |||
| b3672b8c66 | |||
| b33dda4a32 | |||
| 450e565718 | |||
| 00bd72c1e4 | |||
| 81da1f45f1 | |||
| fd3d6433e2 | |||
| 24c24c1307 | |||
| 2bcee5e362 | |||
| 74d402a330 | |||
| 08bd8a9942 | |||
| 6944260767 | |||
| 3ada2d1d9d | |||
| 4a48255be1 | |||
| 25f8712a9f | |||
| f83b8c74ca | |||
| 7a4f3dc4c5 | |||
| 26b52b1ab0 | |||
| 9592a0ddda | |||
| c48c3a4a1c | |||
| 3e92b8dc97 | |||
| 0be33f019c | |||
| 68bda077e9 | |||
| c956ebf618 | |||
| 041f4463f6 | |||
| 1b217f1a54 | |||
| db1d24bf54 | |||
| a67b5a5829 | |||
| a606d0e8b1 | |||
| 05b62016cd | |||
| a0853fc621 | |||
| 469c5ed7d3 | |||
| 920588057a | |||
| 9c044b232a | |||
| 00764d9ac9 | |||
| d30897ac4c | |||
| 49138e87c1 | |||
| 1ddc5fb924 | |||
| 2a2ca248b1 | |||
| ca06e100d3 | |||
| 5fbc05f9ec | |||
| 97d2d0e250 | |||
| 67549661c5 | |||
| 91666efc94 | |||
| d173d82714 | |||
| 6621f93342 | |||
| 4cdba13c8c | |||
| 1d4ea6559a | |||
| 002db4bbf6 | |||
| ae0c77ea0e | |||
| 1b9980c980 | |||
| bf2aefe2da | |||
| bdea9ad4f2 | |||
| d21247c0a6 | |||
| c1994bd3a8 | |||
| 67c9e95017 | |||
| 0ea7467a4e | |||
| 540a31f237 | |||
| 18214653d0 | |||
| 83337945dc | |||
| 9c19da7cd5 | |||
| cfa1f2e9e6 | |||
| ab9dccedc9 | |||
| 58a870449c | |||
| 04146e9bd2 | |||
| e9bfcef165 | |||
| c98f3f20cb | |||
| a4bae6d826 | |||
| 8c5a60c083 | |||
| 4ead565142 | |||
| 3eaa877567 | |||
| d026f13a06 | |||
| ff48f27700 | |||
| f507fbc111 | |||
| 064c3bc02f | |||
| f877363158 | |||
| b6c53cc5c6 | |||
| 8eda537d7c | |||
| e65a9cdee4 | |||
| 2fd3a78cf8 | |||
| e06abd3c7a | |||
| 0d8f5c4eb5 | |||
| ddd5db032e | |||
| 76f418d3df | |||
| 131112f00c | |||
| 04737dbfae | |||
| 3d86672b52 | |||
| 601ff0571b | |||
| 0505045c81 | |||
| aab47ec0c6 | |||
| 7bc60c0574 | |||
| a64246f2c0 | |||
| b5447a6a41 | |||
| adb15b2cae | |||
| 533ec2b0f8 | |||
| c2f9526c6b | |||
| 4348ad1c3e | |||
| 1a18d79d94 | |||
| cef90dd2e4 | |||
| 63565b04d5 | |||
| 6ad7666b93 | |||
| 7975875b07 | |||
| 0760929963 | |||
| 57c4e7f267 | |||
| f7e6578043 | |||
| 7717af32d6 | |||
| ba9321e442 | |||
| f79641c1dd | |||
| 9ef2cd9963 | |||
| 67866a671c | |||
| c865349b27 | |||
| d95f1b67d2 | |||
| 961a2e41e9 | |||
| 5d2be6e20e | |||
| e59131dcc9 | |||
| 2bdc46e50e | |||
| 41705fd929 | |||
| 6dd5089866 | |||
| 126b38a19a | |||
| 06b1cb3400 | |||
| 7101584d75 | |||
| 6e9939f96e | |||
| 42f312d97b | |||
| e52f107dbe | |||
| 22898a3019 | |||
| ff1d58e4f7 | |||
| 25f448b377 | |||
| 258d9cd314 | |||
| f1943096f2 | |||
| 67deef3c4f | |||
| 86129c3158 | |||
| 95dde4dd5d | |||
| 27294a10a7 | |||
| e19b6c8740 | |||
| bc3cd9e0fd | |||
| b47c0558ab | |||
| 9ae1f62555 | |||
| 87b077234a | |||
| b27df509f2 | |||
| c339ae16c2 | |||
| 35943d990c | |||
| 35e0806a59 | |||
| ad017d9f97 | |||
| c0ddcf7c5f | |||
| 2f7de57e21 | |||
| 3e353f4eff | |||
| 35dc9ca1ad | |||
| 0c488c1f90 | |||
| 85321b87c0 | |||
| ce5b5982a3 | |||
| 28a99c42f1 | |||
| 1e8a3060ec | |||
| 41dc311fd9 | |||
| 86e6dc078f | |||
| 9eb298c55d | |||
| 731992b0e5 | |||
| 7ed6cfcdd9 | |||
| 0fbbb33f76 | |||
| 5c6799d386 | |||
| d86d8aaa14 | |||
| 844b3ddb35 | |||
| 3db6ec96e5 | |||
| 76d5296005 | |||
| 3021b6fab9 | |||
| 6797b0a48a | |||
| 37923f550b | |||
| a2ef4cc9c7 | |||
| bb6651adaa | |||
| f595853984 | |||
| 4fb2c76b72 | |||
| 136b2973ca | |||
| 1a2073ca3a | |||
| f94768dcf0 | |||
| 7b671f3e6f | |||
| 1a0805722d | |||
| b3d2fb0bcc | |||
| 59877b2a20 | |||
| 6aef15666a | |||
| 7247d157a7 | |||
| 5b7c68bf9e | |||
| 9506906c92 | |||
| 1bbc1f2d86 | |||
| 7ccab08153 | |||
| 8568957afa | |||
| 5628014ba7 | |||
| e2761a3e03 | |||
| ce4c1d8d60 | |||
| 6991275d54 | |||
| 52d39b7c90 | |||
| 80f8b91631 | |||
| 864591a37a | |||
| 1a703bf738 | |||
| 1762386336 | |||
| b002392c21 | |||
| 4de0c3789a | |||
| 84c33ef8f6 | |||
| 93295ab7f4 | |||
| cc9f06384d | |||
| 18b7e89b6c | |||
| 214419ff57 | |||
| 9982cf6d0e | |||
| 9a2ba0943c | |||
| 1c71a0b226 | |||
| 9349a83479 | |||
| 3454fdeec0 | |||
| 939d02f833 | |||
| 03079e23a6 | |||
| 2e8ddb52eb | |||
| ea62e9cd3f | |||
| cb9f048f15 | |||
| d9eccb6bf5 | |||
| 981a338e9b | |||
| b930916ccd | |||
| 83afaab6bf | |||
| a104902abd | |||
| 12ff850742 | |||
| 252cdfef35 | |||
| b2861fd7fd | |||
| 64a2a4c5da | |||
| bd64c39882 | |||
| 1a856a917e | |||
| c1275c4033 | |||
| f00e909a64 | |||
| fed865872e | |||
| fd270f2c02 | |||
| f2635bf457 | |||
| 4e0813d49e | |||
| 1f8e2bf6c3 | |||
| b58a031a69 | |||
| d96f11d968 | |||
| b22b160aad | |||
| debf19b059 | |||
| 0f8c14971e | |||
| fdd4ce3c19 | |||
| 9317f20917 | |||
| 4228cf45f5 | |||
| 1bedad903b | |||
| e281282514 | |||
| 298789e0e2 | |||
| 007e4bdcfb | |||
| a7378492ef | |||
| 4ad23acfb6 | |||
| 5dfa1170ba | |||
| a4d9b0202b | |||
| 3a23ec2ab3 | |||
| 0dcea3f03a | |||
| 851c54b6af | |||
| bf78926b31 | |||
| 2aada85662 | |||
| 7d569a49cb | |||
| 6d69a06935 | |||
| 77aa0080d9 | |||
| 2ef746bf37 | |||
| 809959289c | |||
| de74542e78 | |||
| 2ae0cb8b51 | |||
| cea880ad5c | |||
| f570c8b174 | |||
| 6f4a95b0da | |||
| 2817974672 | |||
| 1f8ad0fda3 | |||
| 189a1c8fa3 | |||
| 35de0c003c | |||
| 7ccaa8972c | |||
| 9c8418ab40 | |||
| c9a2a56dd9 | |||
| 31cb70ed02 | |||
| 1fc2113c9a | |||
| 8c07b63dec | |||
| 13ec24d95e | |||
| fd5357a736 | |||
| b349f8b156 | |||
| 30d446aa16 | |||
| a5e19c2705 | |||
| d7ac23235a | |||
| 9e95144e86 | |||
| 999957ef56 | |||
| 4a523c611d | |||
| 438d0a7fa2 | |||
| 045a8abcfb | |||
| f5a141daf0 | |||
| d77025cb9e | |||
| 167d2e5c1f | |||
| 36e72169b8 | |||
| 0d67eab7f7 | |||
| c7bfbe6b9f | |||
| 577f846545 | |||
| 05f6071119 | |||
| b57c80a5ae | |||
| f3a00814a5 | |||
| d40e88c945 | |||
| 7671bb3a8c | |||
| 6bc93f8176 | |||
| c5cee7c6de | |||
| 118b847995 | |||
| b5a701d560 | |||
| b84910f7d5 | |||
| 92230b6dda | |||
| 1d2edf8ca7 | |||
| 8012ac42fe | |||
| 16d401ffa6 | |||
| 75569097b2 | |||
| 61c0f94538 | |||
| 9378188b59 | |||
| fa49bf7fc0 | |||
| ee5edd1abc | |||
| 1f43f1ad66 | |||
| d7d12d7ac0 | |||
| 26493be5ee | |||
| 7e399cc181 | |||
| c1a1d16ca8 | |||
| d6d0c9f914 | |||
| 9ece54b099 | |||
| 09130df02d | |||
| 428cbf4781 | |||
| 1be6f4e814 | |||
| 11df2331cd | |||
| 5ebda41e96 | |||
| ec1eeb6368 | |||
| 49efc0e4df | |||
| 49ef8d54db | |||
| 276b88274f | |||
| 5c239a2c53 | |||
| b6161813cb | |||
| eeeb9a3815 | |||
| 924e6c8a2e | |||
| b4d2071ba7 | |||
| 3c7c6e6c41 | |||
| 6c4704de1a | |||
| 92a3abea89 | |||
| 2e3bfffc41 | |||
| 7190c32ebe | |||
| 7506fac410 | |||
| 03d76ce154 | |||
| e29d76f2dc | |||
| 56c0c00cba | |||
| c823c34ac8 | |||
| 0424165a2f | |||
| aa8548d90d | |||
| 400687914a | |||
| 9525b0622b | |||
| 98b59c760b | |||
| 040d657ef6 | |||
| 70ea4c77ae | |||
| 215b87f83c | |||
| 34dc99ff23 |
+1
-2
@@ -7,5 +7,4 @@
|
||||
/.vscode/
|
||||
.air.toml
|
||||
/tmp/
|
||||
/work
|
||||
/cmd/
|
||||
/work
|
||||
@@ -1,88 +0,0 @@
|
||||
variables:
|
||||
PATH: /opt/go-1.23/go/bin/:/opt/node-1.22/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
|
||||
GOROOT: /opt/go-1.23/go
|
||||
GOPROXY: https://goproxy.cn
|
||||
VERSION: $CI_COMMIT_SHORT_SHA
|
||||
APP: apipark
|
||||
APP_PRE: ${APP}_${VERSION}
|
||||
BUILD_DIR: ${APP}-build
|
||||
DEPLOY_DESC: "DEV 环境"
|
||||
VIEW_ADDR: http://172.18.166.219:8288
|
||||
SAVE_DIR: /opt/${APP}
|
||||
NODE_OPTIONS: --max_old_space_size=8192
|
||||
|
||||
stages:
|
||||
# - notice
|
||||
- build
|
||||
- deploy
|
||||
- webhook
|
||||
#
|
||||
#feishu-informer: # 飞书回调
|
||||
# stage: notice
|
||||
# variables:
|
||||
# DIFF_URL: "$CI_MERGE_REQUEST_PROJECT_URL/-/merge_requests/$CI_MERGE_REQUEST_IID/diffs"
|
||||
# rules:
|
||||
# - if: $CI_PIPELINE_SOURCE=="merge_request_event" && $CI_COMMIT_BRANCH =~ "main-github-pro"
|
||||
# script:
|
||||
# - echo "merge request"
|
||||
# - |
|
||||
# curl -X POST -H "Content-Type: application/json" \
|
||||
# -d "{\"msg_type\":\"text\",\"content\":{\"text\":\"项目:${CI_PROJECT_NAME}\\n提交人:${GITLAB_USER_NAME}\\n提交信息:${CI_MERGE_REQUEST_TITLE}\\n合并分支信息:${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} -> ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}\\n差异性地址:${DIFF_URL}\\n请及时review代码\"}}" \
|
||||
# ${FEISHU_WEBHOOK}
|
||||
|
||||
builder:
|
||||
stage: build
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
|
||||
script:
|
||||
- set -e
|
||||
- |
|
||||
if [ ! -d "../artifacts" ]; then
|
||||
mkdir -p ../artifacts
|
||||
fi
|
||||
if [ -d "../artifacts/dist" ]; then
|
||||
cp -r ../artifacts/dist frontend/dist
|
||||
fi
|
||||
- |
|
||||
if [ -n "$(git diff --name-status HEAD~1 HEAD -- frontend)" ]; then
|
||||
./scripts/build.sh $BUILD_DIR ${VERSION} all ""
|
||||
else
|
||||
./scripts/build.sh $BUILD_DIR ${VERSION}
|
||||
fi
|
||||
if [ -d "frontend/dist" ]; then
|
||||
echo "copy frontend/dist to artifacts/dist"
|
||||
rm -fr ../artifacts/dist
|
||||
cp -r frontend/dist ../artifacts/dist
|
||||
fi
|
||||
cp $BUILD_DIR/${APP_PRE}_linux_amd64.tar.gz ${SAVE_DIR}
|
||||
|
||||
deployer:
|
||||
stage: deploy
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
|
||||
variables:
|
||||
APIPARK_GUEST_MODE: allow
|
||||
APIPARK_GUEST_ID: dklejrfbhjqwdh
|
||||
script:
|
||||
- cd ${SAVE_DIR};mkdir -p ${APP_PRE};tar -zxvf ${APP_PRE}_linux_amd64.tar.gz -C ${APP_PRE};cd ${APP_PRE};./install.sh ${SAVE_DIR};./run.sh restart;cd ${SAVE_DIR} && ./clean.sh ${APP_PRE}
|
||||
when: on_success
|
||||
success:
|
||||
stage: webhook
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
|
||||
script:
|
||||
- |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署完成.\\n访问地址:${VIEW_ADDR}\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
|
||||
${FEISHU_WEBHOOK}
|
||||
when: on_success
|
||||
failure:
|
||||
stage: webhook
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "main-github-pro" || $CI_COMMIT_BRANCH == "main"
|
||||
script:
|
||||
- |
|
||||
curl -X POST -H "Content-Type: application/json" \
|
||||
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署失败,请及时到gitlab上查看\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
|
||||
${FEISHU_WEBHOOK}
|
||||
when: on_failure
|
||||
@@ -1,77 +0,0 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func FormatCountInt64(count int64) string {
|
||||
switch {
|
||||
case count < 1000:
|
||||
return strconv.FormatInt(count, 10)
|
||||
case count < 1000000:
|
||||
return fmt.Sprintf("%.1fK", float64(count)/1000)
|
||||
case count < 1000000000:
|
||||
return fmt.Sprintf("%.1fM", float64(count)/1000000)
|
||||
case count < 1000000000000:
|
||||
return fmt.Sprintf("%.1fB", float64(count)/1000000000)
|
||||
default:
|
||||
return fmt.Sprintf("%.1fT", float64(count)/1000000000000)
|
||||
}
|
||||
}
|
||||
|
||||
func FormatCountFloat64(count float64) string {
|
||||
switch {
|
||||
case count < 1000:
|
||||
return fmt.Sprintf("%.1f", count)
|
||||
case count < 1000000:
|
||||
return fmt.Sprintf("%.1fK", count/1000)
|
||||
case count < 1000000000:
|
||||
return fmt.Sprintf("%.1fM", count/1000000)
|
||||
case count < 1000000000000:
|
||||
return fmt.Sprintf("%.1fB", count/1000000000)
|
||||
default:
|
||||
return fmt.Sprintf("%.1fT", count/1000000000000)
|
||||
}
|
||||
}
|
||||
|
||||
func FormatTime(t int64) string {
|
||||
if t < 1000 {
|
||||
return strconv.FormatInt(t, 10) + "ms"
|
||||
}
|
||||
if t < 1000000 {
|
||||
return fmt.Sprintf("%.1fs", float64(t)/1000)
|
||||
}
|
||||
if t < 1000000000 {
|
||||
return fmt.Sprintf("%.1fmin", float64(t)/1000000)
|
||||
}
|
||||
if t < 1000000000000 {
|
||||
return fmt.Sprintf("%.1fhour", float64(t)/1000000000)
|
||||
}
|
||||
return fmt.Sprintf("%.1D", float64(t)/1000000000000)
|
||||
}
|
||||
|
||||
func FormatByte(b int64) string {
|
||||
const (
|
||||
KB = 1000
|
||||
MB = KB * 1000
|
||||
GB = MB * 1000
|
||||
TB = GB * 1000
|
||||
PB = TB * 1000
|
||||
)
|
||||
|
||||
switch {
|
||||
case b < KB:
|
||||
return fmt.Sprintf("%dB", b)
|
||||
case b < MB:
|
||||
return fmt.Sprintf("%.1fKB", float64(b)/KB)
|
||||
case b < GB:
|
||||
return fmt.Sprintf("%.1fMB", float64(b)/MB)
|
||||
case b < TB:
|
||||
return fmt.Sprintf("%.1fGB", float64(b)/GB)
|
||||
case b < PB:
|
||||
return fmt.Sprintf("%.1fTB", float64(b)/TB)
|
||||
default:
|
||||
return fmt.Sprintf("%.1fPB", float64(b)/PB)
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,6 @@ func FmtIntFromInterface(val interface{}) int64 {
|
||||
return int64(ret)
|
||||
case int:
|
||||
return int64(ret)
|
||||
case float64:
|
||||
return int64(ret)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package catalogue
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/catalogue"
|
||||
catalogue_dto "github.com/APIParkLab/APIPark/module/catalogue/dto"
|
||||
"github.com/APIParkLab/APIPark/module/service"
|
||||
"github.com/APIParkLab/APIPark/module/tag"
|
||||
tag_dto "github.com/APIParkLab/APIPark/module/tag/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -15,7 +14,6 @@ var (
|
||||
|
||||
type imlCatalogueController struct {
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
appModule service.IAppModule `autowired:""`
|
||||
tagModule tag.ITagModule `autowired:""`
|
||||
}
|
||||
|
||||
@@ -28,17 +26,7 @@ func (i *imlCatalogueController) Subscribe(ctx *gin.Context, subscribeInfo *cata
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) ServiceDetail(ctx *gin.Context, sid string) (*catalogue_dto.ServiceDetail, error) {
|
||||
detail, err := i.catalogueModule.ServiceDetail(ctx, sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, canSubscribe, err := i.appModule.SearchCanSubscribe(ctx, sid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
detail.CanSubscribe = canSubscribe
|
||||
return detail, nil
|
||||
|
||||
return i.catalogueModule.ServiceDetail(ctx, sid)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Search(ctx *gin.Context, keyword string) ([]*catalogue_dto.Item, []*tag_dto.Item, error) {
|
||||
|
||||
@@ -1,277 +0,0 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
application_authorization "github.com/APIParkLab/APIPark/module/application-authorization"
|
||||
|
||||
mcp_server "github.com/APIParkLab/APIPark/mcp-server"
|
||||
"github.com/APIParkLab/APIPark/module/mcp"
|
||||
"github.com/APIParkLab/APIPark/module/system"
|
||||
"github.com/eolinker/go-common/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
mcp2 "github.com/mark3labs/mcp-go/mcp"
|
||||
"github.com/mark3labs/mcp-go/server"
|
||||
)
|
||||
|
||||
var _ IMcpController = (*imlMcpController)(nil)
|
||||
|
||||
type imlMcpController struct {
|
||||
settingModule system.ISettingModule `autowired:""`
|
||||
authorizationModule application_authorization.IAuthorizationModule `autowired:""`
|
||||
mcpModule mcp.IMcpModule `autowired:""`
|
||||
sessionKeys sync.Map
|
||||
server map[string]http.Handler
|
||||
openServer http.Handler
|
||||
}
|
||||
|
||||
var mcpDefaultConfig = `{
|
||||
"mcpServers": {
|
||||
"%s": {
|
||||
"url": "%s"
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
func (i *imlMcpController) GlobalMCPConfig(ctx *gin.Context) (string, error) {
|
||||
cfg := i.settingModule.Get(ctx)
|
||||
if cfg.SitePrefix == "" {
|
||||
return "", fmt.Errorf("site prefix is empty")
|
||||
}
|
||||
return fmt.Sprintf(mcpDefaultConfig, "APIPark-MCP-Server", fmt.Sprintf("%s/openapi/v1/%s/sse?apikey={your_api_key}", strings.TrimSuffix(cfg.SitePrefix, "/"), mcp_server.GlobalBasePath)), nil
|
||||
}
|
||||
|
||||
func (i *imlMcpController) generateZhCNMCPServer() *server.MCPServer {
|
||||
s := server.NewMCPServer("APIPark MCP Server", "1.0.0", server.WithLogging())
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"service_list",
|
||||
mcp2.WithDescription("此工具用于获取 APIPark 中已注册服务的列表。每个服务包含其唯一标识(service ID)、名称、描述及包含的 API 列表等关键信息。支持通过关键词进行模糊搜索,以便快速缩小查找范围。在获得某个服务的 ID 后,可以调用 openapi_document 工具来获取该服务的 OpenAPI 文档,以便后续调用其提供的 API 接口。"),
|
||||
mcp2.WithString("keyword", mcp2.Description("关键词,用于模糊搜索服务")),
|
||||
),
|
||||
i.mcpModule.Services,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"openapi_document",
|
||||
mcp2.WithDescription("此工具用于获取指定服务的 OpenAPI 接口文档。返回内容支持 OpenAPI v3 与 v2 两种规范格式。通过传入服务 ID,可以查看该服务的所有 API 定义、参数结构、请求方式等详细信息,为后续构造请求做准备。"),
|
||||
mcp2.WithString("service", mcp2.Description("服务的唯一标识 ID")),
|
||||
),
|
||||
i.mcpModule.APIs,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"invoke_api",
|
||||
mcp2.WithDescription("此工具用于直接调用指定的 API 接口。调用前需根据该接口的 OpenAPI 文档构造必要的请求参数,如请求路径、方法、查询参数、请求头、请求体等。调用过程中无需传递认证信息,例如请求头中的 Authorization 字段不需要提供。"),
|
||||
mcp2.WithString("path", mcp2.Description("API 请求路径"), mcp2.Required()),
|
||||
mcp2.WithString("method", mcp2.Description("API 请求方法,例如 GET、POST、PUT"), mcp2.Required()),
|
||||
mcp2.WithString("content-type", mcp2.Description("请求的 Content-Type 类型。如果方法为 POST、PUT 或 PATCH,则必须指定该字段。")),
|
||||
mcp2.WithObject("query", mcp2.Description("请求的查询参数,类型为 map[string]string")),
|
||||
mcp2.WithObject("header", mcp2.Description("请求的头部参数,类型为 map[string]string")),
|
||||
mcp2.WithString("body", mcp2.Description("请求体内容,通常为 JSON 字符串")),
|
||||
),
|
||||
i.mcpModule.Invoke,
|
||||
)
|
||||
return s
|
||||
}
|
||||
|
||||
func (i *imlMcpController) generateZhTWMCPServer() *server.MCPServer {
|
||||
s := server.NewMCPServer("APIPark MCP Server", "1.0.0", server.WithLogging())
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"service_list",
|
||||
mcp2.WithDescription("此工具用於獲取 APIPark 中已註冊服務的清單。每個服務包含其唯一識別碼(service ID)、名稱、描述以及該服務所包含的 API 列表。支援關鍵字模糊搜尋,可快速縮小查詢範圍。獲取到服務 ID 後,可使用 openapi_document 工具來查詢該服務對應的 OpenAPI 文件,為後續 API 呼叫做準備。"),
|
||||
mcp2.WithString("keyword", mcp2.Description("關鍵字,用於模糊搜尋服務")),
|
||||
),
|
||||
i.mcpModule.Services,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"openapi_document",
|
||||
mcp2.WithDescription("此工具用於查詢指定服務的 OpenAPI 文件。返回的格式支援 OpenAPI v3 與 v2 標準。透過輸入服務 ID,可查閱該服務所有 API 的定義、參數結構、請求方式等細節,有助於後續構造 API 呼叫請求。"),
|
||||
mcp2.WithString("service", mcp2.Description("欲查詢的服務唯一識別碼")),
|
||||
),
|
||||
i.mcpModule.APIs,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"invoke_api",
|
||||
mcp2.WithDescription("此工具可直接發送 API 請求。在呼叫此工具之前,需根據該 API 的 OpenAPI 文件構造所需的請求參數,如請求路徑、方法、查詢參數、標頭、主體等。使用此工具時不需傳送任何認證資訊,例如 Authorization 標頭可省略。"),
|
||||
mcp2.WithString("path", mcp2.Description("API 的請求路徑"), mcp2.Required()),
|
||||
mcp2.WithString("method", mcp2.Description("API 的請求方法,例如 GET、POST、PUT"), mcp2.Required()),
|
||||
mcp2.WithString("content-type", mcp2.Description("請求的 Content-Type。若方法為 POST、PUT 或 PATCH,則必須指定")),
|
||||
mcp2.WithObject("query", mcp2.Description("請求的查詢參數,類型為 map[string]string")),
|
||||
mcp2.WithObject("header", mcp2.Description("請求的標頭,類型為 map[string]string")),
|
||||
mcp2.WithString("body", mcp2.Description("請求主體內容,通常為 JSON 字串")),
|
||||
),
|
||||
i.mcpModule.Invoke,
|
||||
)
|
||||
return s
|
||||
}
|
||||
|
||||
func (i *imlMcpController) generateEnMCPServer() *server.MCPServer {
|
||||
s := server.NewMCPServer("APIPark MCP Server", "1.0.0", server.WithLogging())
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"service_list",
|
||||
mcp2.WithDescription("This tool can retrieve a list of registered services on APIPark, including key information such as service ID, name, description, and API list within the service. Support keyword search to quickly narrow down the search scope. After obtaining the service ID, you can use this ID to call the tool openapi_document to obtain the openapi document of the service for the corresponding service, preparing for subsequent API calls."),
|
||||
mcp2.WithString("keyword", mcp2.Description("Keyword for fuzzy search")),
|
||||
),
|
||||
i.mcpModule.Services,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"openapi_document",
|
||||
mcp2.WithDescription("This tool returns the openAPI documentation for the corresponding service. The format supports the specifications of OpenAPI v3 and OpenAPI v2."),
|
||||
mcp2.WithString("service", mcp2.Description("Service ID")),
|
||||
),
|
||||
i.mcpModule.APIs,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"invoke_api",
|
||||
mcp2.WithDescription("This tool can directly make API calls. Before calling this tool, it is necessary to construct relevant parameters based on the corresponding API's openAPI documentation, including query, header, body, method, path, and other parameters. By using this tool, no authentication related information needs to be transmitted, that is, no request header Authorization needs to be transmitted."),
|
||||
mcp2.WithString("path", mcp2.Description("API path"), mcp2.Required()),
|
||||
mcp2.WithString("method", mcp2.Description("API method"), mcp2.Required()),
|
||||
mcp2.WithString("content-type", mcp2.Description("API Request Content-Type. If method is POST,PUT,PATCH, it must be set. If not set, it will be ignored.")),
|
||||
mcp2.WithObject("query", mcp2.Description("API Request query,param type is map[string]string")),
|
||||
mcp2.WithObject("header", mcp2.Description("API Request header,param type is map[string]string")),
|
||||
mcp2.WithString("body", mcp2.Description("API Request body")),
|
||||
),
|
||||
i.mcpModule.Invoke,
|
||||
)
|
||||
return s
|
||||
}
|
||||
|
||||
func (i *imlMcpController) generateJPMCPServer() *server.MCPServer {
|
||||
s := server.NewMCPServer("APIPark MCP Server", "1.0.0", server.WithLogging())
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"service_list",
|
||||
mcp2.WithDescription("このツールは、APIPark に登録されているサービスの一覧を取得するためのものです。各サービスには、サービスID、名称、説明、およびそのサービスに含まれるAPI一覧といった重要な情報が含まれます。キーワードによるあいまい検索が可能で、目的のサービスを素早く絞り込むことができます。取得したサービスIDを使用して openapi_document ツールを呼び出すことで、そのサービスの OpenAPI ドキュメントを取得でき、APIの利用準備が整います。"),
|
||||
mcp2.WithString("keyword", mcp2.Description("キーワード。サービスをあいまい検索するための文字列")),
|
||||
),
|
||||
i.mcpModule.Services,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"openapi_document",
|
||||
mcp2.WithDescription("指定されたサービスの OpenAPI ドキュメントを取得するためのツールです。OpenAPI v3 および v2 のフォーマットに対応しています。このドキュメントを使用することで、APIのエンドポイント、リクエスト方法、パラメータなどの詳細を確認でき、API呼び出しの準備に役立ちます。"),
|
||||
mcp2.WithString("service", mcp2.Description("対象のサービスID")),
|
||||
),
|
||||
i.mcpModule.APIs,
|
||||
)
|
||||
s.AddTool(
|
||||
mcp2.NewTool(
|
||||
"invoke_api",
|
||||
mcp2.WithDescription("このツールは、指定された API を直接呼び出すためのものです。呼び出し前に、OpenAPI ドキュメントに基づいて必要なパラメータ(パス、メソッド、クエリ、ヘッダー、ボディなど)を構築する必要があります。呼び出し時に認証情報(例:Authorization ヘッダー)を送信する必要はありません。"),
|
||||
mcp2.WithString("path", mcp2.Description("API のリクエストパス"), mcp2.Required()),
|
||||
mcp2.WithString("method", mcp2.Description("HTTPメソッド(GET、POST、PUTなど)。"), mcp2.Required()),
|
||||
mcp2.WithString("content-type", mcp2.Description("リクエストの Content-Type。メソッドが POST、PUT、PATCH の場合に必須。")),
|
||||
mcp2.WithObject("query", mcp2.Description("リクエストのクエリパラメータ。型は map[string]string")),
|
||||
mcp2.WithObject("header", mcp2.Description("リクエストヘッダー。型は map[string]string")),
|
||||
mcp2.WithString("body", mcp2.Description("リクエストボディ。通常はJSON文字列")),
|
||||
),
|
||||
i.mcpModule.Invoke,
|
||||
)
|
||||
return s
|
||||
}
|
||||
|
||||
func (i *imlMcpController) OnComplete() {
|
||||
i.server = make(map[string]http.Handler)
|
||||
enSer := i.generateEnMCPServer()
|
||||
i.server["en-US"] = server.NewSSEServer(enSer, server.WithBasePath(fmt.Sprintf("/api/v1/%s", mcp_server.GlobalBasePath)))
|
||||
i.server["zh-CN"] = server.NewSSEServer(i.generateZhCNMCPServer(), server.WithBasePath(fmt.Sprintf("/api/v1/%s", mcp_server.GlobalBasePath)))
|
||||
i.server["zh-TW"] = server.NewSSEServer(i.generateZhTWMCPServer(), server.WithBasePath(fmt.Sprintf("/api/v1/%s", mcp_server.GlobalBasePath)))
|
||||
i.server["ja-JP"] = server.NewSSEServer(i.generateJPMCPServer(), server.WithBasePath(fmt.Sprintf("/api/v1/%s", mcp_server.GlobalBasePath)))
|
||||
|
||||
i.openServer = server.NewSSEServer(enSer, server.WithBasePath(fmt.Sprintf("/openapi/v1/%s", strings.Trim(mcp_server.GlobalBasePath, "/"))))
|
||||
}
|
||||
|
||||
func (i *imlMcpController) GlobalMCPHandle(ctx *gin.Context) {
|
||||
cfg := i.settingModule.Get(ctx)
|
||||
req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress))
|
||||
locale := utils.I18n(ctx)
|
||||
if v, ok := i.server[locale]; ok {
|
||||
v.ServeHTTP(ctx.Writer, req)
|
||||
return
|
||||
}
|
||||
i.server["en-US"].ServeHTTP(ctx.Writer, req)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) GlobalHandleSSE(ctx *gin.Context) {
|
||||
apikey := ctx.Request.URL.Query().Get("apikey")
|
||||
i.handleSSE(ctx, i.openServer, apikey)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) handleSSE(ctx *gin.Context, server http.Handler, apikey string) {
|
||||
|
||||
writer := &ResponseWriter{
|
||||
Writer: ctx.Writer,
|
||||
sessionId: make(chan string),
|
||||
}
|
||||
defer close(writer.sessionId)
|
||||
sessionId := ""
|
||||
go func() {
|
||||
var ok bool
|
||||
sessionId, ok = <-writer.sessionId
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
i.sessionKeys.Store(sessionId, apikey)
|
||||
}()
|
||||
server.ServeHTTP(writer, ctx.Request)
|
||||
i.sessionKeys.Delete(sessionId)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) GlobalHandleMessage(ctx *gin.Context) {
|
||||
i.handleMessage(ctx, i.openServer)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) MCPHandle(ctx *gin.Context) {
|
||||
cfg := i.settingModule.Get(ctx)
|
||||
|
||||
req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress))
|
||||
mcp_server.ServeHTTP(ctx.Writer, req)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) ServiceHandleSSE(ctx *gin.Context) {
|
||||
apikey := ctx.Request.URL.Query().Get("apikey")
|
||||
serviceId := ctx.Param("serviceId")
|
||||
if serviceId == "" {
|
||||
ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid service id", "success": "fail"})
|
||||
return
|
||||
}
|
||||
ok, err := i.authorizationModule.CheckAPIKeyAuthorization(ctx, serviceId, apikey)
|
||||
if err != nil {
|
||||
ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": err.Error(), "success": "fail"})
|
||||
return
|
||||
}
|
||||
if !ok {
|
||||
ctx.AbortWithStatusJSON(403, gin.H{"code": -1, "msg": "invalid apikey", "success": "fail"})
|
||||
return
|
||||
}
|
||||
|
||||
i.handleSSE(ctx, mcp_server.DefaultMCPServer(), apikey)
|
||||
}
|
||||
|
||||
func (i *imlMcpController) ServiceHandleMessage(ctx *gin.Context) {
|
||||
i.handleMessage(ctx, mcp_server.DefaultMCPServer())
|
||||
}
|
||||
|
||||
func (i *imlMcpController) handleMessage(ctx *gin.Context, server http.Handler) {
|
||||
sessionId := ctx.Request.URL.Query().Get("sessionId")
|
||||
apikey, ok := i.sessionKeys.Load(sessionId)
|
||||
if !ok {
|
||||
ctx.String(403, "sessionId not found")
|
||||
return
|
||||
}
|
||||
cfg := i.settingModule.Get(ctx)
|
||||
req := ctx.Request.WithContext(utils.SetGatewayInvoke(ctx.Request.Context(), cfg.InvokeAddress))
|
||||
req = req.WithContext(utils.SetLabel(req.Context(), "apikey", apikey.(string)))
|
||||
server.ServeHTTP(ctx.Writer, req)
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IMcpController interface {
|
||||
MCPHandle(ctx *gin.Context)
|
||||
GlobalMCPHandle(ctx *gin.Context)
|
||||
GlobalHandleSSE(ctx *gin.Context)
|
||||
GlobalHandleMessage(ctx *gin.Context)
|
||||
ServiceHandleSSE(ctx *gin.Context)
|
||||
ServiceHandleMessage(ctx *gin.Context)
|
||||
GlobalMCPConfig(ctx *gin.Context) (string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IMcpController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlMcpController))
|
||||
})
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type ResponseWriter struct {
|
||||
Writer http.ResponseWriter
|
||||
sessionId chan string
|
||||
}
|
||||
|
||||
func (r *ResponseWriter) Flush() {
|
||||
fluster, ok := r.Writer.(http.Flusher)
|
||||
if ok {
|
||||
fluster.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ResponseWriter) Header() http.Header {
|
||||
return r.Writer.Header()
|
||||
}
|
||||
|
||||
func (r *ResponseWriter) Write(bytes []byte) (int, error) {
|
||||
re := regexp.MustCompile(`sessionId=([^&?\s]+)`)
|
||||
match := re.FindStringSubmatch(string(bytes))
|
||||
if len(match) > 1 {
|
||||
r.sessionId <- match[1]
|
||||
}
|
||||
return r.Writer.Write(bytes)
|
||||
}
|
||||
|
||||
func (r *ResponseWriter) WriteHeader(statusCode int) {
|
||||
r.Writer.WriteHeader(statusCode)
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package monitor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/monitor"
|
||||
@@ -18,66 +17,6 @@ type imlMonitorStatisticController struct {
|
||||
module monitor.IMonitorStatisticModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlMonitorStatisticController) ChartRestOverview(ctx *gin.Context, start string, end string) (*monitor_dto.ChartRestOverview, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return i.module.RestChartOverview(ctx, "", s, e)
|
||||
}
|
||||
|
||||
func (i *imlMonitorStatisticController) ChartAIOverview(ctx *gin.Context, start string, end string) (*monitor_dto.ChartAIOverview, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return i.module.AIChartOverview(ctx, "", s, e)
|
||||
}
|
||||
|
||||
func (i *imlMonitorStatisticController) AITopN(ctx *gin.Context, start string, end string, limit string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
l, err := strconv.Atoi(limit)
|
||||
if err != nil {
|
||||
if limit == "" {
|
||||
l = 10
|
||||
} else {
|
||||
return nil, nil, fmt.Errorf("parse limit %s error: %w", limit, err)
|
||||
}
|
||||
}
|
||||
return i.module.Top(ctx, "", s, e, l, "ai")
|
||||
}
|
||||
|
||||
func formatTime(start string, end string) (int64, int64, error) {
|
||||
s, err := strconv.ParseInt(start, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("parse start time %s error: %w", start, err)
|
||||
}
|
||||
e, err := strconv.ParseInt(end, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("parse end time %s error: %w", end, err)
|
||||
}
|
||||
return s, e, nil
|
||||
}
|
||||
|
||||
func (i *imlMonitorStatisticController) RestTopN(ctx *gin.Context, start string, end string, limit string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
l, err := strconv.Atoi(limit)
|
||||
if err != nil {
|
||||
if limit == "" {
|
||||
l = 10
|
||||
} else {
|
||||
return nil, nil, fmt.Errorf("parse limit %s error: %w", limit, err)
|
||||
}
|
||||
}
|
||||
return i.module.Top(ctx, "", s, e, l, "rest")
|
||||
}
|
||||
|
||||
func (i *imlMonitorStatisticController) Statistics(ctx *gin.Context, dataType string, input *monitor_dto.StatisticInput) (interface{}, error) {
|
||||
switch dataType {
|
||||
case monitor_dto.DataTypeApi:
|
||||
|
||||
@@ -22,11 +22,6 @@ type IMonitorStatisticController interface {
|
||||
|
||||
InvokeTrendInner(ctx *gin.Context, dataType string, typ string, api string, provider string, subscriber string, input *monitor_dto.CommonInput) (*monitor_dto.MonInvokeCountTrend, string, error)
|
||||
StatisticsInner(ctx *gin.Context, dataType string, typ string, id string, input *monitor_dto.StatisticInput) (interface{}, error)
|
||||
|
||||
ChartRestOverview(ctx *gin.Context, start string, end string) (*monitor_dto.ChartRestOverview, error)
|
||||
ChartAIOverview(ctx *gin.Context, start string, end string) (*monitor_dto.ChartAIOverview, error)
|
||||
AITopN(ctx *gin.Context, start string, end string, limit string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error)
|
||||
RestTopN(ctx *gin.Context, start string, end string, limit string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error)
|
||||
}
|
||||
|
||||
type IMonitorConfigController interface {
|
||||
|
||||
+20
-211
@@ -5,13 +5,9 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/monitor"
|
||||
monitor_dto "github.com/APIParkLab/APIPark/module/monitor/dto"
|
||||
|
||||
ai_provider_local "github.com/APIParkLab/APIPark/ai-provider/local"
|
||||
|
||||
subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto"
|
||||
@@ -59,6 +55,10 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
//var (
|
||||
// ollamaConfig = "{\n \"mirostat\": 0,\n \"mirostat_eta\": 0.1,\n \"mirostat_tau\": 5.0,\n \"num_ctx\": 4096,\n \"repeat_last_n\":64,\n \"repeat_penalty\": 1.1,\n \"temperature\": 0.7,\n \"seed\": 42,\n \"num_predict\": 42,\n \"top_k\": 40,\n \"top_p\": 0.9,\n \"min_p\": 0.5\n}\n"
|
||||
//)
|
||||
|
||||
var (
|
||||
_ IServiceController = (*imlServiceController)(nil)
|
||||
|
||||
@@ -66,210 +66,20 @@ var (
|
||||
)
|
||||
|
||||
type imlServiceController struct {
|
||||
module service.IServiceModule `autowired:""`
|
||||
docModule service.IServiceDocModule `autowired:""`
|
||||
subscribeModule subscribe.ISubscribeModule `autowired:""`
|
||||
aiAPIModule ai_api.IAPIModule `autowired:""`
|
||||
routerModule router.IRouterModule `autowired:""`
|
||||
apiDocModule api_doc.IAPIDocModule `autowired:""`
|
||||
providerModule ai.IProviderModule `autowired:""`
|
||||
aiLocalModel ai_local.ILocalModelModule `autowired:""`
|
||||
appModule service.IAppModule `autowired:""`
|
||||
upstreamModule upstream.IUpstreamModule `autowired:""`
|
||||
settingModule system.ISettingModule `autowired:""`
|
||||
teamModule team.ITeamModule `autowired:""`
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
monitorModule monitor.IMonitorStatisticModule `autowired:""`
|
||||
monitorConfigModule monitor.IMonitorConfigModule `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlServiceController) RestLogInfo(ctx *gin.Context, serviceId string, logId string) (*service_dto.RestLogInfo, error) {
|
||||
return i.module.RestLogInfo(ctx, serviceId, logId)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) AILogInfo(ctx *gin.Context, serviceId string, logId string) (*service_dto.AILogInfo, error) {
|
||||
return i.module.AILogInfo(ctx, serviceId, logId)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) AILogs(ctx *gin.Context, serviceId string, start string, end string, page string, size string) ([]*service_dto.AILogItem, int64, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if serviceId == "" {
|
||||
return nil, 0, fmt.Errorf("service id is empty")
|
||||
}
|
||||
if page == "" {
|
||||
page = "1"
|
||||
}
|
||||
if size == "" {
|
||||
size = "20"
|
||||
}
|
||||
p, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
ps, err := strconv.Atoi(size)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return i.module.AILogs(ctx, serviceId, s, e, p, ps)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) RestLogs(ctx *gin.Context, serviceId string, start string, end string, page string, size string) ([]*service_dto.RestLogItem, int64, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if serviceId == "" {
|
||||
return nil, 0, fmt.Errorf("service id is empty")
|
||||
}
|
||||
if page == "" {
|
||||
page = "1"
|
||||
}
|
||||
if size == "" {
|
||||
size = "20"
|
||||
}
|
||||
p, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
ps, err := strconv.Atoi(size)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return i.module.RestLogs(ctx, serviceId, s, e, p, ps)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) ServiceOverview(ctx *gin.Context, serviceId string) (*service_dto.Overview, error) {
|
||||
o, err := i.module.ServiceOverview(ctx, serviceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg, err := i.monitorConfigModule.GetMonitorConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(cfg.Config) < 1 {
|
||||
return o, nil
|
||||
}
|
||||
statistics, err := i.monitorModule.ProviderStatistics(ctx, &monitor_dto.StatisticInput{
|
||||
Services: []string{serviceId},
|
||||
CommonInput: &monitor_dto.CommonInput{
|
||||
Start: time.Now().Add(-24 * 30 * time.Hour).Unix(),
|
||||
End: time.Now().Unix(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(statistics) < 1 {
|
||||
return o, nil
|
||||
}
|
||||
o.InvokeNum = statistics[0].RequestTotal
|
||||
return o, nil
|
||||
}
|
||||
|
||||
func (i *imlServiceController) AIChartOverview(ctx *gin.Context, serviceId string, start string, end string) (*monitor_dto.ServiceChartAIOverview, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if serviceId == "" {
|
||||
return nil, fmt.Errorf("service is required")
|
||||
}
|
||||
so, err := i.module.ServiceOverview(ctx, serviceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &monitor_dto.ServiceChartAIOverview{
|
||||
EnableMCP: so.EnableMCP,
|
||||
SubscriberNum: so.SubscriberNum,
|
||||
APINum: so.APINum,
|
||||
ServiceKind: so.ServiceKind,
|
||||
}
|
||||
cfg, err := i.monitorConfigModule.GetMonitorConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(cfg.Config) < 1 {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
o, err := i.monitorModule.AIChartOverview(ctx, serviceId, s, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result.AvailableMonitor = true
|
||||
result.ChartAIOverview = o
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (i *imlServiceController) RestChartOverview(ctx *gin.Context, serviceId string, start string, end string) (*monitor_dto.ServiceChartRestOverview, error) {
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if serviceId == "" {
|
||||
return nil, fmt.Errorf("service is required")
|
||||
}
|
||||
so, err := i.module.ServiceOverview(ctx, serviceId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := &monitor_dto.ServiceChartRestOverview{
|
||||
EnableMCP: so.EnableMCP,
|
||||
SubscriberNum: so.SubscriberNum,
|
||||
APINum: so.APINum,
|
||||
ServiceKind: so.ServiceKind,
|
||||
}
|
||||
cfg, err := i.monitorConfigModule.GetMonitorConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(cfg.Config) < 1 {
|
||||
return result, nil
|
||||
}
|
||||
o, err := i.monitorModule.RestChartOverview(ctx, serviceId, s, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result.AvailableMonitor = true
|
||||
result.ChartRestOverview = o
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func formatTime(start string, end string) (int64, int64, error) {
|
||||
s, err := strconv.ParseInt(start, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("parse start time %s error: %w", start, err)
|
||||
}
|
||||
e, err := strconv.ParseInt(end, 10, 64)
|
||||
if err != nil {
|
||||
return 0, 0, fmt.Errorf("parse end time %s error: %w", end, err)
|
||||
}
|
||||
return s, e, nil
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Top10(ctx *gin.Context, serviceId string, start string, end string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error) {
|
||||
if serviceId == "" {
|
||||
return nil, nil, fmt.Errorf("serviceId is required")
|
||||
}
|
||||
info, err := i.module.Get(ctx, serviceId)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
s, e, err := formatTime(start, end)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return i.monitorModule.Top(ctx, serviceId, s, e, 10, info.ServiceKind)
|
||||
module service.IServiceModule `autowired:""`
|
||||
docModule service.IServiceDocModule `autowired:""`
|
||||
subscribeModule subscribe.ISubscribeModule `autowired:""`
|
||||
aiAPIModule ai_api.IAPIModule `autowired:""`
|
||||
routerModule router.IRouterModule `autowired:""`
|
||||
apiDocModule api_doc.IAPIDocModule `autowired:""`
|
||||
providerModule ai.IProviderModule `autowired:""`
|
||||
aiLocalModel ai_local.ILocalModelModule `autowired:""`
|
||||
appModule service.IAppModule `autowired:""`
|
||||
upstreamModule upstream.IUpstreamModule `autowired:""`
|
||||
settingModule system.ISettingModule `autowired:""`
|
||||
teamModule team.ITeamModule `autowired:""`
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlServiceController) QuickCreateAIService(ctx *gin.Context, input *service_dto.QuickCreateAIService) error {
|
||||
@@ -732,9 +542,8 @@ type imlAppController struct {
|
||||
authModule application_authorization.IAuthorizationModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAppController) SearchCanSubscribe(ctx *gin.Context, serviceId string) ([]*service_dto.SubscribeAppItem, error) {
|
||||
items, _, err := i.module.SearchCanSubscribe(ctx, serviceId)
|
||||
return items, err
|
||||
func (i *imlAppController) SearchCanSubscribe(ctx *gin.Context, serviceId string) ([]*service_dto.SimpleAppItem, error) {
|
||||
return i.module.SearchCanSubscribe(ctx, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlAppController) Search(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package service
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
monitor_dto "github.com/APIParkLab/APIPark/module/monitor/dto"
|
||||
|
||||
service_dto "github.com/APIParkLab/APIPark/module/service/dto"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -34,19 +32,6 @@ type IServiceController interface {
|
||||
|
||||
Swagger(ctx *gin.Context)
|
||||
ExportSwagger(ctx *gin.Context)
|
||||
|
||||
Top10(ctx *gin.Context, serviceId string, start string, end string) ([]*monitor_dto.TopN, []*monitor_dto.TopN, error)
|
||||
|
||||
AIChartOverview(ctx *gin.Context, serviceId string, start string, end string) (*monitor_dto.ServiceChartAIOverview, error)
|
||||
RestChartOverview(ctx *gin.Context, serviceId string, start string, end string) (*monitor_dto.ServiceChartRestOverview, error)
|
||||
|
||||
ServiceOverview(ctx *gin.Context, serviceId string) (*service_dto.Overview, error)
|
||||
|
||||
AILogs(ctx *gin.Context, serviceId string, start string, end string, page string, size string) ([]*service_dto.AILogItem, int64, error)
|
||||
|
||||
RestLogs(ctx *gin.Context, serviceId string, start string, end string, page string, size string) ([]*service_dto.RestLogItem, int64, error)
|
||||
RestLogInfo(ctx *gin.Context, serviceId string, logId string) (*service_dto.RestLogInfo, error)
|
||||
AILogInfo(ctx *gin.Context, serviceId string, logId string) (*service_dto.AILogInfo, error)
|
||||
}
|
||||
|
||||
type IAppController interface {
|
||||
@@ -59,7 +44,7 @@ type IAppController interface {
|
||||
// SimpleApps 获取简易项目列表
|
||||
SimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error)
|
||||
MySimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error)
|
||||
SearchCanSubscribe(ctx *gin.Context, serviceId string) ([]*service_dto.SubscribeAppItem, error)
|
||||
SearchCanSubscribe(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error)
|
||||
GetApp(ctx *gin.Context, appId string) (*service_dto.App, error)
|
||||
DeleteApp(ctx *gin.Context, appId string) error
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package system_apikey
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
system_apikey_dto "github.com/APIParkLab/APIPark/module/system-apikey/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IAPIKeyController interface {
|
||||
Create(ctx *gin.Context, input *system_apikey_dto.Create) error
|
||||
Update(ctx *gin.Context, id string, input *system_apikey_dto.Update) error
|
||||
Delete(ctx *gin.Context, id string) error
|
||||
Get(ctx *gin.Context, id string) (*system_apikey_dto.APIKey, error)
|
||||
Search(ctx *gin.Context, keyword string) ([]*system_apikey_dto.Item, error)
|
||||
SimpleList(ctx *gin.Context) ([]*system_apikey_dto.SimpleItem, error)
|
||||
MyAPIKeys(ctx *gin.Context) ([]*system_apikey_dto.SimpleItem, error)
|
||||
MyAPIKeysByService(ctx *gin.Context, serviceId string) ([]*system_apikey_dto.AuthorizationItem, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IAPIKeyController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlAPIKeyController))
|
||||
})
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package system_apikey
|
||||
|
||||
import (
|
||||
system_apikey "github.com/APIParkLab/APIPark/module/system-apikey"
|
||||
system_apikey_dto "github.com/APIParkLab/APIPark/module/system-apikey/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ IAPIKeyController = new(imlAPIKeyController)
|
||||
|
||||
type imlAPIKeyController struct {
|
||||
apikeyModule system_apikey.IAPIKeyModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) MyAPIKeysByService(ctx *gin.Context, serviceId string) ([]*system_apikey_dto.AuthorizationItem, error) {
|
||||
return i.apikeyModule.MyAPIKeysByService(ctx, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) MyAPIKeys(ctx *gin.Context) ([]*system_apikey_dto.SimpleItem, error) {
|
||||
return i.apikeyModule.MyAPIKeys(ctx)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) Create(ctx *gin.Context, input *system_apikey_dto.Create) error {
|
||||
return i.apikeyModule.Create(ctx, input)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) Update(ctx *gin.Context, id string, input *system_apikey_dto.Update) error {
|
||||
return i.apikeyModule.Update(ctx, id, input)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) Delete(ctx *gin.Context, id string) error {
|
||||
return i.apikeyModule.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) Get(ctx *gin.Context, id string) (*system_apikey_dto.APIKey, error) {
|
||||
return i.apikeyModule.Get(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) Search(ctx *gin.Context, keyword string) ([]*system_apikey_dto.Item, error) {
|
||||
return i.apikeyModule.Search(ctx, keyword)
|
||||
}
|
||||
|
||||
func (i *imlAPIKeyController) SimpleList(ctx *gin.Context) ([]*system_apikey_dto.SimpleItem, error) {
|
||||
return i.apikeyModule.SimpleList(ctx)
|
||||
}
|
||||
@@ -47,11 +47,7 @@
|
||||
"swagger-ui-react": "^5.17.14",
|
||||
"tailwindcss": "^3.3.5",
|
||||
"uuid": "^9.0.1",
|
||||
"vite-tsconfig-paths": "^4.3.2",
|
||||
"react-json-view": "^1.21.3",
|
||||
"zod": "^3.23.8",
|
||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||
"echarts-for-react": "^3.0.2"
|
||||
"vite-tsconfig-paths": "^4.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ant-design/cssinjs": "^1.18.2",
|
||||
|
||||
@@ -36,7 +36,7 @@ function BasicLayout({ project = 'core' }: { project: string }) {
|
||||
const { state, accessData, checkPermission, accessInit, dispatch, resetAccess, getGlobalAccessData, menuList } =
|
||||
useGlobalContext()
|
||||
const [pathname, setPathname] = useState(currentUrl)
|
||||
const mainPage = project === 'core' ? '/service/list' : '/portal/list'
|
||||
const mainPage = project === 'core' ? '/service/list' : '/serviceHub/list'
|
||||
const [menuItems, setMenuItems] = useState<MenuProps['items']>()
|
||||
const pluginSlotHub = usePluginSlotHub()
|
||||
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
import { Breadcrumb } from 'antd'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { LeftOutlined } from '@ant-design/icons'
|
||||
|
||||
const TopBreadcrumb: FC<{ handleBackCallback?: () => void }> = ({ handleBackCallback }) => {
|
||||
const TopBreadcrumb: FC = () => {
|
||||
const { breadcrumb } = useBreadcrumb()
|
||||
useEffect(() => {}, [breadcrumb])
|
||||
const handleBack = () => {
|
||||
handleBackCallback?.()
|
||||
}
|
||||
return (
|
||||
<div className="flex text-[18px] leading-[25px] pb-[12px]">
|
||||
<div
|
||||
onClick={handleBack}
|
||||
className="hover:bg-gray-100 items-center mt-[1px] mr-[12px] flex justify-center rounded-lg border cursor-pointer border-gray-300 w-[30px] h-[30px] border border-solid "
|
||||
>
|
||||
<LeftOutlined className="text-xs" />
|
||||
</div>
|
||||
<Breadcrumb items={breadcrumb} className="flex-1" />
|
||||
</div>
|
||||
)
|
||||
return <Breadcrumb items={breadcrumb} />
|
||||
}
|
||||
|
||||
export default TopBreadcrumb
|
||||
|
||||
@@ -4,12 +4,11 @@ import { $t } from '@common/locales'
|
||||
import { Button, Tag } from 'antd'
|
||||
import { FC, ReactNode } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import TopBreadcrumb from './Breadcrumb'
|
||||
|
||||
class InsidePageProps {
|
||||
showBanner?: boolean = true
|
||||
pageTitle: string | React.ReactNode = ''
|
||||
tagList?: Array<{ label: string | ReactNode; className?: string; color?: string }> = []
|
||||
tagList?: Array<{ label: string | ReactNode }> = []
|
||||
children: React.ReactNode
|
||||
showBtn?: boolean = false
|
||||
btnTitle?: string = ''
|
||||
@@ -26,7 +25,6 @@ class InsidePageProps {
|
||||
scrollInsidePage?: boolean = false
|
||||
customPadding?: boolean
|
||||
customBtn?: ReactNode
|
||||
customBanner?: ReactNode
|
||||
}
|
||||
|
||||
const InsidePage: FC<InsidePageProps> = ({
|
||||
@@ -47,8 +45,7 @@ const InsidePage: FC<InsidePageProps> = ({
|
||||
scrollPage = true,
|
||||
scrollInsidePage = false,
|
||||
customPadding = false,
|
||||
customBtn,
|
||||
customBanner
|
||||
customBtn
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
@@ -63,16 +60,18 @@ const InsidePage: FC<InsidePageProps> = ({
|
||||
<div
|
||||
className={`border-[0px] mr-PAGE_INSIDE_X ${showBorder ? 'border-solid border-b-[1px] border-BORDER' : ''} ${headerClassName}`}
|
||||
>
|
||||
{!pageTitle && !description && !backUrl && !customBtn && !customBanner ? (
|
||||
{!pageTitle && !description && !backUrl && !customBtn ? (
|
||||
<></>
|
||||
) : customBanner ? (
|
||||
<div className={customPadding ? '' : 'mb-[15px]'}>
|
||||
{backUrl && <TopBreadcrumb handleBackCallback={() => goBack()} />}
|
||||
{customBanner}
|
||||
</div>
|
||||
) : (
|
||||
<div className={customPadding ? '' : 'mb-[30px]'}>
|
||||
{backUrl && <TopBreadcrumb handleBackCallback={() => goBack()} />}
|
||||
{backUrl && (
|
||||
<div className="text-[18px] leading-[25px] mb-[12px]">
|
||||
<Button type="text" onClick={goBack}>
|
||||
<ArrowLeftOutlined className="max-h-[14px]" />
|
||||
{$t('返回')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between mb-[20px] items-center ">
|
||||
<div className="flex items-center gap-TAG_LEFT">
|
||||
<div className="text-theme text-[26px] ">{pageTitle}</div>
|
||||
@@ -80,7 +79,7 @@ const InsidePage: FC<InsidePageProps> = ({
|
||||
tagList?.length > 0 &&
|
||||
tagList?.map((tag) => {
|
||||
return (
|
||||
<Tag key={tag.label as string} bordered={false} color={tag.color} className={tag.className}>
|
||||
<Tag key={tag.label as string} bordered={false}>
|
||||
{tag.label}
|
||||
</Tag>
|
||||
)
|
||||
|
||||
@@ -58,7 +58,7 @@ interface PageListProps<T> extends ProTableProps<T, unknown>, RefAttributes<Acti
|
||||
delayLoading?: boolean
|
||||
noScroll?: boolean
|
||||
/* 前端分页的表格,需要传入该字段以支持后端搜索 */
|
||||
manualReloadTable?: () => void
|
||||
manualReloadTable?: () => void,
|
||||
customEmptyRender?: () => React.ReactNode
|
||||
}
|
||||
|
||||
@@ -109,7 +109,6 @@ const PageList = <T extends Record<string, unknown>>(
|
||||
const [allowTableClick, setAllowTableClick] = useState<boolean>(false)
|
||||
const { accessData, checkPermission, accessInit, state } = useGlobalContext()
|
||||
const [minTableWidth, setMinTableWidth] = useState<number>(0)
|
||||
const [enableVirtual, setEnableVirtual] = useState(false)
|
||||
|
||||
useImperativeHandle(ref, () => actionRef.current!)
|
||||
|
||||
@@ -302,7 +301,7 @@ const PageList = <T extends Record<string, unknown>>(
|
||||
<ProTable<T>
|
||||
actionRef={actionRef}
|
||||
columns={newColumns}
|
||||
virtual={enableVirtual}
|
||||
virtual
|
||||
scroll={noScroll ? undefined : { x: tableWidth, y: tableHeight }}
|
||||
size="middle"
|
||||
rowSelection={rowSelection}
|
||||
@@ -329,10 +328,6 @@ const PageList = <T extends Record<string, unknown>>(
|
||||
}
|
||||
: false
|
||||
}}
|
||||
postData={(data: any) => {
|
||||
setEnableVirtual(!!data?.length)
|
||||
return data
|
||||
}}
|
||||
showSorterTooltip={false}
|
||||
columnsState={{ persistenceType: 'localStorage', persistenceKey: id }}
|
||||
pagination={
|
||||
|
||||
@@ -27,7 +27,6 @@ type TimeRangeSelectorProps = {
|
||||
bindRef?: any
|
||||
hideBtns?: TimeRangeButton[]
|
||||
defaultTimeButton?: TimeRangeButton
|
||||
customClassNames?: string
|
||||
}
|
||||
const TimeRangeSelector = (props: TimeRangeSelectorProps) => {
|
||||
const {
|
||||
@@ -39,8 +38,7 @@ const TimeRangeSelector = (props: TimeRangeSelectorProps) => {
|
||||
labelSize = 'default',
|
||||
bindRef,
|
||||
hideBtns = [],
|
||||
defaultTimeButton = 'hour',
|
||||
customClassNames = 'pt-btnybase'
|
||||
defaultTimeButton = 'hour'
|
||||
} = props
|
||||
const [timeButton, setTimeButton] = useState(initialTimeButton || '')
|
||||
const [datePickerValue, setDatePickerValue] = useState<RangeValue>(initialDatePickerValue || [null, null])
|
||||
@@ -112,12 +110,8 @@ const TimeRangeSelector = (props: TimeRangeSelectorProps) => {
|
||||
return current && current.valueOf() > dayjs().startOf('day').valueOf()
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setTimeButton(initialTimeButton || '')
|
||||
}, [initialTimeButton])
|
||||
|
||||
return (
|
||||
<div className={`flex flex-nowrap items-center ${customClassNames} mr-btnybase`}>
|
||||
<div className="flex flex-nowrap items-center pt-btnybase mr-btnybase">
|
||||
{!hideTitle && <label className={`whitespace-nowrap `}>{$t('时间')}:</label>}
|
||||
<Radio.Group className="whitespace-nowrap" value={timeButton} onChange={handleRadioChange} buttonStyle="solid">
|
||||
{hideBtns?.length && hideBtns.includes('hour') ? null : (
|
||||
|
||||
@@ -55,8 +55,6 @@ export const TranslateWord = () => {
|
||||
{$t('打开 OpenAPI YAML 编辑器')}
|
||||
{$t('无需审核:允许任何消费者调用该服务')}
|
||||
{$t('人工审核:仅允许通过人工审核的消费者调用该服务')}
|
||||
{$t('开启:AI Agent 等产品能够通过 MCP 方式调用服务')}
|
||||
{$t('总览')}
|
||||
{$t('永久')}
|
||||
{$t('否')}
|
||||
{$t('是')}
|
||||
@@ -187,9 +185,6 @@ export const TranslateWord = () => {
|
||||
{$t('调用地址')}
|
||||
{$t('消费者 IP')}
|
||||
{$t('鉴权名称')}
|
||||
{$t('日志输出')}
|
||||
{$t('响应时间')}
|
||||
{$t('时间戳')}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,293 +0,0 @@
|
||||
import { Avatar, Button, Card, Tag, Tooltip, App } from 'antd'
|
||||
import { Icon } from '@iconify/react/dist/iconify.js'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { ApiOutlined } from '@ant-design/icons'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { SERVICE_KIND_OPTIONS } from '@core/const/system/const'
|
||||
import { IconButton } from '@common/components/postcat/api/IconButton'
|
||||
import useCopyToClipboard from '@common/hooks/copy'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
|
||||
export type ServiceBasicInfoType = {
|
||||
id?: string
|
||||
logo?: string
|
||||
name: string
|
||||
description: string
|
||||
appNum: number
|
||||
apiNum: number
|
||||
serviceName: string
|
||||
serviceDesc: string
|
||||
invokeCount: number
|
||||
catalogue: {
|
||||
name: string
|
||||
}
|
||||
serviceKind: string
|
||||
service_kind: string
|
||||
enableMcp: boolean
|
||||
enable_mcp: boolean
|
||||
isReleased?: boolean
|
||||
}
|
||||
|
||||
type ServiceInfoCardProps = {
|
||||
actionSlot?: React.ReactNode
|
||||
customClassName?: string
|
||||
serviceId?: string
|
||||
serviceBasicInfo?: ServiceBasicInfoType
|
||||
teamId?: string
|
||||
}
|
||||
const ServiceInfoCard = ({
|
||||
actionSlot,
|
||||
customClassName,
|
||||
serviceId,
|
||||
serviceBasicInfo,
|
||||
teamId
|
||||
}: ServiceInfoCardProps) => {
|
||||
/** 服务指标 */
|
||||
const [serviceMetrics, setServiceMetrics] = useState<{ title: string; icon: React.ReactNode; value: string }[]>([])
|
||||
/** 服务标签 */
|
||||
const [serviceTags, setServiceTags] = useState<
|
||||
{ color: string; textColor: string; title: string; content: React.ReactNode }[]
|
||||
>([])
|
||||
/** 剪切板 */
|
||||
const { copyToClipboard } = useCopyToClipboard()
|
||||
/** 弹窗组件 */
|
||||
const { message } = App.useApp()
|
||||
/** 获取服务信息 */
|
||||
const { fetchData } = useFetch()
|
||||
/** 服务信息 */
|
||||
const [serviceOverview, setServiceOverview] = useState<ServiceBasicInfoType>()
|
||||
|
||||
/**
|
||||
* 复制
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
const handleCopy = async (value: string): Promise<void> => {
|
||||
if (value) {
|
||||
copyToClipboard(value)
|
||||
message.success($t(RESPONSE_TIPS.copySuccess))
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取服务信息 */
|
||||
const getServiceOverview = () => {
|
||||
fetchData<BasicResponse<{ overview: ServiceBasicInfoType }>>('service/overview/basic', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId },
|
||||
eoTransformKeys: [
|
||||
'api_num',
|
||||
'enable_mcp',
|
||||
'service_kind',
|
||||
'subscriber_num',
|
||||
'invoke_num',
|
||||
'avaliable_monitor',
|
||||
'is_released'
|
||||
]
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
const serviceOverview = {
|
||||
...data.overview,
|
||||
appNum: data.overview.subscriberNum,
|
||||
invokeCount: data.overview.invokeNum,
|
||||
serviceName: data.overview.name,
|
||||
serviceDesc: data.overview.description
|
||||
}
|
||||
setServiceOverview(serviceOverview)
|
||||
setServiceMetricsList(serviceOverview)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开服务详情页面
|
||||
*/
|
||||
const openInPortal = () => {
|
||||
window.open(`/portal/detail/${serviceOverview?.id}`, '_blank')
|
||||
}
|
||||
|
||||
// 格式化调用次数,添加K和M单位
|
||||
const formatInvokeCount = (count: number | null | undefined): string => {
|
||||
if (count === null || count === undefined) return '-'
|
||||
if (count >= 1000000) {
|
||||
const value = Math.floor(count / 100000) / 10
|
||||
return `${value}M`
|
||||
}
|
||||
if (count >= 1000) {
|
||||
const value = Math.floor(count / 100) / 10
|
||||
return `${value}K`
|
||||
}
|
||||
return count.toString()
|
||||
}
|
||||
|
||||
const setServiceMetricsList = (serviceOverview: ServiceBasicInfoType) => {
|
||||
// 设置服务指标数据
|
||||
setServiceMetrics([
|
||||
{
|
||||
title: 'API 数量',
|
||||
icon: <ApiOutlined className="mr-[1px] text-[14px] h-[14px] w-[14px]" />,
|
||||
value: serviceOverview.apiNum?.toString() || '0'
|
||||
},
|
||||
{
|
||||
title: '接入消费者数量',
|
||||
icon: <Icon icon="tabler:api-app" width="14" height="14" />,
|
||||
value: serviceOverview.appNum?.toString() || '0'
|
||||
},
|
||||
{
|
||||
title: '30天内调用次数',
|
||||
icon: <Icon icon="iconoir:graph-up" width="14" height="14" />,
|
||||
value: formatInvokeCount(serviceOverview.invokeCount ?? 0)
|
||||
}
|
||||
])
|
||||
const serviceKind = serviceOverview?.serviceKind || serviceOverview?.service_kind
|
||||
// 设置服务标签数据
|
||||
const tags = [
|
||||
{
|
||||
color: '#7371fc1b',
|
||||
textColor: 'text-theme',
|
||||
title: serviceOverview?.catalogue?.name || '-',
|
||||
content: serviceOverview?.catalogue?.name || '-'
|
||||
},
|
||||
{
|
||||
color: `#${serviceKind === 'ai' ? 'EADEFF' : 'DEFFE7'}`,
|
||||
textColor: 'text-[#000]',
|
||||
title: serviceKind || '-',
|
||||
content: SERVICE_KIND_OPTIONS.find((x) => x.value === serviceKind)?.label || '-'
|
||||
}
|
||||
]
|
||||
|
||||
// 如果启用了MCP,添加MCP标签
|
||||
if (serviceOverview?.enableMcp) {
|
||||
tags.push({
|
||||
color: '#FFF0C1',
|
||||
textColor: 'text-[#000]',
|
||||
title: 'MCP',
|
||||
content: 'MCP'
|
||||
})
|
||||
}
|
||||
|
||||
setServiceTags(tags)
|
||||
}
|
||||
useEffect(() => {
|
||||
if (!serviceId && serviceBasicInfo) {
|
||||
setServiceMetricsList(serviceBasicInfo)
|
||||
setServiceOverview(serviceBasicInfo)
|
||||
return
|
||||
}
|
||||
getServiceOverview()
|
||||
}, [serviceId, serviceBasicInfo])
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
style={{
|
||||
borderRadius: '10px',
|
||||
background: 'linear-gradient(35deg, rgb(246, 246, 260) 0%, rgb(255, 255, 255) 40%)'
|
||||
}}
|
||||
className={`w-full ${customClassName}`}
|
||||
classNames={{
|
||||
body: `p-[15px] ${actionSlot ? 'h-[180px]' : 'max-h-[130px]'}`
|
||||
}}
|
||||
>
|
||||
{serviceOverview && (
|
||||
<>
|
||||
<div className="service-info">
|
||||
<div className="flex items-center">
|
||||
<div>
|
||||
<Avatar
|
||||
shape="square"
|
||||
size={50}
|
||||
className={`rounded-[12px] border-none rounded-[12px] ${serviceOverview.logo ? 'bg-[linear-gradient(135deg,white,#f0f0f0)]' : 'bg-theme'}`}
|
||||
src={
|
||||
serviceOverview.logo ? (
|
||||
<img
|
||||
src={serviceOverview.logo}
|
||||
alt="Logo"
|
||||
style={{ maxWidth: '200px', width: '45px', height: '45px', objectFit: 'unset' }}
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
icon={serviceOverview.logo ? '' : <Icon icon="tabler:api-app" />}
|
||||
>
|
||||
{' '}
|
||||
</Avatar>
|
||||
</div>
|
||||
<div className="pl-[20px] w-[calc(100%-50px)] overflow-hidden">
|
||||
<p
|
||||
className={`text-[14px] h-[20px] leading-[20px] truncate font-bold w-full flex items-center gap-[4px]`}
|
||||
>
|
||||
{serviceOverview.serviceName}
|
||||
</p>
|
||||
<div className="mt-[5px] h-[20px] flex items-center font-normal">
|
||||
{serviceTags.map((tag, index) => (
|
||||
<Tag
|
||||
key={index}
|
||||
color={tag.color}
|
||||
className={`${tag.textColor} font-normal border-0 mr-[12px] max-w-[150px] truncate`}
|
||||
bordered={false}
|
||||
title={tag.title}
|
||||
>
|
||||
{tag.content}
|
||||
</Tag>
|
||||
))}
|
||||
{serviceMetrics.map((item, index) => (
|
||||
<Tooltip key={index} title={$t(item.title)}>
|
||||
<span className="mr-[12px] flex items-center">
|
||||
<span className="h-[14px] mr-[4px] flex items-center">{item.icon}</span>
|
||||
<span className="font-normal text-[14px]">{item.value}</span>
|
||||
</span>
|
||||
</Tooltip>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{serviceOverview.id && (
|
||||
<>
|
||||
<div className="absolute top-[14px] right-[20px]">
|
||||
<span className="bg-white relative py-[2px] pl-[10px] pr-[30px] inline-block border-solid border-[1px] border-BORDER rounded-lg">
|
||||
{$t('服务 ID')}:{serviceOverview.id || '-'}
|
||||
<IconButton
|
||||
name="copy"
|
||||
onClick={() => handleCopy(serviceOverview.id || '')}
|
||||
sx={{
|
||||
position: 'absolute',
|
||||
top: '0px',
|
||||
right: '5px',
|
||||
color: '#999',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
</span>
|
||||
<Tooltip title={serviceOverview.isReleased ? '' : $t('服务尚未发布')}>
|
||||
<Button
|
||||
disabled={!serviceOverview.isReleased}
|
||||
className="ml-[10px] !max-h-[28px] rounded-[13px]"
|
||||
type="primary"
|
||||
onClick={() => openInPortal()}
|
||||
>
|
||||
{$t('跳转至详情页')}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<span className="line-clamp-2 mt-[15px] text-[12px] text-[#666]" title={serviceOverview.serviceDesc}>
|
||||
{serviceOverview.serviceDesc || $t('暂无服务描述')}
|
||||
</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="absolute bottom-[15px]">{actionSlot}</div>
|
||||
</Card>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServiceInfoCard
|
||||
@@ -234,16 +234,12 @@ export default function ApiEdit({
|
||||
<>
|
||||
<Space.Compact className="w-full mb-btnybase">
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-[15%] min-w-[100px]"
|
||||
value={apiInfo?.protocol || 'HTTP'}
|
||||
disabled={true}
|
||||
options={protocolOptionList}
|
||||
/>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-[15%] min-w-[100px]"
|
||||
value={apiInfo?.method}
|
||||
disabled={true}
|
||||
|
||||
@@ -1,431 +0,0 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['exports', 'echarts'], factory);
|
||||
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
|
||||
// CommonJS
|
||||
factory(exports, require('echarts'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory({}, root.echarts);
|
||||
}
|
||||
}(this, function (exports, echarts) {
|
||||
var log = function (msg) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console && console.error && console.error(msg);
|
||||
}
|
||||
};
|
||||
if (!echarts) {
|
||||
log('ECharts is not Loaded');
|
||||
return;
|
||||
}
|
||||
echarts.registerTheme('apipark chart palette', {
|
||||
"color": [
|
||||
"#4429e6",
|
||||
"#fd6280",
|
||||
"#28dbe2",
|
||||
"#ffc404",
|
||||
"#b92325",
|
||||
"#1b9f17",
|
||||
"#fe8705",
|
||||
"#97b552",
|
||||
"#95706d",
|
||||
"#dc69aa",
|
||||
"#07a2a4",
|
||||
"#9a7fd1",
|
||||
"#588dd5",
|
||||
"#f5994e",
|
||||
"#333333"
|
||||
],
|
||||
"backgroundColor": "rgba(0,0,0,0)",
|
||||
"textStyle": {},
|
||||
"title": {
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
},
|
||||
"subtextStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"line": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": "2"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true
|
||||
},
|
||||
"radar": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": "2"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true
|
||||
},
|
||||
"bar": {
|
||||
"itemStyle": {
|
||||
"barBorderWidth": "2",
|
||||
"barBorderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"pie": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"scatter": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"boxplot": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"parallel": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"sankey": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"funnel": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"gauge": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"candlestick": {
|
||||
"itemStyle": {
|
||||
"color": "#d87a80",
|
||||
"color0": "#2ec7c9",
|
||||
"borderColor": "#d87a80",
|
||||
"borderColor0": "#2ec7c9",
|
||||
"borderWidth": 1
|
||||
}
|
||||
},
|
||||
"graph": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": 1,
|
||||
"color": "#aaaaaa"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true,
|
||||
"color": [
|
||||
"#4429e6",
|
||||
"#fd6280",
|
||||
"#28dbe2",
|
||||
"#ffc404",
|
||||
"#b92325",
|
||||
"#1b9f17",
|
||||
"#fe8705",
|
||||
"#97b552",
|
||||
"#95706d",
|
||||
"#dc69aa",
|
||||
"#07a2a4",
|
||||
"#9a7fd1",
|
||||
"#588dd5",
|
||||
"#f5994e",
|
||||
"#333333"
|
||||
],
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"itemStyle": {
|
||||
"areaColor": "#dddddd",
|
||||
"borderColor": "#eeeeee",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#d87a80"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"areaColor": "rgba(254,153,78,1)",
|
||||
"borderColor": "#444",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"label": {
|
||||
"color": "rgb(100,0,0)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"geo": {
|
||||
"itemStyle": {
|
||||
"areaColor": "#dddddd",
|
||||
"borderColor": "#eeeeee",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#d87a80"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"areaColor": "rgba(254,153,78,1)",
|
||||
"borderColor": "#444",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"label": {
|
||||
"color": "rgb(100,0,0)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"categoryAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.3)",
|
||||
"rgba(200,200,200,0.3)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"valueAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": true,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"rgba(0,0,0,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"logAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": true,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"rgba(0,0,0,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.3)",
|
||||
"rgba(200,200,200,0.3)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"toolbox": {
|
||||
"iconStyle": {
|
||||
"borderColor": "#000000"
|
||||
},
|
||||
"emphasis": {
|
||||
"iconStyle": {
|
||||
"borderColor": "#000000"
|
||||
}
|
||||
}
|
||||
},
|
||||
"legend": {
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
}
|
||||
},
|
||||
"tooltip": {
|
||||
"axisPointer": {
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.3)",
|
||||
"width": "1"
|
||||
},
|
||||
"crossStyle": {
|
||||
"color": "rgba(0,0,0,0.3)",
|
||||
"width": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeline": {
|
||||
"lineStyle": {
|
||||
"color": "#008acd",
|
||||
"width": 1
|
||||
},
|
||||
"itemStyle": {
|
||||
"color": "#008acd",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"controlStyle": {
|
||||
"color": "#008acd",
|
||||
"borderColor": "#008acd",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"checkpointStyle": {
|
||||
"color": "#2ec7c9",
|
||||
"borderColor": "#2ec7c9"
|
||||
},
|
||||
"label": {
|
||||
"color": "#008acd"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"color": "#a9334c"
|
||||
},
|
||||
"controlStyle": {
|
||||
"color": "#008acd",
|
||||
"borderColor": "#008acd",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#008acd"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visualMap": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"#4429e6"
|
||||
]
|
||||
},
|
||||
"dataZoom": {
|
||||
"backgroundColor": "rgba(47,69,84,0)",
|
||||
"dataBackgroundColor": "#efefff",
|
||||
"fillerColor": "rgba(182,162,222,0.2)",
|
||||
"handleColor": "#008acd",
|
||||
"handleSize": "100%",
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
}
|
||||
},
|
||||
"markPoint": {
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
},
|
||||
"emphasis": {
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
@@ -1,409 +0,0 @@
|
||||
{
|
||||
"color": [
|
||||
"#4429e6",
|
||||
"#fd6280",
|
||||
"#28dbe2",
|
||||
"#ffc404",
|
||||
"#b92325",
|
||||
"#1b9f17",
|
||||
"#fe8705",
|
||||
"#97b552",
|
||||
"#95706d",
|
||||
"#dc69aa",
|
||||
"#07a2a4",
|
||||
"#9a7fd1",
|
||||
"#588dd5",
|
||||
"#f5994e",
|
||||
"#333333"
|
||||
],
|
||||
"backgroundColor": "rgba(0,0,0,0)",
|
||||
"textStyle": {},
|
||||
"title": {
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
},
|
||||
"subtextStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"line": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": "2"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true
|
||||
},
|
||||
"radar": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": "2"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true
|
||||
},
|
||||
"bar": {
|
||||
"itemStyle": {
|
||||
"barBorderWidth": "2",
|
||||
"barBorderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"pie": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"scatter": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"boxplot": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"parallel": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"sankey": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"funnel": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"gauge": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
}
|
||||
},
|
||||
"candlestick": {
|
||||
"itemStyle": {
|
||||
"color": "#d87a80",
|
||||
"color0": "#2ec7c9",
|
||||
"borderColor": "#d87a80",
|
||||
"borderColor0": "#2ec7c9",
|
||||
"borderWidth": 1
|
||||
}
|
||||
},
|
||||
"graph": {
|
||||
"itemStyle": {
|
||||
"borderWidth": "2",
|
||||
"borderColor": "rgba(255,255,255,0.3)"
|
||||
},
|
||||
"lineStyle": {
|
||||
"width": 1,
|
||||
"color": "#aaaaaa"
|
||||
},
|
||||
"symbolSize": "5",
|
||||
"symbol": "circle",
|
||||
"smooth": true,
|
||||
"color": [
|
||||
"#4429e6",
|
||||
"#fd6280",
|
||||
"#28dbe2",
|
||||
"#ffc404",
|
||||
"#b92325",
|
||||
"#1b9f17",
|
||||
"#fe8705",
|
||||
"#97b552",
|
||||
"#95706d",
|
||||
"#dc69aa",
|
||||
"#07a2a4",
|
||||
"#9a7fd1",
|
||||
"#588dd5",
|
||||
"#f5994e",
|
||||
"#333333"
|
||||
],
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"itemStyle": {
|
||||
"areaColor": "#dddddd",
|
||||
"borderColor": "#eeeeee",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#d87a80"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"areaColor": "rgba(254,153,78,1)",
|
||||
"borderColor": "#444",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"label": {
|
||||
"color": "rgb(100,0,0)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"geo": {
|
||||
"itemStyle": {
|
||||
"areaColor": "#dddddd",
|
||||
"borderColor": "#eeeeee",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#d87a80"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"areaColor": "rgba(254,153,78,1)",
|
||||
"borderColor": "#444",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"label": {
|
||||
"color": "rgb(100,0,0)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"categoryAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.3)",
|
||||
"rgba(200,200,200,0.3)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"valueAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": true,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"rgba(0,0,0,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"logAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": true,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"rgba(0,0,0,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.1)"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"color": "#333"
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.3)",
|
||||
"rgba(200,200,200,0.3)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"toolbox": {
|
||||
"iconStyle": {
|
||||
"borderColor": "#000000"
|
||||
},
|
||||
"emphasis": {
|
||||
"iconStyle": {
|
||||
"borderColor": "#000000"
|
||||
}
|
||||
}
|
||||
},
|
||||
"legend": {
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
}
|
||||
},
|
||||
"tooltip": {
|
||||
"axisPointer": {
|
||||
"lineStyle": {
|
||||
"color": "rgba(0,0,0,0.3)",
|
||||
"width": "1"
|
||||
},
|
||||
"crossStyle": {
|
||||
"color": "rgba(0,0,0,0.3)",
|
||||
"width": "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeline": {
|
||||
"lineStyle": {
|
||||
"color": "#008acd",
|
||||
"width": 1
|
||||
},
|
||||
"itemStyle": {
|
||||
"color": "#008acd",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"controlStyle": {
|
||||
"color": "#008acd",
|
||||
"borderColor": "#008acd",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"checkpointStyle": {
|
||||
"color": "#2ec7c9",
|
||||
"borderColor": "#2ec7c9"
|
||||
},
|
||||
"label": {
|
||||
"color": "#008acd"
|
||||
},
|
||||
"emphasis": {
|
||||
"itemStyle": {
|
||||
"color": "#a9334c"
|
||||
},
|
||||
"controlStyle": {
|
||||
"color": "#008acd",
|
||||
"borderColor": "#008acd",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"label": {
|
||||
"color": "#008acd"
|
||||
}
|
||||
}
|
||||
},
|
||||
"visualMap": {
|
||||
"color": [
|
||||
"#ffffff",
|
||||
"#4429e6"
|
||||
]
|
||||
},
|
||||
"dataZoom": {
|
||||
"backgroundColor": "rgba(47,69,84,0)",
|
||||
"dataBackgroundColor": "#efefff",
|
||||
"fillerColor": "rgba(182,162,222,0.2)",
|
||||
"handleColor": "#008acd",
|
||||
"handleSize": "100%",
|
||||
"textStyle": {
|
||||
"color": "#333333"
|
||||
}
|
||||
},
|
||||
"markPoint": {
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
},
|
||||
"emphasis": {
|
||||
"label": {
|
||||
"color": "#fefefe"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// 导入echarts核心模块
|
||||
import * as echarts from 'echarts/core'
|
||||
// 导入主题JSON
|
||||
import themeJson from './apipark-chart-palette.json'
|
||||
|
||||
// 全局注册主题
|
||||
export function registerApiparkTheme() {
|
||||
echarts.registerTheme('apipark', themeJson)
|
||||
}
|
||||
|
||||
// 导出主题名称,方便组件使用
|
||||
export const THEME_NAME = 'apipark'
|
||||
@@ -1,11 +0,0 @@
|
||||
// 导入主题配置
|
||||
import themeJson from './apipark-chart-palette.json'
|
||||
|
||||
// 导出主题配置
|
||||
export const apiparkTheme = themeJson
|
||||
|
||||
// 导出颜色列表,方便单独使用
|
||||
export const chartColors = themeJson.color
|
||||
|
||||
// 导出默认颜色
|
||||
export const defaultColor = chartColors[0]
|
||||
@@ -254,21 +254,6 @@ export const PERMISSION_DEFINITION = [
|
||||
anyOf: [{ backend: ['system.settings.ai_balance.manager'] }]
|
||||
}
|
||||
},
|
||||
'system.settings.mcp.manager': {
|
||||
granted: {
|
||||
anyOf: [{ backend: ['system.settings.mcp.manager'] }]
|
||||
}
|
||||
},
|
||||
'system.settings.mcp.view': {
|
||||
granted: {
|
||||
anyOf: [{ backend: ['system.settings.mcp.view'] }]
|
||||
}
|
||||
},
|
||||
'system.settings.apikey.view': {
|
||||
granted: {
|
||||
anyOf: [{ backend: ['system.settings.apikey.view'] }]
|
||||
}
|
||||
},
|
||||
'system.devops.policy.view': {
|
||||
granted: {
|
||||
anyOf: [{ backend: ['system.settings.strategy.view'] }]
|
||||
|
||||
@@ -81,7 +81,6 @@ export type MatchItem = {
|
||||
export type EntityItem = {
|
||||
id: string
|
||||
name: string
|
||||
isSubscribed: boolean
|
||||
}
|
||||
|
||||
export type DynamicMenuItem = {
|
||||
|
||||
@@ -18,21 +18,5 @@ export const useBreadcrumb = () => {
|
||||
export const BreadcrumbProvider = ({ children }: unknown) => {
|
||||
const [breadcrumb, setBreadcrumb] = useState<BreadcrumbItemType[]>([])
|
||||
|
||||
return (
|
||||
<BreadcrumbContext.Provider
|
||||
value={{
|
||||
setBreadcrumb: (newItems) => {
|
||||
newItems.forEach((item) => {
|
||||
item.title = (
|
||||
<span className={`${item.onClick ? 'cursor-pointer hover:text-theme' : ''}`}>{item.title}</span>
|
||||
)
|
||||
})
|
||||
setBreadcrumb(newItems)
|
||||
},
|
||||
breadcrumb
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</BreadcrumbContext.Provider>
|
||||
)
|
||||
return <BreadcrumbContext.Provider value={{ setBreadcrumb, breadcrumb }}>{children}</BreadcrumbContext.Provider>
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ const mockData = [
|
||||
},
|
||||
{
|
||||
name: 'API 市场',
|
||||
key: 'portal',
|
||||
path: '/portal',
|
||||
key: 'serviceHub',
|
||||
path: '/serviceHub',
|
||||
icon: 'ic:baseline-hub',
|
||||
access: 'system.api_portal.api_portal.view'
|
||||
},
|
||||
@@ -99,31 +99,10 @@ const mockData = [
|
||||
icon: 'ic:baseline-bar-chart',
|
||||
children: [
|
||||
{
|
||||
name: '总览',
|
||||
key: 'analyticsTotal',
|
||||
path: '/analytics/total',
|
||||
icon: 'material-symbols:bar-chart',
|
||||
access: 'system.analysis.run_view.view'
|
||||
},
|
||||
{
|
||||
name: '服务',
|
||||
key: 'analyticsService',
|
||||
path: '/analytics/service/list',
|
||||
icon: 'ic:baseline-blinds-closed',
|
||||
access: 'system.analysis.run_view.view'
|
||||
},
|
||||
{
|
||||
name: '消费者',
|
||||
key: 'analyticsConsumer',
|
||||
path: '/analytics/consumer/list',
|
||||
icon: 'ic:baseline-apps',
|
||||
access: 'system.analysis.run_view.view'
|
||||
},
|
||||
{
|
||||
name: 'API',
|
||||
key: 'analyticsApi',
|
||||
path: '/analytics/api/list',
|
||||
icon: 'gravity-ui:plug-connection',
|
||||
name: '运行视图',
|
||||
key: 'analytics',
|
||||
path: '/analytics',
|
||||
icon: 'ic:baseline-bar-chart',
|
||||
access: 'system.analysis.run_view.view'
|
||||
}
|
||||
],
|
||||
@@ -217,20 +196,6 @@ const mockData = [
|
||||
key: 'maintenanceCenter',
|
||||
path: '/datasourcing',
|
||||
children: [
|
||||
{
|
||||
name: 'MCP 服务',
|
||||
key: 'mcpService',
|
||||
path: '/mcpService',
|
||||
icon: 'ph:network-x',
|
||||
access: 'system.settings.mcp.view'
|
||||
},
|
||||
{
|
||||
name: 'API Key',
|
||||
key: 'mcpKey',
|
||||
path: '/mcpKey',
|
||||
icon: 'material-symbols:key',
|
||||
access: 'system.settings.apikey.view'
|
||||
},
|
||||
{
|
||||
name: '数据源',
|
||||
key: 'datasourcing',
|
||||
@@ -253,7 +218,7 @@ const mockData = [
|
||||
access: 'system.settings.ssl_certificate.view'
|
||||
},
|
||||
{
|
||||
name: '日志输出',
|
||||
name: '日志',
|
||||
key: 'logsettings',
|
||||
path: '/logsettings',
|
||||
icon: 'ic:baseline-sticky-note-2',
|
||||
|
||||
@@ -112,10 +112,10 @@ const mockData = {
|
||||
},
|
||||
{
|
||||
driver: 'apipark.builtIn.component',
|
||||
name: 'portal',
|
||||
name: 'serviceHub',
|
||||
router: [
|
||||
{
|
||||
path: 'portal',
|
||||
path: 'serviceHub',
|
||||
type: 'normal'
|
||||
}
|
||||
]
|
||||
@@ -220,26 +220,6 @@ const mockData = {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
driver: 'apipark.builtIn.component',
|
||||
name: 'mcpService',
|
||||
router: [
|
||||
{
|
||||
path: 'mcpService',
|
||||
type: 'normal'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
driver: 'apipark.builtIn.component',
|
||||
name: 'mcpKey',
|
||||
router: [
|
||||
{
|
||||
path: 'mcpKey',
|
||||
type: 'normal'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
driver: 'apipark.builtIn.component',
|
||||
name: 'loadBalancing',
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
"添加(0)": "Ka7aaaeb",
|
||||
"请输入Key": "Kaff78ecf",
|
||||
"请输入Value": "K65d46535",
|
||||
"返回": "Kc14b2ea3",
|
||||
"ID": "K11d3633a",
|
||||
"名称": "Kbff43de3",
|
||||
"Driver": "K16ca79ef",
|
||||
@@ -54,10 +55,6 @@
|
||||
"上游列表": "K54e44357",
|
||||
"备注": "Kb8e8e6f5",
|
||||
"上线情况": "K7e52ffa3",
|
||||
"服务 ID": "K1e84ad04",
|
||||
"服务尚未发布": "Ke1e649cb",
|
||||
"跳转至详情页": "K2e683a7d",
|
||||
"暂无服务描述": "Ka4b45550",
|
||||
"申请原因": "K1ab0ae5b",
|
||||
"审核意见": "K53c00c3c",
|
||||
"暂无(0)权限,请联系管理员分配。": "Kfd50704d",
|
||||
@@ -117,8 +114,6 @@
|
||||
"打开 OpenAPI YAML 编辑器": "Kdac8ce7e",
|
||||
"无需审核:允许任何消费者调用该服务": "K1fc2cc28",
|
||||
"人工审核:仅允许通过人工审核的消费者调用该服务": "K8dabb98e",
|
||||
"开启:AI Agent 等产品能够通过 MCP 方式调用服务": "Ke959f135",
|
||||
"总览": "Kaf9e8011",
|
||||
"永久": "Kbfe02d7f",
|
||||
"否": "K1e9c479e",
|
||||
"是": "Kaddfcb6b",
|
||||
@@ -246,9 +241,6 @@
|
||||
"调用地址": "K2f5fdf5e",
|
||||
"消费者 IP": "K1bc5e0a3",
|
||||
"鉴权名称": "K6f39ea21",
|
||||
"日志输出": "K3c722abd",
|
||||
"响应时间": "K1be06929",
|
||||
"时间戳": "K5e51f5d",
|
||||
"暂无操作权限,请联系管理员分配。": "K23fda291",
|
||||
"微信小程序": "K4618cb0a",
|
||||
"获取文件,需填路径": "Ka854f511",
|
||||
@@ -368,6 +360,7 @@
|
||||
"管理": "K5974bf24",
|
||||
"调用拓扑图": "K3fa5c4c3",
|
||||
"设置": "Kb5c7b82d",
|
||||
"服务 ID": "K1e84ad04",
|
||||
"新增订阅方": "K39ab0358",
|
||||
"手动添加": "K18307d56",
|
||||
"订阅申请": "K705fe9f5",
|
||||
@@ -382,6 +375,7 @@
|
||||
"拦截接口": "Kee4139c2",
|
||||
"开启拦截后,网关会拦截所有该路径的请求。": "K3e38ea",
|
||||
"模型配置": "K8a35059b",
|
||||
"路由": "Kf9dcef3a",
|
||||
"添加路由": "K6134bbe8",
|
||||
"输入 URL 查找路由": "Kf85b83a0",
|
||||
"线上模型": "K84b2cf2d",
|
||||
@@ -420,16 +414,17 @@
|
||||
"启用": "K52c8a730",
|
||||
"Ollama 地址": "K6b99dce8",
|
||||
"输入例如:https://www.apipark.com": "K8d4f5b44",
|
||||
"自定义(空模板)": "K24f6a5b4",
|
||||
"自定义": "K8929cbb1",
|
||||
"模型名称": "K1fd51aaa",
|
||||
"访问配置": "Kd6285399",
|
||||
"模型参数模板": "K7eb03edd",
|
||||
"模型参数": "K49b434e9",
|
||||
"载入预置模板": "Kea608112",
|
||||
"供应商名称": "K16ef56b1",
|
||||
"注意:": "K484de451",
|
||||
"仅支持使用 OpenAI 输入输出格式和认证方法(APIKey)的供应商。如果不满足此条件,创建后自定义供应商将不可用。": "Kbd80dde0",
|
||||
"从 (0) 获取 API KEY": "Kb3e34847",
|
||||
"该模型为官方模型,不可编辑": "Kcb6a1c57",
|
||||
"存在使用当前模型的接口,需要先解绑后才能编辑": "Kf9300eb4",
|
||||
"该模型为官方模型,不可删除": "K8af71816",
|
||||
"存在使用当前模型的接口,需要先解绑后才能删除": "Kb8ad0af5",
|
||||
"模型值": "K73cb9ff1",
|
||||
@@ -455,7 +450,6 @@
|
||||
"Models": "Ke37a353f",
|
||||
"Keys": "K14bcebd2",
|
||||
"添加供应商": "Kd87397b0",
|
||||
"编辑供应商( (0) )": "Kee7de862",
|
||||
"编辑供应商": "K5bcf8c48",
|
||||
"(0) 模型": "Kf7a916be",
|
||||
"待审核": "K35612f29",
|
||||
@@ -463,7 +457,7 @@
|
||||
"发布申请": "K56b4254f",
|
||||
"API 调用地址": "Kea2f9279",
|
||||
"API base URL 一般设置为API 网关的外部网络访问地址,或者是API网关绑定的域名。": "K7fc496a1",
|
||||
"OpenAPI & MCP 调用地址": "Ka7ca8fde",
|
||||
"集成地址": "K508d8bf4",
|
||||
"与外部平台集成时,获取 API 市场中文档信息的域名": "K67f4e9bb",
|
||||
"常规设置": "K8ab0fc95",
|
||||
"API 请求设置": "Kb66fec9d",
|
||||
@@ -475,7 +469,6 @@
|
||||
"分类名称": "Ke595a20a",
|
||||
"父分类 ID": "K9679728f",
|
||||
"子分类名称": "K9b2d08fd",
|
||||
"暂无权限": "Kce2fcdbf",
|
||||
"添加 Rest 服务": "K2c93168c",
|
||||
"导入OpenAPI文档,将现有系统的API发布到APIPark。": "K39a8d392",
|
||||
"添加在线 AI API": "K68932d54",
|
||||
@@ -556,19 +549,8 @@
|
||||
"访客模式": "K192b3e38",
|
||||
"您可通过访客模式查看所有页面和功能,但是无法编辑数据。访客模式仅用于了解产品功能,您可以在正式产品中关闭该功能。": "K91aa4801",
|
||||
"Version (0)-(1)": "K480045ce",
|
||||
"日志输出设置": "K74a5fbc0",
|
||||
"提供详尽的 API 调用日志,帮助企业监控、分析和审计 API 的运行状况。": "K2724314b",
|
||||
"日志配置": "Kadee8e49",
|
||||
"MCP 配置": "K6e9c928f",
|
||||
"Open API 文档": "Kb6d0eb39",
|
||||
"AI 代理集成": "Ke6908f16",
|
||||
"请先订阅该服务": "K71ed51fa",
|
||||
"申请": "K4aa9ed2c",
|
||||
"选择 API Key": "K1bec8cbe",
|
||||
"新增 API Key": "Kb0e0aeda",
|
||||
"API 密钥可用于调用系统级 Open API 和 MCP。": "K9d81999c",
|
||||
"MCP 服务": "Kf106bc62",
|
||||
"MCP Service 充当 AI 模型与 API 之间的桥梁,允许智能助手(如 Claude)动态发现和调用 Gateway 上的 API,无需繁琐的手动配置或自定义集成。": "K7c2bfeff",
|
||||
"提供详尽的 API 调用日志,帮助企业监控、分析和审计 API 的运行状况。": "K2724314b",
|
||||
"部门名称": "K33c76dbc",
|
||||
"父部门 ID": "K84829ca9",
|
||||
"子部门名称": "K4d7fc74b",
|
||||
@@ -625,7 +607,7 @@
|
||||
"数据源": "K8fa58214",
|
||||
"设置监控报表的数据来源,设置完成之后即可获得详细的API调用统计图表。": "Kdbafd6f9",
|
||||
"统计图表": "K1358acf",
|
||||
"请求日志": "Kc8bf447",
|
||||
"数据日志": "K17dc3a62",
|
||||
"地址(IP:端口)": "K62dabdf6",
|
||||
"组织(Organization)": "K2db12335",
|
||||
"添加策略": "K34d0d409",
|
||||
@@ -659,33 +641,10 @@
|
||||
"支持对系统全局进行统一的策略配置,从而简化管理并确保一致性。全局策略的优先级比服务策略略低。": "Kc975cd5a",
|
||||
"资源配置": "K8e7a0f80",
|
||||
"角色": "Kf644225f",
|
||||
"角色配置": "Kc9f2249c",
|
||||
"设置角色的权限范围。": "K95c3fd8b",
|
||||
"系统级别角色": "K138facd3",
|
||||
"添加角色": "K6eac768d",
|
||||
"团队级别角色": "Kb9c2cf02",
|
||||
"API / Tools": "K9d526cac",
|
||||
"消费者": "K7acfcfad",
|
||||
"HTTP 状态": "Kc68ba0f4",
|
||||
"IP": "Kb09b747",
|
||||
"通过系统级别的 API Key 来调用": "K2eacb44f",
|
||||
"日志详情": "K764bca7c",
|
||||
"暂无数据": "Kf8525cf2",
|
||||
"输入 Token": "K33bc1ad1",
|
||||
"输出 Token": "Ke00ff18b",
|
||||
"订阅数量": "Ke04bc00d",
|
||||
"已开启": "K1b97ae0a",
|
||||
"开启 MCP": "K19ec733b",
|
||||
"API 使用排名": "Kbee2340",
|
||||
"消费者使用排名": "Kf6af1f40",
|
||||
"请求次数": "K9d3f2d9d",
|
||||
"网络流量": "Ke2241377",
|
||||
"平均响应时间": "K7c8d5c23",
|
||||
"平均每消费者的请求次数": "K6c267c7b",
|
||||
"平均每消费者的网络流量": "K133d4291",
|
||||
"Token 消耗": "K37c5f1d0",
|
||||
"平均 Token 消耗": "K10a8bee3",
|
||||
"平均每消费者的 Token 消耗": "Kb98264d4",
|
||||
"单位:ms,最小值:1": "K2a16c93b",
|
||||
"API 路由设置": "Ka945cfb1",
|
||||
"API 基础信息": "K2e050340",
|
||||
@@ -703,13 +662,9 @@
|
||||
"停止": "K24540de",
|
||||
"继续等待": "Kd85b3f64",
|
||||
"只允许上传PNG、JPG或SVG格式的图片": "Ka9c08390",
|
||||
"关闭 MCP": "K30595880",
|
||||
"关闭后将无法通过MCP方式调用服务": "Kc081047c",
|
||||
"了解": "Ka73a5801",
|
||||
"服务名称": "K413b9869",
|
||||
"服务类型": "K9919285b",
|
||||
"REST 服务": "K62840d62",
|
||||
"MCP": "K373c8ab3",
|
||||
"默认 AI 供应商": "Kcef64f4d",
|
||||
"创建 API 时会默认选择该供应商,修改默认供应商不会影响现有 API": "K300c89d4",
|
||||
"未配置任何 AI 模型供应商,": "Kcab588a9",
|
||||
@@ -768,6 +723,7 @@
|
||||
"退出全屏": "Kaf70c3b",
|
||||
"(0)调用详情": "Kd22841a4",
|
||||
"消费者调用统计": "K61cca533",
|
||||
"消费者": "K7acfcfad",
|
||||
"请选择消费者": "Kdfff59d4",
|
||||
"调用趋势": "K8c7f2d2e",
|
||||
"(0)-(1)调用趋势": "K657c3452",
|
||||
@@ -808,13 +764,14 @@
|
||||
"配置集群信息": "Ke5ed9810",
|
||||
"监控设置": "K1a132228",
|
||||
"配置监控信息": "K6af08c3c",
|
||||
"加载数据失败,请重试": "K6c2d93b6",
|
||||
"监控总览": "K4a1a14",
|
||||
"服务被调用统计": "K69741ea7",
|
||||
"API 调用统计": "K9c8d9933",
|
||||
"亿": "K145e4941",
|
||||
"万": "Ke6a935d",
|
||||
"搜索分类或标签": "Kd59290a2",
|
||||
"暂无API数据": "K6b75bdbc",
|
||||
"搜索或选择消费者": "Kb684c806",
|
||||
"该消费者已订阅": "K5611e01e",
|
||||
"申请理由": "K4b15d6f5",
|
||||
"支持把当前服务对接主流的 AI Agent平台,实现在 Agent 平台上快速、安全和合规地使用企业开放的 API 能力。": "K2ec0fa56",
|
||||
"可按以下步骤进行对接:": "K35f23b64",
|
||||
@@ -854,7 +811,6 @@
|
||||
"添加授权": "Kd23d1716",
|
||||
"到期时间": "Kfa920c0",
|
||||
"订阅的服务": "Kcce1af60",
|
||||
"返回": "Kc14b2ea3",
|
||||
"审核详情": "Kfefa9b58",
|
||||
"取消订阅": "K3118fdb0",
|
||||
"请确认是否取消订阅?": "Ked811bb1",
|
||||
@@ -867,20 +823,22 @@
|
||||
"创建并管理自己的消费者实体,每个消费者可以订阅多个API服务,确保在调用之前已获得相应权限。你可以为消费者生成 API 密钥等鉴权方式,用于安全地调用 API 服务": "K5c4e2865",
|
||||
"订阅的服务数量:已通过 (0) 个,申请中 (1) 个": "K3c7b175f",
|
||||
"输入名称、ID 查找消费者": "K3a6f905d",
|
||||
"API 门户": "Kc84dbd1a",
|
||||
"服务市场": "K370a3eb2",
|
||||
"服务详情": "Kf7ec36d",
|
||||
"申请服务": "K58ca9485",
|
||||
"介绍": "K59cdbec3",
|
||||
"Base URL": "Kc29dabf2",
|
||||
"申请": "K4aa9ed2c",
|
||||
"服务信息": "K6c060779",
|
||||
"接入消费者": "Kba74f26d",
|
||||
"供应方": "Kb97544cb",
|
||||
"分类": "Kb32f0afe",
|
||||
"版本": "K81634069",
|
||||
"更新时间": "Keefda53d",
|
||||
"介绍": "K59cdbec3",
|
||||
"API": "K3ba29a85",
|
||||
"无标签": "K96a2f1c8",
|
||||
"分类": "Kb32f0afe",
|
||||
"服务市场": "K370a3eb2",
|
||||
"暂无服务描述": "Ka4b45550",
|
||||
"API 数量": "K72b0c0b3",
|
||||
"接入消费者数量": "K70b79760",
|
||||
"30天内调用次数": "K3d52b756",
|
||||
"关联标签": "K96059c69",
|
||||
"更新者": "K8b7c2592",
|
||||
"添加 Open Api": "K32263abd",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"Kb58e0c3f": "Service",
|
||||
"Kc9e489f5": "Team",
|
||||
"K61c89f5f": "API Portal",
|
||||
"K16d71239": "Analytics",
|
||||
"K16d71239": "Analysis",
|
||||
"K714c192d": "Call Statistics",
|
||||
"Kd57dfe97": "Topology",
|
||||
"K3fe97dcc": "System Settings",
|
||||
@@ -186,7 +186,7 @@
|
||||
"K617f34f1": "Updated By",
|
||||
"K6ebca204": "Update Time",
|
||||
"Kabfe9512": "Save",
|
||||
"K51d1eb5d": "API Routes",
|
||||
"K51d1eb5d": "API",
|
||||
"Ka2b6d281": "API Docs",
|
||||
"Kdefa9caa": "Usage Instructions",
|
||||
"K36856e71": "Publish",
|
||||
@@ -210,7 +210,7 @@
|
||||
"K469e475a": "Max Retry Times",
|
||||
"K8a35059b": "Model Settings",
|
||||
"Kf9dcef3a": "API",
|
||||
"K6134bbe8": "Add API Route",
|
||||
"K6134bbe8": "Add API",
|
||||
"Kf85b83a0": "Enter URL to Search",
|
||||
"Kcf9f90b8": "Model Provider",
|
||||
"Kfede1c7c": "Model",
|
||||
@@ -498,7 +498,7 @@
|
||||
"K370a3eb2": "Service Marketplace",
|
||||
"Kf7ec36d": "Service Details",
|
||||
"K58ca9485": "Subscribe",
|
||||
"K59cdbec3": "Readme",
|
||||
"K59cdbec3": "Intro",
|
||||
"K4aa9ed2c": "Subscribe",
|
||||
"K6c060779": "Service Information",
|
||||
"Kb97544cb": "Provider",
|
||||
@@ -898,79 +898,5 @@
|
||||
"Kce2fcdbf": "No Permission",
|
||||
"K24f6a5b4": "Custom (Empty Template)",
|
||||
"Kea608112": "Load Preset Template",
|
||||
"Kee7de862": "Edit Provider( (0) )",
|
||||
"Kb0e0aeda": "New API Key",
|
||||
"K9d81999c": "The API Key can be used to call system-level Open API and MCP.",
|
||||
"Ka7ca8fde": "OpenAPI & MCP Invocation Address",
|
||||
"K6e9c928f": "MCP Config",
|
||||
"Kb6d0eb39": "Open API Docs",
|
||||
"Ke6908f16": "Integration to AI Agent",
|
||||
"Kf106bc62": "MCP Service",
|
||||
"K7c2bfeff": "MCP Service acts as a bridge between AI models and APIs, enabling intelligent assistants (such as Claude) to dynamically discover and invoke APIs on the Gateway without the need for tedious manual configuration or custom integration.",
|
||||
"K30595880": "Disable MCP",
|
||||
"Kc081047c": "After turning it off, you won’t be able to use the service through the MCP.",
|
||||
"K373c8ab3": "MCP",
|
||||
"K3ba29a85": "API",
|
||||
"K3d52b756": "Number of invocations within 30 days",
|
||||
"Ke959f135": "Enable: AI Agent and other products can invoke services through MCP.",
|
||||
"Ka73a5801": "I Understand",
|
||||
"K6cd677b": "Documentation",
|
||||
"Kec68fe24": "Edit API Settings",
|
||||
"Kc9aeee51": "Add API Settings",
|
||||
"Kf06f6737": "Edit Service Policy",
|
||||
"K205971e1": "Add Service Policy",
|
||||
"Kc9f2249c": "Role Configuration",
|
||||
"Kba68dfc1": "Add API Settings",
|
||||
"Kc84dbd1a": "API Portal",
|
||||
"Ke93388fd": "Edit API",
|
||||
"K84aabfd4": "Add API",
|
||||
"K71ed51fa": "Please subscribe to the service first",
|
||||
"K1bec8cbe": "Select API Key",
|
||||
"K5611e01e": "This consumer is already subscribed",
|
||||
"Kaf9e8011": "Overview",
|
||||
"Ke1e649cb": "Service not released",
|
||||
"K2e683a7d": "Open in Portal",
|
||||
"Ke04bc00d": "Subscribers",
|
||||
"K1b97ae0a": "Enabled",
|
||||
"K19ec733b": "Enable MCP",
|
||||
"Kbee2340": "Top API",
|
||||
"Kf6af1f40": "Top Consumer",
|
||||
"K318a7519": "Requests",
|
||||
"K9ef68e3f": "Token",
|
||||
"Kfb14ccb0": "Models",
|
||||
"K10a8bee3": "Avg Token per Second",
|
||||
"K2727b76b": "Avg Requests per Subscriber",
|
||||
"K4c7a6704": "Avg Token per Subscriber",
|
||||
"K53eb7414": "Traffic",
|
||||
"K7c8d5c23": "Avg Response Time",
|
||||
"Kf9eb702": "QRS",
|
||||
"K7f0aa740": "Avg Traffic per Subscriber",
|
||||
"K9d526cac": "API / Tools",
|
||||
"Kc68ba0f4": "HTTP Status",
|
||||
"Kb09b747": "IP",
|
||||
"K2eacb44f": "Request the API using a system-level API Key",
|
||||
"K764bca7c": "Log Detail",
|
||||
"K6c016898": "Avg Token per Second",
|
||||
"K652843b0": "Avg Requests per Subscriber",
|
||||
"Kdbf831a0": "Avg Token per Subscriber",
|
||||
"K8158a6e4": "Avg Traffic per Subscriber",
|
||||
"K6b882d4a": "Avg Token per Subscriber",
|
||||
"K6c2d93b6": "Failed to load data, please try again",
|
||||
"Kf5eeb9c5": "Avg Token per Subscriber",
|
||||
"K1639a17a": "API Routes Docs",
|
||||
"K33bc1ad1": "Input Token",
|
||||
"Ke00ff18b": "Output Token",
|
||||
"K81140e5b": "Total Token",
|
||||
"K3c722abd": "Log Output",
|
||||
"K74a5fbc0": "Log Output Settings",
|
||||
"Kc8bf447": "Request Log",
|
||||
"Kf8525cf2": "No Data",
|
||||
"K1be06929": "Response Time",
|
||||
"K5e51f5d": "Timestamp",
|
||||
"K9d3f2d9d": "Requests",
|
||||
"Ke2241377": "Traffic",
|
||||
"K6c267c7b": "Avg Requests per Subscriber",
|
||||
"K133d4291": "Avg Traffic per Subscriber",
|
||||
"K37c5f1d0": "Token",
|
||||
"Kb98264d4": "Avg Token per Subscriber"
|
||||
"Kee7de862": "Edit Provider( (0) )"
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
"K617f34f1": "更新者",
|
||||
"K6ebca204": "更新日時",
|
||||
"Kabfe9512": "保存",
|
||||
"K51d1eb5d": "APIルート",
|
||||
"K51d1eb5d": "API",
|
||||
"Ka2b6d281": "API ドキュメント",
|
||||
"Kdefa9caa": "説明ドキュメント",
|
||||
"K36856e71": "公開",
|
||||
@@ -213,7 +213,7 @@
|
||||
"K469e475a": "リトライ回数",
|
||||
"K8a35059b": "モデル設定",
|
||||
"Kf9dcef3a": "API",
|
||||
"K6134bbe8": "APIルートを追加する",
|
||||
"K6134bbe8": "API を追加",
|
||||
"Kf85b83a0": "URL を入力して検索",
|
||||
"Kcf9f90b8": "モデルプロバイダー",
|
||||
"Kfede1c7c": "モデル",
|
||||
@@ -920,79 +920,5 @@
|
||||
"Kce2fcdbf": "権限がありません",
|
||||
"K24f6a5b4": "カスタム(空のテンプレート)",
|
||||
"Kea608112": "プリセットテンプレートを読み込む",
|
||||
"Kee7de862": "サプライヤーを編集( (0) )",
|
||||
"Kb0e0aeda": "APIキーを新規作成",
|
||||
"K9d81999c": "APIキーは、システムレベルのOpen APIおよびMCPの呼び出しに使用できます。",
|
||||
"Ka7ca8fde": "OpenAPI & MCP 呼び出しアドレス",
|
||||
"K6e9c928f": "MCP 設定",
|
||||
"Kb6d0eb39": "Open API ドキュメント",
|
||||
"Ke6908f16": "AI プロキシ統合",
|
||||
"Kf106bc62": "MCP サービス",
|
||||
"K7c2bfeff": "MCP サービスは、AI モデルと API の間の橋渡し役を果たし、スマートアシスタント(Claude など)が、面倒な手動設定やカスタム統合なしで、ゲートウェイ上の API を動的に発見し、呼び出すことを可能にします。",
|
||||
"K30595880": "MCP 無効化",
|
||||
"Kc081047c": "無効化すると、MCP を通じてサービスを呼び出すことができなくなります。",
|
||||
"K373c8ab3": "MCP",
|
||||
"K3ba29a85": "API",
|
||||
"K3d52b756": "30日以内の呼び出し回数",
|
||||
"Ke959f135": "有効化:AI Agent などの製品が MCP 経由でサービスを呼び出すことができる",
|
||||
"Ka73a5801": "理解する",
|
||||
"K6cd677b": "説明書",
|
||||
"Kec68fe24": "API設定の編集",
|
||||
"Kc9aeee51": "API設定の追加",
|
||||
"Kf06f6737": "サービスポリシーの編集",
|
||||
"K205971e1": "サービスポリシーの追加",
|
||||
"Kc9f2249c": "役割の設定",
|
||||
"Kba68dfc1": "API設定の追加",
|
||||
"Kc84dbd1a": "APIポータル",
|
||||
"Ke93388fd": "APIの編集",
|
||||
"K84aabfd4": "APIの追加",
|
||||
"K71ed51fa": "このサービスに先にサブスクリプションしてください",
|
||||
"K1bec8cbe": "APIキーを選択してください",
|
||||
"K5611e01e": "この消費者はすでに購読しています",
|
||||
"Kaf9e8011": "概要",
|
||||
"Ke1e649cb": "サービスはまだ公開されていません",
|
||||
"K2e683a7d": "詳細ページへ移動",
|
||||
"Ke04bc00d": "サブスクリプション数",
|
||||
"K1b97ae0a": "有効",
|
||||
"K19ec733b": "MCP を有効にする",
|
||||
"Kbee2340": "API 使用ランキング",
|
||||
"Kf6af1f40": "コンシューマー使用ランキング",
|
||||
"K318a7519": "リクエスト数",
|
||||
"K9ef68e3f": "トークン",
|
||||
"Kfb14ccb0": "モデル使用量",
|
||||
"K10a8bee3": "平均トークン消費量",
|
||||
"K2727b76b": "ユーザーあたり平均リクエスト数",
|
||||
"K4c7a6704": "ユーザーあたり平均トークン消費量",
|
||||
"K53eb7414": "トラフィック",
|
||||
"K7c8d5c23": "平均応答時間",
|
||||
"Kf9eb702": "毎秒リクエスト数",
|
||||
"K7f0aa740": "ユーザーあたり平均トラフィック",
|
||||
"K9d526cac": "API / ツール",
|
||||
"Kc68ba0f4": "HTTP ステータス",
|
||||
"Kb09b747": "IP",
|
||||
"K2eacb44f": "システムレベルの API Key で呼び出し",
|
||||
"K764bca7c": "ログ詳細",
|
||||
"K6c016898": "平均トークン/s 統計",
|
||||
"K652843b0": "平均リクエスト数",
|
||||
"Kdbf831a0": "平均トークン/加入者 統計",
|
||||
"K8158a6e4": "平均トラフィック",
|
||||
"K6b882d4a": "平均トークン/加入者",
|
||||
"K6c2d93b6": "データの読み込みに失敗しました。もう一度お試しください",
|
||||
"Kf5eeb9c5": "平均トークン/加入者 統計",
|
||||
"K1639a17a": "APIルートのドキュメント",
|
||||
"K33bc1ad1": "入力トークン",
|
||||
"Ke00ff18b": "出力トークン",
|
||||
"K81140e5b": "合計トークン",
|
||||
"K3c722abd": "ログ出力",
|
||||
"K74a5fbc0": "ログ出力設定",
|
||||
"Kc8bf447": "リクエストログ",
|
||||
"Kf8525cf2": "データがありません",
|
||||
"K1be06929": "応答時間",
|
||||
"K5e51f5d": "タイムスタンプ",
|
||||
"K9d3f2d9d": "リクエスト数",
|
||||
"Ke2241377": "ネットワークトラフィック",
|
||||
"K6c267c7b": "消費者あたりの平均リクエスト数",
|
||||
"K133d4291": "消費者あたりの平均ネットワークトラフィック",
|
||||
"K37c5f1d0": "トークン消費量",
|
||||
"Kb98264d4": "消費者あたりの平均トークン消費量"
|
||||
"Kee7de862": "サプライヤーを編集( (0) )"
|
||||
}
|
||||
|
||||
@@ -1 +1,70 @@
|
||||
{}
|
||||
{
|
||||
"K630c9e6d": "APIPark",
|
||||
"Ka3e9f580": "发布名称",
|
||||
"Kb2480682": "策略列表",
|
||||
"K76036e25": "HTTP 请求头",
|
||||
"K44607e3f": "全等匹配",
|
||||
"Kc287500a": "前缀匹配",
|
||||
"Kfc0b1147": "后缀匹配",
|
||||
"Ka4a92043": "子串匹配",
|
||||
"K30b2e44f": "非等匹配",
|
||||
"Kb1587991": "空值匹配",
|
||||
"K1e97dbd8": "存在匹配",
|
||||
"Kc8ee3e62": "不存在匹配",
|
||||
"K87c5a801": "区分大小写的正则匹配",
|
||||
"K95f062f1": "不区分大小写的正则匹配",
|
||||
"Kfbd230a5": "任意匹配",
|
||||
"Kd85208a3": "驳回",
|
||||
"Kad6aa439": "已订阅",
|
||||
"K9a68443b": "取消申请",
|
||||
"Kaeba0229": "透传客户端请求 Host",
|
||||
"K6d7e2fd0": "使用上游服务 Host",
|
||||
"K31332633": "重写 Host",
|
||||
"K2c2bc64f": "动态服务发现",
|
||||
"K78b1ca25": "地址",
|
||||
"K1644b775": "新增",
|
||||
"Kec91f0db": "申请方消费者",
|
||||
"K118d8d74": "数据格式",
|
||||
"Kfe7c7d2d": "关键字",
|
||||
"K2f57a694": "正则表达式",
|
||||
"K8953e0a6": "手机号",
|
||||
"K6f86a038": "身份证号",
|
||||
"K7954e7c8": "银行卡号",
|
||||
"K320fdb17": "金额",
|
||||
"K7867acda": "日期",
|
||||
"K7d327ae8": "局部显示",
|
||||
"Kfbf38e3c": "局部遮蔽",
|
||||
"Kd8c1fbb0": "截取",
|
||||
"K89829921": "替换",
|
||||
"K480a7165": "乱序",
|
||||
"Kea0d69df": "随机字符串",
|
||||
"Ke7c84d1d": "自定义字符串",
|
||||
"K49731763": "请输入IP地址或CIDR范围,每条以换行分割",
|
||||
"K3a34d49b": "待更新",
|
||||
"Kd2850420": "待删除",
|
||||
"K83237c89": "输入的IP或CIDR不符合格式",
|
||||
"K5ae2c87a": "请正确输入路径,如/usr/*或*/usr/*",
|
||||
"K508d8bf4": "集成地址",
|
||||
"K67f4e9bb": "与外部平台集成时,获取 API 市场中文档信息的域名",
|
||||
"Kc82b8374": "编辑策略",
|
||||
"K4b34a5e5": "策略类型",
|
||||
"K57f0fee8": "匹配条件",
|
||||
"K10650c58": "数据脱敏规则",
|
||||
"K1b34a9ab": "配置脱敏规则",
|
||||
"K26d22405": "匹配值",
|
||||
"K1546e1fe": "脱敏类型",
|
||||
"K9b9b0629": "起始位置",
|
||||
"K52c84fe1": "长度",
|
||||
"Kde84409c": "替换类型",
|
||||
"K338653b4": "替换值",
|
||||
"Kbaeed3b7": "JSON Path",
|
||||
"K4cd91d61": "脱敏规则",
|
||||
"K8dcad979": "自定义字符串; 值:",
|
||||
"K82e3f7b7": "起始位置:(0)位;长度:(1)位",
|
||||
"K49dfc123": "已选择(0)项(1)数据",
|
||||
"K8457ea34": "所有(0)",
|
||||
"K7ca9a795": "属性名称",
|
||||
"Kc4391744": "属性值",
|
||||
"K678e13fc": "配置(0)",
|
||||
"Kf5fd27ed": "输入名称查找用户"
|
||||
}
|
||||
@@ -189,7 +189,7 @@
|
||||
"K617f34f1": "更新者",
|
||||
"K6ebca204": "更新时间",
|
||||
"Kabfe9512": "保存",
|
||||
"K51d1eb5d": "API 路由",
|
||||
"K51d1eb5d": "API",
|
||||
"Ka2b6d281": "API 文档",
|
||||
"Kdefa9caa": "说明文档",
|
||||
"K36856e71": "发布",
|
||||
@@ -213,7 +213,7 @@
|
||||
"K469e475a": "最大重试次数",
|
||||
"K8a35059b": "模型设置",
|
||||
"Kf9dcef3a": "API",
|
||||
"K6134bbe8": "添加 API 路由",
|
||||
"K6134bbe8": "添加 API",
|
||||
"Kf85b83a0": "输入 URL 查找",
|
||||
"Kcf9f90b8": "模型供应商",
|
||||
"Kfede1c7c": "模型",
|
||||
@@ -851,77 +851,5 @@
|
||||
"Kce2fcdbf": "暂无权限",
|
||||
"K24f6a5b4": "自定义(空模板)",
|
||||
"Kea608112": "载入预置模板",
|
||||
"Kee7de862": "编辑供应商( (0) )",
|
||||
"Kb0e0aeda": "新增 API Key",
|
||||
"K9d81999c": "API 密钥可用于调用系统级 Open API 和 MCP。",
|
||||
"Ka7ca8fde": "OpenAPI & MCP 调用地址",
|
||||
"K6e9c928f": "MCP 配置",
|
||||
"Kb6d0eb39": "Open API 文档",
|
||||
"Ke6908f16": "AI 代理集成",
|
||||
"Kf106bc62": "MCP 服务",
|
||||
"K7c2bfeff": "MCP Service 充当 AI 模型与 API 之间的桥梁,允许智能助手(如 Claude)动态发现和调用 Gateway 上的 API,无需繁琐的手动配置或自定义集成。",
|
||||
"K30595880": "关闭 MCP",
|
||||
"Kc081047c": "关闭后将无法通过MCP方式调用服务",
|
||||
"K373c8ab3": "MCP",
|
||||
"K3ba29a85": "API",
|
||||
"K3d52b756": "30天内调用次数",
|
||||
"Ke959f135": "开启:AI Agent 等产品能够通过 MCP 方式调用服务",
|
||||
"Ka73a5801": "了解",
|
||||
"K6cd677b": "说明文档",
|
||||
"Kec68fe24": "编辑 API 设置",
|
||||
"Kc9aeee51": "新增 API 设置",
|
||||
"Kf06f6737": "编辑服务策略",
|
||||
"K205971e1": "添加服务策略",
|
||||
"Kc9f2249c": "角色配置",
|
||||
"Kba68dfc1": "添加 API 设置",
|
||||
"Kc84dbd1a": "API 门户",
|
||||
"Ke93388fd": "编辑 API",
|
||||
"K84aabfd4": "添加 API",
|
||||
"K71ed51fa": "请先订阅该服务",
|
||||
"K1bec8cbe": "选择 API Key",
|
||||
"K5611e01e": "该消费者已订阅",
|
||||
"Kaf9e8011": "总览",
|
||||
"Ke1e649cb": "服务尚未发布",
|
||||
"K2e683a7d": "跳转至详情页",
|
||||
"Ke04bc00d": "订阅方数量",
|
||||
"K1b97ae0a": "已开启",
|
||||
"K19ec733b": "开启 MCP",
|
||||
"Kbee2340": "API 使用排名",
|
||||
"Kf6af1f40": "消费者使用排名",
|
||||
"K318a7519": "请求数",
|
||||
"K9ef68e3f": "Token",
|
||||
"Kfb14ccb0": "模型使用量",
|
||||
"K10a8bee3": "平均 Token 消耗",
|
||||
"K2727b76b": "人均请求数",
|
||||
"K4c7a6704": "人均 Token 消耗",
|
||||
"K53eb7414": "流量",
|
||||
"K7c8d5c23": "平均响应时间",
|
||||
"Kf9eb702": "每秒请求数量",
|
||||
"K7f0aa740": "人均流量",
|
||||
"K9d526cac": "API / Tools",
|
||||
"Kc68ba0f4": "HTTP 状态",
|
||||
"Kb09b747": "IP",
|
||||
"K2eacb44f": "通过系统级别的 API Key 来调用",
|
||||
"K764bca7c": "日志详情",
|
||||
"K6c016898": "平均 Token/s 统计",
|
||||
"K652843b0": "平均请求数",
|
||||
"K8158a6e4": "平均流量",
|
||||
"K6c2d93b6": "加载数据失败,请重试",
|
||||
"Kf5eeb9c5": "平均 Token/订阅者统计",
|
||||
"K1639a17a": "API 路由文档",
|
||||
"K33bc1ad1": "输入 Token",
|
||||
"Ke00ff18b": "输出 Token",
|
||||
"K81140e5b": "总 Token",
|
||||
"K3c722abd": "日志输出",
|
||||
"K74a5fbc0": "日志输出设置",
|
||||
"Kc8bf447": "请求日志",
|
||||
"Kf8525cf2": "暂无数据",
|
||||
"K1be06929": "响应时间",
|
||||
"K5e51f5d": "时间",
|
||||
"K9d3f2d9d": "请求次数",
|
||||
"Ke2241377": "网络流量",
|
||||
"K6c267c7b": "平均每消费者的请求次数",
|
||||
"K133d4291": "平均每消费者的网络流量",
|
||||
"K37c5f1d0": "Token 消耗",
|
||||
"Kb98264d4": "平均每消费者的 Token 消耗"
|
||||
"Kee7de862": "编辑供应商( (0) )"
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
"K617f34f1": "更新者",
|
||||
"K6ebca204": "更新時間",
|
||||
"Kabfe9512": "保存",
|
||||
"K51d1eb5d": "API 路由",
|
||||
"K51d1eb5d": "API",
|
||||
"Ka2b6d281": "API 文檔",
|
||||
"Kdefa9caa": "說明文檔",
|
||||
"K36856e71": "發布",
|
||||
@@ -213,7 +213,7 @@
|
||||
"K469e475a": "最大重試次數",
|
||||
"K8a35059b": "模型設置",
|
||||
"Kf9dcef3a": "API",
|
||||
"K6134bbe8": "添加 API 路由",
|
||||
"K6134bbe8": "添加 API",
|
||||
"Kf85b83a0": "輸入 URL 查找",
|
||||
"Kcf9f90b8": "模型供應商",
|
||||
"Kfede1c7c": "模型",
|
||||
@@ -920,79 +920,5 @@
|
||||
"Kce2fcdbf": "暫無權限",
|
||||
"K24f6a5b4": "自訂(空模板)",
|
||||
"Kea608112": "載入預設模板",
|
||||
"Kee7de862": "編輯供應商( (0) )",
|
||||
"Kb0e0aeda": "新增 API 金鑰",
|
||||
"K9d81999c": "API 金鑰可用於調用系統級 Open API 和 MCP。",
|
||||
"Ka7ca8fde": "OpenAPI & MCP 呼叫地址",
|
||||
"K6e9c928f": "MCP 設定",
|
||||
"Kb6d0eb39": "Open API 文件",
|
||||
"Ke6908f16": "AI 代理整合",
|
||||
"Kf106bc62": "MCP 服務",
|
||||
"K7c2bfeff": "MCP 服務作為 AI 模型與 API 之間的橋樑,允許智能助手(如 Claude)動態發現並呼叫 Gateway 上的 API,而無需繁瑣的手動設定或自訂整合。",
|
||||
"K30595880": "關閉 MCP",
|
||||
"Kc081047c": "關閉後將無法透過 MCP 方式呼叫服務",
|
||||
"K373c8ab3": "MCP",
|
||||
"K3ba29a85": "API",
|
||||
"K3d52b756": "30 天內呼叫次數",
|
||||
"Ke959f135": "開啟:AI Agent 等產品能夠透過 MCP 方式呼叫服務",
|
||||
"Ka73a5801": "了解",
|
||||
"K6cd677b": "說明文檔",
|
||||
"Kec68fe24": "編輯 API 設定",
|
||||
"Kc9aeee51": "新增 API 設定",
|
||||
"Kf06f6737": "編輯服務策略",
|
||||
"K205971e1": "新增服務策略",
|
||||
"Kc9f2249c": "角色配置",
|
||||
"Kba68dfc1": "新增 API 設定",
|
||||
"Kc84dbd1a": "API 門戶",
|
||||
"Ke93388fd": "編輯 API",
|
||||
"K84aabfd4": "新增 API",
|
||||
"K71ed51fa": "請先訂閱該服務",
|
||||
"K1bec8cbe": "選擇 API Key",
|
||||
"K5611e01e": "該消費者已訂閱",
|
||||
"Kaf9e8011": "總覽",
|
||||
"Ke1e649cb": "服務尚未發布",
|
||||
"K2e683a7d": "跳轉至詳情頁",
|
||||
"Ke04bc00d": "訂閱數量",
|
||||
"K1b97ae0a": "已開啟",
|
||||
"K19ec733b": "開啟 MCP",
|
||||
"Kbee2340": "API 使用排名",
|
||||
"Kf6af1f40": "消費者使用排名",
|
||||
"K318a7519": "請求數",
|
||||
"K9ef68e3f": "Token",
|
||||
"Kfb14ccb0": "模型使用量",
|
||||
"K10a8bee3": "平均 Token 消耗",
|
||||
"K2727b76b": "人均請求數",
|
||||
"K4c7a6704": "人均 Token 消耗",
|
||||
"K53eb7414": "流量",
|
||||
"K7c8d5c23": "平均回應時間",
|
||||
"Kf9eb702": "每秒請求數量",
|
||||
"K7f0aa740": "人均流量",
|
||||
"K9d526cac": "API / 工具",
|
||||
"Kc68ba0f4": "HTTP 狀態",
|
||||
"Kb09b747": "IP",
|
||||
"K2eacb44f": "透過系統級 API Key 調用",
|
||||
"K764bca7c": "日誌詳情",
|
||||
"K6c016898": "平均 Token/s 統計",
|
||||
"K652843b0": "平均請求數",
|
||||
"Kdbf831a0": "每位訂閱者平均 Token 統計",
|
||||
"K8158a6e4": "平均流量",
|
||||
"K6b882d4a": "每位訂閱者平均 Token",
|
||||
"K6c2d93b6": "載入資料失敗,請重試",
|
||||
"Kf5eeb9c5": "每位訂閱者平均 Token 統計",
|
||||
"K1639a17a": "API 路由文件",
|
||||
"K33bc1ad1": "輸入 Token",
|
||||
"Ke00ff18b": "輸出 Token",
|
||||
"K81140e5b": "總計 Token",
|
||||
"K3c722abd": "日誌輸出",
|
||||
"K74a5fbc0": "日誌輸出設定",
|
||||
"Kc8bf447": "請求日誌",
|
||||
"Kf8525cf2": "暫無資料",
|
||||
"K1be06929": "回應時間",
|
||||
"K5e51f5d": "時間",
|
||||
"K9d3f2d9d": "請求次數",
|
||||
"Ke2241377": "網路流量",
|
||||
"K6c267c7b": "平均每位使用者的請求次數",
|
||||
"K133d4291": "平均每位使用者的網路流量",
|
||||
"K37c5f1d0": "Token 消耗",
|
||||
"Kb98264d4": "平均每位使用者的 Token 消耗"
|
||||
"Kee7de862": "編輯供應商( (0) )"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { PluginEventHubProvider } from '@common/contexts/PluginEventHubContext'
|
||||
import { PluginSlotHubProvider } from '@common/contexts/PluginSlotHubContext'
|
||||
import useInitializeMonaco from '@common/hooks/useInitializeMonaco'
|
||||
import { $t } from '@common/locales'
|
||||
import { registerApiparkTheme } from '@common/const/charts/initChartTheme'
|
||||
import RenderRoutes from '@core/components/aoplatform/RenderRoutes'
|
||||
import { App as AppAntd, ConfigProvider } from 'antd'
|
||||
import { useMemo } from 'react'
|
||||
@@ -131,9 +130,6 @@ const antdComponentThemeToken = {
|
||||
}
|
||||
}
|
||||
|
||||
// 注册 ECharts 主题
|
||||
registerApiparkTheme()
|
||||
|
||||
function App() {
|
||||
const { locale } = useLocaleContext()
|
||||
useInitializeMonaco()
|
||||
|
||||
@@ -6,18 +6,17 @@ import { AiServiceRouterTableListItem, VariableItems } from './type'
|
||||
import { PageProColumns } from '@common/components/aoplatform/PageList'
|
||||
|
||||
export const AI_SERVICE_ROUTER_TABLE_COLUMNS: PageProColumns<AiServiceRouterTableListItem>[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'URL',
|
||||
dataIndex: 'requestPath',
|
||||
ellipsis: true,
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '模型',
|
||||
dataIndex: ['model', 'name'],
|
||||
|
||||
@@ -15,13 +15,12 @@ export type AiServiceConfigFieldType = {
|
||||
logoFile?:UploadFile;
|
||||
tags?:Array<string>;
|
||||
description?: string;
|
||||
team?:EntityItem;
|
||||
team?:string;
|
||||
master?:string;
|
||||
serviceType?:'public'|'inner';
|
||||
catalogue?:string | string[];
|
||||
approvalType?:string;
|
||||
providerType?:string
|
||||
enable_mcp?: boolean
|
||||
};
|
||||
|
||||
export type AiServiceSubServiceTableListItem = {
|
||||
|
||||
@@ -96,20 +96,6 @@ export const routerMap: Map<string, RouterMapConfig> = new Map([
|
||||
key: 'restServiceInside',
|
||||
lazy: lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/system/SystemInsidePage.tsx')),
|
||||
children: [
|
||||
{
|
||||
path: 'overview',
|
||||
key: 'restServiceInsideOverview',
|
||||
lazy: lazy(
|
||||
() => import(/* webpackChunkName: "[request]" */ '@core/pages/serviceOverview/RestServiceContainer')
|
||||
)
|
||||
},
|
||||
{
|
||||
path: 'logs',
|
||||
key: 'restServiceInsideLogs',
|
||||
lazy: lazy(
|
||||
() => import(/* webpackChunkName: "[request]" */ '@core/pages/serviceLogs/RestServiceLogsContainer')
|
||||
)
|
||||
},
|
||||
{
|
||||
path: 'api',
|
||||
key: 'restServiceInsideApi',
|
||||
@@ -282,20 +268,6 @@ export const routerMap: Map<string, RouterMapConfig> = new Map([
|
||||
() => import(/* webpackChunkName: "[request]" */ '@core/pages/aiService/AiServiceInsidePage.tsx')
|
||||
),
|
||||
children: [
|
||||
{
|
||||
path: 'overview',
|
||||
key: 'aiServiceInsideOverview',
|
||||
lazy: lazy(
|
||||
() => import(/* webpackChunkName: "[request]" */ '@core/pages/serviceOverview/AiServiceContainer')
|
||||
)
|
||||
},
|
||||
{
|
||||
path: 'logs',
|
||||
key: 'aiServiceInsideLogs',
|
||||
lazy: lazy(
|
||||
() => import(/* webpackChunkName: "[request]" */ '@core/pages/serviceLogs/AiServiceLogsContainer')
|
||||
)
|
||||
},
|
||||
{
|
||||
path: 'api',
|
||||
key: 'aiServiceInsideApi',
|
||||
@@ -535,7 +507,7 @@ export const routerMap: Map<string, RouterMapConfig> = new Map([
|
||||
],
|
||||
|
||||
[
|
||||
'portal',
|
||||
'serviceHub',
|
||||
{
|
||||
type: 'module',
|
||||
component: <Outlet />,
|
||||
@@ -702,12 +674,12 @@ export const routerMap: Map<string, RouterMapConfig> = new Map([
|
||||
children: [
|
||||
{
|
||||
path: 'total',
|
||||
key: 'analyticsTotal',
|
||||
key: 'analytics2',
|
||||
lazy: lazy(() => import(/* webpackChunkName: "[request]" */ '@dashboard/pages/DashboardTotal.tsx'))
|
||||
},
|
||||
{
|
||||
path: ':dashboardType',
|
||||
key: 'analyticsOther',
|
||||
key: 'analytics3',
|
||||
component: <Outlet />,
|
||||
children: [
|
||||
{
|
||||
@@ -828,22 +800,6 @@ export const routerMap: Map<string, RouterMapConfig> = new Map([
|
||||
]
|
||||
}
|
||||
],
|
||||
[
|
||||
'mcpService',
|
||||
{
|
||||
type: 'module',
|
||||
lazy: lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/mcpService/McpServiceContainer')),
|
||||
key: 'mcpService'
|
||||
}
|
||||
],
|
||||
[
|
||||
'mcpKey',
|
||||
{
|
||||
type: 'module',
|
||||
lazy: lazy(() => import(/* webpackChunkName: "[request]" */ '@core/pages/mcpService/McpKeyContainer')),
|
||||
key: 'mcpKey'
|
||||
}
|
||||
],
|
||||
[
|
||||
'loadBalancing',
|
||||
{
|
||||
|
||||
@@ -123,7 +123,6 @@ export type PartitionDataLogHeaderListFieldType = {
|
||||
export type PartitionDataLogConfigFieldType = {
|
||||
headers: PartitionDataLogHeaderListFieldType[]
|
||||
url: string
|
||||
driver?: string
|
||||
}
|
||||
|
||||
export const PARTITION_DATA_LOG_CONFIG_TABLE_COLUMNS: PageProColumns<PartitionDataLogConfigFieldType & { _id: string }>[] = [
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
} from './type'
|
||||
|
||||
import { PageProColumns } from '@common/components/aoplatform/PageList'
|
||||
import { LogItem } from '@core/pages/serviceLogs/ServiceLogs'
|
||||
|
||||
export enum SubscribeEnum {
|
||||
Rejected = 0,
|
||||
@@ -86,7 +85,7 @@ export const SYSTEM_TABLE_COLUMNS: PageProColumns<SystemTableListItem>[] = [
|
||||
title: '服务名称',
|
||||
dataIndex: 'name',
|
||||
ellipsis: true,
|
||||
width: 220,
|
||||
width: 160,
|
||||
fixed: 'left',
|
||||
sorter: (a, b) => {
|
||||
return a.name.localeCompare(b.name)
|
||||
@@ -101,20 +100,24 @@ export const SYSTEM_TABLE_COLUMNS: PageProColumns<SystemTableListItem>[] = [
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'service_kind',
|
||||
width: 120,
|
||||
width: 140,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '所属团队',
|
||||
dataIndex: ['team', 'name'],
|
||||
ellipsis: true,
|
||||
width: 200
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
width: 140,
|
||||
dataIndex: 'state',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'API 数量',
|
||||
dataIndex: 'apiNum',
|
||||
ellipsis: true,
|
||||
width: 140,
|
||||
sorter: (a, b) => {
|
||||
return a.apiNum - b.apiNum
|
||||
}
|
||||
@@ -242,12 +245,6 @@ export const MATCH_CONFIG: ConfigField<MatchItem>[] = [
|
||||
]
|
||||
|
||||
export const SYSTEM_API_TABLE_COLUMNS: PageProColumns<SystemApiTableListItem>[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'URL',
|
||||
dataIndex: 'requestPath',
|
||||
@@ -365,10 +362,6 @@ export const SERVICE_APPROVAL_OPTIONS = [
|
||||
{ label: '无需审核:允许任何消费者调用该服务', value: 'auto' },
|
||||
{ label: '人工审核:仅允许通过人工审核的消费者调用该服务', value: 'manual' }
|
||||
]
|
||||
export const MCP_OPTIONS = [
|
||||
{ label: '禁用', value: false },
|
||||
{ label: '开启:AI Agent 等产品能够通过 MCP 方式调用服务', value: true }
|
||||
]
|
||||
export const SERVICE_KIND_OPTIONS = [
|
||||
{ label: 'REST', value: 'rest' },
|
||||
{ label: 'AI', value: 'ai' }
|
||||
@@ -507,133 +500,3 @@ export const SYSTEM_PUBLISH_ONLINE_COLUMNS = [
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
/** AI 服务排行 */
|
||||
export const AI_SERVICE_TOP_RANKING_LIST: PageProColumns<any>[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '请求总数',
|
||||
dataIndex: 'request',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'Token',
|
||||
dataIndex: 'token',
|
||||
ellipsis: true
|
||||
}
|
||||
]
|
||||
|
||||
/** REST 服务排行 */
|
||||
export const REST_SERVICE_TOP_RANKING_LIST: PageProColumns<any>[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '请求总数',
|
||||
dataIndex: 'request',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '流量',
|
||||
dataIndex: 'traffic',
|
||||
ellipsis: true
|
||||
}
|
||||
]
|
||||
|
||||
/** REST 服务日志 */
|
||||
export const REST_SERVICE_LOG_LIST: PageProColumns<LogItem>[] = [
|
||||
{
|
||||
title: '时间戳',
|
||||
dataIndex: 'logTime',
|
||||
copyable: false,
|
||||
width: 180,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'API / Tools',
|
||||
dataIndex: ['api', 'name'],
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '消费者',
|
||||
dataIndex: ['consumer', 'name'],
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'HTTP 状态',
|
||||
dataIndex: 'status',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'IP',
|
||||
dataIndex: 'ip',
|
||||
copyable: true,
|
||||
width: 140,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '响应时间',
|
||||
dataIndex: 'responseTime',
|
||||
width: 130,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '流量',
|
||||
dataIndex: 'traffic',
|
||||
ellipsis: true
|
||||
}
|
||||
]
|
||||
|
||||
/** AI 服务日志 */
|
||||
export const AI_SERVICE_LOG_LIST: PageProColumns<LogItem>[] = [
|
||||
{
|
||||
title: '时间戳',
|
||||
dataIndex: 'logTime',
|
||||
copyable: false,
|
||||
width: 200,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'API / Tools',
|
||||
dataIndex: ['api', 'name'],
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '消费者',
|
||||
dataIndex: ['consumer', 'name'],
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'HTTP 状态',
|
||||
dataIndex: 'status',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: '模型',
|
||||
dataIndex: 'model',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'IP',
|
||||
dataIndex: 'ip',
|
||||
copyable: true,
|
||||
width: 140,
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'Token/s',
|
||||
dataIndex: 'tokenPerSecond',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'Token',
|
||||
dataIndex: 'token',
|
||||
ellipsis: true
|
||||
}
|
||||
]
|
||||
|
||||
@@ -31,7 +31,6 @@ export type SystemConfigFieldType = {
|
||||
catalogue?:string | string[];
|
||||
approvalType?:string;
|
||||
modelMapping?: string;
|
||||
enable_mcp?: boolean;
|
||||
};
|
||||
|
||||
export type SystemSubServiceTableListItem = {
|
||||
@@ -97,7 +96,6 @@ export type SystemApiProxyType = {
|
||||
export type SystemApiProxyFieldType = {
|
||||
protocols: string[];
|
||||
id:string;
|
||||
name:string
|
||||
description?:string;
|
||||
disable:boolean;
|
||||
path:string;
|
||||
|
||||
@@ -1109,11 +1109,6 @@ p{
|
||||
width: 16px !important;
|
||||
justify-content:center;
|
||||
}
|
||||
.ant-select .ant-select-clear {
|
||||
height:16px !important;
|
||||
width: 16px !important;
|
||||
top: 45%;
|
||||
}
|
||||
|
||||
.ant-table-wrapper .ant-table{
|
||||
scrollbar-color: none !important;
|
||||
@@ -1156,32 +1151,9 @@ p{
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ranking-list .ant-pro-table{
|
||||
overflow: hidden;
|
||||
border-radius: 10px;
|
||||
border: none !important;
|
||||
}
|
||||
.ranking-list .ant-table-tbody:not(tbody) .ant-table-cell{
|
||||
padding: 10px 10px !important;
|
||||
}
|
||||
.ranking-list .ant-table-container .ant-table-thead th{
|
||||
background-color: #fff !important;
|
||||
padding: 10px 10px !important;
|
||||
}
|
||||
.ranking-list .ant-table-container .ant-table-thead th::before{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ant-alert-info{
|
||||
background: #1784FC1A !important;
|
||||
}
|
||||
.service-log-tab .ant-tabs .ant-tabs-nav .ant-tabs-tab{
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
.service-log-tab .ant-tabs .ant-tabs-tab+.ant-tabs-tab {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.monaco-editor .find-widget .monaco-inputbox.synthetic-focus{
|
||||
outline-color: var(--primary-color) !important;
|
||||
@@ -1241,38 +1213,6 @@ p{
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 将折叠图标移到右侧 */
|
||||
.service-hub-custom-switcher .ant-tree-switcher {
|
||||
position: absolute !important;
|
||||
right: 0 !important;
|
||||
left: auto !important;
|
||||
z-index: 10 !important;
|
||||
}
|
||||
|
||||
/* 设置节点内容宽度 */
|
||||
.service-hub-custom-switcher .ant-tree-node-content-wrapper {
|
||||
width: calc(100% - 24px) !important;
|
||||
padding-left: 8px !important;
|
||||
padding-right: 24px !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
/* 强制控制标题元素的样式 */
|
||||
.service-hub-custom-switcher .ant-tree-title {
|
||||
display: inline-block !important;
|
||||
width: calc(100% - 10px) !important;
|
||||
overflow: hidden !important;
|
||||
white-space: nowrap !important;
|
||||
text-overflow: ellipsis !important;
|
||||
vertical-align: middle !important;
|
||||
}
|
||||
|
||||
/* 确保选中框的间距 */
|
||||
.service-hub-custom-switcher .ant-tree-checkbox {
|
||||
margin-right: 8px !important;
|
||||
}
|
||||
|
||||
|
||||
.no-selected-tree .ant-tree-node-selected{
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
@@ -1,191 +1,145 @@
|
||||
import { Editor } from '@tinymce/tinymce-react'
|
||||
import hljs from 'highlight.js'
|
||||
import 'highlight.js/styles/default.css'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { App, Button } from 'antd'
|
||||
import { EntityItem } from '@common/const/type.ts'
|
||||
import WithPermission from '@common/components/aoplatform/WithPermission.tsx'
|
||||
import { RouterParams } from '@core/components/aoplatform/RenderRoutes'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { $t } from '@common/locales'
|
||||
const ServiceInsideDocument = () => {
|
||||
const { message } = App.useApp()
|
||||
const [updater, setUpdater] = useState<string>()
|
||||
const [updateTime, setUpdateTime] = useState<string>()
|
||||
const [initDoc, setInitDoc] = useState<string>()
|
||||
const [doc, setDoc] = useState<string>()
|
||||
const { fetchData } = useFetch()
|
||||
const { serviceId, teamId } = useParams<RouterParams>()
|
||||
import { Editor } from '@tinymce/tinymce-react';
|
||||
import hljs from 'highlight.js';
|
||||
import 'highlight.js/styles/default.css';
|
||||
import {useEffect, useState} from "react";
|
||||
import {BasicResponse, RESPONSE_TIPS, STATUS_CODE} from "@common/const/const.tsx";
|
||||
import {useFetch} from "@common/hooks/http.ts";
|
||||
import {App, Button} from "antd";
|
||||
import { EntityItem } from '@common/const/type.ts';
|
||||
import WithPermission from '@common/components/aoplatform/WithPermission.tsx';
|
||||
import { RouterParams } from '@core/components/aoplatform/RenderRoutes';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { $t } from '@common/locales';
|
||||
const ServiceInsideDocument = ()=>{
|
||||
const { message } = App.useApp()
|
||||
const [updater,setUpdater] = useState<string>()
|
||||
const [updateTime,setUpdateTime]=useState<string>()
|
||||
const [initDoc, setInitDoc] = useState<string>()
|
||||
const [doc, setDoc] = useState<string>()
|
||||
const {fetchData} = useFetch()
|
||||
const { serviceId, teamId} = useParams<RouterParams>();
|
||||
|
||||
const save = () => {
|
||||
fetchData<
|
||||
BasicResponse<{ service: { id: string; name: string; updater: string; updateTime: string; doc: string } }>
|
||||
>('service/doc', {
|
||||
method: 'PUT',
|
||||
eoBody: { doc: doc },
|
||||
eoParams: { service: serviceId, team: teamId },
|
||||
eoTransformKeys: ['update_time']
|
||||
}).then((response) => {
|
||||
const { code, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
message.success(msg || $t(RESPONSE_TIPS.success))
|
||||
const save = ()=>{
|
||||
fetchData<BasicResponse<{service:{ id:string,name:string,updater:string,updateTime:string, doc:string} }>>('service/doc',{method:'PUT',eoBody:({doc:doc}) ,eoParams:{service:serviceId,team:teamId},eoTransformKeys:['update_time']}).then(response=>{
|
||||
const {code,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
message.success(msg || $t(RESPONSE_TIPS.success))
|
||||
getServiceDoc()
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleEditorChange = (content:string, editor:unknown) => {
|
||||
setDoc(content)
|
||||
};
|
||||
const setupEditor = (editor:unknown) => {
|
||||
editor.on('init', () => {
|
||||
editor.contentDocument.querySelectorAll('pre code').forEach((block:HTMLElement) => {
|
||||
hljs.highlightBlock(block);
|
||||
});
|
||||
});
|
||||
|
||||
editor.on('SetContent', () => {
|
||||
editor.contentDocument.querySelectorAll('pre code').forEach((block:HTMLElement) => {
|
||||
hljs.highlightBlock(block);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getServiceDoc = ()=>{
|
||||
fetchData<BasicResponse<{doc:{ id:string,name:string,updater:EntityItem,updateTime:string,creater:EntityItem, doc:string} }>>('service/doc',{method:'GET',eoParams:{service:serviceId,team:teamId},eoTransformKeys:['update_time']}).then(response=>{
|
||||
const {code,data,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
setUpdater(data.doc.updater.id === '' ? '-' : data.doc.updater.name)
|
||||
setUpdateTime(data.doc.updater.id === '' ? '-' : data.doc.updateTime)
|
||||
setInitDoc(data.doc.doc)
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getServiceDoc()
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleEditorChange = (content: string, editor: unknown) => {
|
||||
setDoc(content)
|
||||
}
|
||||
const setupEditor = (editor: unknown) => {
|
||||
editor.on('init', () => {
|
||||
editor.contentDocument.querySelectorAll('pre code').forEach((block: HTMLElement) => {
|
||||
hljs.highlightBlock(block)
|
||||
})
|
||||
})
|
||||
|
||||
editor.on('SetContent', () => {
|
||||
editor.contentDocument.querySelectorAll('pre code').forEach((block: HTMLElement) => {
|
||||
hljs.highlightBlock(block)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getServiceDoc = () => {
|
||||
fetchData<
|
||||
BasicResponse<{
|
||||
doc: { id: string; name: string; updater: EntityItem; updateTime: string; creater: EntityItem; doc: string }
|
||||
}>
|
||||
>('service/doc', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId },
|
||||
eoTransformKeys: ['update_time']
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setUpdater(data.doc.updater.id === '' ? '-' : data.doc.updater.name)
|
||||
setUpdateTime(data.doc.updater.id === '' ? '-' : data.doc.updateTime)
|
||||
setInitDoc(data.doc.doc)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getServiceDoc()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="flex flex-col h-full border-[1px] rounded-[10px] border-BORDER border-solid mr-PAGE_INSIDE_X">
|
||||
<Editor
|
||||
tinymceScriptSrc={'/tinymce/tinymce.min.js'}
|
||||
initialValue={initDoc}
|
||||
init={{
|
||||
height: '100%',
|
||||
menubar: false,
|
||||
plugins: [
|
||||
'advlist',
|
||||
'autolink',
|
||||
'link',
|
||||
'image',
|
||||
'lists',
|
||||
'charmap',
|
||||
'preview',
|
||||
'anchor',
|
||||
'pagebreak',
|
||||
'searchreplace',
|
||||
'wordcount',
|
||||
'visualblocks',
|
||||
'visualchars',
|
||||
'codesample',
|
||||
'fullscreen',
|
||||
'insertdatetime',
|
||||
'media',
|
||||
'table',
|
||||
'emoticons',
|
||||
'help'
|
||||
],
|
||||
toolbar:
|
||||
'undo redo | styles | bold italic | alignleft aligncenter alignright alignjustify | codesample |table|' +
|
||||
'bullist numlist outdent indent | link image | print preview media fullscreen | ' +
|
||||
'forecolor backcolor emoticons | help',
|
||||
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px; } img { max-width: 100%; }',
|
||||
setup: setupEditor,
|
||||
codesample_languages: [
|
||||
{
|
||||
text: 'HTML/XML',
|
||||
value: 'markup'
|
||||
},
|
||||
{
|
||||
text: 'JavaScript',
|
||||
value: 'javascript'
|
||||
},
|
||||
{
|
||||
text: 'CSS',
|
||||
value: 'css'
|
||||
},
|
||||
{
|
||||
text: 'PHP',
|
||||
value: 'php'
|
||||
},
|
||||
{
|
||||
text: 'Ruby',
|
||||
value: 'ruby'
|
||||
},
|
||||
{
|
||||
text: 'GO',
|
||||
value: 'go'
|
||||
},
|
||||
{
|
||||
text: 'Python',
|
||||
value: 'python'
|
||||
},
|
||||
{
|
||||
text: 'Java',
|
||||
value: 'java'
|
||||
},
|
||||
{
|
||||
text: 'C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
text: 'C#',
|
||||
value: 'csharp'
|
||||
},
|
||||
{
|
||||
text: 'C++',
|
||||
value: 'cpp'
|
||||
},
|
||||
{ text: 'Bash/Shell', value: 'bash' },
|
||||
{ text: 'SQL', value: 'sql' }
|
||||
]
|
||||
}}
|
||||
onEditorChange={handleEditorChange}
|
||||
/>
|
||||
|
||||
<div className=" pl-[8px] py-btnbase ">
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="text-[14px] leading-[20px] text-[#999999]">
|
||||
<span className="mr-[20px]">
|
||||
{$t('最近一次更新者')}:{updater || '-'}
|
||||
</span>
|
||||
<span>
|
||||
{$t('最近一次更新时间')}:{updateTime || '-'}
|
||||
</span>
|
||||
</p>
|
||||
<WithPermission access="team.service.service_intro.edit">
|
||||
<Button type="primary" className="mr-btnbase" onClick={save}>
|
||||
{$t('保存')}
|
||||
</Button>
|
||||
</WithPermission>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
return (
|
||||
<div className="flex flex-col h-full border-[1px] rounded-[10px] border-BORDER border-solid mr-PAGE_INSIDE_X">
|
||||
<Editor
|
||||
tinymceScriptSrc={'/tinymce/tinymce.min.js'}
|
||||
initialValue={initDoc}
|
||||
init={{
|
||||
height: '100%',
|
||||
menubar: false,
|
||||
plugins: [
|
||||
'advlist', 'autolink', 'link', 'image', 'lists', 'charmap', 'preview', 'anchor', 'pagebreak',
|
||||
'searchreplace', 'wordcount', 'visualblocks', 'visualchars', 'codesample', 'fullscreen', 'insertdatetime',
|
||||
'media', 'table', 'emoticons', 'help'
|
||||
], toolbar: 'undo redo | styles | bold italic | alignleft aligncenter alignright alignjustify | codesample |table|' +
|
||||
'bullist numlist outdent indent | link image | print preview media fullscreen | ' +
|
||||
'forecolor backcolor emoticons | help',
|
||||
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px; } img { max-width: 100%; }',
|
||||
setup: setupEditor,
|
||||
codesample_languages:[
|
||||
{
|
||||
text: 'HTML/XML',
|
||||
value: 'markup'
|
||||
},
|
||||
{
|
||||
text: 'JavaScript',
|
||||
value: 'javascript'
|
||||
},
|
||||
{
|
||||
text: 'CSS',
|
||||
value: 'css'
|
||||
},
|
||||
{
|
||||
text: 'PHP',
|
||||
value: 'php'
|
||||
},
|
||||
{
|
||||
text: 'Ruby',
|
||||
value: 'ruby'
|
||||
},
|
||||
{
|
||||
text:'GO',
|
||||
value:'go'
|
||||
},
|
||||
{
|
||||
text: 'Python',
|
||||
value: 'python'
|
||||
},
|
||||
{
|
||||
text: 'Java',
|
||||
value: 'java'
|
||||
},
|
||||
{
|
||||
text: 'C',
|
||||
value: 'c'
|
||||
},
|
||||
{
|
||||
text: 'C#',
|
||||
value: 'csharp'
|
||||
},
|
||||
{
|
||||
text: 'C++',
|
||||
value: 'cpp'
|
||||
},
|
||||
{ text: 'Bash/Shell', value: 'bash' },
|
||||
{ text: 'SQL', value: 'sql' }
|
||||
]
|
||||
}}
|
||||
onEditorChange={handleEditorChange}
|
||||
/>
|
||||
|
||||
<div className=" pl-[8px] py-btnbase ">
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="text-[14px] leading-[20px] text-[#999999]"><span className="mr-[20px]">{$t('最近一次更新者')}:{updater || '-'}</span><span>{$t('最近一次更新时间')}:{updateTime || '-'}</span></p>
|
||||
<WithPermission access="team.service.service_intro.edit"><Button type="primary" className="mr-btnbase" onClick={save}>{$t('保存')}</Button></WithPermission>
|
||||
</div>
|
||||
</div>
|
||||
</div>)
|
||||
}
|
||||
export default ServiceInsideDocument
|
||||
export default ServiceInsideDocument
|
||||
@@ -9,12 +9,11 @@ import { RouterParams } from '@core/components/aoplatform/RenderRoutes.tsx'
|
||||
import { AiServiceConfigFieldType } from '@core/const/ai-service/type.ts'
|
||||
import { App, Menu, MenuProps } from 'antd'
|
||||
import { ItemType, MenuItemGroupType, MenuItemType } from 'antd/es/menu/interface'
|
||||
import ServiceInfoCard from '@common/components/aoplatform/serviceInfoCard.tsx'
|
||||
import Paragraph from 'antd/es/typography/Paragraph'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { FC, useEffect, useMemo, useState } from 'react'
|
||||
import { Link, Outlet, useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
import { useAiServiceContext } from '../../contexts/AiServiceContext.tsx'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
const APP_MODE = import.meta.env.VITE_APP_MODE
|
||||
|
||||
const AiServiceInsidePage: FC = () => {
|
||||
@@ -28,7 +27,6 @@ const AiServiceInsidePage: FC = () => {
|
||||
const [activeMenu, setActiveMenu] = useState<string>()
|
||||
const navigateTo = useNavigate()
|
||||
const [showMenu, setShowMenu] = useState<boolean>(false)
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
|
||||
const getAiServiceInfo = () => {
|
||||
fetchData<BasicResponse<{ service: AiServiceConfigFieldType }>>('service/info', {
|
||||
@@ -69,7 +67,6 @@ const AiServiceInsidePage: FC = () => {
|
||||
'assets',
|
||||
null,
|
||||
[
|
||||
getItem(<Link to="./overview">{$t('总览')}</Link>, 'overview', undefined, undefined, undefined, ''),
|
||||
getItem(
|
||||
<Link to="./route">{$t('API 路由')}</Link>,
|
||||
'route',
|
||||
@@ -152,8 +149,7 @@ const AiServiceInsidePage: FC = () => {
|
||||
'project.myAiService.topology.view'
|
||||
)
|
||||
: null,
|
||||
getItem(<Link to="./setting">{$t('设置')}</Link>, 'setting', undefined, undefined, undefined, ''),
|
||||
getItem(<Link to="./logs">{$t('日志')}</Link>, 'logs', undefined, undefined, undefined, '')
|
||||
getItem(<Link to="./setting">{$t('设置')}</Link>, 'setting', undefined, undefined, undefined, '')
|
||||
],
|
||||
'group'
|
||||
)
|
||||
@@ -206,7 +202,7 @@ const AiServiceInsidePage: FC = () => {
|
||||
} else if (serviceId !== currentUrl.split('/')[currentUrl.split('/').length - 1]) {
|
||||
setActiveMenu(currentUrl.split('/')[currentUrl.split('/').length - 1])
|
||||
} else {
|
||||
setActiveMenu('overview')
|
||||
setActiveMenu('route')
|
||||
}
|
||||
}, [currentUrl])
|
||||
|
||||
@@ -217,35 +213,30 @@ const AiServiceInsidePage: FC = () => {
|
||||
}, [accessData])
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: $t('服务'),
|
||||
onClick: () => navigateTo('/service/list')
|
||||
},
|
||||
{
|
||||
title: aiServiceInfo?.name || ''
|
||||
}
|
||||
])
|
||||
if (activeMenu && serviceId === currentUrl.split('/')[currentUrl.split('/').length - 1]) {
|
||||
navigateTo(`/service/${teamId}/aiInside/${serviceId}/${activeMenu}`)
|
||||
}
|
||||
}, [activeMenu, state.language, aiServiceInfo])
|
||||
}, [activeMenu])
|
||||
|
||||
useEffect(() => {
|
||||
serviceId && getAiServiceInfo()
|
||||
}, [serviceId])
|
||||
// 创建一个回调函数
|
||||
const onSaveCallback = () => {
|
||||
getAiServiceInfo()
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{showMenu ? (
|
||||
<InsidePage
|
||||
pageTitle={aiServiceInfo?.name || '-'}
|
||||
tagList={[
|
||||
{
|
||||
label: (
|
||||
<Paragraph className="mb-0" copyable={serviceId ? { text: serviceId } : false}>
|
||||
{$t('服务 ID')}:{serviceId || '-'}
|
||||
</Paragraph>
|
||||
)
|
||||
}
|
||||
]}
|
||||
backUrl="/service/list"
|
||||
customBanner={<ServiceInfoCard serviceId={serviceId} teamId={teamId} />}
|
||||
>
|
||||
<div className="flex flex-1 h-full">
|
||||
<Menu
|
||||
@@ -259,7 +250,7 @@ const AiServiceInsidePage: FC = () => {
|
||||
<div
|
||||
className={` ${['setting', 'upstream'].indexOf(activeMenu!) !== -1 ? '' : ''} w-full h-full flex flex-1 flex-col overflow-auto bg-MAIN_BG pt-[20px] pl-[20px] pb-PAGE_INSIDE_B `}
|
||||
>
|
||||
<Outlet context={{ onSaveComplete: onSaveCallback }} />
|
||||
<Outlet />
|
||||
</div>
|
||||
</div>
|
||||
</InsidePage>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import {ActionType} from "@ant-design/pro-components";
|
||||
import {FC, forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState} from "react";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {Link, useParams} from "react-router-dom";
|
||||
import {App, Form,TreeSelect} from "antd";
|
||||
import {useBreadcrumb} from "@common/contexts/BreadcrumbContext.tsx";
|
||||
import {useFetch} from "@common/hooks/http.ts";
|
||||
import { RouterParams } from "@core/components/aoplatform/RenderRoutes.tsx";
|
||||
import {BasicResponse, COLUMNS_TITLE, DELETE_TIPS, PLACEHOLDER, RESPONSE_TIPS, STATUS_CODE, VALIDATE_MESSAGE} from "@common/const/const.tsx";
|
||||
@@ -17,6 +18,7 @@ import { checkAccess } from "@common/utils/permission.ts";
|
||||
import { $t } from "@common/locales/index.ts";
|
||||
|
||||
const AiServiceInsideSubscriber:FC = ()=>{
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { modal,message } = App.useApp()
|
||||
const {fetchData} = useFetch()
|
||||
const {serviceId, teamId} = useParams<RouterParams>()
|
||||
@@ -117,6 +119,14 @@ const AiServiceInsideSubscriber:FC = ()=>{
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title:<Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title:$t('订阅方管理')
|
||||
}
|
||||
])
|
||||
getMemberList()
|
||||
manualReloadTable()
|
||||
}, [serviceId]);
|
||||
|
||||
@@ -1,72 +1,58 @@
|
||||
import { forwardRef, useEffect, useState } from 'react'
|
||||
import { Empty, Spin, message } from 'antd'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { LoadingOutlined } from '@ant-design/icons'
|
||||
|
||||
import {forwardRef, useEffect, useState} from "react";
|
||||
import { Empty, Spin, message} from "antd";
|
||||
import {BasicResponse, RESPONSE_TIPS, STATUS_CODE} from "@common/const/const.tsx";
|
||||
import {useFetch} from "@common/hooks/http.ts";
|
||||
import { LoadingOutlined } from "@ant-design/icons";
|
||||
import EmptySVG from '@common/assets/empty.svg'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { $t } from "@common/locales/index.ts";
|
||||
import ApiDocument from '@common/components/aoplatform/ApiDocument.tsx'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { RouterParams } from '@core/components/aoplatform/RenderRoutes.tsx'
|
||||
import {
|
||||
AiServiceInsideApiDocumentHandle,
|
||||
AiServiceInsideApiDocumentProps,
|
||||
AiServiceApiDetail
|
||||
} from '@core/const/ai-service/type.ts'
|
||||
import { useParams } from "react-router-dom";
|
||||
import { RouterParams } from "@core/components/aoplatform/RenderRoutes.tsx";
|
||||
import { AiServiceInsideApiDocumentHandle, AiServiceInsideApiDocumentProps, AiServiceApiDetail } from "@core/const/ai-service/type.ts";
|
||||
|
||||
const AiServiceInsideApiDocument = forwardRef<AiServiceInsideApiDocumentHandle, AiServiceInsideApiDocumentProps>(() => {
|
||||
const { serviceId, teamId } = useParams<RouterParams>()
|
||||
const { fetchData } = useFetch()
|
||||
const [apiDetail, setApiDetail] = useState<AiServiceApiDetail>()
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const AiServiceInsideApiDocument = forwardRef<AiServiceInsideApiDocumentHandle,AiServiceInsideApiDocumentProps>(() => {
|
||||
const {serviceId, teamId} = useParams<RouterParams>()
|
||||
const {fetchData} = useFetch()
|
||||
const [apiDetail, setApiDetail] = useState<AiServiceApiDetail>()
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
useEffect(() => {
|
||||
getApiDetail()
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getApiDetail()
|
||||
}, [])
|
||||
const getApiDetail = ()=>{
|
||||
setLoading(true)
|
||||
fetchData<BasicResponse<{doc:AiServiceApiDetail}>>('service/api_doc',{method:'GET',eoParams:{service:serviceId,team:teamId },eoTransformKeys:['update_time']}).then(response=>{
|
||||
const {code,data,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
setApiDetail(data.doc?.content)
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
}).finally(()=>{setLoading(false)})
|
||||
}
|
||||
|
||||
const getApiDetail = () => {
|
||||
setLoading(true)
|
||||
fetchData<BasicResponse<{ doc: AiServiceApiDetail }>>('service/api_doc', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId },
|
||||
eoTransformKeys: ['update_time']
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setApiDetail(data.doc?.content)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
const ApiPreview = ({ spec }: { spec?: string | object }) => {
|
||||
return (
|
||||
<div className="h-full overflow-hidden">
|
||||
<div className="flex-1 h-full overflow-auto pr-PAGE_INSIDE_X">
|
||||
<ApiDocument spec={spec} />
|
||||
const ApiPreview = ({spec}:{spec?:string | object})=>{
|
||||
return (
|
||||
<div className="h-full overflow-hidden">
|
||||
<div className="flex-1 h-full overflow-auto pr-PAGE_INSIDE_X">
|
||||
<ApiDocument spec={spec}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Spin
|
||||
indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />}
|
||||
spinning={loading}
|
||||
wrapperClassName=" h-full overflow-hidden "
|
||||
>
|
||||
<div className=" h-full ai-service-api-preview">
|
||||
{apiDetail ? <ApiPreview spec={apiDetail} /> : <Empty image={EmptySVG}></Empty>}
|
||||
</div>
|
||||
</Spin>
|
||||
</>
|
||||
)
|
||||
|
||||
return (<>
|
||||
<Spin indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />} spinning={loading} wrapperClassName=' h-full overflow-hidden '>
|
||||
<div className=" h-full ai-service-api-preview">
|
||||
{ apiDetail ? <ApiPreview spec={apiDetail} />
|
||||
: <Empty image={EmptySVG} >
|
||||
</Empty>}
|
||||
</div>
|
||||
</Spin>
|
||||
</>)
|
||||
})
|
||||
|
||||
export default AiServiceInsideApiDocument
|
||||
export default AiServiceInsideApiDocument
|
||||
@@ -21,7 +21,6 @@ import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import AiServiceRouterModelConfig, { AiServiceRouterModelConfigHandle } from './AiServiceInsideRouterModelConfig'
|
||||
import { AiProviderDefaultConfig, AiProviderLlmsItems } from '@core/pages/aiSetting/types'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext'
|
||||
|
||||
type AiServiceRouterField = {
|
||||
name: string
|
||||
@@ -67,7 +66,6 @@ const AiServiceInsideRouterCreate = () => {
|
||||
const [variablesTableRef, setVariablesTableRef] = useState<MutableRefObject<EditableFormInstance<T> | undefined>>()
|
||||
const { state } = useGlobalContext()
|
||||
const [resultPath, setResultPath] = useState<string>('')
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
|
||||
const onFinish = () => {
|
||||
return variablesTableRef?.current
|
||||
@@ -365,6 +363,11 @@ const AiServiceInsideRouterCreate = () => {
|
||||
setDrawerType(undefined)
|
||||
}
|
||||
|
||||
const apiPathMatchRulesOptions = useMemo(
|
||||
() => API_PATH_MATCH_RULES.map((x) => ({ label: $t(x.label), value: x.value })),
|
||||
[state.language]
|
||||
)
|
||||
|
||||
return (
|
||||
<InsidePage
|
||||
pageTitle={$t('AI 路由设置') || '-'}
|
||||
|
||||
@@ -3,6 +3,7 @@ import PageList, { PageProColumns } from '@common/components/aoplatform/PageList
|
||||
import TableBtnWithPermission from '@common/components/aoplatform/TableBtnWithPermission.tsx'
|
||||
import { BasicResponse, COLUMNS_TITLE, DELETE_TIPS, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const.tsx'
|
||||
import { SimpleMemberItem } from '@common/const/type.ts'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
@@ -16,6 +17,7 @@ import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
|
||||
const AiServiceInsideRouterList: FC = () => {
|
||||
const [searchWord, setSearchWord] = useState<string>('')
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { modal, message } = App.useApp()
|
||||
const [tableListDataSource, setTableListDataSource] = useState<AiServiceRouterTableListItem[]>([])
|
||||
const [tableHttpReload, setTableHttpReload] = useState(true)
|
||||
@@ -157,6 +159,14 @@ const AiServiceInsideRouterList: FC = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: <Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title: $t('路由')
|
||||
}
|
||||
])
|
||||
getMemberList()
|
||||
manualReloadTable()
|
||||
}, [serviceId])
|
||||
|
||||
@@ -163,8 +163,6 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
|
||||
>
|
||||
<Form.Item<AiServiceRouterModelConfigField> label={$t('模型类型')} name="type" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={modelTypeList}
|
||||
|
||||
+11
-1
@@ -1,8 +1,9 @@
|
||||
|
||||
import {ActionType} from "@ant-design/pro-components";
|
||||
import {FC, useEffect, useMemo, useRef, useState} from "react";
|
||||
import {Link, useLocation, useNavigate, useParams} from "react-router-dom";
|
||||
import {Link, useLocation, useParams} from "react-router-dom";
|
||||
import PageList, { PageProColumns } from "@common/components/aoplatform/PageList.tsx";
|
||||
import {useBreadcrumb} from "@common/contexts/BreadcrumbContext.tsx";
|
||||
import {App, Button} from "antd";
|
||||
import {
|
||||
SUBSCRIBE_APPROVAL_INNER_DONE_TABLE_COLUMN,
|
||||
@@ -25,6 +26,7 @@ import { SubscribeApprovalInfoType } from "@common/const/approval/type.tsx";
|
||||
import { $t } from "@common/locales";
|
||||
|
||||
const AiServiceInsideApprovalList:FC = ()=>{
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { modal,message } = App.useApp()
|
||||
const {serviceId, teamId} = useParams<RouterParams>();
|
||||
const [init, setInit] = useState<boolean>(true)
|
||||
@@ -139,6 +141,14 @@ const AiServiceInsideApprovalList:FC = ()=>{
|
||||
}, [query]);
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title:<Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title:$t('订阅审核')
|
||||
}
|
||||
])
|
||||
getMemberList()
|
||||
manualReloadTable()
|
||||
}, [serviceId]);
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
import { Tabs } from "antd"
|
||||
import { useState, useEffect, FC, useMemo } from "react"
|
||||
import { Link, Outlet, useLocation, useNavigate } from "react-router-dom"
|
||||
import { useBreadcrumb } from "@common/contexts/BreadcrumbContext"
|
||||
import { SYSTEM_PUBLISH_TAB_ITEMS } from "../../../const/system/const"
|
||||
import { $t } from "@common/locales"
|
||||
import { useGlobalContext } from "@common/contexts/GlobalStateContext"
|
||||
|
||||
const AiServiceInsidePublic:FC = ()=>{
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const query =new URLSearchParams(useLocation().search)
|
||||
const location = useLocation()
|
||||
const currentUrl = location.pathname
|
||||
@@ -23,6 +25,17 @@ const AiServiceInsidePublic:FC = ()=>{
|
||||
setPageStatus(Number(query.get('status') ||0) as 0|1)
|
||||
}, [currentUrl]);
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title:<Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title:$t('发布')
|
||||
}
|
||||
])
|
||||
}, []);
|
||||
|
||||
const tabItems = useMemo(()=>SYSTEM_PUBLISH_TAB_ITEMS?.map((x)=>({...x, label:$t(x.label as string) })),[state.language])
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ActionType, ParamsType } from "@ant-design/pro-components";
|
||||
import { App, Button, Divider } from "antd";
|
||||
import { useState, useRef, useEffect, useMemo, FC } from "react";
|
||||
import { useParams, Link, useLocation, useNavigate } from "react-router-dom";
|
||||
import { useParams, Link, useLocation } from "react-router-dom";
|
||||
import PageList, { PageProColumns } from "@common/components/aoplatform/PageList";
|
||||
import { PublishApprovalModalContent } from "@common/components/aoplatform/PublishApprovalModalContent";
|
||||
import { RouterParams } from "@core/components/aoplatform/RenderRoutes";
|
||||
@@ -9,6 +9,7 @@ import { PUBLISH_APPROVAL_RECORD_INNER_TABLE_COLUMN, PUBLISH_APPROVAL_VERSION_IN
|
||||
import { BasicResponse, COLUMNS_TITLE, DELETE_TIPS, RESPONSE_TIPS, STATUS_CODE } from "@common/const/const";
|
||||
import { SimpleMemberItem } from "@common/const/type.ts";
|
||||
import { MemberTableListItem } from "../../../const/member/type";
|
||||
import { useBreadcrumb } from "@common/contexts/BreadcrumbContext";
|
||||
import { useFetch } from "@common/hooks/http";
|
||||
import WithPermission from "@common/components/aoplatform/WithPermission";
|
||||
import { AiServicePublishReleaseItem } from "../../../const/system/type";
|
||||
@@ -22,6 +23,7 @@ import { DrawerWithFooter } from "@common/components/aoplatform/DrawerWithFooter
|
||||
import { $t } from "@common/locales";
|
||||
|
||||
const AiServiceInsidePublicList:FC = ()=>{
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { modal,message } = App.useApp()
|
||||
const pageListRef = useRef<ActionType>(null);
|
||||
const [tableHttpReload, setTableHttpReload] = useState(true);
|
||||
@@ -348,6 +350,14 @@ const AiServiceInsidePublicList:FC = ()=>{
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title:<Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title:$t('发布')
|
||||
}
|
||||
])
|
||||
getMemberList()
|
||||
manualReloadTable()
|
||||
}, [serviceId]);
|
||||
|
||||
@@ -390,8 +390,6 @@ const AiSettingModalContent = forwardRef<AiSettingModalContentHandle, AiSettingM
|
||||
{source === 'guide' && (
|
||||
<Form.Item label={$t('所属团队')} name="team" className="mt-[16px]" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={teamList}
|
||||
|
||||
@@ -86,9 +86,9 @@ export default function ApiRequestSetting() {
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<ApiRequestSettingFieldType>
|
||||
label={$t('OpenAPI & MCP 调用地址')}
|
||||
label={$t('集成地址')}
|
||||
name="sitePrefix"
|
||||
rules={[{ required: true, whitespace: true }]}
|
||||
rules={[{ whitespace: true }]}
|
||||
extra={$t('与外部平台集成时,获取 API 市场中文档信息的域名')}
|
||||
>
|
||||
<Input className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} />
|
||||
|
||||
@@ -181,8 +181,6 @@ const LocalAiDeploy = forwardRef<LocalAiDeployHandle, any>((props: any, ref: any
|
||||
</Form.Item>
|
||||
<Form.Item label={$t('所属团队')} name="team" className="mt-[16px]" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={teamList}
|
||||
|
||||
@@ -106,8 +106,6 @@ const RestAIDeploy = forwardRef<RestAIDeployHandle, any>((props: any, ref: any)
|
||||
</Form.Item>
|
||||
<Form.Item label={$t('所属团队')} name="team" className="mt-[16px]" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={teamList}
|
||||
|
||||
@@ -39,7 +39,6 @@ const ApiKeyContent: React.FC<ApiKeyContentProps> = forwardRef(({ provider, enti
|
||||
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
// 表单校验
|
||||
const values = await form.validateFields()
|
||||
const { expire_time, ...restValues } = values
|
||||
const expireTime = neverExpire ? 0 : Math.trunc(expire_time.valueOf() / 1000)
|
||||
|
||||
@@ -171,8 +171,6 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
|
||||
>
|
||||
<Form.Item<LoadModelDetailData> label={$t('模型类型')} name="type" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={modelTypeList}
|
||||
|
||||
@@ -68,7 +68,7 @@ const LogSettings = () => {
|
||||
<>
|
||||
<Skeleton className="m-btnbase w-calc-100vw-minus-padding-r" active loading={loading}>
|
||||
<InsidePage
|
||||
pageTitle={$t('日志输出设置')}
|
||||
pageTitle={$t('日志配置')}
|
||||
description={'APIPark ' + $t('提供详尽的 API 调用日志,帮助企业监控、分析和审计 API 的运行状况。')}
|
||||
>
|
||||
<div className="flex h-full">
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
import { App, Form, Input } from 'antd'
|
||||
import { $t } from '@common/locales'
|
||||
import { BasicResponse, PLACEHOLDER, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import { forwardRef, useEffect, useImperativeHandle } from 'react'
|
||||
type modelFieldType = {
|
||||
name: string
|
||||
type: string
|
||||
model_parameters: string
|
||||
access_configuration: string
|
||||
}
|
||||
|
||||
export type addMcpKeysHandle = {
|
||||
save: () => Promise<boolean | string>
|
||||
}
|
||||
|
||||
type addMcpKeysProps = {
|
||||
name?: string
|
||||
value?: string
|
||||
type?: string
|
||||
apikey?: string
|
||||
}
|
||||
|
||||
const AddMcpKey = forwardRef<addMcpKeysHandle, addMcpKeysProps>((props, ref) => {
|
||||
const { name = '', value: editValue = '', type = 'new', apikey = '' } = props
|
||||
const [form] = Form.useForm()
|
||||
const { message } = App.useApp()
|
||||
const { fetchData } = useFetch()
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({
|
||||
name,
|
||||
value: editValue
|
||||
})
|
||||
}, [])
|
||||
/**
|
||||
* 保存
|
||||
* @returns
|
||||
*/
|
||||
const save: () => Promise<boolean | string> = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
form
|
||||
.validateFields()
|
||||
.then((value) => {
|
||||
console.log('value', value)
|
||||
const finalValue = {
|
||||
...value,
|
||||
value: editValue ? editValue : uuidv4(),
|
||||
expired: 0
|
||||
}
|
||||
fetchData<BasicResponse<any>>('system/apikey', {
|
||||
method: type === 'new' ? 'POST' : 'PUT',
|
||||
eoBody: finalValue,
|
||||
...(type === 'edit' ? {
|
||||
eoParams: { apikey }
|
||||
} : {})
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
message.success($t(RESPONSE_TIPS.success) || msg)
|
||||
resolve(true)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
reject(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.catch((errorInfo) => reject(errorInfo))
|
||||
})
|
||||
.catch((errorInfo) => reject(errorInfo))
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
save
|
||||
}))
|
||||
|
||||
return (
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
labelAlign="left"
|
||||
scrollToFirstError
|
||||
className="flex flex-col mx-auto h-full"
|
||||
name="mcpKeyModalConfig"
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item<modelFieldType> label={$t('名称')} name="name" rules={[{ required: true }]}>
|
||||
<Input autoFocus className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
)
|
||||
})
|
||||
|
||||
export default AddMcpKey
|
||||
@@ -1,601 +0,0 @@
|
||||
import { App, Button, Card, CascaderProps, Empty, Select } from 'antd'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { Icon } from '@iconify/react/dist/iconify.js'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||
import ReactJson from 'react-json-view'
|
||||
import { IconButton } from '@common/components/postcat/api/IconButton'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { useConnection } from './hook/useConnection'
|
||||
import { ClientRequest, Tool, ListToolsResultSchema } from '@modelcontextprotocol/sdk/types.js'
|
||||
import { z } from 'zod'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { ServiceDetailType } from '@market/const/serviceHub/type'
|
||||
import useCopyToClipboard from '@common/hooks/copy'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
import { Cascader } from 'antd/lib'
|
||||
|
||||
type ConfigList = {
|
||||
openApi?: {
|
||||
title: string
|
||||
configContent: string
|
||||
apiKeys: string[]
|
||||
}
|
||||
mcp: {
|
||||
title: string
|
||||
configContent: string
|
||||
apiKeys: string[]
|
||||
}
|
||||
}
|
||||
|
||||
type ApiKeyItem = {
|
||||
expired: number
|
||||
id: string
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
interface Option {
|
||||
value: string
|
||||
label: string
|
||||
children?: Option[]
|
||||
}
|
||||
|
||||
type ServiceApiKeyList = {
|
||||
id: string
|
||||
name: string
|
||||
apikeys: Array<{
|
||||
id: string
|
||||
name: string
|
||||
value: string
|
||||
expired: number
|
||||
}>
|
||||
}
|
||||
export interface IntegrationAIContainerRef {
|
||||
getServiceKeysList: () => void;
|
||||
}
|
||||
export interface IntegrationAIContainerProps {
|
||||
type: 'global' | 'service'
|
||||
handleToolsChange: (value: Tool[]) => void
|
||||
customClassName?: string
|
||||
service?: ServiceDetailType
|
||||
serviceId?: string
|
||||
currentTab?: string
|
||||
openModal?: (type: 'apply') => void
|
||||
}
|
||||
export const IntegrationAIContainer = forwardRef<IntegrationAIContainerRef, IntegrationAIContainerProps>(
|
||||
({
|
||||
type,
|
||||
handleToolsChange,
|
||||
customClassName,
|
||||
service,
|
||||
serviceId,
|
||||
currentTab,
|
||||
openModal
|
||||
}: IntegrationAIContainerProps, ref) => {
|
||||
/** 当前激活的标签 */
|
||||
const [activeTab, setActiveTab] = useState(type === 'service' ? 'openApi' : 'mcp')
|
||||
/** 弹窗组件 */
|
||||
const { message } = App.useApp()
|
||||
/** 配置内容 */
|
||||
const [configContent, setConfigContent] = useState<string>('')
|
||||
/** 当前选中 API Key */
|
||||
const [apiKey, setApiKey] = useState<string>('')
|
||||
/** API Key 列表 */
|
||||
const [apiKeyList, setApiKeyList] = useState<any[]>([])
|
||||
/** Cascader Key 列表 */
|
||||
const [cascaderKeyList, setCascaderKeyList] = useState<string[]>([])
|
||||
/** MCP 服务器地址 */
|
||||
const [mcpServerUrl, setMcpServerUrl] = useState<string>('')
|
||||
/** 全局状态 */
|
||||
const { state } = useGlobalContext()
|
||||
const navigator = useNavigate()
|
||||
/** 复制组件 */
|
||||
const { copyToClipboard } = useCopyToClipboard()
|
||||
/** 错误提示 */
|
||||
const [errors, setErrors] = useState<Record<string, string | null>>({
|
||||
resources: null,
|
||||
prompts: null,
|
||||
tools: null
|
||||
})
|
||||
/** 标签内容 */
|
||||
const [tabContent, setTabContent] = useState<ConfigList>({
|
||||
mcp: {
|
||||
title: $t('MCP 配置'),
|
||||
configContent: '',
|
||||
apiKeys: []
|
||||
}
|
||||
})
|
||||
/** HTTP 请求 */
|
||||
const { fetchData } = useFetch()
|
||||
|
||||
/**
|
||||
* 初始化标签数据
|
||||
*/
|
||||
const initTabsData = () => {
|
||||
const params: ConfigList = {
|
||||
mcp: {
|
||||
title: $t('MCP 配置'),
|
||||
configContent: service?.mcpAccessConfig || '',
|
||||
apiKeys: []
|
||||
}
|
||||
}
|
||||
if (type === 'service') {
|
||||
params.openApi = {
|
||||
title: $t('Open API 文档'),
|
||||
configContent: service?.openapiAddress || '',
|
||||
apiKeys: []
|
||||
}
|
||||
}
|
||||
setTabContent(params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
const handleCopy = async (value: string): Promise<void> => {
|
||||
if (value) {
|
||||
copyToClipboard(value)
|
||||
message.success($t(RESPONSE_TIPS.copySuccess))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择 API Key
|
||||
* @param value
|
||||
*/
|
||||
const handleSelectChange = (value: string) => {
|
||||
setApiKey(value)
|
||||
}
|
||||
/**
|
||||
* Cascader 选择
|
||||
* @param value
|
||||
*/
|
||||
const handleCascaderChange: CascaderProps<Option>['onChange'] = (value) => {
|
||||
setApiKey(value.at(-1) || '')
|
||||
setCascaderKeyList(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局 MCP 配置
|
||||
* @returns
|
||||
*/
|
||||
const getGlobalMcpConfig = () => {
|
||||
fetchData<BasicResponse<null>>('global/mcp/config', {
|
||||
method: 'GET'
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg, data } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setTabContent((prevTabContent) => ({
|
||||
...prevTabContent,
|
||||
mcp: {
|
||||
...prevTabContent.mcp,
|
||||
configContent: data.config || ''
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.catch((errorInfo) => {
|
||||
message.error(errorInfo || $t(RESPONSE_TIPS.error))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局 MCP 跳转
|
||||
*/
|
||||
const addKey = () => {
|
||||
navigator('/mcpKey')
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全局 API Key 列表
|
||||
*/
|
||||
const getGlobalKeysList = () => {
|
||||
fetchData<BasicResponse<null>>('simple/system/apikeys', {
|
||||
method: 'GET'
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg, data } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
if (data.apikeys && data.apikeys.length > 0) {
|
||||
setApiKeyList(
|
||||
data.apikeys.map((item: ApiKeyItem) => {
|
||||
return {
|
||||
label: item.name,
|
||||
value: item.value
|
||||
}
|
||||
})
|
||||
)
|
||||
setApiKey(data.apikeys[0].value)
|
||||
}
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.catch((errorInfo) => {
|
||||
message.error(errorInfo || $t(RESPONSE_TIPS.error))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 抛出获取服务 API Key 列表
|
||||
*/
|
||||
useImperativeHandle(ref, () => ({
|
||||
getServiceKeysList
|
||||
}))
|
||||
|
||||
/**
|
||||
* 获取服务 API Key 列表
|
||||
*/
|
||||
const getServiceKeysList = () => {
|
||||
fetchData<BasicResponse<null>>(`my/app/apikeys`, {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId }
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg, data } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
if (data.apps && data.apps.length > 0) {
|
||||
// 转换数据结构为 Cascader 所需格式
|
||||
const transformedData = data.apps.map((app: ServiceApiKeyList) => ({
|
||||
value: app.id,
|
||||
label: app.name,
|
||||
children: app.apikeys.map((key) => ({
|
||||
...key,
|
||||
label: key.name
|
||||
}))
|
||||
}))
|
||||
setApiKeyList(transformedData)
|
||||
if (data.apps[0].apikeys?.length) {
|
||||
setApiKey(data.apps[0].apikeys[0].value)
|
||||
setCascaderKeyList([data.apps[0].id, data.apps[0].apikeys[0].value])
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((errorInfo) => {
|
||||
message.error(errorInfo || $t(RESPONSE_TIPS.error))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除错误提示
|
||||
*/
|
||||
const clearError = (tabKey: keyof typeof errors) => {
|
||||
setErrors((prev) => ({ ...prev, [tabKey]: null }))
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送请求
|
||||
*/
|
||||
const makeRequest = async <T extends z.ZodType>(request: ClientRequest, schema: T, tabKey?: keyof typeof errors) => {
|
||||
try {
|
||||
const response = await makeConnectionRequest(request, schema)
|
||||
if (tabKey !== undefined) {
|
||||
clearError(tabKey)
|
||||
}
|
||||
return response
|
||||
} catch (e) {
|
||||
const errorString = (e as Error).message ?? String(e)
|
||||
if (tabKey !== undefined) {
|
||||
setErrors((prev) => ({
|
||||
...prev,
|
||||
[tabKey]: errorString
|
||||
}))
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 MCP 的 tools
|
||||
*/
|
||||
const listTools = async () => {
|
||||
const response = await makeRequest(
|
||||
{
|
||||
method: 'tools/list' as const,
|
||||
params: {}
|
||||
},
|
||||
ListToolsResultSchema,
|
||||
'tools'
|
||||
)
|
||||
handleToolsChange(response.tools)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化连接 mcp
|
||||
*/
|
||||
const {
|
||||
connectionStatus,
|
||||
serverCapabilities,
|
||||
mcpClient,
|
||||
requestHistory,
|
||||
makeRequest: makeConnectionRequest,
|
||||
sendNotification,
|
||||
handleCompletion,
|
||||
completionsSupported,
|
||||
connect: connectMcpServer,
|
||||
disconnect: disconnectMcpServer
|
||||
} = useConnection({
|
||||
transportType: 'sse',
|
||||
sseUrl: '',
|
||||
proxyServerUrl: mcpServerUrl,
|
||||
requestTimeout: 1000
|
||||
})
|
||||
// 使用 useRef 保存最新的连接状态和断开函数
|
||||
const connectionStatusRef = useRef(connectionStatus)
|
||||
const disconnectFnRef = useRef(disconnectMcpServer)
|
||||
|
||||
// 当连接状态或断开函数变化时更新 ref
|
||||
useEffect(() => {
|
||||
connectionStatusRef.current = connectionStatus
|
||||
disconnectFnRef.current = disconnectMcpServer
|
||||
}, [connectionStatus, disconnectMcpServer])
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
const setupComponent = () => {
|
||||
initTabsData()
|
||||
if (type === 'global') {
|
||||
getGlobalMcpConfig()
|
||||
setMcpServerUrl('mcp/global/sse')
|
||||
getGlobalKeysList()
|
||||
} else {
|
||||
service?.basic.enableMcp && setMcpServerUrl(`mcp/service/${serviceId}/sse`)
|
||||
getServiceKeysList()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
useEffect(() => {
|
||||
setupComponent()
|
||||
}, [service])
|
||||
/**
|
||||
* 初始化标签数据
|
||||
*/
|
||||
useEffect(() => {
|
||||
initTabsData()
|
||||
type === 'global' && getGlobalMcpConfig()
|
||||
}, [state.language])
|
||||
/**
|
||||
* 切换标签
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (type === 'service') {
|
||||
currentTab === 'MCP' ? setActiveTab('mcp') : setActiveTab('openApi')
|
||||
}
|
||||
}, [currentTab])
|
||||
/**
|
||||
* 仅在组件加载时执行初始化逻辑
|
||||
*/
|
||||
useEffect(() => {
|
||||
// 返回清理函数,只会在组件卸载时执行
|
||||
return () => {
|
||||
try {
|
||||
// 使用 ref 中保存的最新函数强制断开连接
|
||||
const disconnectFn = disconnectFnRef.current
|
||||
if (disconnectFn) {
|
||||
disconnectFn()
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('断开连接时出错:', err)
|
||||
}
|
||||
}
|
||||
}, [type])
|
||||
/**
|
||||
* 切换标签时更新配置内容
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (activeTab === 'openApi' && tabContent?.openApi?.configContent) {
|
||||
setConfigContent(tabContent?.openApi?.configContent)
|
||||
} else if (activeTab === 'mcp' && tabContent?.mcp?.configContent) {
|
||||
setConfigContent(tabContent.mcp.configContent?.replace('{your_api_key}', apiKey || '{your_api_key}'))
|
||||
}
|
||||
}, [service, apiKey, activeTab, tabContent])
|
||||
/**
|
||||
* 连接 MCP 服务器
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (mcpServerUrl) {
|
||||
if (connectionStatus === 'connected') {
|
||||
disconnectMcpServer()
|
||||
}
|
||||
connectMcpServer()
|
||||
}
|
||||
}, [mcpServerUrl, ...(type === 'global' ? [state.language] : [])])
|
||||
/**
|
||||
* 获取 MCP tools
|
||||
*/
|
||||
useEffect(() => {
|
||||
if (connectionStatus === 'connected') {
|
||||
listTools()
|
||||
}
|
||||
}, [connectionStatus])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
style={{ borderRadius: '10px' }}
|
||||
className={`w-[400px] h-fit ${customClassName}`}
|
||||
classNames={{
|
||||
body: 'p-[10px]'
|
||||
}}
|
||||
>
|
||||
<p>
|
||||
<Icon
|
||||
icon="icon-park-solid:connection-point-two"
|
||||
className="align-text-bottom mr-[5px]"
|
||||
width="16"
|
||||
height="16"
|
||||
/>
|
||||
{$t('AI 代理集成')}
|
||||
</p>
|
||||
{type === 'service' && service?.basic.enableMcp && (
|
||||
<div className="mt-3 tab-nav flex rounded-md overflow-hidden border border-solid border-[#3D46F2] w-fit">
|
||||
<div
|
||||
className={`tab-item px-5 py-1.5 cursor-pointer text-sm transition-colors ${activeTab === 'openApi' ? 'bg-[#3D46F2] text-white' : 'bg-white text-[#3D46F2]'}`}
|
||||
onClick={() => setActiveTab('openApi')}
|
||||
>
|
||||
Open API
|
||||
</div>
|
||||
<div
|
||||
className={`tab-item px-5 py-1.5 cursor-pointer text-sm transition-colors ${activeTab === 'mcp' ? 'bg-[#3D46F2] text-white' : 'bg-white text-[#3D46F2]'}`}
|
||||
onClick={() => setActiveTab('mcp')}
|
||||
>
|
||||
MCP
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{type === 'service' && !apiKeyList.length ? (
|
||||
<>
|
||||
<Card
|
||||
style={{ borderRadius: '10px' }}
|
||||
className={`w-full mt-3`}
|
||||
classNames={{
|
||||
body: 'p-[10px]'
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-col items-center justify-center py-3">
|
||||
<span className="text-[14px] mb-5">{$t('请先订阅该服务')}</span>
|
||||
<Button type="primary" onClick={() => openModal?.('apply')}>
|
||||
{$t('申请')}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="tab-container mt-3">
|
||||
<div className="tab-content font-semibold mt-[10px]">
|
||||
{activeTab === 'openApi' ? tabContent.openApi?.title : tabContent.mcp.title}
|
||||
</div>
|
||||
{/* 标签页内容区域 */}
|
||||
<div className="bg-[#0a0b21] text-white p-4 rounded-md my-2 font-mono text-sm overflow-auto relative">
|
||||
{activeTab === 'mcp' ? (
|
||||
<ReactJson
|
||||
src={
|
||||
configContent
|
||||
? typeof configContent === 'string'
|
||||
? (() => {
|
||||
try {
|
||||
return JSON.parse(configContent)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
})()
|
||||
: configContent
|
||||
: {}
|
||||
}
|
||||
theme="monokai"
|
||||
indentWidth={2}
|
||||
displayDataTypes={false}
|
||||
displayObjectSize={false}
|
||||
name={false}
|
||||
collapsed={false}
|
||||
enableClipboard={false}
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
wordBreak: 'break-word',
|
||||
whiteSpace: 'normal'
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<pre className="whitespace-pre-wrap break-words">{configContent || ''}</pre>
|
||||
</>
|
||||
)}
|
||||
<IconButton
|
||||
name="copy"
|
||||
onClick={() => handleCopy(configContent)}
|
||||
sx={{
|
||||
position: 'absolute',
|
||||
top: '5px',
|
||||
right: '5px',
|
||||
color: '#999',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
</div>
|
||||
</div>
|
||||
{activeTab === 'mcp' && (
|
||||
<>
|
||||
<div className="tab-content font-semibold my-[10px]">API Key</div>
|
||||
{apiKeyList.length ? (
|
||||
<>
|
||||
{type === 'global' ? (
|
||||
<>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
value={apiKey}
|
||||
className="w-full"
|
||||
onChange={handleSelectChange}
|
||||
options={apiKeyList}
|
||||
/>
|
||||
<Card
|
||||
style={{ borderRadius: '5px' }}
|
||||
className="w-full mt-[5px] "
|
||||
classNames={{
|
||||
body: 'p-[5px]'
|
||||
}}
|
||||
>
|
||||
<div className="relative h-[25px]">
|
||||
{apiKey}
|
||||
<IconButton
|
||||
name="copy"
|
||||
onClick={() => handleCopy(apiKey)}
|
||||
sx={{
|
||||
position: 'absolute',
|
||||
top: '0px',
|
||||
right: '5px',
|
||||
color: '#999',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Cascader
|
||||
className='w-full'
|
||||
allowClear={false}
|
||||
options={apiKeyList}
|
||||
value={cascaderKeyList}
|
||||
onChange={handleCascaderChange}
|
||||
placeholder={$t('选择 API Key')}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={''}>
|
||||
<Button onClick={addKey} type="primary">
|
||||
{$t('新增 API Key')}
|
||||
</Button>
|
||||
</Empty>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
</>
|
||||
)
|
||||
})
|
||||
@@ -1,209 +0,0 @@
|
||||
import InsidePage from '@common/components/aoplatform/InsidePage'
|
||||
import { IconButton } from '@common/components/postcat/api/IconButton'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { Button, Card, App, Empty } from 'antd'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import AddMcpKey, { addMcpKeysHandle } from './AddMcpKey'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
|
||||
const McpKeyContainer = () => {
|
||||
const { fetchData } = useFetch()
|
||||
const { message, modal } = App.useApp()
|
||||
const [keys, setKeys] = useState<any[]>([])
|
||||
const [, forceUpdate] = useState<unknown>(null)
|
||||
const { state } = useGlobalContext()
|
||||
const addMcpKeyModalRef = useRef<addMcpKeysHandle>(null)
|
||||
|
||||
/**
|
||||
* 新增 API Key
|
||||
*/
|
||||
const addKey = () => {
|
||||
modal.confirm({
|
||||
title: $t('新增 API Key'),
|
||||
content: <AddMcpKey ref={addMcpKeyModalRef}></AddMcpKey>,
|
||||
onOk: () => {
|
||||
return addMcpKeyModalRef.current?.save().then((res) => {
|
||||
if (res) {
|
||||
getKeysList()
|
||||
}
|
||||
})
|
||||
},
|
||||
width: 600,
|
||||
okText: $t('确认'),
|
||||
cancelText: $t('取消'),
|
||||
closable: true,
|
||||
icon: <></>
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 API Key 列表
|
||||
*/
|
||||
const getKeysList = () => {
|
||||
fetchData<BasicResponse<null>>('system/apikeys', {
|
||||
method: 'GET'
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg, data } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setKeys(data.apikeys || [])
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.catch((errorInfo) => {
|
||||
message.error(errorInfo || $t(RESPONSE_TIPS.error))
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制 API Key
|
||||
*/
|
||||
const copyCode = async (value: string): Promise<void> => {
|
||||
if (value) {
|
||||
await navigator.clipboard.writeText(value)
|
||||
message.success($t(RESPONSE_TIPS.copySuccess))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 API Key
|
||||
*/
|
||||
const deleteKey = (id: string) => {
|
||||
modal.confirm({
|
||||
title: $t('删除'),
|
||||
content: $t('确定删除吗?'),
|
||||
onOk: async () => {
|
||||
try {
|
||||
const response = await fetchData<BasicResponse<'success'>>('system/apikey', {
|
||||
method: 'DELETE',
|
||||
eoParams: { apikey: id }
|
||||
})
|
||||
if (response.code === STATUS_CODE.SUCCESS) {
|
||||
message.success($t('删除成功'))
|
||||
getKeysList()
|
||||
}
|
||||
} catch (error) {
|
||||
message.error($t('删除失败'))
|
||||
}
|
||||
},
|
||||
width: 600,
|
||||
okText: $t('确认'),
|
||||
cancelText: $t('取消'),
|
||||
closable: true,
|
||||
icon: <></>
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑 API Key
|
||||
*/
|
||||
const editKey = (key: any) => {
|
||||
modal.confirm({
|
||||
title: $t('编辑'),
|
||||
content: (
|
||||
<AddMcpKey ref={addMcpKeyModalRef} name={key.name} value={key.value} apikey={key.id} type={'edit'}></AddMcpKey>
|
||||
),
|
||||
onOk: () => {
|
||||
return addMcpKeyModalRef.current?.save().then((res) => {
|
||||
if (res) {
|
||||
getKeysList()
|
||||
}
|
||||
})
|
||||
},
|
||||
width: 600,
|
||||
okText: $t('确认'),
|
||||
cancelText: $t('取消'),
|
||||
closable: true,
|
||||
icon: <></>
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getKeysList()
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
forceUpdate({})
|
||||
}, [state.language])
|
||||
return (
|
||||
<>
|
||||
<InsidePage
|
||||
pageTitle={$t('API Key')}
|
||||
description={$t('API 密钥可用于调用系统级 Open API 和 MCP。')}
|
||||
showBorder={false}
|
||||
scrollPage={false}
|
||||
>
|
||||
<Button type="primary" onClick={addKey}>
|
||||
{$t('新增 API Key')}
|
||||
</Button>
|
||||
<div className="api-key-container mt-[20px]">
|
||||
{keys.length ? (
|
||||
keys.map((key, index) => (
|
||||
<Card style={{ width: 600, borderRadius: '10px' }} key={index} className="mt-[10px]">
|
||||
<div className="flex">
|
||||
<div className="flex-1">
|
||||
<p className="text-[14px] font-bold">{key.name}</p>
|
||||
<div className="flex">
|
||||
<span className="h-[26px] leading-[28px]">{key.value}</span>
|
||||
<IconButton
|
||||
name="copy"
|
||||
onClick={() => {
|
||||
copyCode(key?.value)
|
||||
}}
|
||||
sx={{
|
||||
color: '#333',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-[30px] flex justify-center items-center">
|
||||
<IconButton
|
||||
name="edit"
|
||||
onClick={() => {
|
||||
editKey(key)
|
||||
}}
|
||||
sx={{
|
||||
color: '#333',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
<IconButton
|
||||
name="delete"
|
||||
onClick={() => {
|
||||
deleteKey(key.id)
|
||||
}}
|
||||
sx={{
|
||||
color: '#333',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': { background: 'transparent', color: 'red', transition: 'none' }
|
||||
}}
|
||||
></IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<>
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE}/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</InsidePage>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default McpKeyContainer
|
||||
@@ -1,37 +0,0 @@
|
||||
import InsidePage from "@common/components/aoplatform/InsidePage"
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { IntegrationAIContainer } from "./IntegrationAIContainer"
|
||||
import { Tool } from "@modelcontextprotocol/sdk/types.js"
|
||||
import { useEffect, useState } from "react"
|
||||
import McpToolsContainer from "./McpToolsContainer"
|
||||
import { useGlobalContext } from "@common/contexts/GlobalStateContext"
|
||||
|
||||
const McpServiceContainer = () => {
|
||||
const [tools, setTools] = useState<Tool[]>([]);
|
||||
const [, forceUpdate] = useState<unknown>(null)
|
||||
const { state } = useGlobalContext()
|
||||
const handleToolsChange = (value: Tool[]) => {
|
||||
setTools(value)
|
||||
}
|
||||
useEffect(() => {
|
||||
forceUpdate({})
|
||||
}, [state.language])
|
||||
return (
|
||||
<>
|
||||
<InsidePage
|
||||
pageTitle={$t('MCP 服务')}
|
||||
description={$t('MCP Service 充当 AI 模型与 API 之间的桥梁,允许智能助手(如 Claude)动态发现和调用 Gateway 上的 API,无需繁琐的手动配置或自定义集成。')}
|
||||
showBorder={false}
|
||||
scrollPage={false}
|
||||
>
|
||||
|
||||
<div className="flex mt-[10px] pr-[40px]">
|
||||
<McpToolsContainer tools={tools} />
|
||||
<IntegrationAIContainer type={'global'} handleToolsChange={handleToolsChange}></IntegrationAIContainer>
|
||||
</div>
|
||||
</InsidePage>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default McpServiceContainer
|
||||
@@ -1,30 +0,0 @@
|
||||
import { Icon } from '@iconify/react/dist/iconify.js'
|
||||
import { Tool } from '@modelcontextprotocol/sdk/types.js'
|
||||
import { Card } from 'antd'
|
||||
|
||||
const McpToolsContainer = ({ tools = [], customClassName }: { tools: Tool[]; customClassName?: string }) => {
|
||||
return (
|
||||
<>
|
||||
<Card
|
||||
style={{ borderRadius: '10px' }}
|
||||
className={`w-full flex-1 mr-[10px] ${customClassName}`}
|
||||
classNames={{
|
||||
body: 'p-[10px]'
|
||||
}}
|
||||
>
|
||||
<div className="mb-[10px]">
|
||||
<Icon icon="gravity-ui:plug-connection" className="align-text-bottom mr-[5px]" width="16" height="16" />
|
||||
<span className="text-[14px] font-bold align-middle">Tools</span>
|
||||
</div>
|
||||
{tools.map((tool, index) => (
|
||||
<Card style={{ borderRadius: '10px' }} key={index} className={`w-full ${index > 0 ? 'mt-[10px]' : ''}`}>
|
||||
<p className="text-[14px] font-bold">{tool.name}</p>
|
||||
<div className="leading-[28px]">{tool.description}</div>
|
||||
</Card>
|
||||
))}
|
||||
</Card>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default McpToolsContainer
|
||||
@@ -1,33 +0,0 @@
|
||||
// import { InspectorConfig } from "./configurationTypes";
|
||||
|
||||
// OAuth-related session storage keys
|
||||
export const SESSION_KEYS = {
|
||||
CODE_VERIFIER: "mcp_code_verifier",
|
||||
SERVER_URL: "mcp_server_url",
|
||||
TOKENS: "mcp_tokens",
|
||||
CLIENT_INFORMATION: "mcp_client_information",
|
||||
} as const;
|
||||
|
||||
export type ConnectionStatus =
|
||||
| "disconnected"
|
||||
| "connected"
|
||||
| "error"
|
||||
| "error-connecting-to-proxy";
|
||||
|
||||
export const DEFAULT_MCP_PROXY_LISTEN_PORT = "6277";
|
||||
|
||||
/**
|
||||
* Default configuration for the MCP Inspector, Currently persisted in local_storage in the Browser.
|
||||
* Future plans: Provide json config file + Browser local_storage to override default values
|
||||
**/
|
||||
export const DEFAULT_INSPECTOR_CONFIG: any = {
|
||||
MCP_SERVER_REQUEST_TIMEOUT: {
|
||||
description: "Timeout for requests to the MCP server (ms)",
|
||||
value: 10000,
|
||||
},
|
||||
MCP_PROXY_FULL_ADDRESS: {
|
||||
description:
|
||||
"Set this if you are running the MCP Inspector Proxy on a non-default address. Example: http://10.1.1.22:5577",
|
||||
value: "",
|
||||
},
|
||||
} as const;
|
||||
@@ -1,22 +0,0 @@
|
||||
import {
|
||||
NotificationSchema as BaseNotificationSchema,
|
||||
ClientNotificationSchema,
|
||||
ServerNotificationSchema,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
import { z } from "zod";
|
||||
|
||||
export const StdErrNotificationSchema = BaseNotificationSchema.extend({
|
||||
method: z.literal("notifications/stderr"),
|
||||
params: z.object({
|
||||
content: z.string(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const NotificationSchema = ClientNotificationSchema.or(
|
||||
StdErrNotificationSchema,
|
||||
)
|
||||
.or(ServerNotificationSchema)
|
||||
.or(BaseNotificationSchema);
|
||||
|
||||
export type StdErrNotification = z.infer<typeof StdErrNotificationSchema>;
|
||||
export type Notification = z.infer<typeof NotificationSchema>;
|
||||
@@ -1,391 +0,0 @@
|
||||
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
||||
import {
|
||||
SSEClientTransport,
|
||||
SseError,
|
||||
} from "@modelcontextprotocol/sdk/client/sse.js";
|
||||
import { App } from 'antd'
|
||||
import {
|
||||
ClientNotification,
|
||||
ClientRequest,
|
||||
CreateMessageRequestSchema,
|
||||
ListRootsRequestSchema,
|
||||
ProgressNotificationSchema,
|
||||
ResourceUpdatedNotificationSchema,
|
||||
LoggingMessageNotificationSchema,
|
||||
Request,
|
||||
Result,
|
||||
ServerCapabilities,
|
||||
PromptReference,
|
||||
ResourceReference,
|
||||
McpError,
|
||||
CompleteResultSchema,
|
||||
ErrorCode,
|
||||
CancelledNotificationSchema,
|
||||
ResourceListChangedNotificationSchema,
|
||||
ToolListChangedNotificationSchema,
|
||||
PromptListChangedNotificationSchema,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
import { useState } from "react";
|
||||
import { z } from "zod";
|
||||
import { ConnectionStatus, SESSION_KEYS } from "./constants";
|
||||
import { Notification, StdErrNotificationSchema } from "./notificationTypes";
|
||||
// import { auth } from "@modelcontextprotocol/sdk/client/auth.js";
|
||||
// import { authProvider } from "../auth";
|
||||
// import packageJson from "../../../package.json";
|
||||
|
||||
|
||||
interface UseConnectionOptions {
|
||||
transportType: "stdio" | "sse";
|
||||
command?: string;
|
||||
args?: string;
|
||||
sseUrl: string;
|
||||
env?: Record<string, string>;
|
||||
proxyServerUrl: string;
|
||||
bearerToken?: string;
|
||||
requestTimeout?: number;
|
||||
onNotification?: (notification: Notification) => void;
|
||||
onStdErrNotification?: (notification: Notification) => void;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
onPendingRequest?: (request: any, resolve: any, reject: any) => void;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
getRoots?: () => any[];
|
||||
}
|
||||
|
||||
interface RequestOptions {
|
||||
signal?: AbortSignal;
|
||||
timeout?: number;
|
||||
suppressToast?: boolean;
|
||||
}
|
||||
|
||||
export function useConnection({
|
||||
transportType,
|
||||
command,
|
||||
args,
|
||||
sseUrl,
|
||||
env,
|
||||
proxyServerUrl,
|
||||
bearerToken,
|
||||
requestTimeout,
|
||||
onNotification,
|
||||
onStdErrNotification,
|
||||
onPendingRequest,
|
||||
getRoots,
|
||||
}: UseConnectionOptions) {
|
||||
const [connectionStatus, setConnectionStatus] =
|
||||
useState<ConnectionStatus>("disconnected");
|
||||
const { message } = App.useApp()
|
||||
const [serverCapabilities, setServerCapabilities] =
|
||||
useState<ServerCapabilities | null>(null);
|
||||
const [mcpClient, setMcpClient] = useState<Client | null>(null);
|
||||
const [requestHistory, setRequestHistory] = useState<
|
||||
{ request: string; response?: string }[]
|
||||
>([]);
|
||||
const [completionsSupported, setCompletionsSupported] = useState(true);
|
||||
|
||||
const pushHistory = (request: object, response?: object) => {
|
||||
setRequestHistory((prev) => [
|
||||
...prev,
|
||||
{
|
||||
request: JSON.stringify(request),
|
||||
response: response !== undefined ? JSON.stringify(response) : undefined,
|
||||
},
|
||||
]);
|
||||
};
|
||||
|
||||
const makeRequest = async <T extends z.ZodType>(
|
||||
request: ClientRequest,
|
||||
schema: T,
|
||||
options?: RequestOptions,
|
||||
): Promise<z.output<T>> => {
|
||||
if (!mcpClient) {
|
||||
throw new Error("MCP client not connected");
|
||||
}
|
||||
|
||||
try {
|
||||
const abortController = new AbortController();
|
||||
const timeoutId = setTimeout(() => {
|
||||
abortController.abort("Request timed out");
|
||||
}, options?.timeout ?? requestTimeout);
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await mcpClient.request(request, schema, {
|
||||
signal: options?.signal ?? abortController.signal,
|
||||
});
|
||||
pushHistory(request, response);
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
pushHistory(request, { error: errorMessage });
|
||||
throw error;
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (e: unknown) {
|
||||
if (!options?.suppressToast) {
|
||||
const errorString = (e as Error).message ?? String(e);
|
||||
message.error(errorString)
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCompletion = async (
|
||||
ref: ResourceReference | PromptReference,
|
||||
argName: string,
|
||||
value: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string[]> => {
|
||||
if (!mcpClient || !completionsSupported) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const request: ClientRequest = {
|
||||
method: "completion/complete",
|
||||
params: {
|
||||
argument: {
|
||||
name: argName,
|
||||
value,
|
||||
},
|
||||
ref,
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await makeRequest(request, CompleteResultSchema, {
|
||||
signal,
|
||||
suppressToast: true,
|
||||
});
|
||||
return response?.completion.values || [];
|
||||
} catch (e: unknown) {
|
||||
// Disable completions silently if the server doesn't support them.
|
||||
// See https://github.com/modelcontextprotocol/specification/discussions/122
|
||||
if (e instanceof McpError && e.code === ErrorCode.MethodNotFound) {
|
||||
setCompletionsSupported(false);
|
||||
return [];
|
||||
}
|
||||
|
||||
// Unexpected errors - show toast and rethrow
|
||||
message.error(e instanceof Error ? e.message : String(e))
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const sendNotification = async (notification: ClientNotification) => {
|
||||
if (!mcpClient) {
|
||||
const error = new Error("MCP client not connected");
|
||||
message.error(error.message)
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await mcpClient.notification(notification);
|
||||
// Log successful notifications
|
||||
pushHistory(notification);
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof McpError) {
|
||||
// Log MCP protocol errors
|
||||
pushHistory(notification, { error: e.message });
|
||||
}
|
||||
message.error(e instanceof Error ? e.message : String(e))
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
// TODO_先屏蔽,暂时不需要
|
||||
// const checkProxyHealth = async () => {
|
||||
// try {
|
||||
// const proxyHealthUrl = new URL(`${proxyServerUrl}/health`);
|
||||
// const proxyHealthResponse = await fetch(proxyHealthUrl);
|
||||
// const proxyHealth = await proxyHealthResponse.json();
|
||||
// if (proxyHealth?.status !== "ok") {
|
||||
// throw new Error("MCP Proxy Server is not healthy");
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error("Couldn't connect to MCP Proxy Server", e);
|
||||
// throw e;
|
||||
// }
|
||||
// };
|
||||
// TODO_先屏蔽,暂时不需要
|
||||
// const handleAuthError = async (error: unknown) => {
|
||||
// if (error instanceof SseError && error.code === 401) {
|
||||
// sessionStorage.setItem(SESSION_KEYS.SERVER_URL, sseUrl);
|
||||
|
||||
// const result = await auth(authProvider, { serverUrl: sseUrl });
|
||||
// return result === "AUTHORIZED";
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// };
|
||||
|
||||
const connect = async (_e?: unknown, retryCount: number = 0) => {
|
||||
const client = new Client<Request, Notification, Result>(
|
||||
{
|
||||
name: "mcp-inspector",
|
||||
version: '0.0.1',
|
||||
},
|
||||
{
|
||||
capabilities: {
|
||||
sampling: {},
|
||||
roots: {
|
||||
listChanged: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
// TODO_暂时不需要
|
||||
// try {
|
||||
// await checkProxyHealth();
|
||||
// } catch {
|
||||
// setConnectionStatus("error-connecting-to-proxy");
|
||||
// return;
|
||||
// }
|
||||
// 使用与http.ts一致的方式处理URL
|
||||
// 注意:proxyServerUrl应该是完整URL,或者我们需要为其添加基础URL
|
||||
// 处理两种情况:完整URL或相对路径
|
||||
let fullUrl;
|
||||
if (proxyServerUrl.startsWith('http://') || proxyServerUrl.startsWith('https://')) {
|
||||
// 如果是完整URL,直接使用
|
||||
fullUrl = `${proxyServerUrl}/sse`;
|
||||
} else {
|
||||
// 如果是相对路径,添加基础URL和API前缀
|
||||
const baseUrl = window.location.origin;
|
||||
const apiPrefix = '/api/v1/';
|
||||
fullUrl = `${baseUrl}${apiPrefix}${proxyServerUrl}`;
|
||||
}
|
||||
// let newSseUrl = ''
|
||||
// if (sseUrl.startsWith('http://') || sseUrl.startsWith('https://')) {
|
||||
// // 如果是完整URL,直接使用
|
||||
// newSseUrl = sseUrl
|
||||
// } else {
|
||||
// // 如果是相对路径,添加基础URL和API前缀
|
||||
// const baseUrl = window.location.origin;
|
||||
// const apiPrefix = '/api/v1/';
|
||||
// newSseUrl = `${baseUrl}${apiPrefix}${sseUrl}`;
|
||||
// }
|
||||
const mcpProxyServerUrl = new URL(fullUrl);
|
||||
// mcpProxyServerUrl.searchParams.append("transportType", transportType);
|
||||
// if (transportType === "stdio") {
|
||||
// mcpProxyServerUrl.searchParams.append("command", command || '');
|
||||
// mcpProxyServerUrl.searchParams.append("args", args || '');
|
||||
// mcpProxyServerUrl.searchParams.append("env", JSON.stringify(env || {}));
|
||||
// } else {
|
||||
// mcpProxyServerUrl.searchParams.append("url", newSseUrl);
|
||||
// }
|
||||
// console.log('sseUrl===', newSseUrl)
|
||||
try {
|
||||
// Inject auth manually instead of using SSEClientTransport, because we're
|
||||
// proxying through the inspector server first.
|
||||
const headers: HeadersInit = {};
|
||||
|
||||
// TODO_暂时不需要。Use manually provided bearer token if available, otherwise use OAuth tokens
|
||||
// const token = bearerToken || (await authProvider.tokens())?.access_token;
|
||||
// if (token) {
|
||||
// headers["Authorization"] = `Bearer ${token}`;
|
||||
// }
|
||||
// 创建SSE客户端传输层
|
||||
const clientTransport = new SSEClientTransport(mcpProxyServerUrl, {
|
||||
eventSourceInit: {
|
||||
fetch: (url, init) => fetch(url, { ...init, headers }),
|
||||
},
|
||||
requestInit: {
|
||||
headers,
|
||||
},
|
||||
});
|
||||
// TODO_暂时不需要
|
||||
// if (onNotification) {
|
||||
// [
|
||||
// CancelledNotificationSchema,
|
||||
// ProgressNotificationSchema,
|
||||
// LoggingMessageNotificationSchema,
|
||||
// ResourceUpdatedNotificationSchema,
|
||||
// ResourceListChangedNotificationSchema,
|
||||
// ToolListChangedNotificationSchema,
|
||||
// PromptListChangedNotificationSchema,
|
||||
// ].forEach((notificationSchema) => {
|
||||
// client.setNotificationHandler(notificationSchema, onNotification);
|
||||
// });
|
||||
|
||||
// client.fallbackNotificationHandler = (
|
||||
// notification: Notification,
|
||||
// ): Promise<void> => {
|
||||
// onNotification(notification);
|
||||
// return Promise.resolve();
|
||||
// };
|
||||
// }
|
||||
|
||||
// if (onStdErrNotification) {
|
||||
// client.setNotificationHandler(
|
||||
// StdErrNotificationSchema,
|
||||
// onStdErrNotification,
|
||||
// );
|
||||
// }
|
||||
|
||||
try {
|
||||
await client.connect(clientTransport);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Failed to connect to MCP Server via the MCP Inspector Proxy: ${mcpProxyServerUrl}:`,
|
||||
error,
|
||||
);
|
||||
// TODO_先屏蔽,后续如果需要再处理
|
||||
// const shouldRetry = await handleAuthError(error);
|
||||
// if (shouldRetry) {
|
||||
// return connect(undefined, retryCount + 1);
|
||||
// }
|
||||
|
||||
if (error instanceof SseError && error.code === 401) {
|
||||
// Don't set error state if we're about to redirect for auth
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const capabilities = client.getServerCapabilities();
|
||||
setServerCapabilities(capabilities ?? null);
|
||||
setCompletionsSupported(true); // Reset completions support on new connection
|
||||
// TODO_暂时不需要
|
||||
// if (onPendingRequest) {
|
||||
// client.setRequestHandler(CreateMessageRequestSchema, (request) => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// onPendingRequest(request, resolve, reject);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// if (getRoots) {
|
||||
// client.setRequestHandler(ListRootsRequestSchema, async () => {
|
||||
// return { roots: getRoots() };
|
||||
// });
|
||||
// }
|
||||
|
||||
setMcpClient(client);
|
||||
setConnectionStatus("connected");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setConnectionStatus("error");
|
||||
}
|
||||
};
|
||||
|
||||
const disconnect = async () => {
|
||||
await mcpClient?.close();
|
||||
setMcpClient(null);
|
||||
setConnectionStatus("disconnected");
|
||||
setCompletionsSupported(false);
|
||||
setServerCapabilities(null);
|
||||
};
|
||||
|
||||
return {
|
||||
connectionStatus,
|
||||
serverCapabilities,
|
||||
mcpClient,
|
||||
requestHistory,
|
||||
makeRequest,
|
||||
sendNotification,
|
||||
handleCompletion,
|
||||
completionsSupported,
|
||||
connect,
|
||||
disconnect,
|
||||
};
|
||||
}
|
||||
@@ -480,8 +480,6 @@ const MemberList = () => {
|
||||
render: (_, entity) => (
|
||||
<WithPermission access="system.organization.member.edit">
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-full"
|
||||
mode="multiple"
|
||||
value={entity.roles?.map((x: EntityItem) => x.id)}
|
||||
|
||||
@@ -60,13 +60,7 @@ export type DashboardSettingEditProps = {
|
||||
name="driver"
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={[...DASHBOARD_SETTING_DRIVER_OPTION_LIST]}
|
||||
/>
|
||||
<Select className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.select)} options={[...DASHBOARD_SETTING_DRIVER_OPTION_LIST]}/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<PartitionDashboardConfigFieldType>
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import EditableTable from '@common/components/aoplatform/EditableTable'
|
||||
import WithPermission from '@common/components/aoplatform/WithPermission'
|
||||
import { BasicResponse, PLACEHOLDER, STATUS_CODE } from '@common/const/const'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { $t } from '@common/locales'
|
||||
import {
|
||||
PARTITION_DATA_LOG_CONFIG_TABLE_COLUMNS,
|
||||
PartitionDataLogConfigFieldType,
|
||||
PartitionDataLogHeaderListFieldType
|
||||
} from '@core/const/partitions/types'
|
||||
import { Button, Form, Input, message, Select } from 'antd'
|
||||
import { useEffect } from 'react'
|
||||
import EditableTable from "@common/components/aoplatform/EditableTable"
|
||||
import WithPermission from "@common/components/aoplatform/WithPermission"
|
||||
import { BasicResponse, PLACEHOLDER, STATUS_CODE } from "@common/const/const"
|
||||
import { useFetch } from "@common/hooks/http"
|
||||
import { $t } from "@common/locales"
|
||||
import { PARTITION_DATA_LOG_CONFIG_TABLE_COLUMNS, PartitionDataLogConfigFieldType, PartitionDataLogHeaderListFieldType } from "@core/const/partitions/types"
|
||||
import { Button, Form, Input, message } from "antd"
|
||||
import { useEffect } from "react"
|
||||
|
||||
export type DashboardPageShowStatus = 'view' | 'edit'
|
||||
export type DashboardSettingEditProps = {
|
||||
@@ -19,7 +15,7 @@ export type DashboardSettingEditProps = {
|
||||
}
|
||||
const DataLogSettingEdit = (props: DashboardSettingEditProps) => {
|
||||
const { changeStatus, refreshData, data } = props
|
||||
const [form] = Form.useForm()
|
||||
const [form] = Form.useForm();
|
||||
const { fetchData } = useFetch()
|
||||
|
||||
const onFinish = () => {
|
||||
@@ -27,16 +23,10 @@ const DataLogSettingEdit = (props: DashboardSettingEditProps) => {
|
||||
const formData = {
|
||||
config: {
|
||||
url: value.url,
|
||||
headers: value.headers
|
||||
.filter((item: PartitionDataLogHeaderListFieldType) => item.key)
|
||||
.map((item: PartitionDataLogHeaderListFieldType) => ({ key: item.key, value: item.value || '' }))
|
||||
headers: value.headers.filter((item: PartitionDataLogHeaderListFieldType) => item.key).map((item: PartitionDataLogHeaderListFieldType) => ({key:item.key, value:item.value || ''}))
|
||||
}
|
||||
}
|
||||
fetchData<BasicResponse<{ info: PartitionDataLogConfigFieldType }>>('log/loki', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(formData),
|
||||
eoParams: {}
|
||||
}).then((response) => {
|
||||
fetchData<BasicResponse<{ info: PartitionDataLogConfigFieldType }>>('log/loki', { method: 'POST', body: JSON.stringify(formData), eoParams: {} }).then(response => {
|
||||
const { code, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
message.success(msg || $t('操作成功,即将刷新页面'))
|
||||
@@ -48,26 +38,15 @@ const DataLogSettingEdit = (props: DashboardSettingEditProps) => {
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({
|
||||
...data,
|
||||
headers: data?.headers?.length ? data.headers : [
|
||||
{
|
||||
key: '',
|
||||
value: ''
|
||||
}
|
||||
],
|
||||
driver: 'loki'
|
||||
})
|
||||
}, [data])
|
||||
useEffect(() => { form.setFieldsValue(data) }, [data])
|
||||
|
||||
useEffect(() => {
|
||||
return form.setFieldsValue({})
|
||||
}, [])
|
||||
return (form.setFieldsValue({}))
|
||||
}, []);
|
||||
return (
|
||||
<>
|
||||
<div className="overflow-auto h-full">
|
||||
<WithPermission access={''}>
|
||||
<WithPermission access={''} >
|
||||
<Form
|
||||
form={form}
|
||||
className="mx-auto flex flex-col justify-between h-full"
|
||||
@@ -76,29 +55,23 @@ const DataLogSettingEdit = (props: DashboardSettingEditProps) => {
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item<PartitionDataLogConfigFieldType>
|
||||
label={$t('数据源类型')}
|
||||
name="driver"
|
||||
label={$t("请求前缀")}
|
||||
name="url"
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
options={[{ label: 'Loki', value: 'loki' }]}
|
||||
></Select>
|
||||
</Form.Item>
|
||||
<Form.Item<PartitionDataLogConfigFieldType> label={$t('请求前缀')} name="url" rules={[{ required: true }]}>
|
||||
<Input className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<PartitionDataLogConfigFieldType> label={$t('HTTP 头部')} name="headers">
|
||||
<Form.Item<PartitionDataLogConfigFieldType>
|
||||
label={$t("HTTP 头部")}
|
||||
name="headers"
|
||||
>
|
||||
<EditableTable<PartitionDataLogConfigFieldType & { _id: string }>
|
||||
configFields={PARTITION_DATA_LOG_CONFIG_TABLE_COLUMNS}
|
||||
/>
|
||||
</Form.Item>
|
||||
<div className="flex gap-btnbase">
|
||||
<WithPermission access="system.devops.data_source.edit">
|
||||
<WithPermission access='system.devops.data_source.edit'>
|
||||
<Button type="primary" htmlType="submit">
|
||||
{$t('保存')}
|
||||
</Button>
|
||||
@@ -111,7 +84,7 @@ const DataLogSettingEdit = (props: DashboardSettingEditProps) => {
|
||||
</WithPermission>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export default DataLogSettingEdit
|
||||
export default DataLogSettingEdit;
|
||||
@@ -161,7 +161,7 @@ const PartitionInsideDashboardSetting: FC = () => {
|
||||
className="overflow-hidden mt-[30px] w-full max-h-full flex flex-col justify-between"
|
||||
title={
|
||||
<div>
|
||||
<span className="text-MAIN_TEXT my-btnybase mr-btnbase"> {$t('请求日志')}</span>
|
||||
<span className="text-MAIN_TEXT my-btnybase mr-btnbase"> {$t('数据日志')}</span>
|
||||
{!dataLogLoading && !dataLogData && <Tag color="#f50">{$t('未配置')}</Tag>}
|
||||
</div>
|
||||
}
|
||||
@@ -220,11 +220,6 @@ export function DataLogConfigPreview(x: PartitionDataLogConfigFieldType) {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-[4px] ">
|
||||
<Row className="">
|
||||
<Col className="font-bold text-right pr-[4px]">{$t('数据源')}:</Col>
|
||||
{/* 先写死,或许会有选择列表,但现在可以不用 */}
|
||||
<Col>Loki</Col>
|
||||
</Row>
|
||||
<Row className="">
|
||||
<Col className="font-bold text-right pr-[4px]">{$t('请求前缀')}:</Col>
|
||||
<Col>{x?.url}</Col>
|
||||
|
||||
@@ -301,13 +301,7 @@ const FilterForm = forwardRef<FilterFormHandle, FilterFormProps>(
|
||||
return (
|
||||
<Form form={form} layout="vertical" onValuesChange={handleValuesChange}>
|
||||
<Form.Item name="name" label={$t('属性名称')} rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
disabled={disabled}
|
||||
onChange={handleTypeChange}
|
||||
options={filterOptionsList}
|
||||
/>
|
||||
<Select disabled={disabled} onChange={handleTypeChange} options={filterOptionsList} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="values"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Outlet, useLocation, useNavigate } from 'react-router-dom'
|
||||
import { useEffect } from "react";
|
||||
import { Outlet, useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
export default function ServicePolicyLayout() {
|
||||
const location = useLocation()
|
||||
const pathName = location.pathname
|
||||
const navigator = useNavigate()
|
||||
useEffect(() => {
|
||||
const tmpPath = pathName.split('/')
|
||||
if (tmpPath[tmpPath.length - 1] === 'servicepolicy') {
|
||||
navigator('datamasking/list')
|
||||
}
|
||||
}, [pathName])
|
||||
return <Outlet></Outlet>
|
||||
}
|
||||
export default function ServicePolicyLayout(){
|
||||
const location = useLocation()
|
||||
const pathName = location.pathname
|
||||
const navigator = useNavigate()
|
||||
useEffect(()=>{
|
||||
const tmpPath = pathName.split('/')
|
||||
if(tmpPath[tmpPath.length -1 ] === 'servicepolicy'){
|
||||
navigator('datamasking/list')
|
||||
}
|
||||
},[pathName])
|
||||
return (<Outlet></Outlet>)
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import FilterTable from "../FilterTable"
|
||||
import { DataMaskingConfigHandle ,DataMaskingConfigFieldType, PolicyMatchType} from "@common/const/policy/type"
|
||||
import {PolicyOptions} from '@common/const/policy/consts'
|
||||
import {v4 as uuidv4} from 'uuid'
|
||||
import { useBreadcrumb } from "@common/contexts/BreadcrumbContext"
|
||||
|
||||
const DataMaskingConfig = forwardRef<DataMaskingConfigHandle>((_,ref) => {
|
||||
const { message,modal } = App.useApp()
|
||||
@@ -25,7 +24,6 @@ const DataMaskingConfig = forwardRef<DataMaskingConfigHandle>((_,ref) => {
|
||||
const { state } = useGlobalContext()
|
||||
const [ loading, setLoading ] = useState<boolean>(false)
|
||||
const navigator = useNavigate()
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
save:onFinish
|
||||
@@ -98,7 +96,7 @@ const DataMaskingConfig = forwardRef<DataMaskingConfigHandle>((_,ref) => {
|
||||
showBorder={false}
|
||||
scrollPage={false}
|
||||
className="overflow-y-auto"
|
||||
backUrl={serviceId ? `/service/${teamId}/aiInside/${serviceId}/servicepolicy` : undefined}
|
||||
backUrl={serviceId ? '../list' : undefined}
|
||||
>
|
||||
<Spin indicator={<LoadingOutlined style={{ fontSize: 24 }} spin />} spinning={loading} wrapperClassName=' pb-PAGE_INSIDE_B pr-PAGE_INSIDE_X'>
|
||||
<WithPermission access={onEdit ? [`${ serviceId === undefined ? 'system.devops':'team.service'}.policy.edit`] :''}>
|
||||
@@ -126,13 +124,8 @@ const DataMaskingConfig = forwardRef<DataMaskingConfigHandle>((_,ref) => {
|
||||
name="type"
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={policyOptions}
|
||||
></Select>
|
||||
<Select className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} options={policyOptions} >
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item<DataMaskingConfigFieldType>
|
||||
|
||||
@@ -146,8 +146,6 @@ const DataMaskRuleForm: React.FC<DataMaskRuleFormProps> = ({
|
||||
<Form form={form} layout="vertical" className="p-4">
|
||||
<Form.Item name={['match', 'type']} label={$t('匹配类型')} rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
onChange={handleMatchTypeChange}
|
||||
options={matchRuleOptions}
|
||||
@@ -158,8 +156,6 @@ const DataMaskRuleForm: React.FC<DataMaskRuleFormProps> = ({
|
||||
<Form.Item name={['match', 'value']} label={$t('匹配值')} rules={[{ required: true }]}>
|
||||
{matchType === 'inner' ? (
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
onChange={handleMatchValueChange}
|
||||
options={dataFormatOptions}
|
||||
@@ -172,8 +168,6 @@ const DataMaskRuleForm: React.FC<DataMaskRuleFormProps> = ({
|
||||
|
||||
<Form.Item name={['mask', 'type']} label={$t('脱敏类型')} rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
onChange={handleMaskTypeChange}
|
||||
options={
|
||||
@@ -203,8 +197,6 @@ const DataMaskRuleForm: React.FC<DataMaskRuleFormProps> = ({
|
||||
rules={[{ required: true }]}
|
||||
>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
onChange={handleReplaceTypeChange}
|
||||
options={dataMaskReplaceStrOptions}
|
||||
|
||||
@@ -1,313 +1,251 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { App, Button, Checkbox, Collapse, Form, GetProp, Input } from 'antd'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { BasicResponse, PLACEHOLDER, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const.tsx'
|
||||
import WithPermission from '@common/components/aoplatform/WithPermission.tsx'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { $t } from '@common/locales'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext'
|
||||
import TopBreadcrumb from '@common/components/aoplatform/Breadcrumb.tsx'
|
||||
import { useEffect, useMemo, useState} from "react";
|
||||
import {App, Button, Checkbox, Collapse, Form, GetProp, Input} from "antd";
|
||||
import {useFetch} from "@common/hooks/http.ts";
|
||||
import {BasicResponse, PLACEHOLDER, RESPONSE_TIPS, STATUS_CODE, VALIDATE_MESSAGE} from "@common/const/const.tsx";
|
||||
import WithPermission from "@common/components/aoplatform/WithPermission.tsx";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { RouterParams } from "@core/components/aoplatform/RenderRoutes.tsx";
|
||||
import { ArrowLeftOutlined } from "@ant-design/icons";
|
||||
import { $t } from "@common/locales";
|
||||
import { useGlobalContext } from "@common/contexts/GlobalStateContext";
|
||||
|
||||
type PermissionItem = {
|
||||
name: string
|
||||
value: string
|
||||
name:string
|
||||
value:string
|
||||
}
|
||||
|
||||
type PermissionClassify = PermissionItem & { children: (PermissionItem & { dependents: string[] })[] }
|
||||
type PermissionClassify = PermissionItem & {children : ( PermissionItem & {dependents:string[]})[]}
|
||||
|
||||
type RolePermissionItem = PermissionItem & {
|
||||
children: PermissionClassify[]
|
||||
}
|
||||
children:PermissionClassify[]}
|
||||
|
||||
type DependenciesMapType = Map<string, { dependents: string[]; control: string[] }>
|
||||
|
||||
type DependenciesMapType = Map<string, {dependents:string[], control:string[]}>
|
||||
|
||||
type PermissionCollapseProps = {
|
||||
id?: string
|
||||
value?: string[]
|
||||
onChange?: (value: string[]) => void
|
||||
permissionTemplate: RolePermissionItem[]
|
||||
dependenciesMap?: DependenciesMapType
|
||||
id?: string;
|
||||
value?: string[];
|
||||
onChange?: (value:string[]) => void;
|
||||
permissionTemplate:RolePermissionItem[]
|
||||
dependenciesMap?: DependenciesMapType
|
||||
}
|
||||
|
||||
type PermissionInfo = {
|
||||
permit: string[]
|
||||
description: string
|
||||
update_time: string
|
||||
create_time: string
|
||||
name: string
|
||||
permit: string[]
|
||||
description: string
|
||||
update_time: string
|
||||
create_time: string
|
||||
name: string
|
||||
}
|
||||
|
||||
const PermissionContent = ({
|
||||
permits,
|
||||
onChange,
|
||||
value = [],
|
||||
id,
|
||||
dependenciesMap
|
||||
}: {
|
||||
permits: PermissionClassify[]
|
||||
dependenciesMap: DependenciesMapType
|
||||
value: string[]
|
||||
id: string
|
||||
onChange?: (value: string[]) => void
|
||||
}) => {
|
||||
const onSingleCheckboxChange: GetProp<typeof Checkbox, 'onChange'> = (e) => {
|
||||
if (e.target.checked) {
|
||||
onChange?.(
|
||||
Array.from(
|
||||
new Set([...value, e.target.id, ...(dependenciesMap?.get(e.target.id!)?.dependents || [])] as string[])
|
||||
)
|
||||
)
|
||||
} else {
|
||||
const cancelValue = [...(dependenciesMap?.get(e.target.id!)?.control || []), e.target.id]
|
||||
onChange?.(value.filter((x) => !cancelValue.includes(x)))
|
||||
const PermissionContent = ({permits,onChange,value=[],id,dependenciesMap}:{permits:PermissionClassify[],dependenciesMap:DependenciesMapType,value:string[],id:string, onChange?: (value:string[]) => void;})=>{
|
||||
|
||||
|
||||
const onSingleCheckboxChange: GetProp<typeof Checkbox, 'onChange'> = (e) => {
|
||||
if(e.target.checked){
|
||||
onChange?.(Array.from(new Set([...value, e.target.id, ...(dependenciesMap?.get(e.target.id!)?.dependents || [])] as string[])))
|
||||
}else{
|
||||
const cancelValue = [...dependenciesMap?.get(e.target.id!)?.control || [], e.target.id]
|
||||
onChange?.(value.filter(x=>!cancelValue.includes(x)))
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div id={id} className="flex flex-col gap-btnbase p-btnbase">
|
||||
{
|
||||
permits.map((item:PermissionClassify)=>(
|
||||
<>
|
||||
<div className="flex flex-col gap-btnbase" key={`group-${item.name}`}>
|
||||
{item.name !== '' && <p className="">{(item.name)}</p>}
|
||||
<div className=" pl-[20px]">
|
||||
{item.children.map(x=><Checkbox id={x.value} key={x.value} checked={value && value.length > 0 && value.indexOf(x.value)>-1} onChange={onSingleCheckboxChange}>{(x.name)}</Checkbox>)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
))
|
||||
}</div>
|
||||
)
|
||||
}
|
||||
// 自定义表单控件
|
||||
const PermissionCollapse:React.FC<PermissionCollapseProps> = (props)=>{
|
||||
const { id, value = [], onChange,permissionTemplate ,dependenciesMap} = props;
|
||||
const [openCollapses, setOpenCollapses] = useState<string[]>([])
|
||||
const {state} = useGlobalContext()
|
||||
|
||||
const items = useMemo(()=>{
|
||||
const generatePermissionItem = (permissionItem:RolePermissionItem[])=> permissionItem.map((item:RolePermissionItem)=>({
|
||||
key:item.name,
|
||||
label:(item.name),
|
||||
children:<PermissionContent value={value} permits={item.children} onChange={(e)=>onChange?.(e)} id={id!} dependenciesMap={dependenciesMap!}/>
|
||||
}))
|
||||
return permissionTemplate && permissionTemplate.length > 0 ? generatePermissionItem(permissionTemplate) : []
|
||||
},[permissionTemplate,value,state.language])
|
||||
|
||||
useEffect(()=>{
|
||||
permissionTemplate && setOpenCollapses(permissionTemplate?.map(x=>x.name))
|
||||
},[permissionTemplate])
|
||||
|
||||
const onCollapseChange = (keys: string | string[]) => {
|
||||
setOpenCollapses(keys as string[])
|
||||
};
|
||||
|
||||
return <Collapse items={items} activeKey={openCollapses} onChange={onCollapseChange} />
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div id={id} className="flex flex-col gap-btnbase p-btnbase">
|
||||
{permits.map((item: PermissionClassify) => (
|
||||
<>
|
||||
<div className="flex flex-col gap-btnbase" key={`group-${item.name}`}>
|
||||
{item.name !== '' && <p className="">{item.name}</p>}
|
||||
<div className=" pl-[20px]">
|
||||
{item.children.map((x) => (
|
||||
<Checkbox
|
||||
id={x.value}
|
||||
key={x.value}
|
||||
checked={value && value.length > 0 && value.indexOf(x.value) > -1}
|
||||
onChange={onSingleCheckboxChange}
|
||||
>
|
||||
{x.name}
|
||||
</Checkbox>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
// 自定义表单控件
|
||||
const PermissionCollapse: React.FC<PermissionCollapseProps> = (props) => {
|
||||
const { id, value = [], onChange, permissionTemplate, dependenciesMap } = props
|
||||
const [openCollapses, setOpenCollapses] = useState<string[]>([])
|
||||
const { state } = useGlobalContext()
|
||||
|
||||
const items = useMemo(() => {
|
||||
const generatePermissionItem = (permissionItem: RolePermissionItem[]) =>
|
||||
permissionItem.map((item: RolePermissionItem) => ({
|
||||
key: item.name,
|
||||
label: item.name,
|
||||
children: (
|
||||
<PermissionContent
|
||||
value={value}
|
||||
permits={item.children}
|
||||
onChange={(e) => onChange?.(e)}
|
||||
id={id!}
|
||||
dependenciesMap={dependenciesMap!}
|
||||
/>
|
||||
)
|
||||
}))
|
||||
return permissionTemplate && permissionTemplate.length > 0 ? generatePermissionItem(permissionTemplate) : []
|
||||
}, [permissionTemplate, value, state.language])
|
||||
const RoleConfig = ()=>{
|
||||
const { message } = App.useApp()
|
||||
const [form] = Form.useForm();
|
||||
const {fetchData} = useFetch()
|
||||
const navigateTo = useNavigate()
|
||||
const { roleType, roleId} = useParams<RouterParams>()
|
||||
const [permissionTemplate, setPermissionTemplate] = useState<RolePermissionItem[]>()
|
||||
const [dependenciesMap, setDependenciesMap] = useState<DependenciesMapType>()
|
||||
const APP_MODE = import.meta.env.VITE_APP_MODE;
|
||||
const [permissionInfo, setPermissionInfo] = useState<PermissionInfo>()
|
||||
const { state } = useGlobalContext()
|
||||
|
||||
useEffect(() => {
|
||||
permissionTemplate && setOpenCollapses(permissionTemplate?.map((x) => x.name))
|
||||
}, [permissionTemplate])
|
||||
const generateDependenciesMap = (data:RolePermissionItem[])=>{
|
||||
const map = new Map<string, {dependents:string[], control:string[]}>()
|
||||
data.forEach((item:RolePermissionItem)=>{
|
||||
item.children.forEach((child:PermissionClassify)=>{
|
||||
child.children.forEach((permission:PermissionItem & {dependents:string[]})=>{
|
||||
|
||||
const onCollapseChange = (keys: string | string[]) => {
|
||||
setOpenCollapses(keys as string[])
|
||||
}
|
||||
|
||||
return <Collapse items={items} activeKey={openCollapses} onChange={onCollapseChange} />
|
||||
}
|
||||
|
||||
const RoleConfig = () => {
|
||||
const { message } = App.useApp()
|
||||
const [form] = Form.useForm()
|
||||
const { fetchData } = useFetch()
|
||||
const navigateTo = useNavigate()
|
||||
const { roleType, roleId } = useParams<RouterParams>()
|
||||
const [permissionTemplate, setPermissionTemplate] = useState<RolePermissionItem[]>()
|
||||
const [dependenciesMap, setDependenciesMap] = useState<DependenciesMapType>()
|
||||
const APP_MODE = import.meta.env.VITE_APP_MODE
|
||||
const [permissionInfo, setPermissionInfo] = useState<PermissionInfo>()
|
||||
const { state } = useGlobalContext()
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
|
||||
const generateDependenciesMap = (data: RolePermissionItem[]) => {
|
||||
const map = new Map<string, { dependents: string[]; control: string[] }>()
|
||||
data.forEach((item: RolePermissionItem) => {
|
||||
item.children.forEach((child: PermissionClassify) => {
|
||||
child.children.forEach((permission: PermissionItem & { dependents: string[] }) => {
|
||||
if (permission.dependents && permission.dependents.length > 0) {
|
||||
// 获取当前权限的依赖
|
||||
const currentDependents = map.get(permission.value)
|
||||
if (currentDependents) {
|
||||
currentDependents.dependents.push(...permission.dependents)
|
||||
} else {
|
||||
map.set(permission.value, { dependents: [...permission.dependents], control: [] })
|
||||
}
|
||||
|
||||
// 更新依赖项的控制项
|
||||
permission.dependents.forEach((dependent: string) => {
|
||||
const dependentEntry = map.get(dependent)
|
||||
if (dependentEntry) {
|
||||
dependentEntry.control.push(permission.value)
|
||||
} else {
|
||||
map.set(dependent, { dependents: [], control: [permission.value] })
|
||||
}
|
||||
if (permission.dependents && permission.dependents.length > 0) {
|
||||
// 获取当前权限的依赖
|
||||
const currentDependents = map.get(permission.value);
|
||||
if (currentDependents) {
|
||||
currentDependents.dependents.push(...permission.dependents);
|
||||
} else {
|
||||
map.set(permission.value, { dependents: [...permission.dependents], control: [] });
|
||||
}
|
||||
|
||||
// 更新依赖项的控制项
|
||||
permission.dependents.forEach((dependent: string) => {
|
||||
const dependentEntry = map.get(dependent);
|
||||
if (dependentEntry) {
|
||||
dependentEntry.control.push(permission.value);
|
||||
} else {
|
||||
map.set(dependent, { dependents: [], control: [permission.value] });
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
setDependenciesMap(map)
|
||||
}
|
||||
|
||||
const generateNewPermit: (data: RolePermissionItem[]) => RolePermissionItem[] = (data: RolePermissionItem[]) => {
|
||||
return data.map((item: RolePermissionItem) => ({
|
||||
...item,
|
||||
children: item.children.map((child: PermissionClassify) => ({
|
||||
...child,
|
||||
children: child.children.map((permission: PermissionItem & { dependents: string[] }) => ({
|
||||
...permission,
|
||||
value: `${roleType}.${item.value}.${child.value}.${permission.value}`
|
||||
}))
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
const getPermissionTemplate = () => {
|
||||
return fetchData<BasicResponse<{ permits: RolePermissionItem[] }>>(`${roleType}/role/template`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
const newPermits = generateNewPermit(data.permits)
|
||||
generateDependenciesMap(newPermits)
|
||||
setPermissionTemplate(newPermits)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.dataError))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getPermissionInfo = () => {
|
||||
fetchData<BasicResponse<{ role: PermissionInfo }>>(`${roleType}/role`, {
|
||||
method: 'GET',
|
||||
eoParams: { role: roleId }
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setPermissionInfo(data.role)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
})
|
||||
.catch((errInfo) => console.error(errInfo))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({ name: $t(permissionInfo?.name || ''), permits: permissionInfo?.permit })
|
||||
}, [permissionInfo, state.language])
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({ name: '', permits: [] })
|
||||
if (roleId) {
|
||||
getPermissionInfo()
|
||||
setDependenciesMap(map)
|
||||
}
|
||||
|
||||
const generateNewPermit:(data:RolePermissionItem[])=>RolePermissionItem[] = (data:RolePermissionItem[]) =>{
|
||||
return data.map((item:RolePermissionItem)=>({
|
||||
...item,children:item.children.map((child:PermissionClassify)=>({
|
||||
...child,
|
||||
children:child.children.map((permission:PermissionItem & {dependents:string[]})=>({
|
||||
...permission, value:`${roleType}.${item.value}.${child.value}.${permission.value}`
|
||||
}))
|
||||
}))
|
||||
}))
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: $t('角色'),
|
||||
onClick: () => navigateTo(-1)
|
||||
},
|
||||
{ title: $t('角色配置') }
|
||||
])
|
||||
getPermissionTemplate()
|
||||
}, [state.language])
|
||||
const getPermissionTemplate = ()=>{
|
||||
return fetchData<BasicResponse<{permits:RolePermissionItem[]}>>(`${roleType}/role/template`,{method:'GET'}).then(response=>{
|
||||
const {code,data,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
const newPermits = generateNewPermit(data.permits)
|
||||
generateDependenciesMap(newPermits)
|
||||
setPermissionTemplate(newPermits)
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.dataError))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const onFinish = async () => {
|
||||
const body = await form.validateFields()
|
||||
const getPermissionInfo = ()=>{
|
||||
fetchData<BasicResponse<{role:PermissionInfo}>>(`${roleType}/role`,{method:'GET',eoParams:{role:roleId}}).then(response=>{
|
||||
const {code,data,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
setPermissionInfo(data.role)
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
}).catch((errInfo)=>console.error(errInfo))
|
||||
}
|
||||
|
||||
return fetchData<BasicResponse<null>>(`${roleType}/role`, {
|
||||
method: roleId === undefined ? 'POST' : 'PUT',
|
||||
eoBody: { ...body },
|
||||
...(roleId !== undefined ? { eoParams: { role: roleId } } : {})
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
message.success(msg || $t(RESPONSE_TIPS.success))
|
||||
return Promise.resolve(true)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
return Promise.reject(msg || $t(RESPONSE_TIPS.error))
|
||||
useEffect(()=>{
|
||||
form.setFieldsValue({name:$t(permissionInfo?.name || ''),permits:permissionInfo?.permit})
|
||||
},[permissionInfo, state.language])
|
||||
|
||||
useEffect(() => {
|
||||
form.setFieldsValue({name:'',permits:[]})
|
||||
if(roleId){
|
||||
getPermissionInfo()
|
||||
}
|
||||
})
|
||||
.catch((errInfo) => Promise.reject(errInfo))
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="h-full flex flex-col overflow-hidden ">
|
||||
<TopBreadcrumb handleBackCallback={() => navigateTo(-1)} />
|
||||
<WithPermission
|
||||
access={
|
||||
roleId !== undefined
|
||||
? `system.organization.role.${roleType}.edit`
|
||||
: `system.organization.role.${roleType}.add`
|
||||
}
|
||||
>
|
||||
<Form
|
||||
id="permission"
|
||||
layout="vertical"
|
||||
labelAlign="left"
|
||||
scrollToFirstError
|
||||
form={form}
|
||||
className="mx-auto w-full flex-1 no-bg-form overflow-hidden "
|
||||
name="rolePermissionConfig"
|
||||
onFinish={onFinish}
|
||||
autoComplete="off"
|
||||
>
|
||||
<div className="flex flex-col h-full">
|
||||
<Form.Item
|
||||
className=" m-btnbase mr-PAGE_INSIDE_X"
|
||||
name="name"
|
||||
rules={[{ required: true, whitespace: true }]}
|
||||
>
|
||||
<Input className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} />
|
||||
</Form.Item>
|
||||
<Form.Item name="permits" className="m-btnbase mr-0 flex-1 overflow-auto pr-PAGE_INSIDE_X">
|
||||
<PermissionCollapse permissionTemplate={permissionTemplate!} dependenciesMap={dependenciesMap} />
|
||||
</Form.Item>
|
||||
useEffect(()=>{
|
||||
getPermissionTemplate()
|
||||
|
||||
{APP_MODE === 'pro' && (
|
||||
<div className="p-btnbase">
|
||||
<WithPermission
|
||||
access={
|
||||
roleId === undefined
|
||||
? `system.organization.role.${roleType}.edit`
|
||||
: `system.organization.role.${roleType}.add`
|
||||
}
|
||||
},[state.language])
|
||||
|
||||
const onFinish =async() => {
|
||||
const body = await form.validateFields()
|
||||
|
||||
return fetchData<BasicResponse<null>>(`${roleType}/role`,{method:roleId === undefined? 'POST' : 'PUT',eoBody:({...body}),...(roleId !== undefined?{eoParams:{role:roleId}}:{})}).then(response=>{
|
||||
const {code,msg} = response
|
||||
if(code === STATUS_CODE.SUCCESS){
|
||||
message.success(msg || $t(RESPONSE_TIPS.success))
|
||||
return Promise.resolve(true)
|
||||
}else{
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
return Promise.reject(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
}).catch((errInfo)=>Promise.reject(errInfo))
|
||||
};
|
||||
|
||||
return (<div className="h-full flex flex-col overflow-hidden ">
|
||||
<div className="text-[18px] leading-[25px] pb-[12px]">
|
||||
<Button className="flex items-center" type="text" onClick={()=>navigateTo(-1)}><ArrowLeftOutlined className="max-h-[14px]" /><span>{$t('返回')}</span></Button>
|
||||
</div>
|
||||
<WithPermission access={roleId !== undefined ? `system.organization.role.${roleType}.edit`: `system.organization.role.${roleType}.add`}>
|
||||
<Form
|
||||
id="permission"
|
||||
layout='vertical'
|
||||
labelAlign='left'
|
||||
scrollToFirstError
|
||||
form={form}
|
||||
className="mx-auto w-full flex-1 no-bg-form overflow-hidden "
|
||||
name="rolePermissionConfig"
|
||||
onFinish={onFinish}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Button type="primary" htmlType="submit">
|
||||
{$t('保存')}
|
||||
</Button>
|
||||
</WithPermission>
|
||||
<Button className="ml-btnrbase" type="default" onClick={() => navigateTo(-1)}>
|
||||
{$t('取消')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Form>
|
||||
</WithPermission>
|
||||
</div>
|
||||
)
|
||||
<div className="flex flex-col h-full">
|
||||
<Form.Item
|
||||
className=" m-btnbase mr-PAGE_INSIDE_X"
|
||||
name="name"
|
||||
rules={[{ required: true,whitespace:true }]}
|
||||
>
|
||||
<Input className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)}/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="permits"
|
||||
className="m-btnbase mr-0 flex-1 overflow-auto pr-PAGE_INSIDE_X"
|
||||
>
|
||||
<PermissionCollapse permissionTemplate={permissionTemplate!} dependenciesMap={dependenciesMap} />
|
||||
</Form.Item>
|
||||
|
||||
{APP_MODE === 'pro' && <div className="p-btnbase">
|
||||
<WithPermission access={roleId === undefined ?`system.organization.role.${roleType}.edit`:`system.organization.role.${roleType}.add`}>
|
||||
<Button type="primary" htmlType="submit">
|
||||
{$t('保存')}
|
||||
</Button>
|
||||
</WithPermission>
|
||||
<Button className="ml-btnrbase" type="default" onClick={() => navigateTo(-1)}>
|
||||
{$t('取消')}
|
||||
</Button>
|
||||
</div>}
|
||||
</div>
|
||||
</Form>
|
||||
</WithPermission>
|
||||
</div>)
|
||||
}
|
||||
export default RoleConfig
|
||||
export default RoleConfig
|
||||
@@ -1,6 +0,0 @@
|
||||
import ServiceLogs from "./ServiceLogs"
|
||||
const AiServiceLogsContainer = () => {
|
||||
return <ServiceLogs serviceType="aiService" />
|
||||
}
|
||||
|
||||
export default AiServiceLogsContainer
|
||||
@@ -1,89 +0,0 @@
|
||||
import { IconButton } from '@common/components/postcat/api/IconButton'
|
||||
import useCopyToClipboard from '@common/hooks/copy'
|
||||
import { RESPONSE_TIPS } from '@common/const/const'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { App } from 'antd'
|
||||
import ReactJson from 'react-json-view'
|
||||
|
||||
const ApiNetWorkDataPreview = ({ configContent = {} }: { configContent?: { [key: string]: string | undefined } }) => {
|
||||
/** 复制组件 */
|
||||
const { copyToClipboard } = useCopyToClipboard()
|
||||
/** 弹窗组件 */
|
||||
const { message } = App.useApp()
|
||||
/**
|
||||
* 复制
|
||||
* @param value
|
||||
* @returns
|
||||
*/
|
||||
const handleCopy = async (value: string): Promise<void> => {
|
||||
if (value) {
|
||||
copyToClipboard(value)
|
||||
message.success($t(RESPONSE_TIPS.copySuccess))
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 判断字符串是否是有效的JSON对象字符串
|
||||
*/
|
||||
const isJsonString = (str: string): boolean => {
|
||||
try {
|
||||
const parsed = JSON.parse(str)
|
||||
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{Object.keys(configContent).filter((item) => !!configContent[item]).map((item) => {
|
||||
return (
|
||||
<div className="overflow-auto mb-[15px]">
|
||||
<div className="font-semibold text-[16px] mb-[10px]">{item}</div>
|
||||
<div className="bg-[#0a0b21] text-white p-4 rounded-md my-2 font-mono text-sm overflow-auto relative">
|
||||
{!configContent[item] ? (
|
||||
<pre className="whitespace-pre-wrap break-words"></pre>
|
||||
) : isJsonString(configContent[item] || '') ? (
|
||||
// 如果是有效的JSON对象字符串,使用ReactJson渲染
|
||||
<ReactJson
|
||||
src={JSON.parse(configContent[item] || '')}
|
||||
theme="monokai"
|
||||
indentWidth={2}
|
||||
displayDataTypes={false}
|
||||
displayObjectSize={false}
|
||||
name={false}
|
||||
collapsed={false}
|
||||
enableClipboard={false}
|
||||
style={{
|
||||
backgroundColor: 'transparent',
|
||||
wordBreak: 'break-word',
|
||||
whiteSpace: 'normal'
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
// 如果是普通字符串,直接用pre渲染
|
||||
<pre className="whitespace-pre-wrap break-words my-[8px]">{configContent[item]}</pre>
|
||||
)}
|
||||
<IconButton
|
||||
name="copy"
|
||||
onClick={() => handleCopy(configContent[item] || '')}
|
||||
sx={{
|
||||
position: 'absolute',
|
||||
top: '5px',
|
||||
right: '5px',
|
||||
color: '#999',
|
||||
transition: 'none',
|
||||
'&.MuiButtonBase-root:hover': {
|
||||
background: 'transparent',
|
||||
color: '#3D46F2',
|
||||
transition: 'none'
|
||||
}
|
||||
}}
|
||||
></IconButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</>
|
||||
)
|
||||
}
|
||||
export default ApiNetWorkDataPreview
|
||||
@@ -1,362 +0,0 @@
|
||||
import { Descriptions, DescriptionsProps, Spin, Tabs, Tooltip, message } from 'antd'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import React from 'react'
|
||||
import { ExclamationCircleOutlined, LoadingOutlined } from '@ant-design/icons'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
import ApiNetWorkDataPreview from './ApiNetWorkDataPreview'
|
||||
import { LogItem } from './ServiceLogs'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
|
||||
// 定义状态码颜色映射枚举
|
||||
export enum HttpStatusColor {
|
||||
SUCCESS = '#7EC26A',
|
||||
CLIENT_ERROR = '#F2CF59',
|
||||
SERVER_ERROR = '#f80f34'
|
||||
}
|
||||
|
||||
type LogDetailProps = {
|
||||
selectedRow?: LogItem
|
||||
serviceType: 'aiService' | 'restService'
|
||||
serviceId?: string
|
||||
teamId?: string
|
||||
}
|
||||
|
||||
type AIServiceDetailType = {
|
||||
id: string
|
||||
api: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
logTime: string
|
||||
consumer: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
isSystemConsumer: boolean
|
||||
status: string
|
||||
provider: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
model: string
|
||||
ip: string
|
||||
request: {
|
||||
header: string
|
||||
body: string
|
||||
origin: string
|
||||
token: number
|
||||
}
|
||||
response: {
|
||||
header: string
|
||||
body: string
|
||||
origin: string
|
||||
token: string
|
||||
}
|
||||
}
|
||||
|
||||
type RestServiceDetailType = {
|
||||
id: string
|
||||
api: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
logTime: string
|
||||
consumer: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
isSystemConsumer: boolean
|
||||
status: string
|
||||
ip: string
|
||||
request: {
|
||||
header: string
|
||||
origin: string
|
||||
}
|
||||
response: {
|
||||
header: string
|
||||
origin: string
|
||||
}
|
||||
}
|
||||
|
||||
const LogDetail = ({ selectedRow, serviceType, serviceId, teamId }: LogDetailProps) => {
|
||||
/** 顶部描述 */
|
||||
const [descriptionItems, setDescriptionItems] = useState<DescriptionsProps['items']>()
|
||||
/** 全局状态 */
|
||||
const { state } = useGlobalContext()
|
||||
/** Request 标签页数据 */
|
||||
const [requestInfoData, setRequestInfoData] = useState<{ [key: string]: string | undefined }>()
|
||||
/** Response 标签页数据 */
|
||||
const [responseInfoData, setResponseInfoData] = useState<{ [key: string]: string | undefined }>()
|
||||
/** 面板 loading */
|
||||
const [dashboardLoading, setDashboardLoading] = useState(true)
|
||||
/**
|
||||
* 请求数据
|
||||
*/
|
||||
const { fetchData } = useFetch()
|
||||
|
||||
/**
|
||||
* 根据状态码返回对应颜色的文本
|
||||
* @param status 状态
|
||||
* @returns
|
||||
*/
|
||||
const renderStatusWithColor = (status: string) => {
|
||||
// 获取状态码首位数字
|
||||
const firstDigit = String(status).charAt(0)
|
||||
let color = ''
|
||||
switch (firstDigit) {
|
||||
case '2':
|
||||
color = HttpStatusColor.SUCCESS
|
||||
break
|
||||
case '4':
|
||||
color = HttpStatusColor.CLIENT_ERROR
|
||||
break
|
||||
case '5':
|
||||
color = HttpStatusColor.SERVER_ERROR
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
return color ? <span style={{ color }}>{status}</span> : status
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签页内容
|
||||
*/
|
||||
const tabItems = useMemo(
|
||||
() => [
|
||||
{
|
||||
key: 'request',
|
||||
label: 'Request',
|
||||
children: <ApiNetWorkDataPreview configContent={requestInfoData} />
|
||||
},
|
||||
{
|
||||
key: 'response',
|
||||
label: 'Response',
|
||||
children: <ApiNetWorkDataPreview configContent={responseInfoData} />
|
||||
}
|
||||
],
|
||||
[state.language, requestInfoData, responseInfoData]
|
||||
)
|
||||
|
||||
/**
|
||||
* 设置 AI 描述文案
|
||||
*/
|
||||
const getAIServiceDescriptionItemsList = ({
|
||||
time,
|
||||
api,
|
||||
consumer,
|
||||
status,
|
||||
model,
|
||||
ip
|
||||
}: {
|
||||
time: string
|
||||
api: string
|
||||
consumer: string
|
||||
status: string
|
||||
model: string
|
||||
ip: string
|
||||
}) => {
|
||||
setDescriptionItems([
|
||||
{
|
||||
key: 'time',
|
||||
label: $t('时间戳'),
|
||||
children: time
|
||||
},
|
||||
{
|
||||
key: 'api',
|
||||
label: $t('API / Tools'),
|
||||
children: api
|
||||
},
|
||||
{
|
||||
key: 'consumer',
|
||||
label: $t('消费者'),
|
||||
children: consumer
|
||||
},
|
||||
{
|
||||
key: 'httpStatus',
|
||||
label: $t('HTTP 状态'),
|
||||
children: renderStatusWithColor(status)
|
||||
},
|
||||
{
|
||||
key: 'model',
|
||||
label: $t('模型'),
|
||||
children: model
|
||||
},
|
||||
{
|
||||
key: 'ip',
|
||||
label: $t('IP'),
|
||||
children: ip
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 REST 描述文案
|
||||
*/
|
||||
const getRestServiceDescriptionItemsList = ({
|
||||
time,
|
||||
api,
|
||||
consumer,
|
||||
isSystemConsumer,
|
||||
status,
|
||||
ip
|
||||
}: {
|
||||
time: string
|
||||
api: string
|
||||
consumer: string
|
||||
isSystemConsumer?: boolean
|
||||
status: string
|
||||
ip: string
|
||||
}) => {
|
||||
setDescriptionItems([
|
||||
{
|
||||
key: 'time',
|
||||
label: $t('时间戳'),
|
||||
children: time
|
||||
},
|
||||
{
|
||||
key: 'api',
|
||||
label: $t('API / Tools'),
|
||||
children: api
|
||||
},
|
||||
{
|
||||
key: 'consumer',
|
||||
label: $t('消费者'),
|
||||
children: (
|
||||
<>
|
||||
<span className="mr-[50px]">{consumer}</span>
|
||||
{isSystemConsumer && (
|
||||
<span>
|
||||
<span>System-level API Key</span>
|
||||
<Tooltip title={$t('通过系统级别的 API Key 来调用')}>
|
||||
<span className="ml-[12px] items-center">
|
||||
<ExclamationCircleOutlined className="text-[14px] h-[14px] w-[14px]" />
|
||||
</span>
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
},
|
||||
{
|
||||
key: 'httpStatus',
|
||||
label: $t('HTTP 状态'),
|
||||
children: renderStatusWithColor(status)
|
||||
},
|
||||
{
|
||||
key: 'ip',
|
||||
label: $t('IP'),
|
||||
children: ip
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 AI 服务日志详情
|
||||
*/
|
||||
const getAIServiceLogDetail = () => {
|
||||
fetchData<BasicResponse<{ log: AIServiceDetailType }>>('service/log/ai', {
|
||||
method: 'GET',
|
||||
eoParams: { log: selectedRow?.id, service: serviceId, team: teamId },
|
||||
eoTransformKeys: ['is_system_consumer', 'log_time']
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
const result = data.log
|
||||
getAIServiceDescriptionItemsList({
|
||||
time: result.logTime,
|
||||
api: result.api.name,
|
||||
consumer: result.consumer.name,
|
||||
status: result.status,
|
||||
model: result.model,
|
||||
ip: result.ip
|
||||
})
|
||||
setRequestInfoData({
|
||||
Header: result.request.header,
|
||||
Body: result.request.body
|
||||
})
|
||||
setResponseInfoData({
|
||||
Header: result.response.header,
|
||||
Body: result.response.body
|
||||
})
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
setDashboardLoading(false)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取 REST 服务日志详情
|
||||
*/
|
||||
const getRestServiceLogDetail = () => {
|
||||
fetchData<BasicResponse<{ log: RestServiceDetailType }>>('service/log/rest', {
|
||||
method: 'GET',
|
||||
eoParams: { log: selectedRow?.id, service: serviceId, team: teamId },
|
||||
eoTransformKeys: ['is_system_consumer', 'log_time']
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
const result = data.log
|
||||
getRestServiceDescriptionItemsList({
|
||||
time: result.logTime,
|
||||
api: result.api.name,
|
||||
consumer: result.consumer.name,
|
||||
status: result.status,
|
||||
ip: result.ip,
|
||||
isSystemConsumer: result.isSystemConsumer
|
||||
})
|
||||
setRequestInfoData({
|
||||
Header: result.request.header,
|
||||
Body: result.request.body
|
||||
})
|
||||
setResponseInfoData({
|
||||
Header: result.response.header,
|
||||
Body: result.response.body
|
||||
})
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
setDashboardLoading(false)
|
||||
})
|
||||
}
|
||||
useEffect(() => {
|
||||
setDashboardLoading(true)
|
||||
serviceType === 'aiService' ? getAIServiceLogDetail() : getRestServiceLogDetail()
|
||||
}, [serviceType])
|
||||
|
||||
return (
|
||||
<Spin
|
||||
className="h-full pb-[20px]"
|
||||
wrapperClassName="h-full min-h-[150px]"
|
||||
indicator={
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<div style={{ transform: 'scale(1.5)' }}>
|
||||
<LoadingOutlined style={{ fontSize: 30 }} spin />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
spinning={dashboardLoading}
|
||||
>
|
||||
<Descriptions
|
||||
column={1}
|
||||
className="[&_.ant-descriptions-item]:p-0 [&_.ant-descriptions-item]:py-[5px]"
|
||||
colon={false}
|
||||
items={descriptionItems}
|
||||
classNames={{
|
||||
label: 'w-[250px] text-right pr-[12px]'
|
||||
}}
|
||||
contentStyle={{ fontWeight: '600' }}
|
||||
/>
|
||||
<div className="mt-[5px] service-log-tab">
|
||||
<Tabs
|
||||
className="overflow-hidden h-full [&>.ant-tabs-content-holder]:overflow-auto global-policy-tabs"
|
||||
items={tabItems}
|
||||
/>
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
|
||||
export default LogDetail
|
||||
@@ -1,7 +0,0 @@
|
||||
import ServiceLogs from "./ServiceLogs"
|
||||
|
||||
const RestServiceLogsContainer = () => {
|
||||
return <ServiceLogs serviceType="restService" />
|
||||
}
|
||||
|
||||
export default RestServiceLogsContainer
|
||||
@@ -1,263 +0,0 @@
|
||||
import { LoadingOutlined } from '@ant-design/icons'
|
||||
import { Drawer, Spin, message } from 'antd'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import DateSelectFilter, { TimeOption } from '../serviceOverview/filter/DateSelectFilter'
|
||||
import { TimeRange } from '@common/components/aoplatform/TimeRangeSelector'
|
||||
import PageList from '@common/components/aoplatform/PageList'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
import { REST_SERVICE_LOG_LIST, AI_SERVICE_LOG_LIST } from '@core/const/system/const'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import LogDetail, { HttpStatusColor } from './LogDetail'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { ActionType, ParamsType } from '@ant-design/pro-components'
|
||||
import { getTime } from '@dashboard/utils/dashboard'
|
||||
|
||||
export type LogItem = {
|
||||
id: string
|
||||
api: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
status: number
|
||||
logTime: string
|
||||
responseTime: string
|
||||
token?: number
|
||||
model?: string
|
||||
tokenPerSecond?: string
|
||||
traffic?: string
|
||||
consumers?: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
provider?: {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
}
|
||||
|
||||
const ServiceLogs = ({ serviceType }: { serviceType: 'aiService' | 'restService' }) => {
|
||||
/** 路由参数 */
|
||||
const { serviceId, teamId } = useParams<{ serviceId: string; teamId: string }>()
|
||||
/** 面板 loading */
|
||||
const [dashboardLoading, setDashboardLoading] = useState(true)
|
||||
/** 当前选中的时间范围 */
|
||||
const [timeRange, setTimeRange] = useState<TimeRange | undefined>()
|
||||
/** 默认时间 */
|
||||
const [defaultTime] = useState<TimeOption>('day')
|
||||
/** 全局状态 */
|
||||
const { state } = useGlobalContext()
|
||||
/**
|
||||
* 请求数据
|
||||
*/
|
||||
const { fetchData } = useFetch()
|
||||
// 打开侧边弹窗
|
||||
const [drawerOpen, setDrawerOpen] = useState<boolean>(false)
|
||||
/** 选中的行 */
|
||||
const [selectedRow, setSelectedRow] = useState<LogItem>()
|
||||
/**
|
||||
* 列表ref
|
||||
*/
|
||||
const pageListRef = useRef<ActionType>(null)
|
||||
/** 列 */
|
||||
const columns = useMemo(() => {
|
||||
return [...(serviceType === 'aiService' ? AI_SERVICE_LOG_LIST : REST_SERVICE_LOG_LIST)].map((x) => {
|
||||
if (x.dataIndex === 'status') {
|
||||
x.render = (text: any, record: any) => (
|
||||
<>
|
||||
<div className="w-full">{renderStatusWithColor(record.status)}</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
return {
|
||||
...x,
|
||||
title: typeof x.title === 'string' ? $t(x.title as string) : x.title
|
||||
}
|
||||
})
|
||||
}, [state.language])
|
||||
|
||||
/**
|
||||
* 根据状态码返回对应颜色的文本
|
||||
* @param status 状态
|
||||
* @returns
|
||||
*/
|
||||
const renderStatusWithColor = (status: string | number) => {
|
||||
// 获取状态码首位数字
|
||||
const firstDigit = status.toString().charAt(0)
|
||||
let color = ''
|
||||
switch (firstDigit) {
|
||||
case '2':
|
||||
color = HttpStatusColor.SUCCESS
|
||||
break
|
||||
case '4':
|
||||
color = HttpStatusColor.CLIENT_ERROR
|
||||
break
|
||||
case '5':
|
||||
color = HttpStatusColor.SERVER_ERROR
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
return color ? <span style={{ color }}>{status}</span> : status
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 AI 列表数据
|
||||
* @param dataType
|
||||
* @returns
|
||||
*/
|
||||
const getAiServiceLogList = (
|
||||
params: ParamsType & {
|
||||
pageSize?: number | undefined
|
||||
current?: number | undefined
|
||||
keyword?: string | undefined
|
||||
}
|
||||
) => {
|
||||
return fetchData<BasicResponse<{ log: LogItem[] }>>(`service/logs/ai`, {
|
||||
method: 'GET',
|
||||
eoParams: {
|
||||
service: serviceId,
|
||||
team: teamId,
|
||||
start: timeRange?.start,
|
||||
end: timeRange?.end,
|
||||
page: params?.current,
|
||||
page_size:params?.pageSize
|
||||
},
|
||||
eoTransformKeys: ['log_time', 'response_time', 'token_per_second']
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
// 保存数据
|
||||
return {
|
||||
data: data.logs,
|
||||
total: data.total,
|
||||
success: true
|
||||
}
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
return { data: [], success: false }
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
return { data: [], success: false }
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 获取 REST 列表数据
|
||||
* @param dataType
|
||||
* @returns
|
||||
*/
|
||||
const getRestServiceLogList = (
|
||||
params: ParamsType & {
|
||||
pageSize?: number | undefined
|
||||
current?: number | undefined
|
||||
keyword?: string | undefined
|
||||
}
|
||||
) => {
|
||||
console.log('params===', params)
|
||||
return fetchData<BasicResponse<{ log: LogItem[] }>>(`service/logs/rest`, {
|
||||
method: 'GET',
|
||||
eoParams: {
|
||||
service: serviceId,
|
||||
team: teamId,
|
||||
start: timeRange?.start,
|
||||
end: timeRange?.end,
|
||||
page: params?.current,
|
||||
page_size:params?.pageSize
|
||||
},
|
||||
eoTransformKeys: ['log_time', 'response_time', 'token_per_second']
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
// 保存数据
|
||||
return {
|
||||
data: data.logs,
|
||||
total: data.total,
|
||||
success: true
|
||||
}
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
return { data: [], success: false }
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
return { data: [], success: false }
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { startTime, endTime } = getTime(defaultTime, [])
|
||||
setTimeRange({
|
||||
start: startTime,
|
||||
end: endTime
|
||||
})
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
if (timeRange) {
|
||||
pageListRef.current?.reload()
|
||||
}
|
||||
}, [timeRange])
|
||||
|
||||
/** 行点击 */
|
||||
const handleRowClick = (record: LogItem) => {
|
||||
setSelectedRow(record)
|
||||
setDrawerOpen(true)
|
||||
}
|
||||
|
||||
/** 时间选择回调 */
|
||||
const selectCallback = (date: TimeRange) => {
|
||||
setTimeRange(date)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setDashboardLoading(false)
|
||||
}, [])
|
||||
return (
|
||||
<Spin
|
||||
className="h-full pb-[20px]"
|
||||
wrapperClassName="h-full min-h-[150px] overflow-hidden"
|
||||
indicator={
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<div style={{ transform: 'scale(1.5)' }}>
|
||||
<LoadingOutlined style={{ fontSize: 30 }} spin />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
spinning={dashboardLoading}
|
||||
>
|
||||
<div className="h-full mr-PAGE_INSIDE_X">
|
||||
<DateSelectFilter selectCallback={selectCallback} customClassNames={'pt-[0px]'} defaultTime={defaultTime} />
|
||||
<div style={{ height: 'calc(100% - -3px)' }} className="mt-[20px] overflow-hidden">
|
||||
<PageList
|
||||
ref={pageListRef}
|
||||
id={`${serviceType}_logs`}
|
||||
columns={[...columns]}
|
||||
request={async (
|
||||
params: ParamsType & {
|
||||
pageSize?: number | undefined
|
||||
current?: number | undefined
|
||||
keyword?: string | undefined
|
||||
}
|
||||
) => (serviceType === 'aiService' ? getAiServiceLogList(params) : getRestServiceLogList(params))}
|
||||
onRowClick={(row: LogItem) => handleRowClick(row)}
|
||||
/>
|
||||
</div>
|
||||
<Drawer
|
||||
destroyOnClose={true}
|
||||
maskClosable={false}
|
||||
title={$t('日志详情')}
|
||||
width={'40%'}
|
||||
onClose={() => setDrawerOpen(false)}
|
||||
open={drawerOpen}
|
||||
>
|
||||
<LogDetail selectedRow={selectedRow} serviceId={serviceId} teamId={teamId} serviceType={serviceType} />
|
||||
</Drawer>
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServiceLogs
|
||||
@@ -1,7 +0,0 @@
|
||||
import ServiceOverview from "./serviceOverview"
|
||||
|
||||
const AiServiceContainer = () => {
|
||||
return <ServiceOverview serviceType="aiService" />
|
||||
}
|
||||
|
||||
export default AiServiceContainer
|
||||
@@ -1,12 +0,0 @@
|
||||
import { FC } from 'react'
|
||||
import ServiceOverview from './serviceOverview'
|
||||
|
||||
const RestServiceContainer: FC = () => {
|
||||
return (
|
||||
<>
|
||||
<ServiceOverview serviceType="restService" />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default RestServiceContainer
|
||||
@@ -1,278 +0,0 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import ECharts, { EChartsOption } from 'echarts-for-react'
|
||||
import { $t } from '@common/locales'
|
||||
|
||||
type AreaChartInfo = {
|
||||
title: string
|
||||
value: string
|
||||
date: string[]
|
||||
data: number[]
|
||||
max: string
|
||||
min: string
|
||||
originValue?: number
|
||||
showXAxis?: boolean
|
||||
}
|
||||
|
||||
type ServiceAreaCharProps = {
|
||||
customClassNames?: string
|
||||
dataInfo?: AreaChartInfo
|
||||
height?: number
|
||||
showAvgLine?: boolean
|
||||
customMarkLineValue?: number
|
||||
}
|
||||
|
||||
const ServiceAreaChart = ({ customClassNames, dataInfo, height, showAvgLine, customMarkLineValue }: ServiceAreaCharProps) => {
|
||||
const chartRef = useRef<ECharts>(null)
|
||||
const [option, setOption] = useState<EChartsOption | undefined>({})
|
||||
const [hasData, setHasData] = useState(true)
|
||||
const setChartOption = (dataInfo: AreaChartInfo) => {
|
||||
const dataExists = dataInfo.data && dataInfo.data.length > 0
|
||||
// 更新hasData状态
|
||||
setHasData(dataExists)
|
||||
const option = {
|
||||
tooltip: dataExists ? {
|
||||
trigger: 'axis',
|
||||
formatter: function (value: any) {
|
||||
// 如果是数组,取第一个参数的name
|
||||
const param = Array.isArray(value) ? value[0] : value
|
||||
let tooltipContent = `<div style="min-width:140px;padding:8px;">`
|
||||
const marker = `<span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${param.color};"></span>`
|
||||
tooltipContent += `<div style="margin-top: 8px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div style="margin-right: 4px;">${marker}</div>${param.name} <div style="font-weight:bold; margin-left: 20px;">${param.value}</div>
|
||||
</div>`
|
||||
tooltipContent += '</div>'
|
||||
return tooltipContent
|
||||
}
|
||||
} : {
|
||||
show: false // 没有数据时不显示tooltip
|
||||
},
|
||||
title: [
|
||||
{
|
||||
text: '{titleStyle|' + $t(dataInfo.title) + '}\n\n{valueStyle|' + dataInfo.value + '}',
|
||||
left: '2%',
|
||||
top: '0',
|
||||
textStyle: {
|
||||
rich: {
|
||||
titleStyle: {
|
||||
fontSize: 14,
|
||||
color: '#999999',
|
||||
fontWeight: 'normal',
|
||||
lineHeight: 20
|
||||
},
|
||||
valueStyle: {
|
||||
fontSize: 32,
|
||||
color: '#101010',
|
||||
fontWeight: 500,
|
||||
lineHeight: 40
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
toolbox: {
|
||||
show: false
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
bottom: '0%',
|
||||
top: '110px',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: dataInfo.date,
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#ccc'
|
||||
}
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
boundaryGap: [0, '5%'],
|
||||
show: dataExists, // 没有数据时不显示Y轴
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLabel: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
// 添加数据缩放组件,实现鼠标放大缩小,后续可能需要
|
||||
// dataZoom: [
|
||||
// {
|
||||
// type: 'inside', // 内置的数据区域缩放组件(使用鼠标滚轮缩放)
|
||||
// xAxisIndex: 0, // 设置缩放作用在第一个x轴
|
||||
// filterMode: 'filter',
|
||||
// start: 0,
|
||||
// end: 100
|
||||
// },
|
||||
// {
|
||||
// type: 'slider', // 滑动条型数据区域缩放组件
|
||||
// xAxisIndex: 0,
|
||||
// filterMode: 'filter',
|
||||
// height: 20,
|
||||
// bottom: 0,
|
||||
// start: 0,
|
||||
// end: 100,
|
||||
// handleIcon:
|
||||
// 'path://M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
|
||||
// handleSize: '80%',
|
||||
// handleStyle: {
|
||||
// color: '#fff',
|
||||
// shadowBlur: 3,
|
||||
// shadowColor: 'rgba(0, 0, 0, 0.6)',
|
||||
// shadowOffsetX: 2,
|
||||
// shadowOffsetY: 2
|
||||
// },
|
||||
// show: false // 默认隐藏底部的滑动条,可以改为 true 显示
|
||||
// }
|
||||
// ],
|
||||
// 添加空状态提示
|
||||
silent: !dataExists,
|
||||
graphic: !dataExists
|
||||
? [
|
||||
{
|
||||
type: 'text',
|
||||
left: 'center',
|
||||
top: 'middle',
|
||||
style: {
|
||||
text: $t('暂无数据'),
|
||||
fontSize: 14,
|
||||
fill: '#999'
|
||||
}
|
||||
}
|
||||
]
|
||||
: [],
|
||||
series: [
|
||||
{
|
||||
name: dataInfo.title,
|
||||
type: 'line',
|
||||
symbol: 'none',
|
||||
sampling: 'lttb',
|
||||
itemStyle: {
|
||||
color: 'rgb(255, 70, 131)'
|
||||
},
|
||||
markLine: showAvgLine ? {
|
||||
silent: false,
|
||||
symbol: 'none',
|
||||
lineStyle: {
|
||||
width: 1,
|
||||
type: 'dashed'
|
||||
},
|
||||
label: {
|
||||
show: false,
|
||||
position: 'insideEndTop',
|
||||
formatter: '{c}',
|
||||
color: '#000',
|
||||
fontSize: 10,
|
||||
backgroundColor: 'transparent',
|
||||
padding: [10, 4],
|
||||
borderRadius: 2,
|
||||
distance: -5
|
||||
},
|
||||
emphasis: {
|
||||
lineStyle: {
|
||||
width: 1 // 保持线条宽度不变,禁用默认的悬停加粗
|
||||
},
|
||||
label: {
|
||||
show: false // 悬停时不显示标签
|
||||
}
|
||||
},
|
||||
data: dataInfo?.originValue !== undefined ?
|
||||
[{ yAxis: dataInfo?.originValue, name: '自定义值' }] :
|
||||
[{ type: 'average', name: 'Avg' }]
|
||||
} : undefined,
|
||||
areaStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{
|
||||
offset: 0,
|
||||
color: 'rgb(255, 158, 68)'
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgb(255, 70, 131)'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
data: dataInfo.data
|
||||
}
|
||||
]
|
||||
}
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
echartsInstance.setOption(option)
|
||||
}
|
||||
}
|
||||
// 使用深度监听来确保图表数据更新
|
||||
useEffect(() => {
|
||||
if (!dataInfo) return
|
||||
|
||||
// 直接获取 ECharts 实例并设置选项
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
// 清除已有的图表
|
||||
echartsInstance.clear()
|
||||
// 重新设置选项
|
||||
setChartOption(dataInfo)
|
||||
}
|
||||
}, [dataInfo, JSON.stringify(dataInfo)])
|
||||
|
||||
// 添加窗口大小变化监听,实现自适应
|
||||
useEffect(() => {
|
||||
// 定义resize处理函数
|
||||
const handleResize = () => {
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
echartsInstance.resize()
|
||||
}
|
||||
}
|
||||
|
||||
// 添加监听
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
// 组件卸载时移除监听
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
}
|
||||
}, [])
|
||||
return (
|
||||
<div className={`w-full ${customClassNames}`}>
|
||||
<div className="absolute top-[10px] left-[10px] w-full">
|
||||
<div className="relative top-[5px]">
|
||||
<div className="absolute top-[23px] right-[5%] grid grid-cols-[auto_auto] justify-items-end">
|
||||
<div className="flex justify-center items-center">
|
||||
<span className="text-[#FE564D] text-[9px]">▲</span>
|
||||
</div>
|
||||
<span className="ml-1 text-right">{dataInfo?.max}</span>
|
||||
<div className="flex justify-center items-center">
|
||||
<span className="text-[#27B148] text-[9px]">▼</span>
|
||||
</div>
|
||||
<span className="ml-1 text-right">{dataInfo?.min}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style={!hasData ? { cursor: 'default', pointerEvents: 'none' } : {}}>
|
||||
<ECharts ref={chartRef} option={option} theme="apipark" style={{ height: height || 400 }} opts={{ renderer: 'svg' }} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServiceAreaChart
|
||||
@@ -1,395 +0,0 @@
|
||||
import ECharts, { EChartsOption } from 'echarts-for-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { chartColors, defaultColor } from '@common/const/charts/theme'
|
||||
|
||||
export type BarChartInfo = {
|
||||
title: string
|
||||
value: string
|
||||
date: string[]
|
||||
data: {
|
||||
name: string
|
||||
color: string
|
||||
value: number[]
|
||||
}[]
|
||||
showXAxis?: boolean
|
||||
inputTokenTotal?: string
|
||||
outputTokenTotal?: string
|
||||
request2xxTotal?: string
|
||||
request4xxTotal?: string
|
||||
request5xxTotal?: string
|
||||
traffic2xxTotal?: string
|
||||
traffic4xxTotal?: string
|
||||
traffic5xxTotal?: string
|
||||
max?: string | number
|
||||
min?: string | number
|
||||
}
|
||||
|
||||
type ServiceBarCharProps = {
|
||||
customClassNames?: string
|
||||
dataInfo?: BarChartInfo
|
||||
height?: number
|
||||
showAvgLine?: boolean
|
||||
showLegendIndicator?: boolean
|
||||
hideIndicatorValue?: boolean
|
||||
}
|
||||
|
||||
const ServiceBarChar = ({
|
||||
customClassNames,
|
||||
dataInfo,
|
||||
height,
|
||||
showAvgLine,
|
||||
showLegendIndicator,
|
||||
hideIndicatorValue
|
||||
}: ServiceBarCharProps) => {
|
||||
const chartRef = useRef<ECharts>(null)
|
||||
const [option, setOption] = useState<EChartsOption | undefined>({})
|
||||
// 使用从主题配置中导入的默认颜色,而不是硬编码的颜色值
|
||||
const [detaultColor] = useState(defaultColor)
|
||||
const [hasData, setHasData] = useState(true)
|
||||
const tokenMap = {
|
||||
inputToken: $t('输入 Token'),
|
||||
outputToken: $t('输出 Token')
|
||||
}
|
||||
const setChartOption = (dataInfo: BarChartInfo) => {
|
||||
const isNumberArray = typeof dataInfo.data[0] !== 'object'
|
||||
const legendData = isNumberArray ? [dataInfo.title] : dataInfo.data.map((item) => item.name)
|
||||
const dataExists = dataInfo.data && dataInfo.data.length > 0
|
||||
// 更新hasData状态
|
||||
setHasData(dataExists)
|
||||
const tooltipFormatter = (params: { name: string; color: string; seriesIndex?: number }) => {
|
||||
let tooltipContent = `<div style="min-width:140px;padding:8px;">
|
||||
<div>${isNumberArray ? '' : params.name}</div>`
|
||||
const data = isNumberArray
|
||||
? [
|
||||
{
|
||||
name: params.name,
|
||||
color: detaultColor,
|
||||
value: dataInfo.data
|
||||
}
|
||||
]
|
||||
: dataInfo.data
|
||||
// 为每个数据系列添加一行
|
||||
data.forEach((item, index) => {
|
||||
// 使用与柱状图相同的颜色策略,确保颜色一致性
|
||||
const color = item.color ? item.color : index < chartColors.length ? chartColors[index] : detaultColor
|
||||
const name = tokenMap[item.name as keyof typeof tokenMap] || item.name
|
||||
const value = item.value[dataInfo.date.indexOf(params.name)] || 0
|
||||
|
||||
const marker = `<span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${color};"></span>`
|
||||
tooltipContent += `<div style="margin-top: ${index === 0 ? 8 : 4}px; display: flex; justify-content: space-between; align-items: center;">
|
||||
<div>${marker} ${name}</div> <div style="font-weight:bold; margin-left: 20px;">${value}</div>
|
||||
</div>`
|
||||
})
|
||||
|
||||
tooltipContent += '</div>'
|
||||
return tooltipContent
|
||||
}
|
||||
const option: EChartsOption = {
|
||||
title: [
|
||||
{
|
||||
text:
|
||||
'{titleStyle|' +
|
||||
$t(dataInfo.title) +
|
||||
`}${hideIndicatorValue ? '' : '\n\n{valueStyle|' + dataInfo.value + '}'}`,
|
||||
left: '2%',
|
||||
top: '0',
|
||||
textStyle: {
|
||||
rich: {
|
||||
titleStyle: {
|
||||
fontSize: 14,
|
||||
color: '#999999',
|
||||
fontWeight: 'normal',
|
||||
lineHeight: 20
|
||||
},
|
||||
valueStyle: {
|
||||
fontSize: 32,
|
||||
color: '#101010',
|
||||
fontWeight: 500,
|
||||
lineHeight: 40
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
bottom: '0%',
|
||||
top: '110px',
|
||||
containLabel: true
|
||||
},
|
||||
tooltip: dataExists
|
||||
? {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
},
|
||||
formatter: function (params: any) {
|
||||
// 如果是数组,取第一个参数的name
|
||||
const param = Array.isArray(params) ? params[0] : params
|
||||
return tooltipFormatter(param)
|
||||
}
|
||||
}
|
||||
: {
|
||||
show: false // 没有数据时不显示tooltip
|
||||
},
|
||||
legend: {
|
||||
show: !isNumberArray,
|
||||
data: legendData,
|
||||
right: '10px',
|
||||
top: hideIndicatorValue ? '10px' : '60px',
|
||||
itemWidth: 10,
|
||||
itemHeight: 10,
|
||||
textStyle: {
|
||||
color: '#333'
|
||||
},
|
||||
icon: 'rect',
|
||||
formatter: function (name: string): string {
|
||||
// 这里可以映射或自定义图例文本
|
||||
const customNames: Record<string, string> = {
|
||||
inputToken: `${$t('输入 Token')} ${showLegendIndicator ? `(${dataInfo.inputTokenTotal})` : ''}`,
|
||||
outputToken: `${$t('输出 Token')} ${showLegendIndicator ? `(${dataInfo.outputTokenTotal})` : ''}`,
|
||||
'2xx': `${'2xx'} ${showLegendIndicator ? `(${dataInfo.request2xxTotal || dataInfo.traffic2xxTotal})` : ''}`,
|
||||
'4xx': `${'4xx'} ${showLegendIndicator ? `(${dataInfo.request4xxTotal || dataInfo.traffic4xxTotal})` : ''}`,
|
||||
'5xx': `${'5xx'} ${showLegendIndicator ? `(${dataInfo.request5xxTotal || dataInfo.traffic5xxTotal})` : ''}`
|
||||
}
|
||||
return customNames[name] || name
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: dataInfo.date,
|
||||
axisTick: {
|
||||
show: false
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#ccc'
|
||||
}
|
||||
},
|
||||
show: false
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: '',
|
||||
min: 0,
|
||||
...(showAvgLine ? {} : { minInterval: 1 }),
|
||||
show: dataExists, // 没有数据时不显示Y轴
|
||||
splitLine: {
|
||||
show: dataExists, // 没有数据时不显示网格线
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: '#eee'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
formatter: '{value}'
|
||||
}
|
||||
},
|
||||
// 添加数据缩放组件,实现鼠标放大缩小,后续可能需要
|
||||
// dataZoom: [
|
||||
// {
|
||||
// type: 'inside', // 内置的数据区域缩放组件(使用鼠标滚轮缩放)
|
||||
// xAxisIndex: 0, // 设置缩放作用在第一个x轴
|
||||
// filterMode: 'filter',
|
||||
// start: 0,
|
||||
// end: 100
|
||||
// },
|
||||
// {
|
||||
// type: 'slider', // 滑动条型数据区域缩放组件
|
||||
// xAxisIndex: 0,
|
||||
// filterMode: 'filter',
|
||||
// height: 20,
|
||||
// bottom: 0,
|
||||
// start: 0,
|
||||
// end: 100,
|
||||
// handleIcon: 'path://M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
|
||||
// handleSize: '80%',
|
||||
// handleStyle: {
|
||||
// color: '#fff',
|
||||
// shadowBlur: 3,
|
||||
// shadowColor: 'rgba(0, 0, 0, 0.6)',
|
||||
// shadowOffsetX: 2,
|
||||
// shadowOffsetY: 2
|
||||
// },
|
||||
// show: false // 默认隐藏底部的滑动条,可以改为 true 显示
|
||||
// }
|
||||
// ],
|
||||
// 添加空状态提示
|
||||
silent: !dataExists,
|
||||
graphic: !dataExists
|
||||
? [
|
||||
{
|
||||
type: 'text',
|
||||
left: 'center',
|
||||
top: 'middle',
|
||||
style: {
|
||||
text: $t('暂无数据'),
|
||||
fontSize: 14,
|
||||
fill: '#999'
|
||||
}
|
||||
}
|
||||
]
|
||||
: [],
|
||||
series: isNumberArray
|
||||
? [
|
||||
{
|
||||
name: dataInfo.title,
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
itemStyle: {
|
||||
color: detaultColor
|
||||
},
|
||||
markLine: showAvgLine
|
||||
? {
|
||||
silent: false,
|
||||
symbol: 'none',
|
||||
lineStyle: {
|
||||
width: 1,
|
||||
type: 'dashed'
|
||||
},
|
||||
label: {
|
||||
show: false,
|
||||
position: 'insideEndTop',
|
||||
formatter: '{c}',
|
||||
color: '#000',
|
||||
fontSize: 10,
|
||||
backgroundColor: 'transparent',
|
||||
padding: [10, 4],
|
||||
borderRadius: 2,
|
||||
distance: -5
|
||||
},
|
||||
emphasis: {
|
||||
lineStyle: {
|
||||
width: 1 // 保持线条宽度不变,禁用默认的悬停加粗
|
||||
},
|
||||
label: {
|
||||
show: false // 悬停时不显示标签
|
||||
}
|
||||
},
|
||||
data: [{ type: 'average', name: 'Avg' }]
|
||||
}
|
||||
: undefined,
|
||||
data: dataInfo.data
|
||||
}
|
||||
]
|
||||
: dataInfo.data.map((item, index) => ({
|
||||
name: item.name,
|
||||
type: 'bar',
|
||||
stack: '总量',
|
||||
markLine: showAvgLine
|
||||
? {
|
||||
silent: false,
|
||||
symbol: 'none',
|
||||
lineStyle: {
|
||||
width: 1,
|
||||
type: 'dashed'
|
||||
},
|
||||
label: {
|
||||
show: false,
|
||||
position: 'insideEndTop',
|
||||
formatter: '{c}',
|
||||
color: '#000',
|
||||
fontSize: 10,
|
||||
backgroundColor: 'transparent',
|
||||
padding: [10, 4],
|
||||
borderRadius: 2,
|
||||
distance: -5
|
||||
},
|
||||
emphasis: {
|
||||
lineStyle: {
|
||||
width: 1 // 保持线条宽度不变,禁用默认的悬停加粗
|
||||
},
|
||||
label: {
|
||||
show: false // 悬停时不显示标签
|
||||
}
|
||||
},
|
||||
data: [{ type: 'average', name: 'Avg' }]
|
||||
}
|
||||
: undefined,
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
itemStyle: {
|
||||
// 使用主题中的颜色列表,如果索引超出范围则使用项目自带的颜色
|
||||
color: item.color ? item.color : index < chartColors.length ? chartColors[index] : detaultColor
|
||||
},
|
||||
data: item.value
|
||||
}))
|
||||
}
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
echartsInstance.setOption(option)
|
||||
}
|
||||
}
|
||||
|
||||
// 使用深度监听来确保图表数据更新
|
||||
useEffect(() => {
|
||||
if (!dataInfo) return
|
||||
|
||||
// 直接获取 ECharts 实例并设置选项
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
// 清除已有的图表
|
||||
echartsInstance.clear()
|
||||
// 重新设置选项
|
||||
setChartOption(dataInfo)
|
||||
}
|
||||
}, [dataInfo, JSON.stringify(dataInfo)])
|
||||
|
||||
// 添加窗口大小变化监听,实现自适应
|
||||
useEffect(() => {
|
||||
// 定义resize处理函数
|
||||
const handleResize = () => {
|
||||
const echartsInstance = chartRef.current?.getEchartsInstance()
|
||||
if (echartsInstance) {
|
||||
echartsInstance.resize()
|
||||
}
|
||||
}
|
||||
|
||||
// 添加监听
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
// 组件卸载时移除监听
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
}
|
||||
}, [])
|
||||
return (
|
||||
<div className={`w-full ${customClassNames}`}>
|
||||
{
|
||||
hideIndicatorValue && (
|
||||
<div className="absolute top-[26px] left-[10px] w-full">
|
||||
<div className="relative top-[5px]">
|
||||
<div className="absolute top-[23px] right-[5%] grid grid-cols-[auto_auto] justify-items-end">
|
||||
<div className="flex justify-center items-center">
|
||||
<span className="text-[#FE564D] text-[9px]">▲</span>
|
||||
</div>
|
||||
<span className="ml-1 text-right">{dataInfo?.max}</span>
|
||||
<div className="flex justify-center items-center">
|
||||
<span className="text-[#27B148] text-[9px]">▼</span>
|
||||
</div>
|
||||
<span className="ml-1 text-right">{dataInfo?.min}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div style={!hasData ? { cursor: 'default', pointerEvents: 'none' } : {}}>
|
||||
<ECharts
|
||||
ref={chartRef}
|
||||
option={option}
|
||||
style={{ height: height || 400 }}
|
||||
opts={{ renderer: 'svg' }}
|
||||
theme="apipark" // 这里应用主题名称,需要先在应用入口注册
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServiceBarChar
|
||||
@@ -1,37 +0,0 @@
|
||||
import TimeRangeSelector, { RangeValue, TimeRange } from '@common/components/aoplatform/TimeRangeSelector'
|
||||
import { useState } from 'react'
|
||||
|
||||
export type TimeOption = '' | 'hour' | 'day' | 'threeDays' | 'sevenDays'
|
||||
const DateSelectFilter = ({
|
||||
selectCallback,
|
||||
defaultTime,
|
||||
customClassNames
|
||||
}: {
|
||||
selectCallback: (timeRange: TimeRange) => void
|
||||
defaultTime: TimeOption
|
||||
customClassNames?: string
|
||||
}) => {
|
||||
/** 默认时间 */
|
||||
const [timeButton, setTimeButton] = useState<TimeOption>(defaultTime || 'hour')
|
||||
/** 日期选择 */
|
||||
const [datePickerValue, setDatePickerValue] = useState<RangeValue>()
|
||||
/** 时间范围变化 */
|
||||
const handleTimeRangeChange = (timeRange: TimeRange) => {
|
||||
selectCallback(timeRange)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<TimeRangeSelector
|
||||
labelSize="small"
|
||||
customClassNames={customClassNames}
|
||||
initialTimeButton={timeButton}
|
||||
onTimeButtonChange={setTimeButton}
|
||||
initialDatePickerValue={datePickerValue}
|
||||
onTimeRangeChange={handleTimeRangeChange}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default DateSelectFilter
|
||||
@@ -1,88 +0,0 @@
|
||||
import { Button, Card } from 'antd'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { $t } from '@common/locales'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { Icon } from '@iconify/react/dist/iconify.js'
|
||||
|
||||
/** 服务指标 */
|
||||
type IndicatorType = {
|
||||
title: string
|
||||
link?: string
|
||||
content: string | React.ReactNode
|
||||
}
|
||||
const Indicator = ({ indicatorInfo }: { indicatorInfo: any }) => {
|
||||
/** 服务指标 */
|
||||
const [indicatorList, setIndicator] = useState<IndicatorType[]>([])
|
||||
/** 路由跳转 */
|
||||
const navigateTo = useNavigate()
|
||||
|
||||
/** 设置服务指标 */
|
||||
const setIndicatorList = () => {
|
||||
const side = indicatorInfo?.serviceKind === 'ai' ? 'aiInside' : 'inside'
|
||||
setIndicator([
|
||||
{
|
||||
title: indicatorInfo?.enableMcp ? 'APIs / Tools' : 'APIs',
|
||||
link: `/service/${indicatorInfo?.teamId}/${side}/${indicatorInfo?.serviceId}/route`,
|
||||
content: indicatorInfo?.apiNum ?? 0
|
||||
},
|
||||
{
|
||||
title: $t('订阅数量'),
|
||||
link: `/service/${indicatorInfo?.teamId}/${side}/${indicatorInfo?.serviceId}/subscriber`,
|
||||
content: indicatorInfo?.subscriberNum ?? 0
|
||||
},
|
||||
{
|
||||
title: 'MCP',
|
||||
link: `/service/${indicatorInfo?.teamId}/${side}/${indicatorInfo?.serviceId}/setting`,
|
||||
content: (
|
||||
<>
|
||||
<Button
|
||||
color={indicatorInfo?.enableMcp ? 'green' : 'primary'}
|
||||
className="w-full rounded-[10px]"
|
||||
variant="outlined"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
navigateTo(`/service/${indicatorInfo?.teamId}/${side}/${indicatorInfo?.serviceId}/setting`)
|
||||
}}
|
||||
>
|
||||
{indicatorInfo?.enableMcp ? $t('已开启') : $t('开启 MCP')}
|
||||
</Button>
|
||||
</>
|
||||
)
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!indicatorInfo) return
|
||||
setIndicatorList()
|
||||
}, [indicatorInfo])
|
||||
|
||||
return (
|
||||
<div className="flex">
|
||||
{indicatorList.map((item, index) => (
|
||||
<Card
|
||||
key={index}
|
||||
className={`flex-1 cursor-pointer rounded-[10px] ${index > 0 ? 'ml-[10px]' : ''}`}
|
||||
classNames={{
|
||||
body: 'py-[20px] px-[18px]'
|
||||
}}
|
||||
onClick={() => {
|
||||
if (item.link) {
|
||||
navigateTo(item.link)
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="text-[14px] text-[#999999] mb-[10px]" style={{ fontFamily: 'Microsoft YaHei' }}>
|
||||
{item.title}
|
||||
{item.link && <Icon icon="uiw:right" width="16" height="16" className="absolute top-[14px] right-[14px]" />}
|
||||
</div>
|
||||
<div className={`${index < 2 ? 'text-[32px] font-medium text-[#101010]' : 'block mt-[30px]'}`} style={{ fontFamily: 'Microsoft YaHei' }}>
|
||||
{item.content}
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Indicator
|
||||
@@ -1,96 +0,0 @@
|
||||
import { useMemo, useRef, useEffect } from 'react'
|
||||
import PageList from '@common/components/aoplatform/PageList'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { Card } from 'antd'
|
||||
import { AI_SERVICE_TOP_RANKING_LIST, REST_SERVICE_TOP_RANKING_LIST } from '@core/const/system/const'
|
||||
|
||||
interface RankingListData {
|
||||
[key: string]: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
request: number;
|
||||
token?: number;
|
||||
traffic?: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface PageListRef {
|
||||
reload: () => void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 排名列表
|
||||
* @returns
|
||||
*/
|
||||
const RankingList = ({ topRankingList, serviceType }: { topRankingList: RankingListData; serviceType: 'aiService' | 'restService' }) => {
|
||||
/** 全局状态 */
|
||||
const { state } = useGlobalContext()
|
||||
/** 表格 ref */
|
||||
const tableRefs = useRef<{ [key: string]: PageListRef | null }>({});
|
||||
/** 列 */
|
||||
const columns = useMemo(() => {
|
||||
return [...(serviceType === 'aiService' ? AI_SERVICE_TOP_RANKING_LIST : REST_SERVICE_TOP_RANKING_LIST)].map((x) => {
|
||||
return {
|
||||
...x,
|
||||
title: typeof x.title === 'string' ? $t(x.title as string) : x.title
|
||||
}
|
||||
})
|
||||
}, [serviceType, state.language])
|
||||
|
||||
/** 监听 serviceType 变化,刷新所有表格 */
|
||||
useEffect(() => {
|
||||
// 重新加载所有表格数据
|
||||
if (Object.keys(tableRefs.current).length > 0) {
|
||||
Object.values(tableRefs.current).forEach(ref => {
|
||||
// 如果组件实例存在并且有reload方法
|
||||
if (ref && typeof ref.reload === 'function') {
|
||||
ref.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [serviceType, topRankingList])
|
||||
|
||||
/**
|
||||
* 获取表格数据
|
||||
* @param item
|
||||
* @returns
|
||||
*/
|
||||
const getTableData = (item: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve({ data: topRankingList[item], success: true })
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div className="flex w-full pb-[10px]">
|
||||
{Object.keys(topRankingList)?.map((item: any, index: number) => (
|
||||
<Card
|
||||
key={index}
|
||||
className={`flex-1 min-w-[430px] h-fit rounded-[10px] ${index > 0 ? 'ml-[10px]' : ''}`}
|
||||
classNames={{
|
||||
body: 'p-[15px]'
|
||||
}}
|
||||
>
|
||||
<div className="mb-[10px]">
|
||||
<span className="text-[14px] text-[#999999]" style={{ fontFamily: 'Microsoft YaHei' }}>{item === 'TOP API' ? $t('API 使用排名') : $t('消费者使用排名')}</span>
|
||||
</div>
|
||||
<PageList
|
||||
id={item}
|
||||
columns={[...columns]}
|
||||
minVirtualHeight={430}
|
||||
noScroll
|
||||
request={() => getTableData(item)}
|
||||
showPagination={false}
|
||||
tableClass="ranking-list"
|
||||
ref={ref => {
|
||||
if (ref) tableRefs.current[item] = ref;
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RankingList
|
||||
@@ -1,428 +0,0 @@
|
||||
import { Card, Spin } from 'antd'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import Indicator from './indicator/Indicator'
|
||||
import { LoadingOutlined } from '@ant-design/icons'
|
||||
import DateSelectFilter, { TimeOption } from './filter/DateSelectFilter'
|
||||
import { TimeRange } from '@common/components/aoplatform/TimeRangeSelector'
|
||||
import ServiceBarChar, { BarChartInfo } from './charts/ServiceBarChar'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { App } from 'antd'
|
||||
import ServiceAreaChart from './charts/ServiceAreaChart'
|
||||
import RankingList from './rankingList/RankingList'
|
||||
import { abbreviateFloat, formatBytes, formatDuration, formatNumberWithUnit, getTime } from '@dashboard/utils/dashboard'
|
||||
import { setBarChartInfoData } from './utils'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext'
|
||||
|
||||
const ServiceOverview = ({ serviceType }: { serviceType: 'aiService' | 'restService' }) => {
|
||||
/** 路由参数 */
|
||||
const { serviceId, teamId } = useParams<{ serviceId: string; teamId: string }>()
|
||||
/** 面板 loading */
|
||||
const [dashboardLoading, setDashboardLoading] = useState(true)
|
||||
/** 默认时间 */
|
||||
const [defaultTime] = useState<TimeOption>('day')
|
||||
/** 当前选中的时间范围 */
|
||||
const [timeRange, setTimeRange] = useState<TimeRange | undefined>()
|
||||
/** 总数数据 */
|
||||
const [barChartInfo, setBarChartInfo] = useState<any>()
|
||||
/** 平均值数据 */
|
||||
const [perBarChartInfo, setPerBarChartInfo] = useState<any>()
|
||||
/** 指标数据 */
|
||||
const [indicatorInfo, setIndicatorInfo] = useState<any>([])
|
||||
/** 排名表格数据 */
|
||||
const [topRankingList, setTopRankingList] = useState<any>([])
|
||||
/** 获取服务信息 */
|
||||
const { fetchData } = useFetch()
|
||||
/** 弹窗组件 */
|
||||
const { message } = App.useApp()
|
||||
/** 全局状态 */
|
||||
const { state } = useGlobalContext()
|
||||
/** AI 服务数据 */
|
||||
const [aiServiceOverview, setAiServiceOverview] = useState<any>()
|
||||
/** REST 服务数据 */
|
||||
const [restServiceOverview, setRestServiceOverview] = useState<any>()
|
||||
/** 时间选择回调 */
|
||||
const selectCallback = (date: TimeRange) => {
|
||||
setTimeRange(date)
|
||||
}
|
||||
|
||||
/** 获取 AI 服务信息 */
|
||||
const getAIServiceOverview = () => {
|
||||
fetchData<BasicResponse<{ overview: any }>>('service/overview/monitor/ai', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId, start: timeRange?.start, end: timeRange?.end },
|
||||
eoTransformKeys: [
|
||||
'enable_mcp',
|
||||
'subscriber_num',
|
||||
'api_num',
|
||||
'service_kind',
|
||||
'avaliable_monitor',
|
||||
'request_overview',
|
||||
'token_overview',
|
||||
'avg_token_overview',
|
||||
'avg_request_per_subscriber_overview',
|
||||
'avg_token_per_subscriber_overview',
|
||||
'request_total',
|
||||
'token_total',
|
||||
'avg_token',
|
||||
'max_token',
|
||||
'min_token',
|
||||
'avg_request_per_subscriber',
|
||||
'avg_token_per_subscriber',
|
||||
'input_token',
|
||||
'output_token',
|
||||
'total_token',
|
||||
'request_2xx_total',
|
||||
'request_4xx_total',
|
||||
'request_5xx_total',
|
||||
'input_token_total',
|
||||
'output_token_total',
|
||||
'max_token_per_subscriber',
|
||||
'min_token_per_subscriber',
|
||||
'max_request_per_subscriber',
|
||||
'min_request_per_subscriber'
|
||||
]
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
// 存储 AI 服务数据
|
||||
setAiServiceOverview(data.overview)
|
||||
// 设置 AI 报表数据
|
||||
setAiChartInfoData(data.overview)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
setDashboardLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 REST 服务数据
|
||||
* */
|
||||
const setRestChartInfoData = (serviceOverview: any) => {
|
||||
// 设置指标数据
|
||||
setIndicatorInfo({
|
||||
apiNum: serviceOverview.apiNum,
|
||||
subscriberNum: serviceOverview.subscriberNum,
|
||||
teamId: teamId,
|
||||
enableMcp: serviceOverview.enableMcp,
|
||||
serviceKind: serviceOverview.serviceKind,
|
||||
serviceId: serviceId
|
||||
})
|
||||
// 设置总数数据
|
||||
setBarChartInfo([
|
||||
// 服务请求次数
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('请求次数'),
|
||||
data: serviceOverview.requestOverview,
|
||||
value: formatNumberWithUnit(serviceOverview.requestTotal),
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
request2xxTotal: formatNumberWithUnit(serviceOverview.request2xxTotal),
|
||||
request4xxTotal: formatNumberWithUnit(serviceOverview.request4xxTotal),
|
||||
request5xxTotal: formatNumberWithUnit(serviceOverview.request5xxTotal)
|
||||
},
|
||||
// 流量消耗总数
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('网络流量'),
|
||||
data: serviceOverview.trafficOverview,
|
||||
value: formatBytes(serviceOverview.trafficTotal),
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
traffic2xxTotal: formatBytes(serviceOverview.traffic2xxTotal),
|
||||
traffic4xxTotal: formatBytes(serviceOverview.traffic4xxTotal),
|
||||
traffic5xxTotal: formatBytes(serviceOverview.traffic5xxTotal)
|
||||
}
|
||||
])
|
||||
// 设置平均值数据
|
||||
setPerBarChartInfo([
|
||||
// 各个模型使用量
|
||||
{
|
||||
title: $t('平均响应时间'),
|
||||
data: serviceOverview.avgResponseTimeOverview,
|
||||
value: formatDuration(serviceOverview.avgResponseTime),
|
||||
originValue: serviceOverview.avgResponseTime,
|
||||
date: serviceOverview.date,
|
||||
max: formatDuration(serviceOverview.maxResponseTime),
|
||||
min: formatDuration(serviceOverview.minResponseTime),
|
||||
type: 'area',
|
||||
showXAxis: false
|
||||
},
|
||||
// 平均请求
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('平均每消费者的请求次数'),
|
||||
data: serviceOverview.avgRequestPerSubscriberOverview,
|
||||
date: serviceOverview.date,
|
||||
showXAxis: false
|
||||
}),
|
||||
max: abbreviateFloat(serviceOverview.maxRequestPerSubscriber),
|
||||
min: abbreviateFloat(serviceOverview.minRequestPerSubscriber)
|
||||
},
|
||||
// 平均流量消耗
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('平均每消费者的网络流量'),
|
||||
data: serviceOverview.avgTrafficPerSubscriberOverview,
|
||||
date: serviceOverview.date,
|
||||
showXAxis: false
|
||||
}),
|
||||
max: formatBytes(serviceOverview.maxTrafficPerSubscriber),
|
||||
min: formatBytes(serviceOverview.minTrafficPerSubscriber)
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 AI 服务数据
|
||||
* */
|
||||
const setAiChartInfoData = (serviceOverview: any) => {
|
||||
// 设置指标数据
|
||||
setIndicatorInfo({
|
||||
apiNum: serviceOverview.apiNum,
|
||||
subscriberNum: serviceOverview.subscriberNum,
|
||||
teamId: teamId,
|
||||
enableMcp: serviceOverview.enableMcp,
|
||||
serviceKind: serviceOverview.serviceKind,
|
||||
serviceId: serviceId
|
||||
})
|
||||
// 设置总数数据
|
||||
setBarChartInfo([
|
||||
// 服务请求次数
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('请求次数'),
|
||||
data: serviceOverview.requestOverview,
|
||||
value: formatNumberWithUnit(serviceOverview.requestTotal),
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
request2xxTotal: formatNumberWithUnit(serviceOverview.request2xxTotal),
|
||||
request4xxTotal: formatNumberWithUnit(serviceOverview.request4xxTotal),
|
||||
request5xxTotal: formatNumberWithUnit(serviceOverview.request5xxTotal)
|
||||
},
|
||||
// token 消耗总数
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('Token 消耗'),
|
||||
data: serviceOverview.tokenOverview.map((item: { inputToken: number; outputToken: number }) => ({
|
||||
inputToken: item.inputToken,
|
||||
outputToken: item.outputToken
|
||||
})),
|
||||
value: formatNumberWithUnit(serviceOverview.tokenTotal),
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
inputTokenTotal: formatNumberWithUnit(serviceOverview.inputTokenTotal),
|
||||
outputTokenTotal: formatNumberWithUnit(serviceOverview.outputTokenTotal)
|
||||
}
|
||||
])
|
||||
// 设置平均值数据
|
||||
setPerBarChartInfo([
|
||||
// 平均 token 消耗
|
||||
{
|
||||
title: $t('平均 Token 消耗'),
|
||||
data: serviceOverview.avgTokenOverview,
|
||||
value: formatNumberWithUnit(serviceOverview.avgToken) + ' Token/s',
|
||||
originValue: serviceOverview.avgToken,
|
||||
date: serviceOverview.date,
|
||||
min: formatNumberWithUnit(serviceOverview.minToken) + ' Token/s',
|
||||
max: formatNumberWithUnit(serviceOverview.maxToken) + ' Token/s',
|
||||
type: 'area'
|
||||
},
|
||||
{
|
||||
// 平均请求
|
||||
...setBarChartInfoData({
|
||||
title: $t('平均每消费者的请求次数'),
|
||||
data: serviceOverview.avgRequestPerSubscriberOverview,
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
max: abbreviateFloat(serviceOverview.maxRequestPerSubscriber),
|
||||
min: abbreviateFloat(serviceOverview.minRequestPerSubscriber)
|
||||
},
|
||||
// 评价 token 消耗
|
||||
{
|
||||
...setBarChartInfoData({
|
||||
title: $t('平均每消费者的 Token 消耗'),
|
||||
data: serviceOverview.avgTokenPerSubscriberOverview.map(
|
||||
(item: { inputToken: number; outputToken: number }) => ({
|
||||
inputToken: item.inputToken,
|
||||
outputToken: item.outputToken
|
||||
})
|
||||
),
|
||||
date: serviceOverview.date
|
||||
}),
|
||||
max: abbreviateFloat(serviceOverview.maxTokenPerSubscriber),
|
||||
min: abbreviateFloat(serviceOverview.minTokenPerSubscriber)
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
/** 获取 REST 服务信息 */
|
||||
const getRestServiceOverview = () => {
|
||||
fetchData<BasicResponse<{ overview: any }>>('service/overview/monitor/rest', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId, start: timeRange?.start, end: timeRange?.end },
|
||||
eoTransformKeys: [
|
||||
'enable_mcp',
|
||||
'subscriber_num',
|
||||
'api_num',
|
||||
'service_kind',
|
||||
'avaliable_monitor',
|
||||
'request_overview',
|
||||
'traffic_overview',
|
||||
'avg_request_per_subscriber_overview',
|
||||
'avg_response_time_overview',
|
||||
'avg_traffic_per_subscriber_overview',
|
||||
'request_total',
|
||||
'traffic_total',
|
||||
'max_response_time',
|
||||
'min_response_time',
|
||||
'avg_response_time',
|
||||
'avg_request_per_subscriber',
|
||||
'avg_traffic_per_subscriber',
|
||||
'request_2xx_total',
|
||||
'request_4xx_total',
|
||||
'request_5xx_total',
|
||||
'traffic_2xx_total',
|
||||
'traffic_4xx_total',
|
||||
'traffic_5xx_total',
|
||||
'max_request_per_subscriber',
|
||||
'min_request_per_subscriber',
|
||||
'max_traffic_per_subscriber',
|
||||
'min_traffic_per_subscriber'
|
||||
]
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
// 存储 REST 服务数据
|
||||
setRestServiceOverview(data.overview)
|
||||
// 设置 REST 报表数据
|
||||
setRestChartInfoData(data.overview)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
setDashboardLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取排名列表 */
|
||||
const getTopRankingList = () => {
|
||||
fetchData<BasicResponse<{ overview: any }>>('service/monitor/top10', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId, start: timeRange?.start, end: timeRange?.end }
|
||||
}).then((response) => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
// 设置排名表格数据
|
||||
setTopRankingList({
|
||||
'TOP API': data.apis,
|
||||
'TOP Consumer': data.consumers
|
||||
})
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
}
|
||||
setDashboardLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const { startTime, endTime } = getTime(defaultTime, [])
|
||||
setTimeRange({
|
||||
start: startTime,
|
||||
end: endTime
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (timeRange) {
|
||||
serviceType === 'aiService' ? getAIServiceOverview() : getRestServiceOverview()
|
||||
getTopRankingList()
|
||||
}
|
||||
}, [timeRange])
|
||||
|
||||
useEffect(() => {
|
||||
if (serviceType === 'aiService') {
|
||||
aiServiceOverview && setAiChartInfoData(aiServiceOverview)
|
||||
} else {
|
||||
restServiceOverview && setRestChartInfoData(restServiceOverview)
|
||||
}
|
||||
}, [state.language])
|
||||
|
||||
return (
|
||||
<Spin
|
||||
className="h-full pb-[20px]"
|
||||
wrapperClassName="h-full min-h-[150px]"
|
||||
indicator={
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<div style={{ transform: 'scale(1.5)' }}>
|
||||
<LoadingOutlined style={{ fontSize: 30 }} spin />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
spinning={dashboardLoading}
|
||||
>
|
||||
<div className="mr-[30px]">
|
||||
<Indicator indicatorInfo={indicatorInfo} />
|
||||
<div className="mt-[20px]">
|
||||
<DateSelectFilter selectCallback={selectCallback} defaultTime={defaultTime} />
|
||||
</div>
|
||||
<div className="mt-[20px] flex mb-[10px]">
|
||||
{barChartInfo?.map((item: BarChartInfo, index: number) => (
|
||||
<Card
|
||||
key={index}
|
||||
className={`flex-1 min-w-[430px] rounded-[10px] ${index > 0 ? 'ml-[10px]' : ''}`}
|
||||
classNames={{
|
||||
body: 'py-[15px] px-[0px]'
|
||||
}}
|
||||
>
|
||||
<ServiceBarChar
|
||||
showLegendIndicator={true}
|
||||
key={index}
|
||||
height={400}
|
||||
dataInfo={item}
|
||||
customClassNames="flex-1"
|
||||
></ServiceBarChar>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex mb-[10px]">
|
||||
{perBarChartInfo?.map((item: any, index: number) => (
|
||||
<Card
|
||||
key={index}
|
||||
className={`flex-1 rounded-[10px] min-w-[284px] ${index > 0 ? 'ml-[10px]' : ''}`}
|
||||
classNames={{
|
||||
body: 'py-[15px] px-[0px]'
|
||||
}}
|
||||
>
|
||||
{item.type === 'area' ? (
|
||||
<>
|
||||
<ServiceAreaChart
|
||||
key={index}
|
||||
height={270}
|
||||
dataInfo={item}
|
||||
showAvgLine={true}
|
||||
customClassNames="flex-1 relative"
|
||||
></ServiceAreaChart>
|
||||
</>
|
||||
) : (
|
||||
<ServiceBarChar
|
||||
key={index}
|
||||
height={270}
|
||||
dataInfo={item}
|
||||
hideIndicatorValue={true}
|
||||
customClassNames="flex-1"
|
||||
></ServiceBarChar>
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
<RankingList topRankingList={topRankingList} serviceType={serviceType} />
|
||||
</div>
|
||||
</Spin>
|
||||
)
|
||||
}
|
||||
|
||||
export default ServiceOverview
|
||||
@@ -1,55 +0,0 @@
|
||||
export type BarData = {
|
||||
title: string
|
||||
value?: string
|
||||
date: string[]
|
||||
data: any[]
|
||||
showXAxis?: boolean
|
||||
}
|
||||
export const setBarChartInfoData = ({ title, value, data, date, showXAxis }: BarData) => {
|
||||
// 首先获取所有的键名(假设所有对象的键名都一样)
|
||||
if (data.length === 0) {
|
||||
return {
|
||||
title,
|
||||
value,
|
||||
date,
|
||||
data: [],
|
||||
showXAxis: !!showXAxis
|
||||
}
|
||||
}
|
||||
if (typeof data[0] !== 'object') {
|
||||
return {
|
||||
title,
|
||||
value,
|
||||
date,
|
||||
data,
|
||||
showXAxis: !!showXAxis
|
||||
}
|
||||
}
|
||||
// 从第一个对象中获取所有键名
|
||||
const keys = Object.keys(data[0])
|
||||
// 定义颜色映射
|
||||
const colorMap: Record<string, string> = {
|
||||
'2xx': '#3ba272',
|
||||
'4xx': '#ffc404',
|
||||
'5xx': '#b92325'
|
||||
}
|
||||
|
||||
// 为每个键创建一个数据集
|
||||
const transformedData = keys.map((key) => {
|
||||
// 为没有映射颜色的键生成随机颜色
|
||||
const color = colorMap[key]
|
||||
|
||||
return {
|
||||
name: key,
|
||||
color: color,
|
||||
value: data.map((item) => item[key])
|
||||
}
|
||||
})
|
||||
return {
|
||||
title,
|
||||
value,
|
||||
date,
|
||||
data: transformedData,
|
||||
showXAxis: !!showXAxis
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { LoadingOutlined } from '@ant-design/icons'
|
||||
import WithPermission from '@common/components/aoplatform/WithPermission.tsx'
|
||||
import { BasicResponse, DELETE_TIPS, PLACEHOLDER, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const.tsx'
|
||||
import { EntityItem, MemberItem, SimpleTeamItem } from '@common/const/type.ts'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
@@ -10,26 +11,14 @@ import { normFile } from '@common/utils/uploadPic.ts'
|
||||
import { validateUrlSlash } from '@common/utils/validate.ts'
|
||||
import { RouterParams } from '@core/components/aoplatform/RenderRoutes.tsx'
|
||||
import { AiServiceConfigFieldType } from '@core/const/ai-service/type.ts'
|
||||
import { MCP_OPTIONS, SERVICE_APPROVAL_OPTIONS } from '@core/const/system/const.tsx'
|
||||
import { SERVICE_APPROVAL_OPTIONS } from '@core/const/system/const.tsx'
|
||||
import { Icon } from '@iconify/react/dist/iconify.js'
|
||||
import { CategorizesType } from '@market/const/serviceHub/type.ts'
|
||||
import {
|
||||
App,
|
||||
Button,
|
||||
Form,
|
||||
Input,
|
||||
Radio,
|
||||
RadioChangeEvent,
|
||||
Row,
|
||||
Select,
|
||||
Tooltip,
|
||||
TreeSelect,
|
||||
Upload
|
||||
} from 'antd'
|
||||
import { App, Button, Form, Input, Radio, Row, Select, Tooltip, TreeSelect, Upload } from 'antd'
|
||||
import { DefaultOptionType } from 'antd/es/cascader'
|
||||
import { RcFile, UploadChangeParam, UploadFile, UploadProps } from 'antd/es/upload/interface'
|
||||
import { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from 'react'
|
||||
import { Link, useLocation, useNavigate, useOutletContext, useParams } from 'react-router-dom'
|
||||
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { SystemConfigFieldType, SystemConfigHandle } from '../../const/system/type.ts'
|
||||
import { useSystemContext } from '../../contexts/SystemContext.tsx'
|
||||
@@ -48,13 +37,12 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
const { fetchData } = useFetch()
|
||||
const [teamOptionList, setTeamOptionList] = useState<DefaultOptionType[]>()
|
||||
const navigate = useNavigate()
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { setSystemInfo } = useSystemContext()
|
||||
const [showClassify, setShowClassify] = useState<boolean>(true)
|
||||
const [showAI, setShowAI] = useState<boolean>(false)
|
||||
const [imageBase64, setImageBase64] = useState<string | null>(null)
|
||||
const [tagOptionList, setTagOptionList] = useState<DefaultOptionType[]>([])
|
||||
const context = useOutletContext<{ onSaveComplete?: () => void }>()
|
||||
const onSaveComplete = context?.onSaveComplete
|
||||
const [serviceClassifyOptionList, setServiceClassifyOptionList] = useState<DefaultOptionType[]>()
|
||||
const [uploadLoading, setUploadLoading] = useState<boolean>(false)
|
||||
const { checkPermission, accessInit, getGlobalAccessData, state, aiConfigFlushed, setAiConfigFlushed } =
|
||||
@@ -286,7 +274,6 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
message.success(msg || $t(RESPONSE_TIPS.success))
|
||||
setSystemInfo(data.service)
|
||||
onSaveComplete?.()
|
||||
return Promise.resolve(true)
|
||||
} else {
|
||||
message.error(msg || $t(RESPONSE_TIPS.error))
|
||||
@@ -353,6 +340,14 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
if (serviceId !== undefined) {
|
||||
setOnEdit(true)
|
||||
getSystemInfo()
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: <Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title: $t('设置')
|
||||
}
|
||||
])
|
||||
} else {
|
||||
getProviderOptionList()
|
||||
setOnEdit(false)
|
||||
@@ -364,32 +359,10 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
form.setFieldValue('team', teamId)
|
||||
form.setFieldValue('serviceType', 'public')
|
||||
form.setFieldValue('approvalType', 'auto')
|
||||
form.setFieldValue('enable_mcp', false)
|
||||
}
|
||||
return form.setFieldsValue({})
|
||||
}, [serviceId])
|
||||
|
||||
const handleMcpChange = (e: RadioChangeEvent) => {
|
||||
if (e.target.value) {
|
||||
return
|
||||
}
|
||||
modal.confirm({
|
||||
title: $t('关闭 MCP'),
|
||||
content: $t('关闭后将无法通过MCP方式调用服务'),
|
||||
onOk: () => {
|
||||
form.setFieldValue('enable_mcp', false)
|
||||
},
|
||||
onCancel: () => {
|
||||
form.setFieldValue('enable_mcp', true)
|
||||
},
|
||||
width: 600,
|
||||
okText: $t('了解'),
|
||||
cancelText: $t('取消'),
|
||||
closable: true,
|
||||
icon: <></>
|
||||
})
|
||||
}
|
||||
|
||||
const deleteSystemModal = async () => {
|
||||
modal.confirm({
|
||||
title: $t('删除'),
|
||||
@@ -414,7 +387,6 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
() => SERVICE_APPROVAL_OPTIONS.map((x) => ({ ...x, label: $t(x.label) })),
|
||||
[state.language]
|
||||
)
|
||||
const mcpOptions = useMemo(() => MCP_OPTIONS.map((x) => ({ ...x, label: $t(x.label) })), [state.language])
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -468,13 +440,6 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
)}
|
||||
<Form.Item<AiServiceConfigFieldType> label={$t('MCP')} name="enable_mcp" rules={[{ required: true }]}>
|
||||
<Radio.Group
|
||||
className="flex flex-col"
|
||||
options={mcpOptions}
|
||||
onChange={serviceId ? handleMcpChange : undefined}
|
||||
/>
|
||||
</Form.Item>
|
||||
{showAI && (
|
||||
<>
|
||||
<Form.Item<AiServiceConfigFieldType>
|
||||
@@ -512,14 +477,10 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
|
||||
className="w-INPUT_NORMAL"
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
options={
|
||||
modelList
|
||||
? modelList.map((x) => ({
|
||||
...x,
|
||||
searchText: x.name.toLowerCase()
|
||||
}))
|
||||
: []
|
||||
}
|
||||
options={modelList ? modelList.map((x) => ({
|
||||
...x,
|
||||
searchText: x.name.toLowerCase()
|
||||
})) : []}
|
||||
></Select>
|
||||
</Form.Item>
|
||||
</>
|
||||
@@ -540,8 +501,6 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
{!onEdit && (
|
||||
<Form.Item<SystemConfigFieldType> label={$t('所属团队')} name="team" rules={[{ required: true }]}>
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
disabled={onEdit}
|
||||
placeholder={$t(PLACEHOLDER.input)}
|
||||
@@ -618,8 +577,6 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
|
||||
|
||||
<Form.Item<SystemConfigFieldType> label={$t('标签')} name="tags">
|
||||
<Select
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
className="w-INPUT_NORMAL"
|
||||
mode="tags"
|
||||
placeholder={$t(PLACEHOLDER.select)}
|
||||
|
||||
@@ -18,6 +18,7 @@ const ServiceInsideDocument = () => {
|
||||
const [doc, setDoc] = useState<string>()
|
||||
const { fetchData } = useFetch()
|
||||
const { serviceId, teamId } = useParams<RouterParams>()
|
||||
|
||||
const save = () => {
|
||||
fetchData<
|
||||
BasicResponse<{
|
||||
|
||||
@@ -14,8 +14,6 @@ import { FC, useEffect, useMemo, useState } from 'react'
|
||||
import { Link, Outlet, useLocation, useNavigate, useParams } from 'react-router-dom'
|
||||
import { SystemConfigFieldType } from '../../const/system/type.ts'
|
||||
import { useSystemContext } from '../../contexts/SystemContext.tsx'
|
||||
import ServiceInfoCard from '@common/components/aoplatform/serviceInfoCard.tsx'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
|
||||
const SystemInsidePage: FC = () => {
|
||||
const { message } = App.useApp()
|
||||
@@ -28,13 +26,12 @@ const SystemInsidePage: FC = () => {
|
||||
const [activeMenu, setActiveMenu] = useState<string>()
|
||||
const navigateTo = useNavigate()
|
||||
const [showMenu, setShowMenu] = useState<boolean>(false)
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
|
||||
const getSystemInfo = () => {
|
||||
fetchData<BasicResponse<{ service: SystemConfigFieldType }>>('service/info', {
|
||||
method: 'GET',
|
||||
eoParams: { team: teamId, service: serviceId }
|
||||
}).then((response) => {
|
||||
}).then(response => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setSystemInfo(data.service)
|
||||
@@ -50,7 +47,7 @@ const SystemInsidePage: FC = () => {
|
||||
fetchData<BasicResponse<{ prefix: string; force: boolean }>>('service/router/define', {
|
||||
method: 'GET',
|
||||
eoParams: { service: serviceId, team: teamId }
|
||||
}).then((response) => {
|
||||
}).then(response => {
|
||||
const { code, data, msg } = response
|
||||
if (code === STATUS_CODE.SUCCESS) {
|
||||
setApiPrefix(data.prefix)
|
||||
@@ -68,7 +65,6 @@ const SystemInsidePage: FC = () => {
|
||||
'assets',
|
||||
null,
|
||||
[
|
||||
getItem(<Link to="./overview">{$t('总览')}</Link>, 'overview', undefined, undefined, undefined, ''),
|
||||
getItem(
|
||||
<Link to="./route">{$t('API 路由')}</Link>,
|
||||
'route',
|
||||
@@ -150,10 +146,9 @@ const SystemInsidePage: FC = () => {
|
||||
null,
|
||||
[
|
||||
// APP_MODE === 'pro' ? getItem(<Link to="./topology">{$t('调用拓扑图')}</Link>, 'topology',undefined,undefined,undefined,'project.mySystem.topology.view'):null,
|
||||
getItem(<Link to="./setting">{$t('设置')}</Link>, 'setting', undefined, undefined, undefined, ''),
|
||||
getItem(
|
||||
<Link to="./logs">{$t('日志')}</Link>,
|
||||
'logs',
|
||||
<Link to="./setting">{$t('设置')}</Link>,
|
||||
'setting',
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
@@ -171,11 +166,12 @@ const SystemInsidePage: FC = () => {
|
||||
const newMenu = cloneDeep(menu)
|
||||
return newMenu!.filter((m: MenuItemGroupType) => {
|
||||
if (m && m.children && m.children.length > 0) {
|
||||
m.children = m.children.filter((c) => {
|
||||
m.children = m.children.filter(c => {
|
||||
if (!c) return false
|
||||
return (c as MenuItemType & { access: string }).access
|
||||
? checkPermission(
|
||||
(c as MenuItemType & { access: string }).access as keyof (typeof PERMISSION_DEFINITION)[0]
|
||||
(c as MenuItemType & { access: string })
|
||||
.access as keyof (typeof PERMISSION_DEFINITION)[0]
|
||||
)
|
||||
: true
|
||||
})
|
||||
@@ -184,8 +180,12 @@ const SystemInsidePage: FC = () => {
|
||||
})
|
||||
}
|
||||
const filteredMenu = filterMenu(SYSTEM_PAGE_MENU_ITEMS as MenuItemGroupType<MenuItemType>[])
|
||||
const menu = (activeMenu ?? filteredMenu[0]?.children) ? filteredMenu[0]?.children?.[0]?.key : filteredMenu[0]?.key
|
||||
if (menu && currentUrl.split('/')[-1] !== menu) navigateTo(`/service/${teamId}/inside/${serviceId}/${menu}`)
|
||||
const menu =
|
||||
(activeMenu ?? filteredMenu[0]?.children)
|
||||
? filteredMenu[0]?.children?.[0]?.key
|
||||
: filteredMenu[0]?.key
|
||||
if (menu && currentUrl.split('/')[-1] !== menu)
|
||||
navigateTo(`/service/${teamId}/inside/${serviceId}/${menu}`)
|
||||
return filteredMenu || []
|
||||
}, [accessData, accessInit, SYSTEM_PAGE_MENU_ITEMS])
|
||||
|
||||
@@ -208,7 +208,7 @@ const SystemInsidePage: FC = () => {
|
||||
} else if (serviceId !== currentUrl.split('/')[currentUrl.split('/').length - 1]) {
|
||||
setActiveMenu(currentUrl.split('/')[currentUrl.split('/').length - 1])
|
||||
} else {
|
||||
setActiveMenu('overview')
|
||||
setActiveMenu('route')
|
||||
}
|
||||
}, [currentUrl])
|
||||
|
||||
@@ -219,19 +219,10 @@ const SystemInsidePage: FC = () => {
|
||||
}, [accessData])
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: $t('服务'),
|
||||
onClick: () => navigateTo('/service/list')
|
||||
},
|
||||
{
|
||||
title: systemInfo?.name || ''
|
||||
}
|
||||
])
|
||||
if (activeMenu && serviceId === currentUrl.split('/')[currentUrl.split('/').length - 1]) {
|
||||
navigateTo(`/service/${teamId}/inside/${serviceId}/${activeMenu}`)
|
||||
}
|
||||
}, [activeMenu, systemInfo, state.language])
|
||||
}, [activeMenu])
|
||||
|
||||
useEffect(() => {
|
||||
serviceId && getSystemInfo()
|
||||
@@ -242,7 +233,15 @@ const SystemInsidePage: FC = () => {
|
||||
{showMenu ? (
|
||||
<InsidePage
|
||||
pageTitle={systemInfo?.name || '-'}
|
||||
customBanner={<ServiceInfoCard serviceId={serviceId} teamId={teamId} />}
|
||||
tagList={[
|
||||
{
|
||||
label: (
|
||||
<Paragraph className="mb-0" copyable={serviceId ? { text: serviceId } : false}>
|
||||
{$t('服务 ID')}:{serviceId || '-'}
|
||||
</Paragraph>
|
||||
)
|
||||
}
|
||||
]}
|
||||
backUrl="/service/list"
|
||||
>
|
||||
<div className="flex flex-1 h-full">
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
STATUS_CODE
|
||||
} from '@common/const/const.tsx'
|
||||
import { SimpleMemberItem } from '@common/const/type.ts'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
@@ -19,7 +20,7 @@ import { RouterParams } from '@core/components/aoplatform/RenderRoutes.tsx'
|
||||
import { App, Form, TreeSelect } from 'antd'
|
||||
import { DefaultOptionType } from 'antd/es/cascader'
|
||||
import { FC, forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { Link, useParams } from 'react-router-dom'
|
||||
import { SYSTEM_SUBSCRIBER_TABLE_COLUMNS } from '../../const/system/const.tsx'
|
||||
import {
|
||||
SimpleSystemItem,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
} from '../../const/system/type.ts'
|
||||
|
||||
const SystemInsideSubscriber: FC = () => {
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const { modal, message } = App.useApp()
|
||||
const { fetchData } = useFetch()
|
||||
const { serviceId, teamId } = useParams<RouterParams>()
|
||||
@@ -159,6 +161,14 @@ const SystemInsideSubscriber: FC = () => {
|
||||
]
|
||||
|
||||
useEffect(() => {
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: <Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title: $t('订阅方管理')
|
||||
}
|
||||
])
|
||||
getMemberList()
|
||||
manualReloadTable()
|
||||
}, [serviceId])
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useBreadcrumb } from '@common/contexts/BreadcrumbContext.tsx'
|
||||
import { useGlobalContext } from '@common/contexts/GlobalStateContext.tsx'
|
||||
import { useFetch } from '@common/hooks/http.ts'
|
||||
import { $t } from '@common/locales/index.ts'
|
||||
import { App, Tag } from 'antd'
|
||||
import { App } from 'antd'
|
||||
import { FC, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { SERVICE_KIND_OPTIONS, SYSTEM_TABLE_COLUMNS } from '../../const/system/const.tsx'
|
||||
@@ -176,30 +176,10 @@ const SystemList: FC = () => {
|
||||
x.valueEnum = teamList
|
||||
}
|
||||
if ((x.dataIndex as string) === 'service_kind') {
|
||||
x.render = (dom: React.ReactNode, record: any) => (
|
||||
<span
|
||||
className={`text-[13px] `}
|
||||
>
|
||||
<Tag
|
||||
color={`#${record.service_kind === 'ai' ? 'EADEFF' : 'DEFFE7'}`}
|
||||
className={`text-[#000] font-normal border-0 mr-[10px] max-w-[150px] truncate`}
|
||||
bordered={false}
|
||||
title={record.service_kind || '-'}
|
||||
>
|
||||
{SERVICE_KIND_OPTIONS.find((x) => x.value === record.service_kind)?.label || '-'}
|
||||
</Tag>
|
||||
{record?.enable_mcp && (
|
||||
<Tag
|
||||
color="#FFF0C1"
|
||||
className="text-[#000] font-normal border-0 mr-[12px] max-w-[150px] truncate"
|
||||
bordered={false}
|
||||
title={'MCP'}
|
||||
>
|
||||
MCP
|
||||
</Tag>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
x.valueEnum = {}
|
||||
SERVICE_KIND_OPTIONS.forEach((option) => {
|
||||
;(x.valueEnum as any)[option.value] = { text: $t(option.label) }
|
||||
})
|
||||
}
|
||||
if ((x.dataIndex as string) === 'state') {
|
||||
x.render = (dom: React.ReactNode, record: any) => (
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ZoomInOutlined, ZoomOutOutlined } from '@ant-design/icons'
|
||||
import G6, { EdgeConfig, Graph, NodeConfig } from '@antv/g6'
|
||||
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
|
||||
import { EntityItem } from '@common/const/type'
|
||||
import { useBreadcrumb } from '@common/contexts/BreadcrumbContext'
|
||||
import { useFetch } from '@common/hooks/http'
|
||||
import { $t } from '@common/locales'
|
||||
import { getNodeSpacing } from '@common/utils/systemRunning'
|
||||
@@ -9,7 +10,7 @@ import { RouterParams } from '@core/components/aoplatform/RenderRoutes'
|
||||
import { App, Button } from 'antd'
|
||||
import { debounce } from 'lodash-es'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { Link, useParams } from 'react-router-dom'
|
||||
import { RELATIVE_PICTURE_NODE_FONTSIZE } from '../../const/system-running/const'
|
||||
import { GraphData } from '../../const/system-running/type'
|
||||
import { SYSTEM_TOPOLOGY_NODE_TYPE_COLOR_MAP } from '../../const/system/const'
|
||||
@@ -25,9 +26,9 @@ export default function SystemTopology() {
|
||||
const [graph, setGraph] = useState<Graph | null>(null)
|
||||
const { fetchData } = useFetch()
|
||||
const { systemInfo } = useSystemContext()
|
||||
const { setBreadcrumb } = useBreadcrumb()
|
||||
const [zoomNum, setZoomNum] = useState<number>(1)
|
||||
|
||||
|
||||
const getNodeData = () => {
|
||||
fetchData<BasicResponse<SystemTopologyResponse>>('service/topology', {
|
||||
method: 'GET',
|
||||
@@ -102,6 +103,14 @@ export default function SystemTopology() {
|
||||
|
||||
useEffect(() => {
|
||||
getNodeData()
|
||||
setBreadcrumb([
|
||||
{
|
||||
title: <Link to={`/service/list`}>{$t('服务')}</Link>
|
||||
},
|
||||
{
|
||||
title: $t('调用拓扑图')
|
||||
}
|
||||
])
|
||||
}, [serviceId])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user