mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 11:40:07 +00:00
Compare commits
2920 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 090fd1da2a | |||
| 93e27eb525 | |||
| 3717eac7bb | |||
| e617f0c2cb | |||
| bdd375270d | |||
| 10847605a6 | |||
| 25a4ecfd03 | |||
| 3221ec05fc | |||
| 3f72d9dcc2 | |||
| 8d6df2fdc6 | |||
| 6ef21630c3 | |||
| 5096360762 | |||
| 44c1ed360d | |||
| fa7bb87aa1 | |||
| ffa3cb723a | |||
| 899e7beed9 | |||
| 180c472e54 | |||
| 3e7a39f0e4 | |||
| 73381fdb0a | |||
| d4f9d305eb | |||
| 4eef356a83 | |||
| 547448d190 | |||
| d6903f1747 | |||
| 24ca422d56 | |||
| 33d0e5365c | |||
| 44d180bf0e | |||
| a0835d095c | |||
| e6e689bfba | |||
| cbb7ac09a0 | |||
| 919eefde16 | |||
| 6a919da365 | |||
| 3dd78df7d7 | |||
| 01e4a3120b | |||
| 2c78ad3261 | |||
| a8dd5a70db | |||
| db022d1307 | |||
| ec0d0faac9 | |||
| 1caae3fa7b | |||
| fbc4642e8a | |||
| 464674d9be | |||
| 9fa6111eab | |||
| 65d2e60a3e | |||
| a0e3f8d865 | |||
| becd2ecfd2 | |||
| 4b2376dca9 | |||
| 52abf500cf | |||
| 8bb80dddcc | |||
| c1b4ba0dea | |||
| 254442459f | |||
| 199a97d822 | |||
| 84e4da1127 | |||
| 2de40bd0dd | |||
| 8c5af983a6 | |||
| cace90d983 | |||
| 4e4752464a | |||
| 2556627bef | |||
| b0803c6ad7 | |||
| 854e96e5ec | |||
| 21288f0095 | |||
| 660e064434 | |||
| 01c7855fca | |||
| 40a18616ad | |||
| 0fe1e1934c | |||
| 3af84d0749 | |||
| 81e4cb5bdb | |||
| 4fca2b7bb9 | |||
| 4d5d272ccd | |||
| a093191835 | |||
| db3839ae16 | |||
| d866527d9c | |||
| b888cde521 | |||
| 47fce207fe | |||
| ca47d3e0fa | |||
| 94dd9945c0 | |||
| d626e4cd9e | |||
| 44d9970496 | |||
| 44779b2013 | |||
| d8af6b7dd7 | |||
| 71a1f24291 | |||
| 4b647b37e7 | |||
| ea0248ff8a | |||
| 7b697a1ac6 | |||
| 5a4598e9ef | |||
| 01cbf1ac6f | |||
| 9b8331942f | |||
| 64df7bac19 | |||
| cc1b7d1487 | |||
| 6832c69f55 | |||
| 088b9c77c2 | |||
| 9fea61dd65 | |||
| 49e574a938 | |||
| 62ada95404 | |||
| b5f6c11ef1 | |||
| e986022ce4 | |||
| fe96595709 | |||
| e7e875ab13 | |||
| 6ebfbdd377 | |||
| 4dda2093d5 | |||
| 493474dde4 | |||
| 7292b6623c | |||
| 4b670db1ef | |||
| d525fa71d6 | |||
| d6d78c9895 | |||
| 34ee07b07d | |||
| 9bd40adcbd | |||
| f4ee33b0eb | |||
| 9d7ab7d018 | |||
| 45c0bab76e | |||
| 948d66dca0 | |||
| d0f6a7e539 | |||
| f8b2718041 | |||
| 8d34e9a83c | |||
| 9f8bafb817 | |||
| b5e0d07e00 | |||
| bc2c9ae6f4 | |||
| 49c0743f47 | |||
| 0bab1722b4 | |||
| 43ae49105b | |||
| 3bb9f679ff | |||
| be7f04e20f | |||
| 22ed34b793 | |||
| f107740489 | |||
| 0c1cefa33b | |||
| 3ce9495146 | |||
| a9d53072e4 | |||
| a6edf76855 | |||
| 1556c241df | |||
| d24ec0ccd1 | |||
| 2e3a2bc97d | |||
| 194e10dba5 | |||
| ff32633a2b | |||
| 3b87e9e4b5 | |||
| 52c14dc2f4 | |||
| 94a8a44d03 | |||
| 2c18a0156b | |||
| 49c77b851b | |||
| 85be3acb27 | |||
| cff725817e | |||
| 27b7485276 | |||
| bbda4c2cda | |||
| ebc6c5a8f1 | |||
| fef951eb47 | |||
| e9f7d5858d | |||
| 8f7c71846f | |||
| 6b70fafdfe | |||
| 5066ae948d | |||
| 93e266111d | |||
| 79fe90aaff | |||
| 5858d33c60 | |||
| 4c235a3c44 | |||
| 2ba08b6e14 | |||
| 40296e118b | |||
| 14e675cda7 | |||
| 9db0c6f9d1 | |||
| 6aa8c32ba5 | |||
| efe9e044dd | |||
| 23422f1a9c | |||
| 10f56eb305 | |||
| 750dd3f9fe | |||
| d28d05187f | |||
| 3c05c06b1b | |||
| 7e85ea0b4e | |||
| a176c3bb74 | |||
| e72fbb2853 | |||
| 77b34b15ea | |||
| 57e603cdc3 | |||
| fac70f1232 | |||
| a2bd266791 | |||
| 9d98415922 | |||
| b1506ae7da | |||
| 15811b9171 | |||
| 7aeb89d21e | |||
| 26e8355640 | |||
| 736e372c3c | |||
| 7f58bf6365 | |||
| 7767b65584 | |||
| 1d067ee975 | |||
| 60542021c6 | |||
| 23d44e2143 | |||
| 4e0de502e3 | |||
| 9cf2d62b8c | |||
| f5e12d656c | |||
| 7f8286d341 | |||
| acaac14dc9 | |||
| 37fa15061d | |||
| 7bfc94bd61 | |||
| bc80105cd4 | |||
| f965b89128 | |||
| c9004cea49 | |||
| 7f4677b246 | |||
| 17445ea3e7 | |||
| ba08de0d9f | |||
| 29cdea2ce2 | |||
| eb4c715437 | |||
| 32452f532a | |||
| 9e115ceb8c | |||
| 31ef5fee82 | |||
| f91bf5fbe4 | |||
| 3f1cf4fe1d | |||
| 33baf89304 | |||
| f4f62008b2 | |||
| f961ef35ff | |||
| ecf427d01e | |||
| 248538b3e9 | |||
| 8275c935e3 | |||
| 01622042d7 | |||
| 2d908f963f | |||
| 76d77df654 | |||
| 7dd1b0d834 | |||
| 9ad56c8739 | |||
| 89a7f76cb8 | |||
| 25904c3ca5 | |||
| 2e9f3ce433 | |||
| d2e1158f8f | |||
| 7cffb0f3da | |||
| da04a3f608 | |||
| b67a4ef923 | |||
| 3fbdaa65a2 | |||
| 4187fd4fe4 | |||
| 5aaa725ac0 | |||
| 38dbd3daa0 | |||
| e339f9a957 | |||
| 43a8f2206a | |||
| 16923e2ef2 | |||
| 1939ced794 | |||
| b687ca5785 | |||
| 1c188c0655 | |||
| 93cee7b155 | |||
| ec3489ee7a | |||
| bc1f67ae70 | |||
| 21a54a0b86 | |||
| e972dbde38 | |||
| cba7d1ef7b | |||
| e596e9f0aa | |||
| 6a129d37bd | |||
| 2d99d4ca06 | |||
| edb1f596f8 | |||
| 548ded1b98 | |||
| ffcb631d5a | |||
| b9b2c423c0 | |||
| c605d8d5be | |||
| 4cb14c5a3a | |||
| 6522ed8a45 | |||
| 427c049495 | |||
| aa7c50ae40 | |||
| e6bef3956f | |||
| 06d02f6f3b | |||
| 8a782075ec | |||
| 5b606d34cf | |||
| 238d629642 | |||
| 7ad863651d | |||
| 86ffbe6b8f | |||
| efd85e8834 | |||
| 7c12aec9ab | |||
| f49e7fde50 | |||
| 23aad5c6c6 | |||
| a4f23d2c2f | |||
| cee4366e04 | |||
| 53b017d5b4 | |||
| 12efe86589 | |||
| 6b4b192583 | |||
| f92356fe7a | |||
| 2ea610eab9 | |||
| 084837f13c | |||
| a81b6bd396 | |||
| 91605602d2 | |||
| dd0381a920 | |||
| 79e8f732ee | |||
| a6df9449af | |||
| 383de0d558 | |||
| 0e95d5a036 | |||
| f5d8a9a6e3 | |||
| e9cc2f1b21 | |||
| de5d88a8f3 | |||
| adf8eabe04 | |||
| e1e14bf5d3 | |||
| bd5fd1b393 | |||
| b3691d91e7 | |||
| 06c096ae46 | |||
| 1028efb7f1 | |||
| 73a39677bc | |||
| 04d39ac72e | |||
| 2ff148467a | |||
| e6e2b49503 | |||
| 4319a3bfe8 | |||
| f4dfc97dc1 | |||
| b4b4c7217c | |||
| 40d2978622 | |||
| a6eb591591 | |||
| ed0a7aab4f | |||
| cff1a7881f | |||
| 2fd81eeacd | |||
| e1dc751d97 | |||
| 45ff5e3184 | |||
| 065e114834 | |||
| 40b40b839b | |||
| 8ba2c5aca8 | |||
| f2ac112ae5 | |||
| b952c43706 | |||
| a6d0ebb905 | |||
| cfbe1eccc6 | |||
| ba275da012 | |||
| 0bafe0f2f7 | |||
| eea18b3ede | |||
| 6946cb93e6 | |||
| 5219a26f70 | |||
| 0be3b159aa | |||
| cb9aa2c7b0 | |||
| eb180c7d67 | |||
| f7562c7734 | |||
| ccd224cd80 | |||
| 9b0041c66b | |||
| f52d24c4d8 | |||
| e6aa5118fa | |||
| 0cbd2beab3 | |||
| 4b85727237 | |||
| 5ae9408682 | |||
| 8ec17fc7f1 | |||
| 34d06aee00 | |||
| 86923c6504 | |||
| 51541b0a15 | |||
| 161a5c75ad | |||
| 71fb1e8e80 | |||
| 863e31aaa9 | |||
| 1454587a18 | |||
| 2fa3ba28a3 | |||
| 724e8fea33 | |||
| a3ee8b97b1 | |||
| 4fade68d57 | |||
| 67a1013fd0 | |||
| 0ba2631f16 | |||
| ea9e00a655 | |||
| db00e09573 | |||
| 3251a1e350 | |||
| 3224afdb7a | |||
| 18a6ddf6ab | |||
| 9392f03200 | |||
| fcf0be8a60 | |||
| 5cb20ec52c | |||
| 3aee91fed8 | |||
| 678933ee6d | |||
| c7cde6c084 | |||
| 80689f16be | |||
| ac05ff442f | |||
| 35ab311ebc | |||
| f9582f5331 | |||
| 15ec2bd54d | |||
| 9bc3d4d70e | |||
| cf83140c64 | |||
| b8a0518faf | |||
| 99e6003873 | |||
| 3ab7bdf4af | |||
| 5539fc4c65 | |||
| 20992bd3f1 | |||
| 79821ecc4e | |||
| 96373f535b | |||
| 9695c155a7 | |||
| bc44c4e71d | |||
| d017ee5c3b | |||
| 950ae6b65e | |||
| 3682e208f6 | |||
| ef9e0c577e | |||
| 6718ca5fd4 | |||
| 20a750984d | |||
| 4145f4caa5 | |||
| d5ce4bef3c | |||
| a233f58b63 | |||
| 138afd6983 | |||
| bc0c6be2a5 | |||
| 0e502e647a | |||
| 8a1a5c01db | |||
| a5cf261e49 | |||
| efc7035a76 | |||
| 817676bb54 | |||
| 375708e4e8 | |||
| b0dcc8aa82 | |||
| a27839dd4f | |||
| d957f0ae3f | |||
| 555436dec3 | |||
| e8eaeaa694 | |||
| 28157bc8fc | |||
| e17f5b4fbe | |||
| 8f4d8340e0 | |||
| 750a13a415 | |||
| 7365c9ccb1 | |||
| 276cfa55e6 | |||
| 7a5bb9d64e | |||
| cc8bc0c093 | |||
| 4216dfe0fd | |||
| 2874087118 | |||
| edb3b8696b | |||
| 1e846a768c | |||
| 1824d7da12 | |||
| b169c44199 | |||
| 9deab31482 | |||
| c27d05bce9 | |||
| ef49458491 | |||
| 578cbb14ee | |||
| ae37848e49 | |||
| 1b4a22a1b1 | |||
| e334f1366d | |||
| 15329206bc | |||
| 6fc7c6326e | |||
| cda1dfe9e2 | |||
| 4abc0eb919 | |||
| 16269d0723 | |||
| a9b2f56b03 | |||
| 9d9a931632 | |||
| ace0d5d151 | |||
| c2381d4474 | |||
| c94e2f528b | |||
| 779262060d | |||
| 4cf4ae6b44 | |||
| 3a519c2aef | |||
| 7a1ec6bc20 | |||
| 3c6148f412 | |||
| cdf3decfcd | |||
| 821d485a27 | |||
| 81641320bd | |||
| c106c4b027 | |||
| f54618bfe4 | |||
| 61e0df2121 | |||
| 371ff7eb67 | |||
| 2fb2ffc2c2 | |||
| d37327c8a3 | |||
| 6519df5652 | |||
| b74d3ed7d0 | |||
| 6bbaaf0f26 | |||
| 2228490bb8 | |||
| df8b0def93 | |||
| 7b54e138ad | |||
| a3de3bdaa4 | |||
| 0d157adc20 | |||
| 91c7720fb1 | |||
| 24523e2609 | |||
| 5e08d46c89 | |||
| c1079edfe8 | |||
| b49b0f4af1 | |||
| 77b3174f3a | |||
| 2782869958 | |||
| c1c966680f | |||
| 6bcf49e9f5 | |||
| cb4bd7e7a1 | |||
| bd091f4bb5 | |||
| af49445548 | |||
| 19395ecf99 | |||
| 916f4b006f | |||
| fd7bac5443 | |||
| 39433f3f3f | |||
| 6f8070628b | |||
| 118ccc9b9e | |||
| 01de69a238 | |||
| f307ea0b3d | |||
| 2e298cbbe9 | |||
| 70315fb46d | |||
| a1add00fe6 | |||
| 4877873ee0 | |||
| e286416466 | |||
| e00e12716f | |||
| ff7f0b79ab | |||
| 9d93608c5a | |||
| 024133d56b | |||
| f56ad69359 | |||
| ba1f0d3d89 | |||
| 5c617b0a76 | |||
| e6e667d788 | |||
| 510d928ccc | |||
| 9b20c512e2 | |||
| f8a63c4d41 | |||
| acd68498c6 | |||
| 5dca245242 | |||
| ef74425651 | |||
| 307f197ed2 | |||
| 64e90fd2c6 | |||
| 36b2079038 | |||
| 858993b67f | |||
| 24e629ba16 | |||
| 3d3fb71b38 | |||
| c1a5d0ab45 | |||
| edf5e75068 | |||
| 51d49e14e1 | |||
| 8acf1d0b39 | |||
| 93a30cf25c | |||
| 5fb19da544 | |||
| 1ccf28c63c | |||
| 079d5ac82a | |||
| a59263224f | |||
| 3ce376c89f | |||
| bbf23bf882 | |||
| 6bbde48bfa | |||
| a7e9de58ba | |||
| dd4e3af756 | |||
| 916e7ab617 | |||
| 7f5ad99405 | |||
| ea7ba31fb2 | |||
| e064b82767 | |||
| 0ba3a16ca8 | |||
| bbff88a518 | |||
| 4fbad3cf1f | |||
| 64d9446090 | |||
| 79ec4e158c | |||
| 0df5551eda | |||
| 1344561ce7 | |||
| 039be6a829 | |||
| c6e5139a8c | |||
| a34cc1ef46 | |||
| c7d864e76c | |||
| 310e55bb29 | |||
| ba8eed936a | |||
| f3abad510c | |||
| 1fca981e6e | |||
| 4d8e20f272 | |||
| da8caec3db | |||
| 0c4d45f81f | |||
| 25e67cc31f | |||
| 7dfff109ae | |||
| a0dd2fe4df | |||
| ba10b1b964 | |||
| bbc4851ef7 | |||
| 3a55355e59 | |||
| 663dd6c094 | |||
| 4ce5bb6357 | |||
| daf82da3ef | |||
| bc25d75e52 | |||
| 1fb70a4324 | |||
| e9d18699b6 | |||
| dfb2afe684 | |||
| e7ba61dd4a | |||
| dcbf077e86 | |||
| 6d76af0d3b | |||
| e034278892 | |||
| 0d6b7d641d | |||
| a789fe32f9 | |||
| b0c090674f | |||
| aeece29a95 | |||
| b4fc522ea8 | |||
| ec1b4e1321 | |||
| b2b54ec238 | |||
| 33dcd42a1a | |||
| 13d69ee3dc | |||
| 11541f4030 | |||
| 5e0efc472d | |||
| 0d166eb89a | |||
| e0e40639bf | |||
| 4b6a1fcb8f | |||
| 92fc4b645f | |||
| ee6cfaa7d5 | |||
| 62f1a74c36 | |||
| ec244c3d39 | |||
| e63e9c34ac | |||
| a3c77be76d | |||
| 756d93d06a | |||
| 4dc5dbd403 | |||
| 7d4a8ca233 | |||
| a499c51f32 | |||
| 003ed9bbcc | |||
| 9b2b79a333 | |||
| 904f9d4549 | |||
| bc18c1c108 | |||
| 09594892ca | |||
| fffa05d3dc | |||
| 7807d16244 | |||
| 002a879d80 | |||
| 0d283c1a7e | |||
| f6c2819c03 | |||
| 333c6e99c5 | |||
| 4700bdf221 | |||
| f909e9b787 | |||
| 822e0a472a | |||
| d0c0dd3894 | |||
| 6f42ab690c | |||
| 4e72bd8bf0 | |||
| d9adfc5323 | |||
| 921276d158 | |||
| 34726280fd | |||
| 38fe01a37a | |||
| 8e8b1e610b | |||
| 79f58ea0fe | |||
| e032f11801 | |||
| 64af0b4be1 | |||
| 1c5fa664fd | |||
| 0e3ecda2e0 | |||
| 5064f3e823 | |||
| eeee60a65a | |||
| b7a803dd1f | |||
| 5770a3ec32 | |||
| 0fbdafb4f3 | |||
| c8b47d573d | |||
| 338ba5a0cc | |||
| dd66245c6b | |||
| f0025b9e47 | |||
| e2be98aa10 | |||
| 6f551b177e | |||
| 4e447ff52b | |||
| 626796e658 | |||
| b7c8f413f2 | |||
| 417ed2bf64 | |||
| bbfc96be97 | |||
| f7876e23bb | |||
| e981610612 | |||
| d014bf3e2d | |||
| ccc131cfcf | |||
| d7282d63be | |||
| dee0cbc74f | |||
| 4741b5c4fa | |||
| cf95fa97bc | |||
| e7b94c3c24 | |||
| a2f311ff75 | |||
| 7791f8a62b | |||
| 1aa84f297b | |||
| f085f333d1 | |||
| 5c772ca9a6 | |||
| 1ac41290ef | |||
| da518bde90 | |||
| 0be6a9c532 | |||
| d772381244 | |||
| da4afdcac3 | |||
| d036d5cdb8 | |||
| bff9afdd13 | |||
| fecf5077e7 | |||
| 814b0491ec | |||
| 8b4696735a | |||
| 0b8002e336 | |||
| 4dfe569c91 | |||
| b2ea1214c2 | |||
| f35a630d0e | |||
| f2f4c918bb | |||
| 6059fffbd5 | |||
| e4c133b32e | |||
| 390609db14 | |||
| 320b4a9596 | |||
| 6a0fe2da6e | |||
| 6dc810da53 | |||
| ff520aaa5a | |||
| f29d29beaf | |||
| e7461142e2 | |||
| 4642082840 | |||
| 9aca0102f2 | |||
| faf2cb6a98 | |||
| 2acb157fff | |||
| a3c1ef816f | |||
| cb6086a548 | |||
| 0cdd64148f | |||
| 4d5eed63d9 | |||
| 9193eee9e0 | |||
| b6eda769a8 | |||
| 1684ff73af | |||
| 79d7f828cf | |||
| 9795d0fde4 | |||
| c52f2096f6 | |||
| 223e258109 | |||
| fbaaaa31cf | |||
| 2b81c475b9 | |||
| 6864c228d1 | |||
| cbaa9e24dc | |||
| af6ad8827e | |||
| b5c1d686a6 | |||
| 82c03e5240 | |||
| d86090b8e4 | |||
| 9f2c174680 | |||
| 67d5446aed | |||
| 34c6c1be15 | |||
| 85ff0913e8 | |||
| 9e1604c1c4 | |||
| 4e6dac09e3 | |||
| 50199b8921 | |||
| c7282fe6ce | |||
| 882078d396 | |||
| 92219b6458 | |||
| 146a4ad380 | |||
| c2e08a2a3c | |||
| 28a8ae5448 | |||
| f6079b452c | |||
| 944d9d5477 | |||
| ffc08ec828 | |||
| bee2123550 | |||
| 089201500b | |||
| f83e7ad77b | |||
| eae9f3c5f6 | |||
| 5176aa19ad | |||
| 7abb237b60 | |||
| 8d495cd25e | |||
| 4b7e40d075 | |||
| b78c2fb864 | |||
| 15f253c767 | |||
| fcc6944556 | |||
| 94cf7c4cfc | |||
| 9222c33463 | |||
| 2398f54851 | |||
| 5f04e6d5ab | |||
| f0fe705aa3 | |||
| e9d2e78c18 | |||
| 2f2d157f90 | |||
| 47fec542b2 | |||
| 8f3499d19a | |||
| 180f055991 | |||
| 437a4c158a | |||
| 4f6c4c038b | |||
| 9a4f561214 | |||
| f32d61dd41 | |||
| cd93cbd65f | |||
| 51e66e95d4 | |||
| d45a43d861 | |||
| 50c3573626 | |||
| 8ac866e7b8 | |||
| 4a1c9a0e2f | |||
| 2d326dcc36 | |||
| 6d1dbc7fef | |||
| d3c8577f83 | |||
| 83b930fc67 | |||
| 33a4dd58e5 | |||
| 86d848c277 | |||
| f8b31fb17b | |||
| aabb8b4e5b | |||
| 0adc475330 | |||
| 5725042837 | |||
| c4eab621a8 | |||
| c5bb486113 | |||
| 34723c2b6b | |||
| beeb50accb | |||
| afdf26c25c | |||
| f40f3fd1dd | |||
| 7e3b1abbef | |||
| 947d1c13f7 | |||
| 4939e4fd75 | |||
| 44bee884d2 | |||
| 53e65a578e | |||
| da3246e301 | |||
| 8cf14549b8 | |||
| 81b1cd6f9e | |||
| c5baf2488a | |||
| 6d2303ce5b | |||
| 906c52286f | |||
| af03a7b957 | |||
| b2afb11f5e | |||
| 42729eed91 | |||
| 1e64aab52a | |||
| 3108bbc464 | |||
| 4b225c524a | |||
| 2c5614f662 | |||
| 060ac7723f | |||
| 3c191c4eab | |||
| cf930bfcd5 | |||
| b8ae646336 | |||
| 25b12f0928 | |||
| fd63a568a0 | |||
| ca9d991c26 | |||
| 673adc9df7 | |||
| 9ba715aef5 | |||
| 58f12782be | |||
| 1c75d6703d | |||
| 342d634772 | |||
| 719fde30ea | |||
| c15f9fd801 | |||
| 47630471f4 | |||
| bb8c75ccbf | |||
| d68a511f7c | |||
| 1f2207f096 | |||
| 82fed2fdbe | |||
| f95dc40e8c | |||
| 696278a5aa | |||
| fe7b7f4df8 | |||
| 0c4dcfd3fc | |||
| d5c710f428 | |||
| e9c203a821 | |||
| eddbed3581 | |||
| cc79400f59 | |||
| 19318bc136 | |||
| 782ced08c5 | |||
| 5e72a3c0eb | |||
| a9bd7a6243 | |||
| 55968de40b | |||
| b9b1d14fc3 | |||
| febdffdd65 | |||
| eaedabff0c | |||
| f75dab5da0 | |||
| 5286bfc7c5 | |||
| a10ddbbaea | |||
| 98a455d85d | |||
| 51967e6359 | |||
| d91235ade4 | |||
| cf4fd59421 | |||
| 549f93ddd6 | |||
| 86be13400c | |||
| e0a8afa8c4 | |||
| 0a682e2320 | |||
| 26c48bd806 | |||
| 858e148831 | |||
| 0397b4b92e | |||
| 2bdb1cb2ea | |||
| 2e6fd373d9 | |||
| 065fb7d0c1 | |||
| bfc85822a5 | |||
| 7592c1143b | |||
| 78c005ca4e | |||
| 826c5928ba | |||
| 2cd3f45d1a | |||
| b296f013db | |||
| c45c9fd95b | |||
| 41081be1c7 | |||
| 8ec3709882 | |||
| efb1003347 | |||
| 08f655fbca | |||
| c8a43117f3 | |||
| 092b63a1e2 | |||
| 8abe5d7fbb | |||
| 19c32dcf7b | |||
| 4379f1048c | |||
| 04e0e16f7a | |||
| ed52c9b21d | |||
| b69cd46667 | |||
| 382de6e6cd | |||
| ce81cced17 | |||
| 650c34cdeb | |||
| 3ad45eb50d | |||
| 52546d291b | |||
| 403503e7a1 | |||
| 9b0ab2a229 | |||
| c7b3143749 | |||
| 3b9f9793cc | |||
| aec73ca83c | |||
| 07668ea63a | |||
| 294056a132 | |||
| 73a70d541b | |||
| 506a1c0683 | |||
| 26dbf010e0 | |||
| b20d9322f2 | |||
| ad198c0272 | |||
| 28e38978a1 | |||
| 0f1ade86d4 | |||
| 912e207f58 | |||
| 5c2b7c67be | |||
| 19a51db7f3 | |||
| 6f82a0d530 | |||
| e4faab12eb | |||
| 4ce4191fd8 | |||
| 5acdf2ec50 | |||
| caeda909aa | |||
| 584a286712 | |||
| 0460c79a9f | |||
| a2dae10b55 | |||
| 93ee04167a | |||
| 15b9783991 | |||
| ed2ae7246e | |||
| 6492daaba1 | |||
| 81f214d7a3 | |||
| 29aa9db6b7 | |||
| 55e59c2e41 | |||
| a2bd69a05b | |||
| 54d51ce31e | |||
| 3de170ddac | |||
| dbd4e277a9 | |||
| 21df74b7ac | |||
| 9b21ffbe80 | |||
| bb273c9f7d | |||
| c15c6e02d1 | |||
| 137c529c0c | |||
| c402e0809e | |||
| 1394c74c32 | |||
| 7a02e919e2 | |||
| f707bc715b | |||
| 457cf4f8ae | |||
| 1f2c907d55 | |||
| d7f4f3b52d | |||
| faaf1fb860 | |||
| 379e8fc234 | |||
| bce67819d9 | |||
| 3bfe69e7ac | |||
| 6a98da3045 | |||
| 8fc10f588a | |||
| e28cdacca7 | |||
| cacbb4c927 | |||
| 5aa0907fc7 | |||
| af2fda8ef1 | |||
| dd078e1969 | |||
| 5f546ad10a | |||
| 77a40a8ff0 | |||
| 1d56ad7f85 | |||
| 3015ae49ab | |||
| 6340a509eb | |||
| 93e3a3c336 | |||
| 23eaeaf0f8 | |||
| e39b5cc8cd | |||
| d73d926f7a | |||
| 69dae88217 | |||
| ef979e952b | |||
| 0d4e2fde58 | |||
| f19a04146b | |||
| 4aa107317b | |||
| 6bf6c064c1 | |||
| 474b5f90a5 | |||
| 327a57a3a8 | |||
| cb7e4e63ae | |||
| d8bbb6e1b0 | |||
| 74a6a9c219 | |||
| e8cd377f76 | |||
| b72ed90254 | |||
| 73f8331960 | |||
| 0738714376 | |||
| f2c37ec8ba | |||
| 1c6bb8d5b3 | |||
| b3fae16939 | |||
| c764b66fcb | |||
| f0e5461eda | |||
| 3eb7b1ec0d | |||
| 5da8f01afc | |||
| 0855762516 | |||
| 2830dd8266 | |||
| 7011299251 | |||
| 27d2a072cc | |||
| b35749dcd2 | |||
| a394aa6e33 | |||
| b2e962f158 | |||
| 98079d42e8 | |||
| 34f2da0c46 | |||
| 328b50f9aa | |||
| a47199d741 | |||
| 7616baa9a9 | |||
| b433fd5db0 | |||
| 47bb15f409 | |||
| c0e57d16b1 | |||
| f2e32565a5 | |||
| 8afffd20c6 | |||
| 3b6ac7f5a8 | |||
| 0339cdcd1a | |||
| 89e50cde43 | |||
| 15c47a7f05 | |||
| 0989914f79 | |||
| 55589d9ec0 | |||
| 01f6331bd7 | |||
| a97c6e9371 | |||
| daf3246c57 | |||
| e8074584d2 | |||
| 4637c700ec | |||
| 5db9e93f00 | |||
| 614a7b317f | |||
| 265a37643b | |||
| 2b13f75e30 | |||
| ac057b3157 | |||
| cd41d69410 | |||
| 53b0e0f9fa | |||
| 81729b367a | |||
| 3d2e4a36ad | |||
| 1ae9e920af | |||
| 5b119df0a6 | |||
| cf404182fb | |||
| b126f4d095 | |||
| 016f420789 | |||
| 2a9827575c | |||
| 4b5350776e | |||
| 578354f78f | |||
| feb6989d2f | |||
| 846ddb3f32 | |||
| 2723c07e52 | |||
| 076156656c | |||
| 0e2f4dd6a7 | |||
| 527c17cb32 | |||
| 61c254c025 | |||
| 5c486c544d | |||
| 37864a19e2 | |||
| 6afb87e77c | |||
| cdd835f551 | |||
| c57fc51ed6 | |||
| e4be7d53c2 | |||
| 021a81d365 | |||
| f903b4327c | |||
| f5f8b3c6e9 | |||
| 09974f1481 | |||
| 17713972e9 | |||
| fc87d74af0 | |||
| 76a6ffb1ea | |||
| c5b5f6d59d | |||
| 49c8e26290 | |||
| 02cf4c43d4 | |||
| 2aff6e8c7c | |||
| 9c1bc99be2 | |||
| 2f9a573803 | |||
| 4ef420d969 | |||
| e1c2a36758 | |||
| 67a9e55a72 | |||
| 63471353e0 | |||
| 5a13da984f | |||
| 5d781b362e | |||
| 9c015b838e | |||
| 969b55a9e9 | |||
| f0a449ea69 | |||
| b22860d359 | |||
| 52d8169a3c | |||
| 5c6bdbe7b7 | |||
| d6b5ce2f4d | |||
| 109e409faa | |||
| 9fe9824ca9 | |||
| f7ff6151cb | |||
| 060122375f | |||
| b1dfa1adde | |||
| ba1e56ea68 | |||
| 331aaa91dc | |||
| f6f73896f4 | |||
| f5f627e778 | |||
| 2be1480a4f | |||
| 66b3ccb5e8 | |||
| 1608b250f7 | |||
| 8465294b5c | |||
| 801d1cbdaf | |||
| 00c7750b6e | |||
| 8cacbf9531 | |||
| 72c19b53b0 | |||
| ebb40bf2f2 | |||
| 69676baa9a | |||
| 070616b453 | |||
| 535fb43a9e | |||
| 4a06250703 | |||
| b112ddf5fe | |||
| 52e76a656e | |||
| 30641dc19f | |||
| 319d539ab7 | |||
| 35e8d86dce | |||
| c27c846bdc | |||
| 89d6ebd68b | |||
| 3923b33f66 | |||
| 4c59e0a027 | |||
| ac40a4166d | |||
| a5f4bd34ad | |||
| 5c764393cc | |||
| 4f89ada4d5 | |||
| 3501b12dfb | |||
| 03f21f41b2 | |||
| 01f73d08f8 | |||
| b80269918c | |||
| 1ef6f890d4 | |||
| c257fa5372 | |||
| ab6231437f | |||
| 66606076ca | |||
| d292a30a08 | |||
| 927f1aa71e | |||
| 8d7f929f0f | |||
| 4903f89396 | |||
| ebc1e7613e | |||
| 5aea71fc35 | |||
| a5e98787b3 | |||
| 3f21b51832 | |||
| 817b8f0c01 | |||
| 7ffbfb874e | |||
| 8817545868 | |||
| 768ad43251 | |||
| 2c6782b744 | |||
| 5c1475da92 | |||
| e3c22aa2bd | |||
| 6e13861e34 | |||
| b217008efc | |||
| ec2f58c411 | |||
| 06a835f658 | |||
| 049772b62b | |||
| 5341788028 | |||
| 9dfe0f27ac | |||
| 90fad70639 | |||
| 1ce01626a7 | |||
| 46035c3c50 | |||
| e82f325a67 | |||
| c1eb42c3ff | |||
| dea8eee1fd | |||
| d9785b773a | |||
| 50583df4a9 | |||
| 8021a382c7 | |||
| 1895594b1e | |||
| 493f719a5f | |||
| 6b0117298b | |||
| 1fec02995b | |||
| cc7b5c57f3 | |||
| 84f7864342 | |||
| 46bbce7072 | |||
| 08e80e26c9 | |||
| a5a5426f0b | |||
| 2c74eab219 | |||
| 0081efed82 | |||
| 5d89cd1662 | |||
| b6b7d2930d | |||
| f4228e2bfa | |||
| f1543357f4 | |||
| b254fe2b4e | |||
| cc490b1991 | |||
| af6903709c | |||
| ae8d1df882 | |||
| 3f54dda0de | |||
| 775b017ac3 | |||
| a21ad0e407 | |||
| ad8488d669 | |||
| 6cbad61c1f | |||
| 4483d45638 | |||
| 04c272a7c2 | |||
| 476420f173 | |||
| 2bc179c6e9 | |||
| 5b946471ce | |||
| 084de093e0 | |||
| 2ae443b647 | |||
| 25b480a009 | |||
| 0ea29a9e44 | |||
| 280f4f82a1 | |||
| a4c4c15025 | |||
| 811abbb518 | |||
| 0a777124a1 | |||
| bdf29bb650 | |||
| 265fc79e38 | |||
| 7e4fa4973d | |||
| 8cb135a62d | |||
| 9c0d32588a | |||
| d9f9485bd4 | |||
| 4f5e5df19f | |||
| 305f21dce1 | |||
| 0dd017a3b8 | |||
| a54a25ee80 | |||
| f1910e88ea | |||
| fdb118c5fc | |||
| 898ddc0d3a | |||
| 563e9fa429 | |||
| 8e7cb96101 | |||
| b004f145c2 | |||
| 9f604448a8 | |||
| a3a28f5394 | |||
| 890525eb8e | |||
| ece98ac78e | |||
| ec60989a2f | |||
| ffbc088251 | |||
| fdd29da548 | |||
| 5cb947870a | |||
| f7f64f5826 | |||
| 41d6802d70 | |||
| adde1d5b8a | |||
| d933931b04 | |||
| eb4acb7d2e | |||
| 91b3bd7bd6 | |||
| e095f4c4c2 | |||
| 6287d5bca9 | |||
| 13e352b93d | |||
| 2200bf4de8 | |||
| ac7f8843f7 | |||
| b8f37f3358 | |||
| 255da92a43 | |||
| 024764c5b4 | |||
| 97f20a08ce | |||
| ede90c78a8 | |||
| f57fab67d8 | |||
| ce2a07b0bd | |||
| 01b729b908 | |||
| 8816215a48 | |||
| 213c3cc2b6 | |||
| 24a8c3b855 | |||
| 82a1dfb18b | |||
| 53611ac8bc | |||
| fe430e4948 | |||
| acbc6a8b01 | |||
| b9fe0484c1 | |||
| 28d9978d68 | |||
| 069479cb82 | |||
| 7a74488729 | |||
| 9723e4502f | |||
| 44f60d1031 | |||
| ed08b8b392 | |||
| a5a4ae2afd | |||
| 68206c07ce | |||
| c2acd4eeed | |||
| f09dd3c679 | |||
| a3f88e6a4d | |||
| 131d94e926 | |||
| 1f78e99227 | |||
| 046021ea96 | |||
| 78013c737d | |||
| 58c7c76688 | |||
| fafc9b4358 | |||
| 5f5ccd7259 | |||
| 7b06dd3645 | |||
| 07be98b95d | |||
| 503a337ff3 | |||
| 7c87061378 | |||
| 0264cf7324 | |||
| ad50498a2a | |||
| fce0240fe7 | |||
| bfd38b738f | |||
| 277927bd8a | |||
| a592b79ce4 | |||
| b20d357282 | |||
| 3e48204af0 | |||
| b7ebb35be8 | |||
| a5316d957a | |||
| 056297b125 | |||
| cd3a8912e9 | |||
| db71b04dc2 | |||
| 207edaaef2 | |||
| e18b72ac57 | |||
| db125ce552 | |||
| 618278845f | |||
| f47cb915f6 | |||
| 35b25461dc | |||
| d4e067e68e | |||
| 7f0c25b4a5 | |||
| 8c8cc7cd75 | |||
| 3991ef9d2f | |||
| ba3ca47915 | |||
| 972226a7e6 | |||
| f79fb8b9df | |||
| 460559ebd8 | |||
| 9bed53304d | |||
| aafbc127cc | |||
| 35f76c77f9 | |||
| e276039d55 | |||
| d5554d0e1b | |||
| 9eb5928ca2 | |||
| fdf2b32bb5 | |||
| 57fd95d578 | |||
| 2a03e1a03a | |||
| 274c6cd124 | |||
| a92994257a | |||
| f06748b6b5 | |||
| 0fa54ce433 | |||
| bd23ea87cf | |||
| b8defef41c | |||
| 39c5b18802 | |||
| a75b3b1616 | |||
| 81c774bd68 | |||
| b4cfef5577 | |||
| f4b5470f44 | |||
| 00bd28c38a | |||
| 3e7bbf7e50 | |||
| f405cc5746 | |||
| c9e99ec3ed | |||
| 18dce0d2d9 | |||
| 3253cd8a16 | |||
| 808b9e4752 | |||
| 23f6a79198 | |||
| b889bea6a4 | |||
| 304a55e296 | |||
| bddbed22ff | |||
| 1722924867 | |||
| 8c0f415d17 | |||
| 840f538626 | |||
| 001cfbe023 | |||
| cde8ab0dbb | |||
| 5d82315c59 | |||
| 200f56d75c | |||
| cfd207f48a | |||
| 03faea6385 | |||
| 0223f81383 | |||
| e24e53cb73 | |||
| 058a995d0b | |||
| 602d4b46f3 | |||
| e836d14ccf | |||
| ff59976fa1 | |||
| 4fd484df99 | |||
| dc700ce2ad | |||
| eb8d5104a5 | |||
| 5fec178cf1 | |||
| 954cbd7e07 | |||
| 94b5bdb61e | |||
| 81a155dde6 | |||
| 425f02be13 | |||
| 8e0205e136 | |||
| c5d0be57fd | |||
| 35525dd13a | |||
| 17eae18117 | |||
| 2162081e2f | |||
| db29b2ed53 | |||
| 7bcf8f11a5 | |||
| 29a639b6a8 | |||
| 8625330b02 | |||
| 76ae78e376 | |||
| fe18faff00 | |||
| f26268846f | |||
| f947b61bd8 | |||
| 519d3cfd45 | |||
| 75452b3c6a | |||
| 9167d4a23d | |||
| 0a4ddefa45 | |||
| f1ade10360 | |||
| ee345fa8c8 | |||
| 40172cabd1 | |||
| e9440be4d1 | |||
| ef5ceea994 | |||
| 7f02b93e67 | |||
| df33463d58 | |||
| a54e3edd57 | |||
| a56e588dd3 | |||
| 955569c83a | |||
| e8ed741d0e | |||
| ba406d40e0 | |||
| 8d188a2486 | |||
| 1ca6f61bdd | |||
| 0a9fc79dfa | |||
| cfd485e9bc | |||
| 8a81fa3064 | |||
| 07c280a310 | |||
| 77d7bd2446 | |||
| cf5b264425 | |||
| d39436ab6f | |||
| 0d621f394b | |||
| af1c2513a7 | |||
| a6a4d277e4 | |||
| 3986f54da3 | |||
| 062f673771 | |||
| 7ca7359321 | |||
| 869f41a7bf | |||
| 741dc406c1 | |||
| 0bd3693943 | |||
| 66be752d56 | |||
| e2df1f55e2 | |||
| 1c23c259d0 | |||
| 3b1ad5ed4a | |||
| 69be3b2093 | |||
| d8e951be7b | |||
| 9152a6056d | |||
| 098c0f9bb2 | |||
| 6fa0df3754 | |||
| 464c77744f | |||
| 0b2a95be31 | |||
| e610b9aa77 | |||
| 4aad143869 | |||
| 43cf34a907 | |||
| e4900ef555 | |||
| a33b591f03 | |||
| b01a3c4d22 | |||
| 59059704fe | |||
| 5e1a79b1d0 | |||
| 2e495b8f25 | |||
| 838e8edb0c | |||
| 1c62820690 | |||
| 194efbdbae | |||
| 9f0559df9a | |||
| 8e90760f0f | |||
| 5e3a1e43d9 | |||
| f43a0454ff | |||
| 2f2ed0a749 | |||
| ef971e3b35 | |||
| 27469f4507 | |||
| b8140164f5 | |||
| 3ae8f65665 | |||
| 75f8638837 | |||
| 0b7ea79ab9 | |||
| c41942385a | |||
| 6da153ea9a | |||
| f0c6f0ea68 | |||
| c7d8c6c7fb | |||
| 3c8f426f32 | |||
| 7f136b9bb7 | |||
| 2a6045904a | |||
| b5196959dd | |||
| 1bc7cedd0d | |||
| 55a8c8fa46 | |||
| 364f406724 | |||
| f334a6144c | |||
| 6fddfdee94 | |||
| eb6421b91d | |||
| 6deb9a8c9e | |||
| b77eba2e4e | |||
| 8cba37abdc | |||
| 286f196cfe | |||
| 8b98a26ec5 | |||
| 72e44721cc | |||
| 3bdb3f517f | |||
| 5cf496fbb4 | |||
| 8f1576af2b | |||
| 70701b63d6 | |||
| 54ffb2883d | |||
| d0a5c234f8 | |||
| 98a88c50e3 | |||
| 1d422dca6a | |||
| e4495ef3ad | |||
| 620152fd01 | |||
| 761075c27c | |||
| 125cd36f25 | |||
| 6133efb039 | |||
| 52a8ccd649 | |||
| 27aed8ed68 | |||
| 4ff0dcb2a3 | |||
| be1708b80e | |||
| c1ee603d77 | |||
| 0f4ac990e6 | |||
| 3f1e7c2423 | |||
| 38c984344b | |||
| d6659f2395 | |||
| e90f10a236 | |||
| 11f9b04410 | |||
| 531e4b52cc | |||
| 5b15610288 | |||
| 8c729f4948 | |||
| 4a79fbfe55 | |||
| d97dcfdb9e | |||
| f46cb637b5 | |||
| 2e8ba4227c | |||
| c2ba60a497 | |||
| a732ff46b9 | |||
| 81e0253a2b | |||
| 4a42190768 | |||
| 7de6b34d1f | |||
| 9da1812022 | |||
| f3d9f47fd2 | |||
| 6a699a5194 | |||
| fa3b5f95c5 | |||
| fd82aceabd | |||
| e16956c985 | |||
| cbdbdde3c5 | |||
| 4bbcc58b10 | |||
| 8deb13c805 | |||
| 7a4fc8ee96 | |||
| cd879b5802 | |||
| 12691d7162 | |||
| 7153cf0a43 | |||
| c8bc3488af | |||
| 798e89f7e3 | |||
| b85d4a4539 | |||
| ecc540774e | |||
| 8099279a02 | |||
| 6fb282e896 | |||
| 3572f755c3 | |||
| 324f7a1d55 | |||
| a6cb48c96a | |||
| d8f9c0ec5e | |||
| 54d3ceffe8 | |||
| d8b15c595a | |||
| c8db8f3ade | |||
| e697fb44d5 | |||
| ada3734e44 | |||
| 00ef72f286 | |||
| 96ef8181fe | |||
| 5852bf5f3b | |||
| 2cf7b658a4 | |||
| cc79324af8 | |||
| cad99c7a43 | |||
| de46c76283 | |||
| fd7479bf2d | |||
| 1db96bd00a | |||
| a4e5ec4cb7 | |||
| b4a87d486e | |||
| 7bf696bac7 | |||
| 271a5e6c6c | |||
| b2e83f9859 | |||
| 0da66d831f | |||
| 8a9fc29f90 | |||
| 731665481d | |||
| f19597e20a | |||
| 4959b087ff | |||
| 5eef140bfd | |||
| 10991058ac | |||
| e4c2a17ef7 | |||
| 80c1061e42 | |||
| 46e72334ca | |||
| 26122adce3 | |||
| 424d13345c | |||
| da7d337ebf | |||
| 19a7107121 | |||
| 227457e58a | |||
| 9a39b3706f | |||
| ec02fd3795 | |||
| 52cf91a88c | |||
| 0489bfe05e | |||
| 593c57ada1 | |||
| e4725ad547 | |||
| f332845a82 | |||
| d4a83591e7 | |||
| 6be55d69b6 | |||
| ffbdfa046c | |||
| bf96f92174 | |||
| faf13f860b | |||
| 243b019b6d | |||
| 5d31fcbbbf | |||
| bb77fb0ee7 | |||
| 39c4b2b0cb | |||
| fb5df0e12c | |||
| 48486e54a4 | |||
| 26d32bfc9d | |||
| 8d89237202 | |||
| dbc1db18f6 | |||
| 8588d78bfe | |||
| b8cfd671ac | |||
| de459ba0e2 | |||
| 67db0f1f67 | |||
| fb4750ce3d | |||
| 8c17dd0878 | |||
| ccaf9a6841 | |||
| 8a4e882a67 | |||
| 0aaea3c8ce | |||
| b86fdcbb9f | |||
| 3707253092 | |||
| c2deef3fcf | |||
| 3dfd6be20f | |||
| 8706fe2fea | |||
| 52e7eeb4da | |||
| fa95196af4 | |||
| 3d6f1906e9 | |||
| 0d43302752 | |||
| b6ae51c1e2 | |||
| e767610291 | |||
| c63e68505b | |||
| a376ce99ea | |||
| 87bfc21ec8 | |||
| c1af5ca4f1 | |||
| 7e3f6de904 | |||
| c8041d9472 | |||
| 7c73148247 | |||
| cc750ad185 | |||
| bd3417efa7 | |||
| f400440460 | |||
| 2c704079fb | |||
| ab89da6378 | |||
| 78a043d73e | |||
| aea0e3c855 | |||
| ee3edf62d3 | |||
| af18497bb1 | |||
| 0c9dcaf22d | |||
| 03318fbec3 | |||
| a19fd2aec1 | |||
| bdcc039d28 | |||
| b36dc98db3 | |||
| 12c7c8bf2e | |||
| b8cafb02dc | |||
| 56816f88c9 | |||
| e7fe1b11b5 | |||
| 44cad087d4 | |||
| ecf430e91f | |||
| fc62be181c | |||
| c9f198f778 | |||
| 3d0c21108b | |||
| 07b12c1500 | |||
| d6f4e11be1 | |||
| ebb53c7c7a | |||
| cc9e7dce47 | |||
| 6f363cf52f | |||
| ba1d609fdb | |||
| d24898abd1 | |||
| 02c9b77a7e | |||
| 9d78dc7ffb | |||
| 5e831e9dd4 | |||
| a0cf89d784 | |||
| dc6e1083f8 | |||
| 3ae64130ea | |||
| fcb283f334 | |||
| ad4df46d12 | |||
| b4af21c06b | |||
| fecb6b70dc | |||
| 9d1231070c | |||
| 7b6bf25731 | |||
| 888fab0c8a | |||
| 08a770752e | |||
| 9fd5422f94 | |||
| 8afb8c8f73 | |||
| 441234b514 | |||
| f137dd5b09 | |||
| b4a96fc974 | |||
| bec77579a1 | |||
| 0e2926b12b | |||
| 8e3db4714d | |||
| ae84291d10 | |||
| 8c577cd895 | |||
| 2b3109407f | |||
| 17f114ed35 | |||
| d3294222ea | |||
| 2ecd540860 | |||
| 3f7e64c9e8 | |||
| 6dfe33f0c0 | |||
| 6a3212e6d7 | |||
| 564295014b | |||
| 004f8f2e66 | |||
| 8b4444f9d9 | |||
| b12b5f7546 | |||
| 85f36a57b6 | |||
| 65a0290fac | |||
| cc3054acc7 | |||
| f81c7fcc03 | |||
| 4dd25e23ae | |||
| 40bef66b35 | |||
| fa125da59c | |||
| 4e22219c3b | |||
| 81b0148462 | |||
| 68659ba7e2 | |||
| aeebdba86e | |||
| e5bf00699d | |||
| 9218af6090 | |||
| ceea80ada2 | |||
| f874a36dbc | |||
| faff412bd3 | |||
| dbdf172f2a | |||
| 698bf897b1 | |||
| 64b0197667 | |||
| fecd9fbc3a | |||
| 8e8a9e969a | |||
| 8dcbc2d091 | |||
| 2a18944f50 | |||
| 8ba6bb63f1 | |||
| a03a281131 | |||
| bb313cd642 | |||
| de58f7b53d | |||
| 23cfd7f87f | |||
| 6c75804616 | |||
| 5aa178ac11 | |||
| af01118c2f | |||
| d4db11c16f | |||
| d92266839b | |||
| 29bf585107 | |||
| aed0bd1bb2 | |||
| 6c54fa9936 | |||
| 621838490d | |||
| 179c0fb2b8 | |||
| e66da570b4 | |||
| b620b05d6b | |||
| 2e8203c0dd | |||
| a3ccf1511b | |||
| 8b8b42d804 | |||
| 2bfb95b88c | |||
| a30a82f169 | |||
| 62a4c94c5e | |||
| a09fdc608a | |||
| a407b615f9 | |||
| 2580f9f9cb | |||
| 40a6df58fe | |||
| 2d4ee60471 | |||
| 1964d345a8 | |||
| a0d729d26b | |||
| 76358c2e87 | |||
| 930317fe1c | |||
| fa1da1b807 | |||
| 2b6b34648e | |||
| c1d2e43365 | |||
| ae4d14fcd9 | |||
| aa27fbd811 | |||
| 9471720b29 | |||
| 5abd0f841c | |||
| af271a6943 | |||
| fcbd825ecf | |||
| 36495e86d9 | |||
| c8f63e305d | |||
| 50e2371cee | |||
| 1ef6030360 | |||
| 3ebc34b0f4 | |||
| be884947d7 | |||
| 407270de3b | |||
| f330019a4e | |||
| ffbca77785 | |||
| f5c4edfb17 | |||
| 1c39a53267 | |||
| 957bf8f8da | |||
| 04766492bc | |||
| b52c6c6e5c | |||
| 70fd819906 | |||
| b7e8218d6c | |||
| 9009205b91 | |||
| d20ca67005 | |||
| 78736b7df5 | |||
| 07ff858493 | |||
| 0b1a96bea3 | |||
| 7b928c1991 | |||
| e3ec0e1901 | |||
| 64d90a74cc | |||
| fd62adfd1b | |||
| 313bb91624 | |||
| bc21d870fe | |||
| 4d724676c8 | |||
| cbf7fe6580 | |||
| 05588d6af0 | |||
| 4527165a8c | |||
| 4977b0c2ae | |||
| bd1ac588cc | |||
| deff90f41b | |||
| b87c90252a | |||
| 1d8b299bca | |||
| 8e41d28c4d | |||
| 01e6cc3751 | |||
| e4aec311c4 | |||
| 8fcdd5cb54 | |||
| 120c2b57d2 | |||
| 4b2dba83d6 | |||
| f1b7346781 | |||
| 82082cbe71 | |||
| e49957781e | |||
| 524d9444ff | |||
| 6f09ebecda | |||
| 9a9c5bd798 | |||
| 3d3dec312f | |||
| d9684920e4 | |||
| 0b78fae56f | |||
| f3cb0f1dca | |||
| bf34a6e112 | |||
| cbd7ea4ff5 | |||
| 3d5c9ac401 | |||
| b161737598 | |||
| be829ba250 | |||
| 76292e251d | |||
| fcb1ff3b7c | |||
| 2b2a9a9878 | |||
| 04ff084560 | |||
| f240b49d3d | |||
| a2afdb48a8 | |||
| 506be63688 | |||
| 2fa54efe31 | |||
| 11b10c3ec2 | |||
| 24939981c5 | |||
| 559e5f854b | |||
| 513158a2fb | |||
| 59a0cb8c30 | |||
| 3e55bb95c4 | |||
| 76411971d8 | |||
| 948a5a1af2 | |||
| bde6675368 | |||
| e0a12c89a2 | |||
| 3f33596df2 | |||
| 0403991d42 | |||
| c57665cc2b | |||
| b19645bf1b | |||
| 78ebfa5a6d | |||
| 607201168b | |||
| 84ecde7d6a | |||
| f97fbf2cca | |||
| d114e7b7aa | |||
| 8fd0009116 | |||
| 9a9416889b | |||
| a027b5200a | |||
| d6dea96e23 | |||
| f4c2a46966 | |||
| 616a3f9c46 | |||
| 3e52f7bdfa | |||
| ee91f0de9e | |||
| 9fad52bb04 | |||
| bab636927d | |||
| 4aceab4494 | |||
| 90b7ac7d46 | |||
| a73816c9be | |||
| 86448fc4dd | |||
| a3781f8c4a | |||
| 5dc9bf67cb | |||
| 8f3ee3a569 | |||
| 9da078a7e3 | |||
| dea510fc5b | |||
| 3bf91fd73c | |||
| 35cdfd4d65 | |||
| 992e71cc57 | |||
| 9ea0ed55b1 | |||
| af8b6fb2de | |||
| 427ae1da50 | |||
| 659f14a674 | |||
| 4727eca376 | |||
| 9e8a7217f6 | |||
| cf8f6ce28a | |||
| 894d4f5cf8 | |||
| 94cba17e7e | |||
| 3b2ceecf70 | |||
| 183b0a0e21 | |||
| d9a9228b99 | |||
| f50ca37bf0 | |||
| 25881e2d1f | |||
| e897deb324 | |||
| 7d18190ff6 | |||
| efa78434fb | |||
| 360e956c48 | |||
| a6f12e9142 | |||
| 0213c36332 | |||
| bb424ffc60 | |||
| 5df59bf800 | |||
| a24f7fa4a4 | |||
| e8ddaf7319 | |||
| 7f60737adf | |||
| cda59b0ccc | |||
| 74c50137e9 | |||
| 182f6f81c6 | |||
| 28acfb3290 | |||
| d08522f898 | |||
| 59bd752669 | |||
| c136c61d9c | |||
| 3b2f2a75bf | |||
| a33f2308b9 | |||
| 0810a8efbc | |||
| 98dbfa23fb | |||
| d6e8a3d044 | |||
| b308693056 | |||
| 8dc521d510 | |||
| 119d0c34d9 | |||
| c9f7c42f5c | |||
| 1072408c8d | |||
| 5646302bf4 | |||
| 195a875b40 | |||
| 01d9c363de | |||
| 5479099a77 | |||
| 3b127b567b | |||
| 20e91dda7a | |||
| cd281c1076 | |||
| 3b9231ee5e | |||
| 443e71de8a | |||
| 08498f4717 | |||
| 33644e6e6e | |||
| 006fd41fc4 | |||
| cb942f517a | |||
| 987c0391cf | |||
| e26491b26c | |||
| 01c1b6f1e1 | |||
| 520c45543c | |||
| 0c164f755f | |||
| cffdc57dd1 | |||
| cd35d5c774 | |||
| 16a06804d3 | |||
| a6cf0044dc | |||
| 03486a7836 | |||
| 8034bf8464 | |||
| 98f27a6428 | |||
| 86276c20be | |||
| 98bfa6214b | |||
| d41a0e6688 | |||
| 85e7b9f90f | |||
| ad7f83a34e | |||
| 25733cb25a | |||
| 1a92483774 | |||
| b5981e7334 | |||
| fe2274318c | |||
| 2719d4681a | |||
| 92123f90b7 | |||
| e127df3e94 | |||
| 5a201e0a00 | |||
| 7cac8ce688 | |||
| bcfc157aa7 | |||
| 2c1557348a | |||
| bce6889e0a | |||
| 1ed839342f | |||
| 1acab0b61a | |||
| 17da80406a | |||
| 4f3ef1e628 | |||
| 64560eca3d | |||
| ccf85f118c | |||
| 78495ebaf4 | |||
| 46455f8f69 | |||
| 3f2471badf | |||
| 99230dba53 | |||
| d790ff3d79 | |||
| 1f4536c4de | |||
| 212d111259 | |||
| b4696f1de1 | |||
| 3ae4b5efc2 | |||
| e2d842fda7 | |||
| 16c24abf53 | |||
| cd4b8c6dfc | |||
| 0486b498a8 | |||
| 17471e7c7e | |||
| e332b7048a | |||
| b186bd82fa | |||
| d7680ed316 | |||
| 47938e3285 | |||
| 13d575d6f9 | |||
| 6308103a9a | |||
| ac3549bed5 | |||
| 4cd25c8e04 | |||
| e7d30d6183 | |||
| 457abdd115 | |||
| ba81cccc77 | |||
| a3c7b9931f | |||
| f8c9f8a94a | |||
| 26f77da3ec | |||
| 813e272ed1 | |||
| b10dc974e8 | |||
| 352781c3fc | |||
| f7670605a5 | |||
| a8bc4b60d9 | |||
| 972f555c29 | |||
| bda43f0b19 | |||
| 0d87d74de2 | |||
| e474e40657 | |||
| c4c20a025f | |||
| f2968a7d49 | |||
| fe5c4f211d | |||
| 3c9482591f | |||
| 90923f0ad3 | |||
| 6431794406 | |||
| 28371c5eb5 | |||
| 7354b6c9d6 | |||
| 8a3b3305d1 | |||
| 531da18311 | |||
| 0534aa6f42 | |||
| 2fba21b716 | |||
| a427efc1ba | |||
| 695da32b22 | |||
| c320d6c812 | |||
| 686427b4fe | |||
| d876e5d4bb | |||
| fc8416aaa6 | |||
| 6cad87c923 | |||
| f70a0283e0 | |||
| 8d7ec30216 | |||
| ab1acef075 | |||
| fefa0f4779 | |||
| 1a15122749 | |||
| c1051ecf7b | |||
| 1a09dac1b1 | |||
| 83c17a0801 | |||
| c5d0a0c4ab | |||
| b0665a3b89 | |||
| 758103520e | |||
| 1e1dab96f5 | |||
| 6b6aaa2afa | |||
| 1f304acca0 | |||
| 3861b21a5c | |||
| c9888ba32a | |||
| 8dbb865950 | |||
| 384008acd8 | |||
| e9ca3a36b6 | |||
| 2562d495b2 | |||
| 0cb326a9ee | |||
| 61bae5e14f | |||
| e513ef1a8e | |||
| 5b0d0dccc7 | |||
| 468c93a64b | |||
| c638f985d7 | |||
| c094aec6cc | |||
| 74ca5b085f | |||
| 66d258c512 | |||
| bb0de6dabc | |||
| 6b0da01ab1 | |||
| 9affbde802 | |||
| f6a7e3cd16 | |||
| e381335f71 | |||
| fec3ef1ad0 | |||
| 258bda6e7d | |||
| 86b3d106c3 | |||
| 12478cc110 | |||
| 46e6573866 | |||
| 11eeb012dd | |||
| 64066d9add | |||
| ab16381963 | |||
| 6c5c21b5a8 | |||
| b408dc9c34 | |||
| 6096a84ac4 | |||
| 1ad357c75e | |||
| fbff3f21f6 | |||
| 67846ca997 | |||
| 67fde12515 | |||
| 0649260c80 | |||
| 8914d3e548 | |||
| 54ff85835b | |||
| c8dbfba62a | |||
| 0551e329cf | |||
| 338cfe0147 | |||
| 89ad095fb9 | |||
| d5c37fafe2 | |||
| b9fdb97eec | |||
| 2d598ba2a7 | |||
| 8c1f9abac7 | |||
| ded467e4d3 | |||
| 58cd206bab | |||
| 8dadf668f2 | |||
| 2db614146c | |||
| 751700d3d5 | |||
| ba972ddb02 | |||
| a13d6bdcc1 | |||
| 7bce9add62 | |||
| 557313427a | |||
| 3ed3907789 | |||
| e7a1a4d3de | |||
| a5469cb815 | |||
| a113748b88 | |||
| c1f9cca98b | |||
| 1e047a909e | |||
| fa267bb523 | |||
| 04f081f785 | |||
| 945b6abc3f | |||
| cdde0e8a18 | |||
| 88decd6eaa | |||
| ff3767b41a | |||
| 13ca4a5fec | |||
| ca643e5adb | |||
| ba703d99f2 | |||
| 41e6260068 | |||
| 815eb92706 | |||
| 6270c2c0b9 | |||
| 3e42b4eb82 | |||
| 74c7a7343d | |||
| 19df671f2c | |||
| f4397561f3 | |||
| 41adf68217 | |||
| eee0161492 | |||
| c2f8c1f590 | |||
| 71a313d9c7 | |||
| dcbee310bb | |||
| 0ac28c4986 | |||
| e95756c8a8 | |||
| 60b7fa3683 | |||
| 7eded0bebe | |||
| 232875d6ea | |||
| ed75d0d01b | |||
| 56547b4d4b | |||
| e873844e2b | |||
| b0fda7666b | |||
| 112bc90b40 | |||
| ef7f3b2e36 | |||
| 1d7ea27f95 | |||
| 7ddfc5467c | |||
| 69abeb16ec | |||
| 9e3ed0c0da | |||
| 1eb4ba2d01 | |||
| d00425930f | |||
| 4e4fa5d82a | |||
| 2ac5caba3f | |||
| b9f5dfc62d | |||
| 097be6636d | |||
| 17a432bc82 | |||
| 99ef221db5 | |||
| c2af874b19 | |||
| 0f898ac60a | |||
| 945964b15c | |||
| 3f90092d47 | |||
| 203865b88a | |||
| a165c3f287 | |||
| 064241b9b6 | |||
| 57c34766d0 | |||
| bf5d7941b0 | |||
| 5f3981050a | |||
| b7c587e092 | |||
| b8a4e4b62e | |||
| 7438f99d61 | |||
| dbb8cb4eff | |||
| 1ee3dbd739 | |||
| 813eb03109 | |||
| 7a1892859c | |||
| 00e46718a5 | |||
| 850f808b7b | |||
| 74aac750b5 | |||
| 96517ba6f1 | |||
| 50be546209 | |||
| fb4301effe | |||
| d8e59d53b1 | |||
| a9a6f02d7e | |||
| fd4117fdd4 | |||
| 0b8bcd9e38 | |||
| 00185c5691 | |||
| 31587bbd7d | |||
| 9821d0f3a5 | |||
| 1105411484 | |||
| 307f121dfa | |||
| 7d3175d1f1 | |||
| fbec440606 | |||
| dd820a6f5d | |||
| 8143b6d4aa | |||
| c0921767cf | |||
| 9bc6511c82 | |||
| 0e9b31d188 | |||
| 9d74a9a36d | |||
| 29c9e72675 | |||
| 7dd843e2a2 | |||
| 034599d486 | |||
| b86cd21c4b | |||
| 99f201ccd2 | |||
| 17ea0208e9 | |||
| a9154224ee | |||
| 6b3d5cf62b | |||
| 8444bb750d | |||
| 41471b8899 | |||
| b5bd0acb6f | |||
| af856e7a93 | |||
| 28fc835f1d | |||
| aa2b0c574d | |||
| 3fa6cbd63b | |||
| 80fee9ff4e | |||
| e3bc99e117 | |||
| 644ba641b9 | |||
| ee41a9b3b1 | |||
| 17a5cad517 | |||
| c764f9b03d | |||
| 018efd7fab | |||
| 728a6983a7 | |||
| 2beaabb3bc | |||
| 192eb2aced | |||
| b580e181a6 | |||
| b8d69669da | |||
| 387671e8fa | |||
| 7b183898bd | |||
| 0833c9ec12 | |||
| 9d779a3872 | |||
| 28e87ecc05 | |||
| 05920b41b8 | |||
| 113ddeb5b7 | |||
| c2cfe14ffb | |||
| c8b47925f2 | |||
| d71221dfc3 | |||
| fb58115039 | |||
| d73544b965 | |||
| 42a8e7e64a | |||
| dc69a44965 | |||
| 10edf30634 | |||
| 2d65d4774d | |||
| 8bbbf8c00c | |||
| 9f1bbd7274 | |||
| 2d8e60bd1e | |||
| 8581e2d777 | |||
| f4c55ce499 | |||
| cee687b207 | |||
| 571d05d6d0 | |||
| f48821e799 | |||
| 56a2d7dab5 | |||
| 4c2ed2ae78 | |||
| 5a628581bf | |||
| 61cc534e49 | |||
| 1db4bfd55c | |||
| 950158ddb2 | |||
| 44141fdd7a | |||
| 8df9a808a1 | |||
| 1b0b5444da | |||
| ab7e34d6aa | |||
| 6ddc1c2c34 | |||
| 18f91c9082 | |||
| 290c00036e | |||
| eb999ca73d | |||
| 5df632fc0a | |||
| be5fccc8da | |||
| ce42c775e6 | |||
| 63ba09ac7c | |||
| dad6f77330 | |||
| 3865ab6091 | |||
| 7b81620f81 | |||
| 8c69731e9c | |||
| 9cd97c243b | |||
| 6bd5a82da2 | |||
| 65dc69a5c2 | |||
| 446f74a8e5 | |||
| cd76e7859c | |||
| a7494dd1d0 | |||
| 9e2a4216ad | |||
| bb94988697 | |||
| 44bbd480fc | |||
| 5bd14190c2 | |||
| 7cc98d06d9 | |||
| 257ca0b547 | |||
| da3f83484d | |||
| 73ccecaefa | |||
| e0c322c87d | |||
| 479091cb8c | |||
| 18d3422045 | |||
| 1a977b0268 | |||
| 78255804b7 | |||
| 263891b4b5 | |||
| db84516256 | |||
| b0aaac5e77 | |||
| 521dcd0324 | |||
| e26bcfeac3 | |||
| 9ff59ecee9 | |||
| 9cf9fbadee | |||
| c395b7151b | |||
| e6dfb11630 | |||
| e0b4510aed | |||
| 2107a9ab32 | |||
| be2ce5cf83 | |||
| cf2881f928 | |||
| a420c2ff69 | |||
| da5855d417 | |||
| 7984656758 | |||
| cb7c340b15 | |||
| 8e2812df2f | |||
| adf54759b1 | |||
| 9f31744718 | |||
| bbaa6e4ff0 | |||
| cabf7515df | |||
| 6e91ff5d91 | |||
| 620868be8a | |||
| 50fdb274be | |||
| c5f3064e36 | |||
| 9facd0bfe7 | |||
| 07334ad493 | |||
| 0aaf793864 | |||
| c3469eaa81 | |||
| 9e60e28b80 | |||
| eb283f93f0 | |||
| 8521c5a1a7 | |||
| f4c24da901 | |||
| 8ba2175472 | |||
| 4239a8529b | |||
| 631f803963 | |||
| c63f5dcbff | |||
| ebb66a71c3 | |||
| 156efd9416 | |||
| f30be92ed2 | |||
| 833221236b | |||
| 8d74e707a5 | |||
| 43a3bfb129 | |||
| 69756ea5c6 | |||
| 7902ebcdf0 | |||
| 1cdb5fce2e | |||
| d99933adaa | |||
| b2e528b725 | |||
| 8370d3323b | |||
| cb6dad5ae4 | |||
| 1d886cb0f4 | |||
| 5d54622125 | |||
| 18d89582ed | |||
| 0c2d624ed9 | |||
| fa0de8af1c | |||
| 3b71ec17ce | |||
| 732a538273 | |||
| 83ba705c25 | |||
| 7846d71a88 | |||
| 81e0cea858 | |||
| 32cb0bb062 | |||
| e18b472418 | |||
| 875a9b0214 | |||
| 1d5b2cf6a8 | |||
| 40c236292e | |||
| 9bacadad25 | |||
| 7d933f2c79 | |||
| 654e890bbb | |||
| 6f911d67f7 | |||
| 8a2caf73ee | |||
| c466898859 | |||
| a8f7f56c60 | |||
| a7a95bd899 | |||
| a2423b40d4 | |||
| f66f7951e9 | |||
| d36801a911 | |||
| e35abe61bf | |||
| ef66636f8a | |||
| 2e1c766f57 | |||
| a512bd4908 | |||
| af3712c693 | |||
| 60bcb0eafa | |||
| f5e2762b5d | |||
| a301d0a56a | |||
| 079fd70a9e | |||
| e06eb07d6c | |||
| fcf7fd31e1 | |||
| 0e0fb8140a | |||
| a319a5cb6d | |||
| ded9bb1bfb | |||
| b60709a53f | |||
| 20f89853cb | |||
| 7233203288 | |||
| bf3ec82884 | |||
| 661ee47189 | |||
| 076f0c76ac | |||
| 5b0ab4d425 | |||
| faf520a9b3 | |||
| 243c4f975b | |||
| f6cbab2238 | |||
| f42e0a863f | |||
| c8740bd684 | |||
| 5ae91d2192 | |||
| f2720d844e | |||
| f8f0f4854d | |||
| 7211cc3e29 | |||
| 7193b328d4 | |||
| a60818c913 | |||
| 253ffb6b03 | |||
| 79b0fefb5f | |||
| 07d118f4bf | |||
| 89e88e7841 | |||
| 714534d8b7 | |||
| b7aa2256e8 | |||
| d0e464a6bb | |||
| 3dec5c3ccf | |||
| a38d9d01c9 | |||
| 9c2dd8412e | |||
| d9bea5fd4a | |||
| 1acb55c0dd | |||
| ddce81c85a | |||
| 7f574d3a3c | |||
| dc9d7a33ad | |||
| ad168f2a4a | |||
| f796cfbcb0 | |||
| eb94ec458d | |||
| bcb1f9948c | |||
| 5049b25259 | |||
| efc67f0f7b | |||
| 277b0d43e0 | |||
| cad8c5c4f4 | |||
| ea38f30523 | |||
| f1dd0dbaa2 | |||
| a0b32e5d65 | |||
| 526889ecf4 | |||
| 3f3b162746 | |||
| 7232025676 | |||
| c8b70de0a4 | |||
| 102e0386a4 | |||
| 570a1030aa | |||
| 7dcc8cfb90 | |||
| 817be0568f | |||
| 6d4fe46fdd | |||
| 9b746e6d2a | |||
| 964c594bab | |||
| 3aba235c68 | |||
| f8f65e1d8a | |||
| f0f1ad6173 | |||
| cc4c60e6b9 | |||
| 6d1c1e21a8 | |||
| 7b08192348 | |||
| cc357b565b | |||
| 344f6cc56b | |||
| 37948cc98f | |||
| 2f3668b10c | |||
| 58ccff8614 | |||
| 5d90ff47df | |||
| a579cb984f | |||
| 7afdb8500f | |||
| 5b6e43e2cd | |||
| fef4ffe3b4 | |||
| dd517f36f8 | |||
| c667ee0489 | |||
| 830687d656 | |||
| a3bd92b120 | |||
| ad5f739575 | |||
| 7e6d26dcc4 | |||
| 1131bbc4de | |||
| ce3480c3c2 | |||
| c337ad6c09 | |||
| 3f26859943 | |||
| 2de34f4226 | |||
| bcdf46b018 | |||
| 6e9c3e817a | |||
| c67984e29e | |||
| 30ca0bf67c | |||
| 06c6455bc1 | |||
| de0466962d | |||
| 9cb6c90666 | |||
| d762536412 | |||
| 0623c85425 | |||
| 035f1f3263 | |||
| 0983a93420 | |||
| c11c325836 | |||
| 997c464e57 | |||
| 6e3464fd16 | |||
| 2a0efb3ca5 | |||
| 29e782874a | |||
| 8ea0f3944b | |||
| 4a498e3c2c | |||
| be40ed6cb5 | |||
| 5b3d8fea65 | |||
| e3a28eabdb | |||
| 4a5482c750 | |||
| 99c5ec9d11 | |||
| 1ed92977c6 | |||
| f703968531 | |||
| a230f6aae9 | |||
| 7470ed24e2 | |||
| 679287b0ab | |||
| c11bd05347 | |||
| 8c1b4b8e8c | |||
| b36b5100b0 | |||
| 57c555cfb4 | |||
| 710622fc6b | |||
| 748722300c | |||
| 2971de9df1 | |||
| a602edaffd | |||
| fc8aeebb3e | |||
| 06b52bb274 | |||
| 639914b21b | |||
| 5709dddbd0 | |||
| 033889b24a | |||
| 1e98c2729f | |||
| 4b83582818 | |||
| 7fd40d8618 | |||
| c233dab4ab | |||
| 0dee90b5b2 | |||
| f40ce17466 | |||
| ccd3d6d97b | |||
| 76b0fcc359 | |||
| 4cd6b41d51 | |||
| cc2a51d4dd | |||
| 994784322b | |||
| df3e1b6299 | |||
| 1ca3a938ec | |||
| 370e7e7b4b | |||
| ca87277bf8 | |||
| fd36eede8b | |||
| ab3b8d419b | |||
| c134e19680 | |||
| b8a28b6ed3 | |||
| 2008b11462 | |||
| f20a76a37d | |||
| 9a6c55f1d4 | |||
| da1f665cdd | |||
| 500d7514f7 | |||
| d521bb0d67 | |||
| a89d87980c | |||
| 60b3e1d311 | |||
| 48fe062c3f | |||
| a0981eb135 | |||
| 7019e6d16d | |||
| 55da943cff | |||
| 8e88d22806 | |||
| 8c61bd8775 | |||
| 6a14384701 | |||
| 8b98a25ef3 | |||
| 75f529936f | |||
| b9885799a0 | |||
| b093f643aa | |||
| 07713ca17f | |||
| 8d07c8ce52 | |||
| 2336c01c8e | |||
| a9ea475832 | |||
| fc5cb972a7 | |||
| f4948c0a93 | |||
| 544a5fe57d | |||
| 1b964088fc | |||
| 7c174fa4f2 | |||
| dbe3c9f9b5 | |||
| abd69e1fa2 | |||
| 0083733985 | |||
| 21e6e3877b | |||
| e14139ad21 | |||
| 72df277675 | |||
| ae8a224d88 | |||
| 9ac68990ea | |||
| 3c729180c3 | |||
| c49d51d202 | |||
| a1ad15d5a6 | |||
| bf194e8d13 | |||
| 28f7c8aae8 | |||
| 6980c0eec7 | |||
| 7cb3906749 | |||
| 41804e14de | |||
| 4267b9c57c | |||
| 9f0c15ae6a | |||
| ae50ed0f8c | |||
| 606f9d3cba | |||
| 7c3918bb39 | |||
| de234bcf14 | |||
| 8445ed8e62 | |||
| f951cf953e | |||
| 816db760c9 | |||
| 18126b77b5 | |||
| e967180ecb | |||
| 08b22d077e | |||
| e220495603 | |||
| 6115c4172c | |||
| ee098ea68b | |||
| ed5f19f557 | |||
| c1d0b21ce8 | |||
| cc10dfbcd0 | |||
| f86c8ff719 | |||
| 5423595ef1 | |||
| 9643a7004d | |||
| 2dff2c8ece | |||
| e302337243 | |||
| 2d0bc9bd73 | |||
| e9766abebb | |||
| c41e1b4b5e | |||
| 17293d2b00 | |||
| 0a4ca92d0e | |||
| 0eb0214850 | |||
| cab61d09bc | |||
| 12561c9b42 | |||
| f04e746133 | |||
| 55e8cbed43 | |||
| 66495842af | |||
| a7b80f13c4 | |||
| a5abfcf349 | |||
| 03f8a09d9b | |||
| c61dfb3695 | |||
| 77638946c9 | |||
| 4693c2573d | |||
| d6e55bd8cd | |||
| c7ba2f9ae6 | |||
| 64a2f0a5da | |||
| 037feb4cdf | |||
| 4b1854b89f | |||
| af0fed2470 | |||
| 08af6632e5 | |||
| fea8259cf5 | |||
| 50bca1862f | |||
| 979915818c | |||
| bb326101e5 | |||
| 32facda50f | |||
| f06b7ad2a9 | |||
| e8ee807d17 | |||
| 35c69cb0f2 | |||
| ac04ea1883 | |||
| 1365e7bd16 | |||
| 256025ca28 | |||
| 092ac001b6 | |||
| 0a33d4b0ed | |||
| 221caa3205 | |||
| 0411a8242b | |||
| 1e84d2f424 | |||
| 942b66ec93 | |||
| f224bf127b | |||
| 48a299b06e | |||
| 2f93158f94 | |||
| ff4d80c310 | |||
| 33bf44dd4a | |||
| a366d2452c | |||
| eaac6f0da8 | |||
| 94a267caf8 | |||
| 5172a5f112 | |||
| 5b85791f45 | |||
| 7b6498b25a | |||
| 6a86d0ac9b | |||
| 01e36c7c6a | |||
| 492170fcf4 | |||
| ed0f04c53b | |||
| b05a685f25 | |||
| fe775bcd4f | |||
| 2d8e796f26 | |||
| 9fb863f635 | |||
| f826caffa7 | |||
| 8fbe8643e8 | |||
| d6c91479c6 | |||
| c3c6f045e5 | |||
| f884515ed2 | |||
| 9f6fc15098 | |||
| c4ee1e4e40 | |||
| a1079d1c2c | |||
| 75716a4ae5 | |||
| 98164f36c5 | |||
| ca6e88ce16 | |||
| 26dd1ef375 | |||
| 2228441aeb | |||
| 25c85b104d | |||
| 01a399c722 | |||
| 7e3ca958e7 | |||
| 8b471754e4 | |||
| 0ad1a40efb | |||
| 91bb47c65f | |||
| 30b7b0f413 | |||
| adc189bcbd | |||
| 5aa8e872e7 | |||
| 267e9e7ce8 | |||
| 4a2e2ca811 | |||
| 78921d1474 | |||
| edb35a0e9e | |||
| 7b81bf82f4 | |||
| 16a98215ca | |||
| 34b49afd9a | |||
| 802206a2ee | |||
| 1b8d2c9298 | |||
| 51783adeb5 | |||
| d560b5779f | |||
| 199d31395a | |||
| 1cfc697fa9 | |||
| 6cd9dad145 | |||
| 28c3232b2c | |||
| 5f7e16a234 | |||
| 41204e8376 | |||
| d8a26c1dad | |||
| d991e6b8eb | |||
| 8cdc08ac37 | |||
| 97c7f4dbff | |||
| 8f7103d0e1 | |||
| e2a31314a0 | |||
| 9b62d51a24 | |||
| 3aa05c898a | |||
| 0df7ecb7a0 | |||
| e35f9f7afc | |||
| 51b575c8df | |||
| 59e547510d | |||
| 6591a474fe | |||
| 4a0187f1d9 | |||
| 2e07000d9c | |||
| 5e8f93127e | |||
| 131e4f8b96 | |||
| 10b8273d9b | |||
| d3691371f1 | |||
| 5239af4592 | |||
| aa32938632 | |||
| c45fcef3fd | |||
| e957329f5c | |||
| 6c6a14c755 | |||
| 7c5357cc70 | |||
| bacb0e125c | |||
| 068bc3d230 | |||
| fbad3ac44b | |||
| 8cb023f257 | |||
| 3efbf49c97 | |||
| 20a24fdf16 | |||
| 7b4cc90707 | |||
| c0b84f84ef | |||
| 18cb3ef4f3 | |||
| 44c12178b8 | |||
| 9cdc953d0b | |||
| 771bbe200e | |||
| 4c97799a81 | |||
| 7486f87c86 | |||
| 15c53a21a0 | |||
| e3d11762c4 | |||
| 7657ae10d1 | |||
| 1d2ffb13dc | |||
| 1c7da649a4 | |||
| 9513cb954c | |||
| a67c20114a | |||
| 80ba342128 | |||
| 19dfe632c3 | |||
| 0415e55fa4 | |||
| 31f35e0f62 | |||
| 2e18289df1 | |||
| f63cafa3b5 | |||
| 7db1847c41 | |||
| 1ad43cbd06 | |||
| 035bb4679b | |||
| 24f07060b4 | |||
| 88afa9fd97 | |||
| 78b6fe4f45 | |||
| 9fc2bd38ab | |||
| f8ec69a2ae | |||
| 2c97056c24 | |||
| c72091233b | |||
| 53bcc6a4e6 | |||
| 2e1d5bde9e | |||
| 68782decf3 | |||
| c52a24524d | |||
| ca20df4494 | |||
| b76c7da844 | |||
| 0fddcf7608 | |||
| 32a7776453 | |||
| 15fcb61de7 | |||
| 068fa06797 | |||
| 82f4943a82 | |||
| a4ef2aee23 | |||
| 1792a0cbe6 | |||
| 30998056bd | |||
| b156de1ada | |||
| 9ddc86a85d | |||
| 477f5a3543 | |||
| 0e9c96b2a2 | |||
| 9c06999083 | |||
| 6404ef65d1 | |||
| 0248ade57a | |||
| 7663154953 | |||
| dc4bf29924 | |||
| 56f9df8b07 | |||
| 221fc498dd | |||
| b1ce53d1a0 | |||
| 75ffd2cd1b | |||
| 339a63a27c | |||
| 3c3296047c | |||
| 5807d47428 | |||
| 7574275d61 | |||
| 8a32281179 | |||
| cda0cacf57 | |||
| bd7d95d035 | |||
| b80f7e68dd | |||
| 469be14b76 | |||
| 9a5daf2442 | |||
| 7243e7fa59 | |||
| 1b4ee4dbbc | |||
| e59e6c303f | |||
| 1b73c28539 | |||
| ef1fd656a7 | |||
| 51afd59888 | |||
| 4085fde3f9 | |||
| 247dd0de23 | |||
| ded2760092 | |||
| 67b01c9c4c | |||
| 89a30a4df6 | |||
| 49cc7f01b4 | |||
| e3e1f7b762 | |||
| 8de708ff64 | |||
| 28d149b816 | |||
| fc575d1b5e | |||
| f82d34013b | |||
| d271982775 | |||
| 079739bf0a | |||
| d92f42c2e0 | |||
| ec6acaca5c | |||
| 023598d489 | |||
| c47b944856 | |||
| 8996d05c4c | |||
| ad77b6a63b | |||
| e8d396c44b | |||
| 3c984bfc0c | |||
| 676cf1c2a3 | |||
| 490addb7ee | |||
| 0fa3135419 | |||
| 350d5d488e | |||
| c1b2430701 | |||
| 659226d730 | |||
| 9f855ac1aa | |||
| b2d0bad783 | |||
| b6a4cf4f8c | |||
| a2a32d41cf | |||
| 84700f7578 | |||
| 0cce2ad195 | |||
| 8ff794e756 | |||
| c24b2c3469 | |||
| d90696da1e | |||
| 755aa92db4 | |||
| 2f907d87e5 | |||
| e2e77f05ea | |||
| 013405f808 | |||
| 6d9a7c088a | |||
| bfdbf4d2c3 | |||
| 79daf018bd | |||
| cf797fecec | |||
| 88f773b6d5 | |||
| e7da01f9d7 | |||
| d141f81b62 | |||
| c833e9109f | |||
| 67c5339087 | |||
| 0f89385946 | |||
| 3ebe01c82f | |||
| 9024fac0dd | |||
| f37f370192 | |||
| 8ff3a20342 | |||
| 65c167e6df | |||
| 4c425412e2 | |||
| 7024991b0d | |||
| 5c53537fec | |||
| a8ef6a65cc | |||
| cd085abb3a | |||
| 1d6b4968a1 | |||
| ca45e9b877 | |||
| bc130c90d6 | |||
| e71fc19806 | |||
| 641d119478 | |||
| 58ace31d71 | |||
| 2e025eb52c | |||
| be040c6879 | |||
| 71c3b1eb88 | |||
| 9e72f3f911 | |||
| d70b28e19f | |||
| c237db1f8b | |||
| 94fba085fc | |||
| 3f5716f511 | |||
| daf6fb7953 | |||
| ce9aaf4874 | |||
| 4506a95fe2 | |||
| b2097b2293 | |||
| 3e7e017f9a | |||
| b96b87d18c | |||
| 7aec3fd5fd | |||
| e7def7b9aa | |||
| 165c3a81fa | |||
| 2e85b21569 | |||
| 50dcef6dc0 | |||
| d4f68c30bd | |||
| ddf04bffc6 | |||
| 28fdc948cc | |||
| 9940777b8b | |||
| 95f344f0ed | |||
| d695bbb358 | |||
| c6ede66d05 | |||
| 0fef692a03 | |||
| e448a332ff | |||
| de2bf272b0 | |||
| ee7bb2a772 | |||
| 2219ad1ee9 | |||
| da24ec7f9f | |||
| fb573a68d1 | |||
| 744e8bceb1 | |||
| c1e458f5ee | |||
| b524e9939e | |||
| a07d5aedb0 | |||
| 1eae504c4e | |||
| 687b5a1ec1 | |||
| c45da25d7e | |||
| 0c2dbc5097 | |||
| 4d583f5226 | |||
| 7abac9d3f1 | |||
| 9dbcb09f41 | |||
| 629b202253 | |||
| ac7bca7ee9 | |||
| f4251188fe | |||
| 6202387db6 | |||
| 345f0e9a0d | |||
| f980d448db | |||
| 8a129b6722 | |||
| 73ff722c5a | |||
| 342bb36a32 | |||
| 9ca2360340 | |||
| 63929d0e51 | |||
| 2b997beb6b | |||
| e0f4b6bb78 | |||
| f28ce98863 | |||
| a3358eff23 | |||
| 567e463a08 | |||
| 0d689cde6f | |||
| 6e318bdc9f | |||
| f2ba63f0e7 | |||
| 428cf121dd | |||
| 571c5e8024 | |||
| 1b86735e97 | |||
| 1b68c60dbb | |||
| 87baef2b84 | |||
| 0ea4f909be | |||
| d7ff01d84e | |||
| 1aa40f6111 | |||
| a32263cefe | |||
| 91f35fdda5 | |||
| ff4aa279b8 | |||
| 52dd6bd3a1 | |||
| 8e4c579cd2 | |||
| 8090579d4f | |||
| 2628d7e86c | |||
| 3617fd3fcc | |||
| b471b7bc7c | |||
| 4d78d7845b | |||
| 06d274e82d | |||
| 6588e1cb8c | |||
| 61a065631a | |||
| c82ffd92a3 | |||
| 325aabd105 | |||
| 317a764b03 | |||
| 8d0002c6e0 | |||
| 4c75dd87c8 | |||
| 3ef400d5d2 | |||
| a1edadc7ef | |||
| a37990f8aa | |||
| 06dcb42895 | |||
| e8274e5d57 | |||
| 17e6255e94 | |||
| 1cb7c95161 | |||
| 0926694053 | |||
| 3a1ca8d285 | |||
| 7fcb949ef0 | |||
| da1a4bbf99 | |||
| 95535a43e3 | |||
| 02bdc01d9b | |||
| 8187b75cf7 | |||
| 6cb059fd54 | |||
| 00cee5d9da | |||
| bef7bf72bc | |||
| 581faeb263 | |||
| a54985acae | |||
| 8308bd2c19 | |||
| bfd5d18d7b | |||
| 07df06999f | |||
| 6f15cd1622 | |||
| bc0e0bbec0 | |||
| 8afc5e037e | |||
| d18d9beed9 | |||
| 35e12be680 | |||
| ace6cf9627 | |||
| 2daf36c77e | |||
| 8759c9b4f3 | |||
| 422435084a | |||
| e669ddc2b2 | |||
| 3cbeafe313 | |||
| 54d6c8415e | |||
| ce653150db | |||
| fd4280356c | |||
| ba1697d29c | |||
| 06e0db8c84 | |||
| 34bacbe8a8 | |||
| a83abd7631 | |||
| 63e1520c5b | |||
| ebfab68344 | |||
| 1ec7bda209 | |||
| 1c66f19529 | |||
| 0ff86daf68 | |||
| 8ca5583d2b | |||
| e12b060b75 | |||
| 18b4bc6376 | |||
| adc7d0a36d | |||
| 8db6c3b4a3 | |||
| ddd7918383 | |||
| 52a32043bc | |||
| 81fcc5f8c9 | |||
| 892e3c122e | |||
| 243acf498e | |||
| 1de9a410b1 | |||
| ba18a0c9b4 | |||
| 932baec440 | |||
| ac6f5e49be | |||
| d38ba9d9ab | |||
| 37e8ec4c0f | |||
| 46893cc26c | |||
| c2af8ff424 | |||
| 8b22a30692 | |||
| 4f0d11e4af | |||
| 758ec3b4ed | |||
| 20c84941ea | |||
| 6065de2a3b | |||
| d3c7aee663 | |||
| c8d7dafcf3 | |||
| a4422cb56e | |||
| c135ed22d9 | |||
| a9401058cb | |||
| 057d2396ad | |||
| 77547a2a68 | |||
| a18d65355a | |||
| fb13eb3cf0 | |||
| 45bd10931f | |||
| cde92bbe0f | |||
| f5ee92323f | |||
| a6f3f3f54c | |||
| 257eaa4a8e | |||
| 16a80e892a | |||
| 9a58610d21 | |||
| 0f6396b50a | |||
| d3f1bcffc1 | |||
| 65e49f3041 | |||
| 02062f5db2 | |||
| 10a1337fd9 | |||
| 30f52fafc3 | |||
| 4c987c7b4f | |||
| b6c78e5960 | |||
| 990284d0a7 | |||
| b9c151bde6 | |||
| b219efa571 | |||
| b83b69e056 | |||
| b648a96c9c | |||
| a4f91009a6 | |||
| 8bbe4376c5 | |||
| 0896f8b152 | |||
| 1263ec7faf | |||
| 46b399c400 | |||
| 216906eff9 | |||
| 742a9fdb35 | |||
| 87e32c6e51 | |||
| e7ebe2c7b6 | |||
| 77966ac172 | |||
| a8e1f49554 | |||
| dc27cfe3e7 | |||
| af8340ae84 | |||
| 5ab9726db2 | |||
| 606b0e88ea | |||
| b0196cff3f | |||
| 19eb31a5f0 | |||
| 7ca9fc4210 | |||
| dc48155b11 | |||
| bbf06e799a | |||
| ba2ba4d65b | |||
| beb8c7713a | |||
| 7189940bc5 | |||
| fac2a1dc39 | |||
| d57a987428 | |||
| 88ce659ee9 | |||
| b8bae9d04d | |||
| 0bd6aa4d6f | |||
| 569b8d927c | |||
| 036e93f2f1 | |||
| ef67885121 | |||
| dadd100b66 | |||
| 46903e868a | |||
| b4a088d994 | |||
| 75f9195ce4 |
@@ -1,3 +0,0 @@
|
||||
[install.lockfile]
|
||||
|
||||
save = false
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@lobehub/lint').changelog;
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@lobehub/lint').commitlint;
|
||||
@@ -1,176 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: src/services/**/*,src/database/**/*,src/server/**/*
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# LobeChat 后端技术架构指南
|
||||
|
||||
本指南旨在阐述 LobeChat 项目的后端分层架构,重点介绍各核心目录的职责以及它们之间的协作方式。
|
||||
|
||||
## 目录结构映射
|
||||
|
||||
```
|
||||
src/
|
||||
├── server/
|
||||
│ ├── routers/ # tRPC API 路由定义
|
||||
│ └── services/ # 业务逻辑服务层
|
||||
│ └── */impls/ # 平台特定实现
|
||||
├── database/
|
||||
│ ├── models/ # 数据模型 (单表 CRUD)
|
||||
│ ├── repositories/ # 仓库层 (复杂查询/聚合)
|
||||
│ └── schemas/ # Drizzle ORM 表定义
|
||||
└── services/ # 客户端服务 (调用 tRPC 或直接访问 Model)
|
||||
```
|
||||
|
||||
## 核心架构分层
|
||||
|
||||
LobeChat 的后端设计注重模块化、可测试性和灵活性,以适应不同的运行环境(如浏览器端 PGLite、服务端远程 PostgreSQL 以及 Electron 桌面应用)。
|
||||
|
||||
其主要分层如下:
|
||||
|
||||
1. 客户端服务层 (`src/services`):
|
||||
- 位于 src/services/。
|
||||
- 这是客户端业务逻辑的核心层,负责封装各种业务操作和数据处理逻辑。
|
||||
- 环境适配: 根据不同的运行环境,服务层会选择合适的数据访问方式:
|
||||
- 本地数据库模式: 直接调用 `Model` 层进行数据操作,适用于浏览器 PGLite 和本地 Electron 应用。
|
||||
- 远程数据库模式: 通过 `tRPC` 客户端调用服务端 API,适用于需要云同步的场景。
|
||||
- 类型转换: 对于简单的数据类型转换,直接在此层进行类型断言,如 `this.pluginModel.query() as Promise<LobeTool[]>`
|
||||
- 每个服务模块通常包含 `client.ts`(本地模式)、`server.ts`(远程模式)和 `type.ts`(接口定义)文件,在实现时应该确保本地模式和远程模式业务逻辑实现一致,只是数据库不同。
|
||||
|
||||
2. API 接口层 (`TRPC`):
|
||||
- 位于 src/server/routers/
|
||||
- 使用 `tRPC` 构建类型安全的 API。Router 根据运行时环境(如 Edge Functions, Node.js Lambda)进行组织。
|
||||
- 负责接收客户端请求,并将其路由到相应的 `Service` 层进行处理。
|
||||
- 新建 lambda 端点时可以参考 src/server/routers/lambda/\_template.ts
|
||||
|
||||
3. 仓库层 (`Repositories`):
|
||||
- 位于 src/database/repositories/。
|
||||
- 主要处理复杂的跨表查询和数据聚合逻辑,特别是当需要从多个 `Model` 获取数据并进行组合时。
|
||||
- 与 `Model` 层不同,`Repository` 层专注于复杂的业务查询场景,而不涉及简单的领域模型转换。
|
||||
- 当业务逻辑涉及多表关联、复杂的数据统计或需要事务处理时,会使用 `Repository` 层。
|
||||
- 如果数据操作简单(仅涉及单个 `Model`),则通常直接在 `src/services` 层调用 `Model` 并进行简单的类型断言。
|
||||
|
||||
4. 模型层 (`Models`):
|
||||
- 位于 src/database/models/ (例如 src/database/models/plugin.ts 和 src/database/models/document.ts)。
|
||||
- 提供对数据库中各个表(由 src/database/schemas/ 中的 Drizzle ORM schema 定义)的基本 CRUD (创建、读取、更新、删除) 操作和简单的查询能力。
|
||||
- `Model` 类专注于单个数据表的直接操作,不涉及复杂的领域模型转换,这些转换通常在上层的 `src/services` 中通过类型断言完成。
|
||||
- model(例如 Topic) 层接口经常需要从对应的 schema 层导入 NewTopic 和 TopicItem
|
||||
- 创建新的 model 时可以参考 src/database/models/\_template.ts
|
||||
|
||||
5. 数据库 (`Database`):
|
||||
- 客户端模式 (浏览器/PWA): 使用 PGLite (基于 WASM 的 PostgreSQL),数据存储在用户浏览器本地。
|
||||
- 服务端模式 (云部署): 使用远程 PostgreSQL 数据库。
|
||||
- Electron 桌面应用:
|
||||
- Electron 客户端会启动一个本地 Node.js 服务。
|
||||
- 本地服务通过 `tRPC` 与 Electron 的渲染进程通信。
|
||||
- 数据库选择依赖于是否开启云同步功能:
|
||||
- 云同步开启: 连接到远程 PostgreSQL 数据库。
|
||||
- 云同步关闭: 使用 PGLite (通过 Node.js 的 WASM 实现) 在本地存储数据。
|
||||
|
||||
## 数据流向说明
|
||||
|
||||
### 浏览器/PWA 模式
|
||||
|
||||
```
|
||||
UI (React) → Zustand action -> Client Service → Model Layer → PGLite (本地数据库)
|
||||
```
|
||||
|
||||
### 服务端模式
|
||||
|
||||
```
|
||||
UI (React) → Zustand action → Client Service -> TRPC Client → TRPC Routers → Repositories/Models → Remote PostgreSQL
|
||||
```
|
||||
|
||||
### Electron 桌面应用模式
|
||||
|
||||
```
|
||||
UI (Electron Renderer) → Zustand action → Client Service -> TRPC Client → 本地 Node.js 服务 → TRPC Routers → Repositories/Models → PGLite/Remote PostgreSQL (取决于云同步设置)
|
||||
```
|
||||
|
||||
## 服务层 (Server Services)
|
||||
|
||||
- 位于 src/server/services/。
|
||||
- 核心职责是封装独立的、可复用的业务逻辑单元。这些服务应易于测试。
|
||||
- 平台差异抽象: 一个关键特性是通过其内部的 `impls` 子目录(例如 src/server/services/file/impls 包含 s3.ts 和 local.ts)来抹平不同运行环境带来的差异(例如云端使用 S3 存储,桌面版使用本地文件系统)。这使得上层(如 `tRPC` routers)无需关心底层具体实现。
|
||||
- 目标是使 `tRPC` router 层的逻辑尽可能纯粹,专注于请求处理和业务流程编排。
|
||||
- 服务可能会调用 `Repository` 层或直接调用 `Model` 层进行数据持久化和检索,也可能调用其他服务。
|
||||
|
||||
## 最佳实践 (Best Practices)
|
||||
|
||||
### 数据库操作封装原则
|
||||
|
||||
**连续的数据库操作应该封装到 Model 层**
|
||||
|
||||
当业务逻辑涉及多个相关的数据库操作时,建议将这些操作封装到 Model 层中,而不是在上层(Service 或 Router 层)中进行多次数据库调用。
|
||||
|
||||
**优势:**
|
||||
|
||||
- **代码复用**: Client DB 环境的 service 实现和 Server DB 的 lambda 层实现可以复用相同的 Model 方法
|
||||
- **事务一致性**: 相关的数据库操作可以在同一个方法中管理,便于维护数据一致性
|
||||
- **性能优化**: 减少数据库连接次数,提高查询效率
|
||||
- **职责清晰**: Model 层专注数据访问,上层专注业务协调
|
||||
|
||||
**示例:**
|
||||
|
||||
```typescript
|
||||
// ✅ 推荐:在 Model 层封装连续的数据库操作
|
||||
class GenerationBatchModel {
|
||||
async delete(id: string): Promise<{ deletedBatch: BatchItem; thumbnailUrls: string[] }> {
|
||||
// 1. 查询相关数据
|
||||
const batchWithGenerations = await this.db.query.generationBatches.findFirst({...});
|
||||
|
||||
// 2. 收集需要处理的数据
|
||||
const thumbnailUrls = [...];
|
||||
|
||||
// 3. 执行删除操作
|
||||
const [deletedBatch] = await this.db.delete(generationBatches)...;
|
||||
|
||||
return { deletedBatch, thumbnailUrls };
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ 上层使用简洁
|
||||
const { thumbnailUrls } = await model.delete(id);
|
||||
await fileService.deleteFiles(thumbnailUrls);
|
||||
```
|
||||
|
||||
### 文件操作与数据库操作的执行顺序
|
||||
|
||||
**删除操作原则:数据库删除在前,文件删除在后**
|
||||
|
||||
当业务逻辑同时涉及数据库记录和文件系统操作时,应该遵循"数据库优先"的原则。
|
||||
|
||||
**原因:**
|
||||
|
||||
- **用户体验优先**: 如果先删除文件再删除数据库记录,可能出现文件已删除但数据库记录仍存在的情况,用户访问时会遇到文件不存在的错误
|
||||
- **影响程度较小**: 如果先删除数据库记录再删除文件,即使文件删除失败,用户也看不到这个记录,只是造成一些存储空间浪费,对用户体验影响更小
|
||||
- **数据一致性**: 数据库记录是业务逻辑的核心,应该优先保证其一致性
|
||||
|
||||
**示例:**
|
||||
|
||||
```typescript
|
||||
// ✅ 推荐:先删除数据库记录,再删除文件
|
||||
async deleteGeneration(id: string) {
|
||||
// 1. 先删除数据库记录
|
||||
const deletedGeneration = await generationModel.delete(id);
|
||||
|
||||
// 2. 再删除相关文件
|
||||
if (deletedGeneration.asset?.thumbnailUrl) {
|
||||
await fileService.deleteFile(deletedGeneration.asset.thumbnailUrl);
|
||||
}
|
||||
}
|
||||
|
||||
// ❌ 不推荐:先删除文件
|
||||
async deleteGeneration(id: string) {
|
||||
const generation = await generationModel.findById(id);
|
||||
|
||||
// 如果这里删除成功,但后面数据库删除失败,用户会遇到访问错误
|
||||
await fileService.deleteFile(generation.asset.thumbnailUrl);
|
||||
await generationModel.delete(id); // 可能失败
|
||||
}
|
||||
```
|
||||
|
||||
**创建操作原则:数据库创建在前,文件操作在后**
|
||||
|
||||
创建操作同样应该优先处理数据库记录,确保数据的一致性和完整性。
|
||||
@@ -1,75 +0,0 @@
|
||||
---
|
||||
description: How to code review
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Role Description
|
||||
|
||||
- You are a senior full-stack engineer skilled in performance optimization, security, and design systems.
|
||||
- You excel at reviewing code and providing constructive feedback.
|
||||
- Your task is to review submitted Git diffs **in Chinese** and return a structured review report.
|
||||
- Review style: concise, direct, focused on what matters most, with actionable suggestions.
|
||||
|
||||
## Before the Review
|
||||
|
||||
Gather the modified code and context. Please strictly follow the process below:
|
||||
|
||||
1. Use `read_file` to read [package.json](mdc:package.json)
|
||||
2. Use terminal to run command `git diff HEAD | cat` to obtain the diff and list the changed files. If you recieived empty result, run the same command once more.
|
||||
3. Use `read_file` to open each changed file.
|
||||
4. Use `read_file` to read [rules-attach.mdc](mdc:.cursor/rules/rules-attach.mdc). Even if you think it's unnecessary, you must read it.
|
||||
5. combine changed files, step3 and `agent_requestable_workspace_rules`, list the rules which need to read
|
||||
6. Use `read_file` to read the rules list in step 5
|
||||
|
||||
## Review
|
||||
|
||||
### Code Style
|
||||
|
||||
read [typescript.mdc](mdc:.cursor/rules/typescript.mdc) to learn the project's code style.
|
||||
|
||||
- Ensure JSDoc comments accurately reflect the implementation; update them when needed.
|
||||
- Look for opportunities to simplify or modernize code with the latest JavaScript/TypeScript features.
|
||||
- Prefer `async`/`await` over callbacks or chained `.then` promises.
|
||||
- Use consistent, descriptive naming—avoid obscure abbreviations.
|
||||
- Replace magic numbers or strings with well-named constants.
|
||||
- Use semantically meaningful variable, function, and class names.
|
||||
- Ignore purely formatting issues and other autofixable lint problems.
|
||||
|
||||
### Code Optimization
|
||||
|
||||
- Prefer `for…of` loops to index-based `for` loops when feasible.
|
||||
- Decide whether callbacks should be **debounced** or **throttled**.
|
||||
- Use components from `@lobehub/ui`, Ant Design, or the existing design system instead of raw HTML tags (e.g., `Button` vs. `button`).
|
||||
- reuse npm packages already installed (e.g., `lodash/omit`) rather than reinventing the wheel.
|
||||
- Design for dark mode and mobile responsiveness:
|
||||
- Use the `antd-style` token system instead of hard-coded colors.
|
||||
- Select the proper component variants.
|
||||
- Performance considerations:
|
||||
- Where safe, convert sequential async flows to concurrent ones with `Promise.all`, `Promise.race`, etc.
|
||||
- Query only the required columns from a database rather than selecting entire rows.
|
||||
|
||||
### Obvious Bugs
|
||||
|
||||
- Do not silently swallow errors in `catch` blocks; at minimum, log them.
|
||||
- Revert temporary code used only for testing (e.g., debug logs, temporary configs).
|
||||
- Remove empty handlers (e.g., an empty `onClick`).
|
||||
- Confirm the UI degrades gracefully for unauthenticated users.
|
||||
- Don't leave any debug logs in the code (except when using the `debug` module properly).
|
||||
- When using the `debug` module, avoid `import { log } from 'debug'` as it logs directly to console. Use proper debug namespaces instead.
|
||||
- Check logs for sensitive information like api key, etc
|
||||
|
||||
## After the Review: output
|
||||
|
||||
1. Summary
|
||||
- Start with a brief explanation of what the change set does.
|
||||
- Summarize the changes for each modified file (or logical group).
|
||||
2. Comments Issues
|
||||
- List the most critical issues first.
|
||||
- Use an ordered list, which will be convenient for me to reference later.
|
||||
- For each issue:
|
||||
- Mark severity tag (`❌ Must fix`, `⚠️ Should fix`, `💅 Nitpick`)
|
||||
- Provode file path to the relevant file.
|
||||
- Provide recommended fix
|
||||
- End with a **git commit** command, instruct the author to run it.
|
||||
- We use gitmoji to label commit messages, format: [emoji] <type>(<scope>): <subject>
|
||||
@@ -1,28 +0,0 @@
|
||||
---
|
||||
description: cursor rules writing and optimization guide
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
当你编写或修改 Cursor Rule 时,请遵循以下准则:
|
||||
|
||||
- 当你知道 rule 的文件名时,使用 `read_file` 而不是 `fetch_rules` 去读取它们,它们都在项目根目录的 `.cursor/rules/` 文件夹下
|
||||
|
||||
- 代码示例
|
||||
- 示例应尽量精简,仅保留演示核心
|
||||
- 删除与示例无关的导入/导出语句,但保留必要的导入
|
||||
- 同一文件存在多个示例时,若前文已演示模块导入,后续示例可省略重复导入
|
||||
- 无需书写 `export`
|
||||
- 可省略与演示无关或重复的 props、配置对象属性、try/catch、CSS 等代码
|
||||
- 删除无关注释,保留有助理解的注释
|
||||
|
||||
- 格式
|
||||
- 修改前请先确认原始文档语言,并保持一致
|
||||
- 无序列表统一使用 `-`
|
||||
- 列表末尾的句号是多余的
|
||||
- 非必要不使用加粗、行内代码等样式,Rule 主要供 LLM 阅读
|
||||
- 避免中英文逐句对照。若括号内容为示例而非翻译,可保留
|
||||
|
||||
- Review
|
||||
- 修正 Markdown 语法问题
|
||||
- 纠正错别字
|
||||
- 指出示例与说明不一致之处
|
||||
@@ -1,104 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# Guide to Optimize Output(Response) Rendering
|
||||
|
||||
## File Path and Code Symbol Rendering
|
||||
|
||||
- When rendering file paths, use backtick wrapping instead of markdown links so they can be parsed as clickable links in Cursor IDE.
|
||||
- Good: `src/components/Button.tsx`
|
||||
- Bad: [src/components/Button.tsx](src/components/Button.tsx)
|
||||
|
||||
- Don't use line and column number in file path, this will make file path not clickable in Cursor IDE.
|
||||
- Good: `src/components/Button.tsx` `10:20` (add a space between the file path and the line and column number)
|
||||
- Bad: `src/components/Button.tsx:10:20`
|
||||
|
||||
- When rendering functions, variables, or other code symbols, use backtick wrapping so they can be parsed as navigable links in Cursor IDE
|
||||
- Good: The `useState` hook in `MyComponent`
|
||||
- Bad: The useState hook in MyComponent
|
||||
|
||||
## Markdown Render
|
||||
|
||||
- don't use br tag to wrap in table cell
|
||||
|
||||
## Terminal Command Output
|
||||
|
||||
- If terminal commands don't produce output, it's likely due to paging issues. Try piping the command to `cat` to ensure full output is displayed.
|
||||
- Good: `git show commit_hash -- file.txt | cat`
|
||||
- Good: `git log --oneline | cat`
|
||||
- Reason: Some git commands use pagers by default, which may prevent output from being captured properly
|
||||
|
||||
## Mermaid Diagram Generation: Strict Syntax Validation Checklist
|
||||
|
||||
Before producing any Mermaid diagram, you **must** compare your final code line-by-line against every rule in the following checklist to ensure 100% compliance. **This is a hard requirement and takes precedence over other stylistic suggestions.** Please follow these action steps:
|
||||
|
||||
1. Plan the Mermaid diagram logic in your mind.
|
||||
2. Write the Mermaid code.
|
||||
3. **Carefully review your code line-by-line against the entire checklist below.**
|
||||
4. Fix any aspect of your code that doesn't comply.
|
||||
5. Use the `validateMermaid` tool to check your code for syntax errors. Only proceed if validation passes.
|
||||
6. Output the final, compliant, and copy-ready Mermaid code block.
|
||||
7. Immediately after the Mermaid code block, output:
|
||||
I have checked that the Mermaid syntax fully complies with the validation checklist.
|
||||
|
||||
---
|
||||
|
||||
### Checklist Details
|
||||
|
||||
#### Rule 1: Edge Labels – Must Be Plain Text Only
|
||||
|
||||
> **Essence:** Anything inside `|...|` must contain pure, unformatted text. Absolutely NO Markdown, list markers, or parentheses/brackets allowed—these often cause rendering failures.
|
||||
|
||||
- **✅ Do:** `A -->|Process plain text data| B`
|
||||
- **❌ Don't:** `A -->|1. Ordered list item| B` (No numbered lists)
|
||||
- **❌ Don't:** `CC --"1. fetch('/api/...')"--> API` (No square brackets)
|
||||
- **❌ Don't:** `A -->|- Unordered list item| B` (No hyphen lists)
|
||||
- **❌ Don't:** `A -->|Transform (important)| B` (No parentheses)
|
||||
- **❌ Don't:** `A -->|Transform [important]| B` (No square brackets)
|
||||
|
||||
#### Rule 2: Node Definition – Handle Special Characters with Care
|
||||
|
||||
> **Essence:** When node text or subgraph titles contain special characters like `()` or `[]`, wrap the text in quotes to avoid conflicts with Mermaid shape syntax.
|
||||
|
||||
- **When your node text includes parentheses (e.g., 'React (JSX)'):**
|
||||
- **✅ Do:** `I_REACT["<b>React component (JSX)</b>"]` (Quotes wrap all text)
|
||||
- **❌ Don't:** `I_REACT(<b>React component (JSX)</b>)` (Wrong, Mermaid parses this as a shape)
|
||||
- **❌ Don't:** `subgraph Plugin Features (Plugins)` (Wrong, subgraph titles with parentheses must also be wrapped in quotes)
|
||||
|
||||
#### Rule 3: Double Quotes in Text – Must Be Escaped
|
||||
|
||||
> **Essence:** Use `"` for double quotes **inside node text**.
|
||||
|
||||
- **✅ Do:** `A[This node contains "quotes"]`
|
||||
- **❌ Don't:** `A[This node contains "quotes"]`
|
||||
|
||||
#### Rule 4: All Formatting Must Use HTML Tags (NOT Markdown!)
|
||||
|
||||
> **Essence:** For newlines, bold, and other text formatting in nodes, use HTML tags only. Markdown is not supported.
|
||||
|
||||
- **✅ Do (robust):** `A["<b>Bold</b> and <code>code</code><br>This is a new line"]`
|
||||
- **❌ Don't (not rendered):** `C["# This is a heading"]`
|
||||
- **❌ Don't (not rendered):** ``C["`const` means constant"]``
|
||||
- **⚠️ Warning (unreliable):** `B["Markdown **bold** might sometimes work but DON'T rely on it"]`
|
||||
|
||||
#### Rule 5: No HTML Tags for Participants and Message Labels (Sequence Diagrams)
|
||||
|
||||
> **Important Addition:**
|
||||
> In Mermaid sequence diagrams, you MUST NOT use any HTML tags (such as `<b>`, `<code>`, etc.) in:
|
||||
>
|
||||
> - `participant` display names (`as` part)
|
||||
> - Message labels (the text after `:` in diagram flows)
|
||||
>
|
||||
> These tags are generally not rendered—they may appear as-is or cause compatibility issues.
|
||||
|
||||
- **✅ Do:** `participant A as Client`
|
||||
- **❌ Don't:** `participant A as <b>Client</b>`
|
||||
- **✅ Do:** `A->>B: 1. Establish connection`
|
||||
- **❌ Don't:** `A->>B: 1. <code>Establish connection</code>`
|
||||
|
||||
---
|
||||
|
||||
**Validate each Mermaid code block by running it through the `validateMermaid` tool before delivering your output!**
|
||||
@@ -1,84 +0,0 @@
|
||||
---
|
||||
description: 包含添加 debug 日志请求时
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# Debug 包使用指南
|
||||
|
||||
本项目使用 [debug](mdc:https:/github.com/debug-js/debug) 包进行调试日志记录。使用此规则来确保团队成员统一调试日志格式。
|
||||
|
||||
## 基本用法
|
||||
|
||||
1. 导入 debug 包:
|
||||
|
||||
```typescript
|
||||
import debug from 'debug';
|
||||
```
|
||||
|
||||
2. 创建一个命名空间的日志记录器:
|
||||
|
||||
```typescript
|
||||
// 格式: lobe:[模块]:[子模块]
|
||||
const log = debug('lobe-[模块名]:[子模块名]');
|
||||
```
|
||||
|
||||
3. 使用日志记录器:
|
||||
|
||||
```typescript
|
||||
log('简单消息');
|
||||
log('带变量的消息: %O', object);
|
||||
log('格式化数字: %d', number);
|
||||
```
|
||||
|
||||
## 命名空间约定
|
||||
|
||||
- 桌面应用相关: `lobe-desktop:[模块]`
|
||||
- 服务端相关: `lobe-server:[模块]`
|
||||
- 客户端相关: `lobe-client:[模块]`
|
||||
- 路由相关: `lobe-[类型]-router:[模块]`
|
||||
|
||||
## 格式说明符
|
||||
|
||||
- `%O` - 对象展开(推荐用于复杂对象)
|
||||
- `%o` - 对象
|
||||
- `%s` - 字符串
|
||||
- `%d` - 数字
|
||||
|
||||
## 示例
|
||||
|
||||
查看 [market/index.ts](mdc:src/server/routers/edge/market/index.ts) 中的使用示例:
|
||||
|
||||
```typescript
|
||||
import debug from 'debug';
|
||||
|
||||
const log = debug('lobe-edge-router:market');
|
||||
|
||||
log('getAgent input: %O', input);
|
||||
```
|
||||
|
||||
## 启用调试
|
||||
|
||||
要在开发时启用调试输出,需设置环境变量:
|
||||
|
||||
### 在浏览器中
|
||||
|
||||
在控制台执行:
|
||||
```javascript
|
||||
localStorage.debug = 'lobe-*'
|
||||
```
|
||||
|
||||
### 在 Node.js 环境中
|
||||
|
||||
```bash
|
||||
DEBUG=lobe-* npm run dev
|
||||
# 或者
|
||||
DEBUG=lobe-* pnpm dev
|
||||
```
|
||||
|
||||
### 在 Electron 应用中
|
||||
|
||||
可以在主进程和渲染进程启动前设置环境变量:
|
||||
|
||||
```typescript
|
||||
process.env.DEBUG = 'lobe-*';
|
||||
```
|
||||
@@ -1,193 +0,0 @@
|
||||
---
|
||||
description: Debug 调试指南
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# Debug 调试指南
|
||||
|
||||
## 💡 调试流程概览
|
||||
|
||||
当遇到问题时,请按照以下优先级进行处理:
|
||||
|
||||
1. **快速判断** - 对于熟悉的错误,直接提供解决方案
|
||||
2. **信息收集** - 使用工具搜索相关代码和配置
|
||||
3. **网络搜索** - 查找现有解决方案
|
||||
4. **定位调试** - 添加日志进行问题定位
|
||||
5. **临时方案** - 如果找不到根本解决方案,提供临时解决方案
|
||||
6. **解决实施** - 提供可维护的最终解决方案
|
||||
|
||||
## 🔍 错误信息分析
|
||||
|
||||
### 错误来源识别
|
||||
|
||||
错误信息可能来自:
|
||||
|
||||
- **Terminal 输出** - 构建、运行时错误
|
||||
- **浏览器控制台** - 前端 JavaScript 错误
|
||||
- **开发工具** - ESLint、TypeScript、测试框架等
|
||||
- **服务器日志** - API、数据库连接等后端错误
|
||||
- **截图或文本** - 用户直接提供的错误信息
|
||||
|
||||
## 🛠️ 信息收集工具
|
||||
|
||||
### 代码搜索工具
|
||||
|
||||
使用以下工具收集相关信息,并根据场景选择最合适的工具:
|
||||
|
||||
- **`codebase_search` (语义搜索)**
|
||||
- **何时使用**: 当你不确定具体的代码实现,想要寻找相关概念、功能或逻辑时。
|
||||
- **示例**: `查询"文件上传"功能的实现`
|
||||
- **`grep_search` (精确/正则搜索)**
|
||||
- **何时使用**: 当你知道要查找的确切字符串、函数名、变量名或一个特定的模式时。
|
||||
- **示例**: `查找所有使用了 'useState' 的地方`
|
||||
- **`file_search` (文件搜索)**
|
||||
- **何时使用**: 当你知道文件名的一部分,需要快速定位文件时。
|
||||
- **示例**: `查找 'Button.tsx' 组件`
|
||||
- **`read_file` (内容读取)**
|
||||
- **何时使用**: 在定位到具体文件后,用于查看其完整内容和上下文。
|
||||
- **`web_search` (网络搜索)**
|
||||
- **何时使用**: 当错误信息可能与第三方库、API 或常见问题相关时,用于获取外部信息。
|
||||
|
||||
### 环境与依赖检查
|
||||
|
||||
- **检查 `package.json`**: 查看 `scripts` 了解项目如何运行、构建和测试。查看 `dependencies` 和 `devDependencies` 确认库版本,版本冲突有时是问题的根源。
|
||||
- **运行测试**: 使用 `ni vitest` 运行单元测试和集成测试,这可以快速定位功能回归或组件错误。
|
||||
|
||||
### 项目特定搜索目标
|
||||
|
||||
针对 lobe-chat 项目,重点关注:
|
||||
|
||||
- **配置文件**: [package.json](mdc:package.json), [next.config.mjs](mdc:next.config.mjs)
|
||||
- **核心功能**: `src/features/` 下的相关模块
|
||||
- **状态管理**: `src/store/` 下的 Zustand stores
|
||||
- **数据库**: `src/database/` 和 `src/migrations/`
|
||||
- **类型定义**: `src/types/` 下的类型文件
|
||||
- **服务层**: `src/services/` 下的 API 服务
|
||||
- **启动流程**: [apps/desktop/src/main/core/App.ts](mdc:apps/desktop/src/main/core/App.ts) - 了解应用启动流程
|
||||
|
||||
## 🌐 网络搜索策略
|
||||
|
||||
### 搜索顺序优先级
|
||||
|
||||
1. **和问题相关的项目的 github issue**
|
||||
|
||||
2. **技术社区**
|
||||
- Stack Overflow
|
||||
- GitHub Discussions
|
||||
- Reddit
|
||||
|
||||
3. **官方文档**
|
||||
- 使用 `mcp_context7_resolve-library-id` 和 `mcp_context7_get-library-docs` 工具
|
||||
- 查阅官方文档网站
|
||||
|
||||
### 搜索关键词策略
|
||||
|
||||
- **错误信息**: 完整的错误消息
|
||||
- **技术栈**: "Next.js 15" + "error message"
|
||||
- **上下文**: 添加功能相关的关键词
|
||||
|
||||
## 🔧 问题定位与结构化思考
|
||||
|
||||
如果问题比较复杂,我们要按照先定位问题,再解决问题的大方向进行。
|
||||
|
||||
### 结构化思考工具
|
||||
|
||||
对于复杂或多步骤的调试任务,使用 `mcp_sequential-thinking_sequentialthinking` 工具来结构化思考过程。这有助于:
|
||||
|
||||
- **分解问题**: 将大问题拆解成可管理的小步骤。
|
||||
- **清晰追踪**: 记录每一步的发现和决策,避免遗漏。
|
||||
- **自我修正**: 在过程中评估和调整调试路径。
|
||||
|
||||
### 日志调试
|
||||
|
||||
在问题产生的路径上添加日志,可以简单使用 `console.log` 或者参考 [debug-usage.mdc](mdc:.cursor/rules/debug-usage.mdc) 使用 `debug` 模块。添加完日志后,请求我运行相关的代码并提供关键输出和错误信息。
|
||||
|
||||
### 引导式交互调试
|
||||
|
||||
虽然我无法直接操作浏览器开发者工具,但我可以引导你进行交互式调试:
|
||||
|
||||
1. **设置断点**: 我会告诉你可以在哪些关键代码行设置断点。
|
||||
2. **检查变量**: 我会请你在断点处检查特定变量的值或 `props`/`state`。
|
||||
3. **分析调用栈**: 我会请你提供调用栈信息,以帮助理解代码执行流程。
|
||||
|
||||
## 💡 临时解决方案策略
|
||||
|
||||
当无法找到根本解决方案时,提供临时解决方案:
|
||||
|
||||
### 临时方案准则
|
||||
|
||||
- **快速修复** - 优先让功能可用
|
||||
- **最小修改** - 减少对现有代码的影响
|
||||
- **清晰标记** - 明确标注这是临时方案
|
||||
- **后续计划** - 说明后续如何找到更好的解决方案
|
||||
|
||||
### 临时方案模板
|
||||
|
||||
```markdown
|
||||
## 临时解决方案 ⚠️
|
||||
|
||||
**问题**: [简要描述问题]
|
||||
|
||||
**临时修复**:
|
||||
[具体的临时修复步骤]
|
||||
|
||||
**风险说明**:
|
||||
|
||||
- [可能的副作用或限制]
|
||||
- [需要注意的事项]
|
||||
|
||||
**后续计划**:
|
||||
|
||||
- [ ] 深入调研根本原因
|
||||
- [ ] 寻找更优雅的解决方案
|
||||
- [ ] 监控是否有其他影响
|
||||
```
|
||||
|
||||
## ✅ 解决方案准则
|
||||
|
||||
### 方案质量标准
|
||||
|
||||
提供的解决方案应该:
|
||||
|
||||
- **✅ 低侵入性** - 最小化对现有代码的修改
|
||||
- **✅ 可维护性** - 易于理解和后续维护
|
||||
- **✅ 类型安全** - 符合 TypeScript 规范
|
||||
- **✅ 最佳实践** - 遵循项目的编码规范
|
||||
- **✅ 测试友好** - 便于编写和运行测试
|
||||
- **❌ 避免长期 Hack** - 临时方案可以 hack,但要明确标注
|
||||
|
||||
### 解决方案模板
|
||||
|
||||
```markdown
|
||||
## 问题原因
|
||||
|
||||
[简要说明问题产生的根本原因]
|
||||
|
||||
## 解决方案
|
||||
|
||||
[详细的解决步骤]
|
||||
|
||||
## 代码修改
|
||||
|
||||
[具体的代码变更]
|
||||
|
||||
## 验证方法
|
||||
|
||||
[如何验证问题已解决]
|
||||
|
||||
## 预防措施
|
||||
|
||||
[如何避免类似问题再次发生]
|
||||
```
|
||||
|
||||
## 🔄 迭代调试流程
|
||||
|
||||
如果初次解决方案无效:
|
||||
|
||||
1. **重新收集信息** - 基于新的错误信息搜索
|
||||
2. **深入代码分析** - 查看更多相关代码文件
|
||||
3. **运行相关测试** - 编写或运行一个失败的测试来稳定复现问题。
|
||||
4. **扩大搜索范围** - 搜索更广泛的相关问题
|
||||
5. **请求更多日志** - 添加更详细的调试信息
|
||||
6. **提供临时方案** - 如果根本解决方案复杂,先提供临时修复
|
||||
7. **分解问题** - 将复杂问题拆解为更小的子问题
|
||||
@@ -1,8 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: src/database/models/**/*
|
||||
alwaysApply: false
|
||||
---
|
||||
1. first read [lobe-chat-backend-architecture.mdc](mdc:.cursor/rules/lobe-chat-backend-architecture.mdc)
|
||||
2. refer to the [_template.ts](mdc:src/database/models/_template.ts) to create new model
|
||||
3. if an operation involves multiple models or complex queries, consider defining it in the `repositories` layer under `src/database/repositories/`
|
||||
@@ -1,188 +0,0 @@
|
||||
---
|
||||
description: 桌面端测试
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# 桌面端控制器单元测试指南
|
||||
|
||||
## 测试框架与目录结构
|
||||
|
||||
LobeChat 桌面端使用 Vitest 作为测试框架。控制器的单元测试应放置在对应控制器文件同级的 `__tests__` 目录下,并以原控制器文件名加 `.test.ts` 作为文件名。
|
||||
|
||||
```
|
||||
apps/desktop/src/main/controllers/
|
||||
├── __tests__/
|
||||
│ ├── index.test.ts
|
||||
│ ├── MenuCtr.test.ts
|
||||
│ └── ...
|
||||
├── McpCtr.ts
|
||||
├── MenuCtr.ts
|
||||
└── ...
|
||||
```
|
||||
|
||||
## 测试文件基本结构
|
||||
|
||||
```typescript
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import type { App } from '@/core/App';
|
||||
|
||||
import YourController from '../YourControllerName';
|
||||
|
||||
// 模拟依赖
|
||||
vi.mock('依赖模块', () => ({
|
||||
依赖函数: vi.fn(),
|
||||
}));
|
||||
|
||||
// 模拟 App 实例
|
||||
const mockApp = {
|
||||
// 按需模拟必要的 App 属性和方法
|
||||
} as unknown as App;
|
||||
|
||||
describe('YourController', () => {
|
||||
let controller: YourController;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
controller = new YourController(mockApp);
|
||||
});
|
||||
|
||||
describe('方法名', () => {
|
||||
it('测试场景描述', async () => {
|
||||
// 准备测试数据
|
||||
|
||||
// 执行被测方法
|
||||
const result = await controller.方法名(参数);
|
||||
|
||||
// 验证结果
|
||||
expect(result).toMatchObject(预期结果);
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## 模拟外部依赖
|
||||
|
||||
### 模拟模块函数
|
||||
|
||||
```typescript
|
||||
const mockFunction = vi.fn();
|
||||
|
||||
vi.mock('module-name', () => ({
|
||||
functionName: mockFunction,
|
||||
}));
|
||||
```
|
||||
|
||||
### 模拟 Node.js 核心模块
|
||||
|
||||
例如模拟 `child_process.exec` 和 `util.promisify`:
|
||||
|
||||
```typescript
|
||||
// 存储模拟的 exec 实现
|
||||
const mockExecImpl = vi.fn();
|
||||
|
||||
// 模拟 child_process.exec
|
||||
vi.mock('child_process', () => ({
|
||||
exec: vi.fn((cmd, callback) => {
|
||||
return mockExecImpl(cmd, callback);
|
||||
}),
|
||||
}));
|
||||
|
||||
// 模拟 util.promisify
|
||||
vi.mock('util', () => ({
|
||||
promisify: vi.fn((fn) => {
|
||||
return async (cmd: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
mockExecImpl(cmd, (error: Error | null, result: any) => {
|
||||
if (error) reject(error);
|
||||
else resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
}),
|
||||
}));
|
||||
```
|
||||
|
||||
## 编写有效的测试用例
|
||||
|
||||
### 测试分类
|
||||
|
||||
将测试用例分为不同类别,每个类别测试一个特定场景:
|
||||
|
||||
```typescript
|
||||
// 成功场景
|
||||
it('应该成功完成操作', async () => {});
|
||||
|
||||
// 边界条件
|
||||
it('应该处理边界情况', async () => {});
|
||||
|
||||
// 错误处理
|
||||
it('应该优雅地处理错误', async () => {});
|
||||
```
|
||||
|
||||
### 设置测试数据
|
||||
|
||||
```typescript
|
||||
// 模拟返回值
|
||||
mockExecImpl.mockImplementation((cmd: string, callback: any) => {
|
||||
if (cmd === '命令') {
|
||||
callback(null, { stdout: '成功输出' });
|
||||
} else {
|
||||
callback(new Error('错误信息'), null);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### 断言
|
||||
|
||||
使用 Vitest 的断言函数验证结果:
|
||||
|
||||
```typescript
|
||||
// 检查基本值
|
||||
expect(result.success).toBe(true);
|
||||
|
||||
// 检查对象部分匹配
|
||||
expect(result.data).toMatchObject({
|
||||
key: 'value',
|
||||
});
|
||||
|
||||
// 检查数组
|
||||
expect(result.items).toHaveLength(2);
|
||||
expect(result.items[0].name).toBe('expectedName');
|
||||
|
||||
// 检查函数调用
|
||||
expect(mockFunction).toHaveBeenCalledWith(expectedArgs);
|
||||
expect(mockFunction).toHaveBeenCalledTimes(1);
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **隔离测试**:确保每个测试互不影响,使用 `beforeEach` 重置模拟和状态
|
||||
2. **全面覆盖**:测试正常流程、边界条件和错误处理
|
||||
3. **清晰命名**:测试名称应清晰描述测试内容和预期结果
|
||||
4. **避免测试实现细节**:测试应该关注行为而非实现细节,使代码重构不会破坏测试
|
||||
5. **模拟外部依赖**:使用 `vi.mock()` 模拟所有外部依赖,减少测试的不确定性
|
||||
|
||||
## 示例:测试 IPC 事件处理方法
|
||||
|
||||
```typescript
|
||||
it('应该正确处理 IPC 事件', async () => {
|
||||
// 模拟依赖
|
||||
mockSomething.mockReturnValue({ result: 'success' });
|
||||
|
||||
// 调用 IPC 方法
|
||||
const result = await controller.ipcMethodName({
|
||||
param1: 'value1',
|
||||
param2: 'value2',
|
||||
});
|
||||
|
||||
// 验证结果
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
data: { result: 'success' },
|
||||
});
|
||||
|
||||
// 验证依赖调用
|
||||
expect(mockSomething).toHaveBeenCalledWith('value1', 'value2');
|
||||
});
|
||||
```
|
||||
@@ -1,154 +0,0 @@
|
||||
---
|
||||
description: 当要做 electron 相关工作时
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
**桌面端新功能实现指南**
|
||||
|
||||
## 桌面端应用架构概述
|
||||
|
||||
LobeChat 桌面端基于 Electron 框架构建,采用主进程-渲染进程架构:
|
||||
|
||||
1. **主进程 (Main Process)**:
|
||||
- 位置:`apps/desktop/src/main`
|
||||
- 职责:控制应用生命周期、系统API交互、窗口管理、后台服务
|
||||
|
||||
2. **渲染进程 (Renderer Process)**:
|
||||
- 复用 Web 端代码,位于 `src` 目录
|
||||
- 通过 IPC 与主进程通信
|
||||
|
||||
3. **预加载脚本 (Preload)**:
|
||||
- 位置:`apps/desktop/src/preload`
|
||||
- 职责:安全地暴露主进程功能给渲染进程
|
||||
|
||||
## 添加新桌面端功能流程
|
||||
|
||||
### 1. 确定功能需求与设计
|
||||
|
||||
首先确定新功能的需求和设计,包括:
|
||||
- 功能描述和用例
|
||||
- 是否需要系统级API(如文件系统、网络等)
|
||||
- UI/UX设计(如必要)
|
||||
- 与现有功能的交互方式
|
||||
|
||||
### 2. 在主进程中实现核心功能
|
||||
|
||||
1. **创建控制器 (Controller)**
|
||||
- 位置:`apps/desktop/src/main/controllers/`
|
||||
- 示例:创建 `NewFeatureCtr.ts`
|
||||
- 规范:按 `_template.ts` 模板格式实现
|
||||
- 注册:在 `apps/desktop/src/main/controllers/index.ts` 导出
|
||||
|
||||
2. **定义 IPC 事件处理器**
|
||||
- 使用 `@ipcClientEvent('eventName')` 装饰器注册事件处理函数
|
||||
- 处理函数应接收前端传递的参数并返回结果
|
||||
- 处理可能的错误情况
|
||||
|
||||
3. **实现业务逻辑**
|
||||
- 可能需要调用 Electron API 或 Node.js 原生模块
|
||||
- 对于复杂功能,可以创建专门的服务类 (`services/`)
|
||||
|
||||
### 3. 定义 IPC 通信类型
|
||||
|
||||
1. **在共享类型定义中添加新类型**
|
||||
- 位置:`packages/electron-client-ipc/src/types.ts`
|
||||
- 添加参数类型接口(如 `NewFeatureParams`)
|
||||
- 添加返回结果类型接口(如 `NewFeatureResult`)
|
||||
|
||||
### 4. 在渲染进程实现前端功能
|
||||
|
||||
1. **创建服务层**
|
||||
- 位置:`src/services/electron/`
|
||||
- 添加服务方法调用 IPC
|
||||
- 使用 `dispatch` 或 `invoke` 函数
|
||||
|
||||
```typescript
|
||||
// src/services/electron/newFeatureService.ts
|
||||
import { dispatch } from '@lobechat/electron-client-ipc';
|
||||
import { NewFeatureParams } from 'types';
|
||||
|
||||
export const newFeatureService = async (params: NewFeatureParams) => {
|
||||
return dispatch('newFeatureEventName', params);
|
||||
};
|
||||
```
|
||||
|
||||
2. **实现 Store Action**
|
||||
- 位置:`src/store/`
|
||||
- 添加状态更新逻辑和错误处理
|
||||
|
||||
3. **添加 UI 组件**
|
||||
- 根据需要在适当位置添加UI组件
|
||||
- 通过 Store 或 Service 层调用功能
|
||||
|
||||
### 5. 如果是新增内置工具,遵循工具实现流程
|
||||
|
||||
参考 [desktop-local-tools-implement.mdc](mdc:desktop-local-tools-implement.mdc) 了解更多关于添加内置工具的详细步骤。
|
||||
|
||||
### 6. 添加测试
|
||||
|
||||
1. **单元测试**
|
||||
- 位置:`apps/desktop/src/main/controllers/__tests__/`
|
||||
- 测试主进程组件功能
|
||||
|
||||
2. **集成测试**
|
||||
- 测试 IPC 通信和功能完整流程
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **安全性考虑**
|
||||
- 谨慎处理用户数据和文件系统访问
|
||||
- 适当验证和清理输入数据
|
||||
- 限制暴露给渲染进程的API范围
|
||||
|
||||
2. **性能优化**
|
||||
- 对于耗时操作,考虑使用异步方法
|
||||
- 大型数据传输考虑分批处理
|
||||
|
||||
3. **用户体验**
|
||||
- 为长时间操作添加进度指示
|
||||
- 提供适当的错误反馈
|
||||
- 考虑操作的可撤销性
|
||||
|
||||
4. **代码组织**
|
||||
- 遵循项目现有的命名和代码风格约定
|
||||
- 为新功能添加适当的文档和注释
|
||||
- 功能模块化,避免过度耦合
|
||||
|
||||
## 示例:实现系统通知功能
|
||||
|
||||
```typescript
|
||||
// apps/desktop/src/main/controllers/NotificationCtr.ts
|
||||
import { BrowserWindow, Notification } from 'electron';
|
||||
import { ipcClientEvent } from 'electron-client-ipc';
|
||||
|
||||
interface ShowNotificationParams {
|
||||
title: string;
|
||||
body: string;
|
||||
}
|
||||
|
||||
export class NotificationCtr {
|
||||
@ipcClientEvent('showNotification')
|
||||
async handleShowNotification({ title, body }: ShowNotificationParams) {
|
||||
try {
|
||||
if (!Notification.isSupported()) {
|
||||
return { success: false, error: 'Notifications not supported' };
|
||||
}
|
||||
|
||||
const notification = new Notification({
|
||||
title,
|
||||
body,
|
||||
});
|
||||
|
||||
notification.show();
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error('Failed to show notification:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Unknown error'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
**新增桌面端工具流程:**
|
||||
|
||||
1. **定义工具接口 (Manifest):**
|
||||
* **文件:** `src/tools/[tool_category]/index.ts` (例如: `src/tools/local-files/index.ts`)
|
||||
* **操作:**
|
||||
* 在 `ApiName` 对象(例如 `LocalFilesApiName`)中添加一个新的、唯一的 API 名称。
|
||||
* 在 `Manifest` 对象(例如 `LocalFilesManifest`)的 `api` 数组中,新增一个对象来定义新工具的接口。
|
||||
* **关键字段:**
|
||||
* `name`: 使用上一步定义的 API 名称。
|
||||
* `description`: 清晰描述工具的功能,供 Agent 理解和向用户展示。
|
||||
* `parameters`: 使用 JSON Schema 定义工具所需的输入参数。
|
||||
* `type`: 通常是 'object'。
|
||||
* `properties`: 定义每个参数的名称、`description`、`type` (string, number, boolean, array, etc.),使用英文。
|
||||
* `required`: 一个字符串数组,列出必须提供的参数名称。
|
||||
|
||||
2. **定义相关类型:**
|
||||
* **文件 1:** `packages/electron-client-ipc/src/types.ts` (或类似的共享 IPC 类型文件)
|
||||
* **操作:** 定义传递给 IPC 事件的参数类型接口 (例如: `RenameLocalFileParams`, `MoveLocalFileParams`)。确保与 Manifest 中定义的 `parameters` 一致。
|
||||
* **文件 2:** `src/tools/[tool_category]/type.ts` (例如: `src/tools/local-files/type.ts`)
|
||||
* **操作:** 定义此工具执行后,存储在前端 Zustand Store 中的状态类型接口 (例如: `LocalRenameFileState`, `LocalMoveFileState`)。这通常包含操作结果(成功/失败)、错误信息以及相关数据(如旧路径、新路径等)。
|
||||
|
||||
3. **实现前端状态管理 (Store Action):**
|
||||
* **文件:** `src/store/chat/slices/builtinTool/actions/[tool_category].ts` (例如: `src/store/chat/slices/builtinTool/actions/localFile.ts`)
|
||||
* **操作:**
|
||||
* 导入在步骤 2 中定义的 IPC 参数类型和状态类型。
|
||||
* 在 Action 接口 (例如: `LocalFileAction`) 中添加新 Action 的方法签名,使用对应的 IPC 参数类型。
|
||||
* 在 `createSlice` (例如: `localFileSlice`) 中实现该 Action 方法:
|
||||
* 接收 `id` (消息 ID) 和 `params` (符合 IPC 参数类型)。
|
||||
* 设置加载状态 (`toggleLocalFileLoading(id, true)`)。
|
||||
* 调用对应的 `Service` 层方法 (见步骤 4),传递 `params`。
|
||||
* 使用 `try...catch` 处理 `Service` 调用可能发生的错误。
|
||||
* **成功时:**
|
||||
* 调用 `updatePluginState(id, {...})` 更新插件状态,使用步骤 2 中定义的状态类型。
|
||||
* 调用 `internal_updateMessageContent(id, JSON.stringify({...}))` 更新消息内容,通常包含成功确认信息。
|
||||
* **失败时:**
|
||||
* 记录错误 (`console.error`)。
|
||||
* 调用 `updatePluginState(id, {...})` 更新插件状态,包含错误信息。
|
||||
* 调用 `internal_updateMessagePluginError(id, {...})` 设置消息的错误状态。
|
||||
* 调用 `internal_updateMessageContent(id, JSON.stringify({...}))` 更新消息内容,包含错误信息。
|
||||
* 在 `finally` 块中取消加载状态 (`toggleLocalFileLoading(id, false)`)。
|
||||
* 返回操作是否成功 (`boolean`)。
|
||||
|
||||
4. **实现 Service 层 (调用 IPC):**
|
||||
* **文件:** `src/services/electron/[tool_category]Service.ts` (例如: `src/services/electron/localFileService.ts`)
|
||||
* **操作:**
|
||||
* 导入在步骤 2 中定义的 IPC 参数类型。
|
||||
* 添加一个新的 `async` 方法,方法名通常与 Action 名称对应 (例如: `renameLocalFile`)。
|
||||
* 方法接收 `params` (符合 IPC 参数类型)。
|
||||
* 使用从 `@lobechat/electron-client-ipc` 导入的 `dispatch` (或 `invoke`) 函数,调用与 Manifest 中 `name` 字段匹配的 IPC 事件名称,并将 `params` 传递过去。
|
||||
* 定义方法的返回类型,通常是 `Promise<{ success: boolean; error?: string }>`,与后端 Controller 返回的结构一致。
|
||||
|
||||
5. **实现后端逻辑 (Controller / IPC Handler):**
|
||||
* **文件:** `apps/desktop/src/main/controllers/[ToolName]Ctr.ts` (例如: `apps/desktop/src/main/controllers/LocalFileCtr.ts`)
|
||||
* **操作:**
|
||||
* 导入 Node.js 相关模块 (`fs`, `path` 等) 和 IPC 相关依赖 (`ipcClientEvent`, 参数类型等)。
|
||||
* 添加一个新的 `async` 方法,方法名通常以 `handle` 开头 (例如: `handleRenameFile`)。
|
||||
* 使用 `@ipcClientEvent('yourApiName')` 装饰器将此方法注册为对应 IPC 事件的处理器,确保 `'yourApiName'` 与 Manifest 中的 `name` 和 Service 层调用的事件名称一致。
|
||||
* 方法的参数应解构自 Service 层传递过来的对象,类型与步骤 2 中定义的 IPC 参数类型匹配。
|
||||
* 实现核心业务逻辑:
|
||||
* 进行必要的输入验证。
|
||||
* 执行文件系统操作或其他后端任务 (例如: `fs.promises.rename`)。
|
||||
* 使用 `try...catch` 捕获执行过程中的错误。
|
||||
* 处理特定错误码 (`error.code`) 以提供更友好的错误消息。
|
||||
* 返回一个包含 `success` (boolean) 和可选 `error` (string) 字段的对象。
|
||||
|
||||
6. **更新 Agent 文档 (System Role):**
|
||||
* **文件:** `src/tools/[tool_category]/systemRole.ts` (例如: `src/tools/local-files/systemRole.ts`)
|
||||
* **操作:**
|
||||
* 在 `<core_capabilities>` 部分添加新工具的简要描述。
|
||||
* 如果需要,更新 `<workflow>`。
|
||||
* 在 `<tool_usage_guidelines>` 部分为新工具添加详细的使用说明,解释其参数、用途和预期行为。
|
||||
* 如有必要,更新 `<security_considerations>`。
|
||||
* 如有必要(例如工具返回了新的数据结构或路径),更新 `<response_format>` 中的示例。
|
||||
|
||||
通过遵循这些步骤,可以系统地将新的桌面端工具集成到 LobeChat 的插件系统中。
|
||||
@@ -1,197 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
**桌面端菜单配置指南**
|
||||
|
||||
## 菜单系统概述
|
||||
|
||||
LobeChat 桌面应用有三种主要的菜单类型:
|
||||
|
||||
1. **应用菜单 (App Menu)**:显示在应用窗口顶部(macOS)或窗口标题栏(Windows/Linux)
|
||||
2. **上下文菜单 (Context Menu)**:右键点击时显示的菜单
|
||||
3. **托盘菜单 (Tray Menu)**:点击系统托盘图标显示的菜单
|
||||
|
||||
## 菜单相关文件结构
|
||||
|
||||
```
|
||||
apps/desktop/src/main/
|
||||
├── menus/ # 菜单定义
|
||||
│ ├── appMenu.ts # 应用菜单配置
|
||||
│ ├── contextMenu.ts # 上下文菜单配置
|
||||
│ └── factory.ts # 菜单工厂函数
|
||||
├── controllers/
|
||||
│ ├── MenuCtr.ts # 菜单控制器
|
||||
│ └── TrayMenuCtr.ts # 托盘菜单控制器
|
||||
```
|
||||
|
||||
## 菜单配置流程
|
||||
|
||||
### 1. 应用菜单配置
|
||||
|
||||
应用菜单在 `apps/desktop/src/main/menus/appMenu.ts` 中定义:
|
||||
|
||||
1. **导入依赖**
|
||||
```typescript
|
||||
import { app, BrowserWindow, Menu, MenuItem, MenuItemConstructorOptions } from 'electron';
|
||||
import { is } from 'electron-util';
|
||||
```
|
||||
|
||||
2. **定义菜单项**
|
||||
- 使用 `MenuItemConstructorOptions` 类型定义菜单结构
|
||||
- 每个菜单项可以包含:label, accelerator (快捷键), role, submenu, click 等属性
|
||||
|
||||
3. **创建菜单工厂函数**
|
||||
```typescript
|
||||
export const createAppMenu = (win: BrowserWindow) => {
|
||||
const template = [
|
||||
// 定义菜单项...
|
||||
];
|
||||
|
||||
return Menu.buildFromTemplate(template);
|
||||
};
|
||||
```
|
||||
|
||||
4. **注册菜单**
|
||||
- 在 `MenuCtr.ts` 控制器中使用 `Menu.setApplicationMenu(menu)` 设置应用菜单
|
||||
|
||||
### 2. 上下文菜单配置
|
||||
|
||||
上下文菜单通常在特定元素上右键点击时显示:
|
||||
|
||||
1. **在主进程中定义菜单模板**
|
||||
```typescript
|
||||
// apps/desktop/src/main/menus/contextMenu.ts
|
||||
export const createContextMenu = () => {
|
||||
const template = [
|
||||
// 定义菜单项...
|
||||
];
|
||||
|
||||
return Menu.buildFromTemplate(template);
|
||||
};
|
||||
```
|
||||
|
||||
2. **在适当的事件处理器中显示菜单**
|
||||
```typescript
|
||||
const menu = createContextMenu();
|
||||
menu.popup();
|
||||
```
|
||||
|
||||
### 3. 托盘菜单配置
|
||||
|
||||
托盘菜单在 `TrayMenuCtr.ts` 中配置:
|
||||
|
||||
1. **创建托盘图标**
|
||||
```typescript
|
||||
this.tray = new Tray(trayIconPath);
|
||||
```
|
||||
|
||||
2. **定义托盘菜单**
|
||||
```typescript
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: '显示主窗口', click: this.showMainWindow },
|
||||
{ type: 'separator' },
|
||||
{ label: '退出', click: () => app.quit() },
|
||||
]);
|
||||
```
|
||||
|
||||
3. **设置托盘菜单**
|
||||
```typescript
|
||||
this.tray.setContextMenu(contextMenu);
|
||||
```
|
||||
|
||||
## 多语言支持
|
||||
|
||||
为菜单添加多语言支持:
|
||||
|
||||
1. **导入本地化工具**
|
||||
```typescript
|
||||
import { i18n } from '../locales';
|
||||
```
|
||||
|
||||
2. **使用翻译函数**
|
||||
```typescript
|
||||
const template = [
|
||||
{
|
||||
label: i18n.t('menu.file'),
|
||||
submenu: [
|
||||
{ label: i18n.t('menu.new'), click: createNew },
|
||||
// ...
|
||||
]
|
||||
},
|
||||
// ...
|
||||
];
|
||||
```
|
||||
|
||||
3. **在语言切换时更新菜单**
|
||||
在 `MenuCtr.ts` 中监听语言变化事件并重新创建菜单
|
||||
|
||||
## 添加新菜单项流程
|
||||
|
||||
1. **确定菜单位置**
|
||||
- 决定添加到哪个菜单(应用菜单、上下文菜单或托盘菜单)
|
||||
- 确定在菜单中的位置(主菜单项或子菜单项)
|
||||
|
||||
2. **定义菜单项**
|
||||
```typescript
|
||||
const newMenuItem: MenuItemConstructorOptions = {
|
||||
label: '新功能',
|
||||
accelerator: 'CmdOrCtrl+N',
|
||||
click: (_, window) => {
|
||||
// 处理点击事件
|
||||
if (window) window.webContents.send('trigger-new-feature');
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
3. **添加到菜单模板**
|
||||
将新菜单项添加到相应的菜单模板中
|
||||
|
||||
4. **对于与渲染进程交互的功能**
|
||||
- 使用 `window.webContents.send()` 发送 IPC 消息到渲染进程
|
||||
- 在渲染进程中监听该消息并处理
|
||||
|
||||
## 菜单项启用/禁用控制
|
||||
|
||||
动态控制菜单项状态:
|
||||
|
||||
1. **保存对菜单项的引用**
|
||||
```typescript
|
||||
this.menuItems = {};
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
this.menuItems.newFeature = menu.getMenuItemById('new-feature');
|
||||
```
|
||||
|
||||
2. **根据条件更新状态**
|
||||
```typescript
|
||||
updateMenuState(state) {
|
||||
if (this.menuItems.newFeature) {
|
||||
this.menuItems.newFeature.enabled = state.canUseNewFeature;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **使用标准角色**
|
||||
- 尽可能使用 Electron 预定义的角色(如 `role: 'copy'`)以获得本地化和一致的行为
|
||||
|
||||
2. **平台特定菜单**
|
||||
- 使用 `process.platform` 检查为不同平台提供不同菜单
|
||||
```typescript
|
||||
if (process.platform === 'darwin') {
|
||||
template.unshift({ role: 'appMenu' });
|
||||
}
|
||||
```
|
||||
|
||||
3. **快捷键冲突**
|
||||
- 避免与系统快捷键冲突
|
||||
- 使用 `CmdOrCtrl` 代替 `Ctrl` 以支持 macOS 和 Windows/Linux
|
||||
|
||||
4. **保持菜单简洁**
|
||||
- 避免过多嵌套的子菜单
|
||||
- 将相关功能分组在一起
|
||||
|
||||
5. **添加分隔符**
|
||||
- 使用 `{ type: 'separator' }` 在逻辑上分隔不同组的菜单项
|
||||
@@ -1,296 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
**桌面端窗口管理指南**
|
||||
|
||||
## 窗口管理概述
|
||||
|
||||
LobeChat 桌面应用使用 Electron 的 `BrowserWindow` 管理应用窗口。主要的窗口管理功能包括:
|
||||
|
||||
1. **窗口创建和配置**
|
||||
2. **窗口状态管理**(大小、位置、最大化等)
|
||||
3. **多窗口协调**
|
||||
4. **窗口事件处理**
|
||||
|
||||
## 相关文件结构
|
||||
|
||||
```
|
||||
apps/desktop/src/main/
|
||||
├── appBrowsers.ts # 窗口管理的核心文件
|
||||
├── controllers/
|
||||
│ └── BrowserWindowsCtr.ts # 窗口控制器
|
||||
└── modules/
|
||||
└── browserWindowManager.ts # 窗口管理模块
|
||||
```
|
||||
|
||||
## 窗口管理流程
|
||||
|
||||
### 1. 窗口创建
|
||||
|
||||
在 `appBrowsers.ts` 或 `BrowserWindowsCtr.ts` 中定义窗口创建逻辑:
|
||||
|
||||
```typescript
|
||||
export const createMainWindow = () => {
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
minWidth: 600,
|
||||
minHeight: 400,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '../preload/index.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
// 其他窗口配置项...
|
||||
});
|
||||
|
||||
// 加载应用内容
|
||||
if (isDev) {
|
||||
mainWindow.loadURL('http://localhost:3000');
|
||||
mainWindow.webContents.openDevTools();
|
||||
} else {
|
||||
mainWindow.loadFile(path.join(__dirname, '../../renderer/index.html'));
|
||||
}
|
||||
|
||||
return mainWindow;
|
||||
};
|
||||
```
|
||||
|
||||
### 2. 窗口状态管理
|
||||
|
||||
实现窗口状态持久化保存和恢复:
|
||||
|
||||
1. **保存窗口状态**
|
||||
```typescript
|
||||
const saveWindowState = (window: BrowserWindow) => {
|
||||
if (!window.isMinimized() && !window.isMaximized()) {
|
||||
const position = window.getPosition();
|
||||
const size = window.getSize();
|
||||
|
||||
settings.set('windowState', {
|
||||
x: position[0],
|
||||
y: position[1],
|
||||
width: size[0],
|
||||
height: size[1],
|
||||
});
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
2. **恢复窗口状态**
|
||||
```typescript
|
||||
const restoreWindowState = (window: BrowserWindow) => {
|
||||
const savedState = settings.get('windowState');
|
||||
|
||||
if (savedState) {
|
||||
window.setBounds({
|
||||
x: savedState.x,
|
||||
y: savedState.y,
|
||||
width: savedState.width,
|
||||
height: savedState.height,
|
||||
});
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
3. **监听窗口事件**
|
||||
```typescript
|
||||
window.on('close', () => saveWindowState(window));
|
||||
window.on('moved', () => saveWindowState(window));
|
||||
window.on('resized', () => saveWindowState(window));
|
||||
```
|
||||
|
||||
### 3. 实现多窗口管理
|
||||
|
||||
对于需要多窗口支持的功能:
|
||||
|
||||
1. **跟踪窗口**
|
||||
```typescript
|
||||
export class WindowManager {
|
||||
private windows: Map<string, BrowserWindow> = new Map();
|
||||
|
||||
createWindow(id: string, options: BrowserWindowConstructorOptions) {
|
||||
const window = new BrowserWindow(options);
|
||||
this.windows.set(id, window);
|
||||
|
||||
window.on('closed', () => {
|
||||
this.windows.delete(id);
|
||||
});
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
getWindow(id: string) {
|
||||
return this.windows.get(id);
|
||||
}
|
||||
|
||||
getAllWindows() {
|
||||
return Array.from(this.windows.values());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **窗口间通信**
|
||||
```typescript
|
||||
// 从一个窗口向另一个窗口发送消息
|
||||
sendMessageToWindow(targetWindowId, channel, data) {
|
||||
const targetWindow = this.getWindow(targetWindowId);
|
||||
if (targetWindow) {
|
||||
targetWindow.webContents.send(channel, data);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. 窗口与渲染进程通信
|
||||
|
||||
通过 IPC 实现窗口操作:
|
||||
|
||||
1. **在主进程中注册 IPC 处理器**
|
||||
```typescript
|
||||
// BrowserWindowsCtr.ts
|
||||
@ipcClientEvent('minimizeWindow')
|
||||
handleMinimizeWindow() {
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
if (focusedWindow) {
|
||||
focusedWindow.minimize();
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@ipcClientEvent('maximizeWindow')
|
||||
handleMaximizeWindow() {
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
if (focusedWindow) {
|
||||
if (focusedWindow.isMaximized()) {
|
||||
focusedWindow.restore();
|
||||
} else {
|
||||
focusedWindow.maximize();
|
||||
}
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@ipcClientEvent('closeWindow')
|
||||
handleCloseWindow() {
|
||||
const focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
if (focusedWindow) {
|
||||
focusedWindow.close();
|
||||
}
|
||||
return { success: true };
|
||||
}
|
||||
```
|
||||
|
||||
2. **在渲染进程中调用**
|
||||
```typescript
|
||||
// src/services/electron/windowService.ts
|
||||
import { dispatch } from '@lobechat/electron-client-ipc';
|
||||
|
||||
export const windowService = {
|
||||
minimize: () => dispatch('minimizeWindow'),
|
||||
maximize: () => dispatch('maximizeWindow'),
|
||||
close: () => dispatch('closeWindow'),
|
||||
};
|
||||
```
|
||||
|
||||
### 5. 自定义窗口控制 (无边框窗口)
|
||||
|
||||
对于自定义窗口标题栏:
|
||||
|
||||
1. **创建无边框窗口**
|
||||
```typescript
|
||||
const window = new BrowserWindow({
|
||||
frame: false,
|
||||
titleBarStyle: 'hidden',
|
||||
// 其他选项...
|
||||
});
|
||||
```
|
||||
|
||||
2. **在渲染进程中实现拖拽区域**
|
||||
```css
|
||||
/* CSS */
|
||||
.titlebar {
|
||||
-webkit-app-region: drag;
|
||||
}
|
||||
|
||||
.titlebar-button {
|
||||
-webkit-app-region: no-drag;
|
||||
}
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **性能考虑**
|
||||
- 避免创建过多窗口
|
||||
- 使用 `show: false` 创建窗口,在内容加载完成后再显示,避免白屏
|
||||
|
||||
2. **安全性**
|
||||
- 始终设置适当的 `webPreferences` 确保安全
|
||||
```typescript
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '../preload/index.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
sandbox: true,
|
||||
}
|
||||
```
|
||||
|
||||
3. **跨平台兼容性**
|
||||
- 考虑不同操作系统的窗口行为差异
|
||||
- 使用 `process.platform` 为不同平台提供特定实现
|
||||
|
||||
4. **崩溃恢复**
|
||||
- 监听 `webContents.on('crashed')` 事件处理崩溃
|
||||
- 提供崩溃恢复选项
|
||||
|
||||
5. **内存管理**
|
||||
- 确保窗口关闭时清理所有相关资源
|
||||
- 使用 `window.on('closed')` 而不是 `window.on('close')` 进行最终清理
|
||||
|
||||
## 示例:创建设置窗口
|
||||
|
||||
```typescript
|
||||
// apps/desktop/src/main/controllers/BrowserWindowsCtr.ts
|
||||
|
||||
@ipcClientEvent('openSettings')
|
||||
handleOpenSettings() {
|
||||
// 检查设置窗口是否已经存在
|
||||
if (this.settingsWindow && !this.settingsWindow.isDestroyed()) {
|
||||
// 如果窗口已存在,将其置于前台
|
||||
this.settingsWindow.focus();
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
// 创建新窗口
|
||||
this.settingsWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: 'Settings',
|
||||
parent: this.mainWindow, // 设置父窗口,使其成为模态窗口
|
||||
modal: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, '../preload/index.js'),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
});
|
||||
|
||||
// 加载设置页面
|
||||
if (isDev) {
|
||||
this.settingsWindow.loadURL('http://localhost:3000/settings');
|
||||
} else {
|
||||
this.settingsWindow.loadFile(
|
||||
path.join(__dirname, '../../renderer/index.html'),
|
||||
{ hash: 'settings' }
|
||||
);
|
||||
}
|
||||
|
||||
// 监听窗口关闭事件
|
||||
this.settingsWindow.on('closed', () => {
|
||||
this.settingsWindow = null;
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
```
|
||||
@@ -1,202 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: src/database/schemas/*
|
||||
alwaysApply: false
|
||||
---
|
||||
# Drizzle ORM Schema Style Guide for lobe-chat
|
||||
|
||||
This document outlines the conventions and best practices for defining PostgreSQL Drizzle ORM schemas within the lobe-chat project.
|
||||
|
||||
## Configuration
|
||||
|
||||
- Drizzle configuration is managed in [drizzle.config.ts](mdc:drizzle.config.ts)
|
||||
- Schema files are located in the src/database/schemas/ directory
|
||||
- Migration files are output to `src/database/migrations/`
|
||||
- The project uses `postgresql` dialect with `strict: true`
|
||||
|
||||
## Helper Functions
|
||||
|
||||
Commonly used column definitions, especially for timestamps, are centralized in [src/database/schemas/_helpers.ts](mdc:src/database/schemas/_helpers.ts):
|
||||
- `timestamptz(name: string)`: Creates a timestamp column with timezone
|
||||
- `createdAt()`, `updatedAt()`, `accessedAt()`: Helper functions for standard timestamp columns
|
||||
- `timestamps`: An object `{ createdAt, updatedAt, accessedAt }` for easy inclusion in table definitions
|
||||
|
||||
## Naming Conventions
|
||||
|
||||
- **Table Names**: Use plural snake_case (e.g., `users`, `agents`, `session_groups`)
|
||||
- **Column Names**: Use snake_case (e.g., `user_id`, `created_at`, `background_color`)
|
||||
|
||||
## Column Definitions
|
||||
|
||||
### Primary Keys (PKs)
|
||||
- Typically `text('id')` (or `varchar('id')` for some OIDC tables)
|
||||
- Often use `.$defaultFn(() => idGenerator('table_name'))` for automatic ID generation with meaningful prefixes
|
||||
- **ID Prefix Purpose**: Makes it easy for users and developers to distinguish different entity types at a glance
|
||||
- For internal/system tables that users don't need to see, can use `uuid` or auto-increment keys
|
||||
- Composite PKs are defined using `primaryKey({ columns: [t.colA, t.colB] })`
|
||||
|
||||
### Foreign Keys (FKs)
|
||||
- Defined using `.references(() => otherTable.id, { onDelete: 'cascade' | 'set null' | 'no action' })`
|
||||
- FK columns are usually named `related_table_singular_name_id` (e.g., `user_id` references `users.id`)
|
||||
- Most tables include a `user_id` column referencing `users.id` with `onDelete: 'cascade'`
|
||||
|
||||
### Timestamps
|
||||
- Consistently use the `...timestamps` spread from [_helpers.ts](mdc:src/database/schemas/_helpers.ts) for `created_at`, `updated_at`, and `accessed_at` columns
|
||||
|
||||
### Default Values
|
||||
- `.$defaultFn(() => expression)` for dynamic defaults (e.g., `idGenerator()`, `randomSlug()`)
|
||||
- `.default(staticValue)` for static defaults (e.g., `boolean('enabled').default(true)`)
|
||||
|
||||
### Indexes
|
||||
- Defined in the table's second argument: `pgTable('name', {...columns}, (t) => ({ indexName: indexType().on(...) }))`
|
||||
- Use `uniqueIndex()` for unique constraints and `index()` for non-unique indexes
|
||||
- Naming pattern: `table_name_column(s)_idx` or `table_name_column(s)_unique`
|
||||
- Many tables feature a `clientId: text('client_id')` column, often part of a composite unique index with `user_id`
|
||||
|
||||
### Data Types
|
||||
- Common types: `text`, `varchar`, `jsonb`, `boolean`, `integer`, `uuid`, `pgTable`
|
||||
- For `jsonb` fields, specify the TypeScript type using `.$type<MyType>()` for better type safety
|
||||
|
||||
## Zod Schemas & Type Inference
|
||||
|
||||
- Utilize `drizzle-zod` to generate Zod schemas for validation:
|
||||
- `createInsertSchema(tableName)`
|
||||
- `createSelectSchema(tableName)` (less common)
|
||||
- Export inferred types: `export type NewEntity = typeof tableName.$inferInsert;` and `export type EntityItem = typeof tableName.$inferSelect;`
|
||||
|
||||
## Relations
|
||||
|
||||
- Table relationships are defined centrally in [src/database/schemas/relations.ts](mdc:src/database/schemas/relations.ts) using the `relations()` utility from `drizzle-orm`
|
||||
|
||||
## Code Style & Structure
|
||||
|
||||
- **File Organization**: Each main database entity typically has its own schema file (e.g., [user.ts](mdc:src/database/schemas/user.ts), [agent.ts](mdc:src/database/schemas/agent.ts))
|
||||
- All schemas are re-exported from [src/database/schemas/index.ts](mdc:src/database/schemas/index.ts)
|
||||
- **ESLint**: Files often start with `/* eslint-disable sort-keys-fix/sort-keys-fix */`
|
||||
- **Comments**: Use JSDoc-style comments to explain the purpose of tables and complex columns, fields that are self-explanatory do not require jsdoc explanations, such as id, user_id, etc.
|
||||
|
||||
## Example Pattern
|
||||
|
||||
```typescript
|
||||
// From src/database/schemas/agent.ts
|
||||
export const agents = pgTable(
|
||||
'agents',
|
||||
{
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => idGenerator('agents'))
|
||||
.notNull(),
|
||||
slug: varchar('slug', { length: 100 })
|
||||
.$defaultFn(() => randomSlug(4))
|
||||
.unique(),
|
||||
userId: text('user_id')
|
||||
.references(() => users.id, { onDelete: 'cascade' })
|
||||
.notNull(),
|
||||
clientId: text('client_id'),
|
||||
chatConfig: jsonb('chat_config').$type<LobeAgentChatConfig>(),
|
||||
...timestamps,
|
||||
},
|
||||
// return array instead of object, the object style is deprecated
|
||||
(t) => [
|
||||
uniqueIndex('client_id_user_id_unique').on(t.clientId, t.userId),
|
||||
],
|
||||
);
|
||||
|
||||
export const insertAgentSchema = createInsertSchema(agents);
|
||||
export type NewAgent = typeof agents.$inferInsert;
|
||||
export type AgentItem = typeof agents.$inferSelect;
|
||||
```
|
||||
|
||||
## Common Patterns
|
||||
|
||||
### 1. userId + clientId Pattern (Legacy)
|
||||
Some existing tables include both fields for different purposes:
|
||||
|
||||
```typescript
|
||||
// Example from agents table (legacy pattern)
|
||||
userId: text('user_id')
|
||||
.references(() => users.id, { onDelete: 'cascade' })
|
||||
.notNull(),
|
||||
clientId: text('client_id'),
|
||||
|
||||
// Usually with a composite unique index
|
||||
clientIdUnique: uniqueIndex('agents_client_id_user_id_unique').on(t.clientId, t.userId),
|
||||
```
|
||||
|
||||
- **`userId`**: Server-side user association, ensures data belongs to specific user
|
||||
- **`clientId`**: Unique key for import/export operations, supports data migration between instances
|
||||
- **Current Status**: New tables should NOT include `clientId` unless specifically needed for import/export functionality
|
||||
- **Note**: This pattern is being phased out for new features to simplify the schema
|
||||
|
||||
### 2. Junction Tables (Many-to-Many Relationships)
|
||||
Use composite primary keys for relationship tables:
|
||||
|
||||
```typescript
|
||||
// Example: agents_knowledge_bases (from agent.ts)
|
||||
export const agentsKnowledgeBases = pgTable(
|
||||
'agents_knowledge_bases',
|
||||
{
|
||||
agentId: text('agent_id').references(() => agents.id, { onDelete: 'cascade' }).notNull(),
|
||||
knowledgeBaseId: text('knowledge_base_id').references(() => knowledgeBases.id, { onDelete: 'cascade' }).notNull(),
|
||||
userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
|
||||
enabled: boolean('enabled').default(true),
|
||||
...timestamps,
|
||||
},
|
||||
(t) => [
|
||||
primaryKey({ columns: [t.agentId, t.knowledgeBaseId] }),
|
||||
],
|
||||
);
|
||||
```
|
||||
|
||||
**Pattern**: `{entity1}Id` + `{entity2}Id` as composite PK, plus `userId` for ownership
|
||||
|
||||
### 3. OIDC Tables Special Patterns
|
||||
OIDC tables use `varchar` IDs instead of `text` with custom generators:
|
||||
|
||||
```typescript
|
||||
// Example from oidc.ts
|
||||
export const oidcAuthorizationCodes = pgTable('oidc_authorization_codes', {
|
||||
id: varchar('id', { length: 255 }).primaryKey(), // varchar not text
|
||||
data: jsonb('data').notNull(),
|
||||
expiresAt: timestamptz('expires_at').notNull(),
|
||||
// ... other fields
|
||||
});
|
||||
```
|
||||
|
||||
**Reason**: OIDC standards expect specific ID formats and lengths
|
||||
|
||||
### 4. File Processing with Async Tasks
|
||||
File-related tables reference async task IDs for background processing:
|
||||
|
||||
```typescript
|
||||
// Example from files table
|
||||
export const files = pgTable('files', {
|
||||
// ... other fields
|
||||
chunkTaskId: uuid('chunk_task_id').references(() => asyncTasks.id, { onDelete: 'set null' }),
|
||||
embeddingTaskId: uuid('embedding_task_id').references(() => asyncTasks.id, { onDelete: 'set null' }),
|
||||
// ...
|
||||
});
|
||||
```
|
||||
|
||||
**Purpose**:
|
||||
- Track file chunking progress (breaking files into smaller pieces)
|
||||
- Track embedding generation progress (converting text to vectors)
|
||||
- Allow querying task status and handling failures
|
||||
|
||||
### 5. Slug Pattern (Legacy)
|
||||
Some entities include auto-generated slugs - this is legacy code:
|
||||
|
||||
```typescript
|
||||
slug: varchar('slug', { length: 100 })
|
||||
.$defaultFn(() => randomSlug(4))
|
||||
.unique(),
|
||||
|
||||
// Often with composite unique constraint
|
||||
slugUserIdUnique: uniqueIndex('slug_user_id_unique').on(t.slug, t.userId),
|
||||
```
|
||||
|
||||
**Current usage**: Only used to identify default agents/sessions (legacy pattern)
|
||||
**Future refactor**: Will likely be replaced with `isDefault: boolean()` field
|
||||
**Note**: Avoid using slugs for new features - prefer explicit boolean flags for status tracking
|
||||
|
||||
By following these guidelines, maintain consistency, type safety, and maintainability across database schema definitions.
|
||||
@@ -1,181 +0,0 @@
|
||||
---
|
||||
description: i18n workflow and troubleshooting
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# LobeChat 国际化指南
|
||||
|
||||
## 架构概览
|
||||
|
||||
LobeChat 使用 react-i18next 进行国际化,采用良好的命名空间架构:
|
||||
|
||||
- 默认语言:中文(zh-CN),作为源语言
|
||||
- 支持语言:18 种语言,包括英语、日语、韩语、阿拉伯语等
|
||||
- 框架:react-i18next 配合 Next.js app router
|
||||
- 翻译自动化:@lobehub/i18n-cli 用于自动翻译,配置文件:.i18nrc.js
|
||||
|
||||
## 目录结构
|
||||
|
||||
```
|
||||
src/locales/
|
||||
├── default/ # 源语言文件(zh-CN)
|
||||
│ ├── index.ts # 命名空间导出
|
||||
│ ├── common.ts # 通用翻译
|
||||
│ ├── chat.ts # 聊天相关翻译
|
||||
│ ├── setting.ts # 设置翻译
|
||||
│ └── ... # 其他命名空间文件
|
||||
└── resources.ts # 类型定义和语言配置
|
||||
|
||||
locales/ # 翻译文件
|
||||
├── en-US/ # 英语翻译
|
||||
│ ├── common.json # 通用翻译
|
||||
│ ├── chat.json # 聊天翻译
|
||||
│ ├── setting.json # 设置翻译
|
||||
│ └── ... # 其他命名空间 JSON 文件
|
||||
├── ja-JP/ # 日语翻译
|
||||
│ ├── common.json
|
||||
│ ├── chat.json
|
||||
│ └── ...
|
||||
└── ... # 其他语言文件夹
|
||||
```
|
||||
|
||||
## 添加新翻译的工作流程
|
||||
|
||||
### 1. 添加新的翻译键
|
||||
|
||||
第一步:在 src/locales/default 目录下的相应命名空间文件中添加翻译键
|
||||
|
||||
```typescript
|
||||
// 示例:src/locales/default/common.ts
|
||||
export default {
|
||||
// ... 现有键
|
||||
newFeature: {
|
||||
title: "新功能标题",
|
||||
description: "功能描述文案",
|
||||
button: "操作按钮",
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
第二步:如果创建新命名空间,需要在 src/locales/default/index.ts 中导出
|
||||
|
||||
```typescript
|
||||
import newNamespace from "./newNamespace";
|
||||
|
||||
const resources = {
|
||||
// ... 现有命名空间
|
||||
newNamespace,
|
||||
} as const;
|
||||
```
|
||||
|
||||
### 2. 翻译过程
|
||||
|
||||
开发模式:
|
||||
|
||||
一般情况下不需要你帮我跑自动翻译工具,跑一次很久,需要的时候我会自己跑。
|
||||
但是为了立马能看到效果,还是需要先翻译 `locales/zh-CN/namespace.json`,不需要翻译其它语言。
|
||||
|
||||
生产模式:
|
||||
|
||||
```bash
|
||||
# 为所有语言生成翻译
|
||||
npm run i18n
|
||||
```
|
||||
|
||||
## 在组件中使用
|
||||
|
||||
### 基本用法
|
||||
|
||||
```tsx
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const MyComponent = () => {
|
||||
const { t } = useTranslation("common");
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{t("newFeature.title")}</h1>
|
||||
<p>{t("newFeature.description")}</p>
|
||||
<button>{t("newFeature.button")}</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### 带参数的用法
|
||||
|
||||
```tsx
|
||||
const { t } = useTranslation("common");
|
||||
|
||||
<p>{t("welcome.message", { name: "John" })}</p>;
|
||||
|
||||
// 对应的语言文件:
|
||||
// welcome: { message: '欢迎 {{name}} 使用!' }
|
||||
```
|
||||
|
||||
### 多个命名空间
|
||||
|
||||
```tsx
|
||||
const { t } = useTranslation(['common', 'chat']);
|
||||
|
||||
<button>{t('common:save')}</button>
|
||||
<span>{t('chat:typing')}</span>
|
||||
```
|
||||
|
||||
## 类型安全
|
||||
|
||||
项目使用 TypeScript 实现类型安全的翻译,类型从 src/locales/resources.ts 自动生成:
|
||||
|
||||
```typescript
|
||||
import type { DefaultResources, NS, Locales } from "@/locales/resources";
|
||||
|
||||
// 可用类型:
|
||||
// - NS: 可用命名空间键 ('common' | 'chat' | 'setting' | ...)
|
||||
// - Locales: 支持的语言代码 ('en-US' | 'zh-CN' | 'ja-JP' | ...)
|
||||
|
||||
const namespace: NS = "common";
|
||||
const locale: Locales = "en-US";
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
### 1. 命名空间组织
|
||||
|
||||
- common: 共享 UI 元素(按钮、标签、操作)
|
||||
- chat: 聊天特定功能
|
||||
- setting: 配置和设置
|
||||
- error: 错误消息和处理
|
||||
- [feature]: 功能特定或页面特定的命名空间
|
||||
- components: 可复用组件文案
|
||||
|
||||
### 2. 键命名约定
|
||||
|
||||
```typescript
|
||||
// ✅ 好:层次结构
|
||||
export default {
|
||||
modal: {
|
||||
confirm: {
|
||||
title: "确认操作",
|
||||
message: "确定要执行此操作吗?",
|
||||
actions: {
|
||||
confirm: "确认",
|
||||
cancel: "取消",
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// ❌ 避免:扁平结构
|
||||
export default {
|
||||
modalConfirmTitle: "确认操作",
|
||||
modalConfirmMessage: "确定要执行此操作吗?",
|
||||
};
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 缺少翻译键
|
||||
|
||||
- 检查键是否存在于 src/locales/default/namespace.ts 中
|
||||
- 确保在组件中正确导入命名空间
|
||||
- 确保新命名空间已在 src/locales/default/index.ts 中导出
|
||||
@@ -1,119 +0,0 @@
|
||||
---
|
||||
description: react flex layout package `react-layout-kit` usage
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
# React Layout Kit 使用指南
|
||||
|
||||
react-layout-kit 是一个功能丰富的 React flex 布局组件库,在 lobe-chat 项目中被广泛使用。以下是重点组件的使用方法:
|
||||
|
||||
## Flexbox 组件
|
||||
|
||||
Flexbox 是最常用的布局组件,用于创建弹性布局,类似于 CSS 的 display: flex。
|
||||
|
||||
### 基本用法
|
||||
|
||||
```jsx
|
||||
import { Flexbox } from 'react-layout-kit';
|
||||
|
||||
// 默认垂直布局
|
||||
<Flexbox>
|
||||
<div>子元素1</div>
|
||||
<div>子元素2</div>
|
||||
</Flexbox>
|
||||
|
||||
// 水平布局
|
||||
<Flexbox horizontal>
|
||||
<div>左侧元素</div>
|
||||
<div>右侧元素</div>
|
||||
</Flexbox>
|
||||
```
|
||||
|
||||
### 常用属性
|
||||
|
||||
- horizontal: 布尔值,设置为水平方向布局
|
||||
- flex: 数值或字符串,控制 flex 属性
|
||||
- gap: 数值,设置子元素之间的间距
|
||||
- align: 对齐方式,如 'center', 'flex-start' 等
|
||||
- justify: 主轴对齐方式,如 'space-between', 'center' 等
|
||||
- padding: 内边距值
|
||||
- paddingInline: 水平内边距值
|
||||
- paddingBlock: 垂直内边距值
|
||||
- width/height: 设置宽高,通常用 '100%' 或具体像素值
|
||||
- style: 自定义样式对象
|
||||
|
||||
### 实际应用示例
|
||||
|
||||
```jsx
|
||||
// 经典三栏布局
|
||||
<Flexbox horizontal height={'100%'} width={'100%'}>
|
||||
{/* 左侧边栏 */}
|
||||
<Flexbox
|
||||
width={260}
|
||||
style={{
|
||||
borderRight: `1px solid ${theme.colorBorderSecondary}`,
|
||||
height: '100%',
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<SidebarContent />
|
||||
</Flexbox>
|
||||
|
||||
{/* 中间内容区 */}
|
||||
<Flexbox flex={1} style={{ height: '100%' }}>
|
||||
{/* 主要内容 */}
|
||||
<Flexbox flex={1} padding={24} style={{ overflowY: 'auto' }}>
|
||||
<MainContent />
|
||||
</Flexbox>
|
||||
|
||||
{/* 底部区域 */}
|
||||
<Flexbox
|
||||
style={{
|
||||
borderTop: `1px solid ${theme.colorBorderSecondary}`,
|
||||
padding: '16px 24px',
|
||||
}}
|
||||
>
|
||||
<Footer />
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
</Flexbox>
|
||||
```
|
||||
|
||||
## Center 组件
|
||||
|
||||
Center 是对 Flexbox 的封装,使子元素水平和垂直居中。
|
||||
|
||||
### 基本用法
|
||||
|
||||
```jsx
|
||||
<Center width={'100%'} height={'100%'}>
|
||||
<Content />
|
||||
</Center>
|
||||
```
|
||||
|
||||
Center 组件继承了 Flexbox 的所有属性,同时默认设置了居中对齐。主要用于快速创建居中布局。
|
||||
|
||||
### 实际应用示例
|
||||
|
||||
```jsx
|
||||
// 登录页面居中布局
|
||||
<Flexbox height={'100%'} width={'100%'}>
|
||||
<Center height={'100%'} width={'100%'}>
|
||||
<LoginForm />
|
||||
</Center>
|
||||
</Flexbox>
|
||||
|
||||
// 图标居中显示
|
||||
<Center className={styles.icon} flex={'none'} height={40} width={40}>
|
||||
<Icon icon={icon} size={24} />
|
||||
</Center>
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
- 使用 flex={1} 让组件填充可用空间
|
||||
- 使用 gap 代替传统的 margin 设置元素间距
|
||||
- 嵌套 Flexbox 创建复杂布局
|
||||
- 设置 overflow: 'auto' 使内容可滚动
|
||||
- 使用 horizontal 创建水平布局,默认为垂直布局
|
||||
- 与 antd-style 的 useTheme hook 配合使用创建主题响应式的布局
|
||||
@@ -1,58 +0,0 @@
|
||||
---
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
## Project Description
|
||||
|
||||
You are developing an open-source, modern-design AI chat framework: lobe chat.
|
||||
|
||||
Emoji logo: 🤯
|
||||
|
||||
## Project Technologies Stack
|
||||
|
||||
read [package.json](mdc:package.json) to know all npm packages you can use. read [folder-structure.mdx](mdc:docs/development/basic/folder-structure.mdx) to learn project structure.
|
||||
|
||||
The project uses the following technologies:
|
||||
|
||||
- pnpm as package manager
|
||||
- Next.js 15 for frontend and backend, using app router instead of pages router
|
||||
- react 19, using hooks, functional components, react server components
|
||||
- TypeScript programming language
|
||||
- antd, @lobehub/ui for component framework
|
||||
- antd-style for css-in-js framework
|
||||
- react-layout-kit for flex layout
|
||||
- react-i18next for i18n
|
||||
- lucide-react, @ant-design/icons for icons
|
||||
- @lobehub/icons for AI provider/model logo icon
|
||||
- @formkit/auto-animate for react list animation
|
||||
- zustand for global state management
|
||||
- nuqs for type-safe search params state manager
|
||||
- SWR for react data fetch
|
||||
- aHooks for react hooks library
|
||||
- dayjs for date and time library
|
||||
- lodash-es for utility library
|
||||
- fast-deep-equal for deep comparison of JavaScript objects
|
||||
- zod for data validation
|
||||
- TRPC for type safe backend
|
||||
- PGLite for client DB and PostgreSQL for backend DB
|
||||
- Drizzle ORM
|
||||
- Vitest for testing, testing-library for react component test
|
||||
- Prettier for code formatting
|
||||
- ESLint for code linting
|
||||
- Cursor AI for code editing and AI coding assistance
|
||||
|
||||
Note: All tools and libraries used are the latest versions. The application only needs to be compatible with the latest browsers;
|
||||
|
||||
## Often used npm scripts
|
||||
|
||||
```bash
|
||||
# type check
|
||||
bun type-check
|
||||
|
||||
# install dependencies
|
||||
pnpm install
|
||||
|
||||
# !: don't any build script to check weather code can work after modify
|
||||
```
|
||||
|
||||
check [testing guide](./testing-guide/testing-guide.mdc) to learn test scripts.
|
||||
@@ -1,153 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: *.tsx
|
||||
alwaysApply: false
|
||||
---
|
||||
# react component 编写指南
|
||||
|
||||
- 如果要写复杂样式的话用 antd-style ,简单的话可以用 style 属性直接写内联样式
|
||||
- 如果需要 flex 布局或者居中布局应该使用 react-layout-kit 的 Flexbox 和 Center 组件
|
||||
- 选择组件时优先顺序应该是 src/components > 安装的组件 package > lobe-ui > antd
|
||||
|
||||
## antd-style token system
|
||||
|
||||
### 访问 token system 的两种方式
|
||||
|
||||
#### 使用 antd-style 的 useTheme hook
|
||||
|
||||
```tsx
|
||||
import { useTheme } from 'antd-style';
|
||||
|
||||
const MyComponent = () => {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
color: theme.colorPrimary,
|
||||
backgroundColor: theme.colorBgContainer,
|
||||
padding: theme.padding,
|
||||
borderRadius: theme.borderRadius
|
||||
}}>
|
||||
使用主题 token 的组件
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
#### 使用 antd-style 的 createStyles
|
||||
|
||||
```tsx
|
||||
const useStyles = createStyles(({ css, token }) => {
|
||||
return {
|
||||
container: css`
|
||||
background-color: ${token.colorBgContainer};
|
||||
border-radius: ${token.borderRadius}px;
|
||||
padding: ${token.padding}px;
|
||||
color: ${token.colorText};
|
||||
`,
|
||||
title: css`
|
||||
font-size: ${token.fontSizeLG}px;
|
||||
font-weight: ${token.fontWeightStrong};
|
||||
margin-bottom: ${token.marginSM}px;
|
||||
`,
|
||||
content: css`
|
||||
font-size: ${token.fontSize}px;
|
||||
line-height: ${token.lineHeight};
|
||||
`
|
||||
};
|
||||
});
|
||||
|
||||
const Card: FC<CardProps> = ({ title, content }) => {
|
||||
const { styles } = useStyles();
|
||||
|
||||
return (
|
||||
<Flexbox className={styles.container}>
|
||||
<div className={styles.title}>{title}</div>
|
||||
<div className={styles.content}>{content}</div>
|
||||
</Flexbox>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
### 一些你经常会忘记使用的 token
|
||||
|
||||
请注意使用下面的 token 而不是 css 字面值。可以访问 https://ant.design/docs/react/customize-theme-cn 了解所有 token
|
||||
|
||||
- 动画类
|
||||
- token.motionDurationMid
|
||||
- token.motionEaseInOut
|
||||
- 包围盒属性
|
||||
- token.paddingSM
|
||||
- token.marginLG
|
||||
|
||||
|
||||
## Lobe UI 包含的组件
|
||||
|
||||
- 不知道 @lobehub/ui 的组件怎么用,有哪些属性,就自己搜下这个项目其它地方怎么用的,不要瞎猜,大部分组件都是在 antd 的基础上扩展了属性
|
||||
- 具体用法不懂可以联网搜索,例如 ActionIcon 就爬取 https://ui.lobehub.com/components/action-icon
|
||||
|
||||
- General
|
||||
ActionIcon
|
||||
ActionIconGroup
|
||||
Block
|
||||
Button
|
||||
Icon
|
||||
- Data Display
|
||||
Avatar
|
||||
Collapse
|
||||
FileTypeIcon
|
||||
FluentEmoji
|
||||
GuideCard
|
||||
Highlighter
|
||||
Hotkey
|
||||
Image
|
||||
List
|
||||
Markdown
|
||||
MaterialFileTypeIcon
|
||||
Mermaid
|
||||
Segmented
|
||||
Snippet
|
||||
SortableList
|
||||
Tag
|
||||
Tooltip
|
||||
Video
|
||||
- Data Entry
|
||||
AutoComplete
|
||||
CodeEditor
|
||||
ColorSwatches
|
||||
CopyButton
|
||||
DatePicker
|
||||
EditableText
|
||||
EmojiPicker
|
||||
Form
|
||||
FormModal
|
||||
HotkeyInput
|
||||
ImageSelect
|
||||
Input
|
||||
SearchBar
|
||||
Select
|
||||
SliderWithInput
|
||||
ThemeSwitch
|
||||
- Feedback
|
||||
Alert
|
||||
Drawer
|
||||
Modal
|
||||
- Layout
|
||||
DraggablePanel
|
||||
Footer
|
||||
Grid
|
||||
Header
|
||||
Layout
|
||||
MaskShadow
|
||||
ScrollShadow
|
||||
- Navigation
|
||||
Burger
|
||||
Dropdown
|
||||
Menu
|
||||
SideNav
|
||||
Tabs
|
||||
Toc
|
||||
- Theme
|
||||
ConfigProvider
|
||||
FontLoader
|
||||
ThemeProvider
|
||||
@@ -1,85 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
# LobeChat Cursor Rules System Guide
|
||||
|
||||
This document explains how the LobeChat project's Cursor rules system works and serves as an index for manually accessible rules.
|
||||
|
||||
## 🎯 Core Principle
|
||||
|
||||
**All rules are equal** - there are no priorities or "recommendations" between different rule sources. You should follow all applicable rules simultaneously.
|
||||
|
||||
## 📚 Four Ways to Access Rules
|
||||
|
||||
### 1. **Always Applied Rules** - `always_applied_workspace_rules`
|
||||
|
||||
- **What**: Core project guidelines that are always active
|
||||
- **Content**: Project tech stack, basic coding standards, output formatting rules
|
||||
- **Access**: No tools needed - automatically provided in every conversation
|
||||
|
||||
### 2. **Dynamic Context Rules** - `cursor_rules_context`
|
||||
|
||||
- **What**: Rules automatically matched based on files referenced in the conversation
|
||||
- **Trigger**: Only when user **explicitly @ mentions files** or **opens files in Cursor**
|
||||
- **Content**: May include brief descriptions or full rule content, depending on relevance
|
||||
- **Access**: No tools needed - automatically updated when files are referenced
|
||||
|
||||
### 3. **Agent Requestable Rules** - `agent_requestable_workspace_rules`
|
||||
|
||||
- **What**: Detailed operational guides that can be requested on-demand
|
||||
- **Access**: Use `fetch_rules` tool with rule names
|
||||
- **Examples**: `debug`, `i18n/i18n`, `code-review`
|
||||
|
||||
### 4. **Manual Rules Index** - This file + `read_file`
|
||||
|
||||
- **What**: Additional rules not covered by the above mechanisms
|
||||
- **Why needed**: Cursor's rule system only supports "agent request" or "auto attach" modes
|
||||
- **Access**: Use `read_file` tool to read specific `.mdc` files
|
||||
|
||||
## 🔧 When to Use `read_file` for Rules
|
||||
|
||||
Use `read_file` to access rules from the index below when:
|
||||
|
||||
1. **Gap identification**: You determine a rule is needed for the current task
|
||||
2. **No auto-trigger**: The rule isn't provided in `cursor_rules_context` (because relevant files weren't @ mentioned)
|
||||
3. **Not agent-requestable**: The rule isn't available via `fetch_rules`
|
||||
|
||||
## 📋 Available Rules Index
|
||||
|
||||
The following rules are available via `read_file` from the `.cursor/rules/` directory:
|
||||
|
||||
- `backend-architecture.mdc` – Backend layer architecture and design guidelines
|
||||
- `define-database-model.mdc` – Database model definition guidelines
|
||||
- `drizzle-schema-style-guide.mdc` – Style guide for defining Drizzle ORM schemas
|
||||
- `react-component.mdc` – React component style guide and conventions
|
||||
- `testing-guide.mdc` – Comprehensive testing guide for Vitest environment
|
||||
- `typescript.mdc` – TypeScript code style guide
|
||||
- `zustand-action-patterns.mdc` – Recommended patterns for organizing Zustand actions
|
||||
- `zustand-slice-organization.mdc` – Best practices for structuring Zustand slices
|
||||
|
||||
## ❌ Common Misunderstandings to Avoid
|
||||
|
||||
1. **"Priority confusion"**: There's no hierarchy between rule sources - they're complementary, not competitive
|
||||
2. **"Dynamic expectations"**: `cursor_rules_context` only updates when you @ files - it won't automatically include rules for tasks you're thinking about
|
||||
3. **"Tool redundancy"**: Each access method serves a different purpose - they're not alternatives to choose from
|
||||
|
||||
## 🛠️ Practical Workflow
|
||||
|
||||
```
|
||||
1. Start with always_applied_workspace_rules (automatic)
|
||||
2. Check cursor_rules_context for auto-matched rules (automatic)
|
||||
3. If you need specific guides: fetch_rules (manual)
|
||||
4. If you identify gaps: consult this index → read_file (manual)
|
||||
```
|
||||
|
||||
## Example Decision Flow
|
||||
|
||||
**Scenario**: Working on a new Zustand store slice
|
||||
|
||||
1. Follow always_applied_workspace_rules ✅
|
||||
2. If store files were @ mentioned → use cursor_rules_context rules ✅
|
||||
3. Need detailed Zustand guidance → `read_file('.cursor/rules/zustand-slice-organization.mdc')` ✅
|
||||
4. All rules apply simultaneously - no conflicts ✅
|
||||
@@ -1,43 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs:
|
||||
alwaysApply: true
|
||||
---
|
||||
|
||||
## System Role
|
||||
|
||||
You are an expert in full-stack Web development, proficient in JavaScript, TypeScript, CSS, React, Node.js, Next.js, Postgresql, all kinds of network protocols.
|
||||
|
||||
You are an expert in LLM and Ai art. In Ai image generation, you are proficient in Stable Diffusion and ComfyUI's architectural principles, workflows, model structures, parameter configurations, training methods, and inference optimization.
|
||||
|
||||
You are an expert in UI/UX design, proficient in web interaction patterns, responsive design, accessibility, and user behavior optimization. You excel at improving user retention and paid conversion rates through various interaction details.
|
||||
|
||||
## Problem Solving
|
||||
|
||||
- Before formulating any response, you must first gather context by using tools like codebase_search, grep_search, file_search, web_search, fetch_rules, context7, and read_file to avoid making assumptions.
|
||||
- When modifying existing code, clearly describe the differences and reasons for the changes
|
||||
- Provide alternative solutions that may be better overall or superior in specific aspects
|
||||
- Provide optimization suggestions for deprecated API usage
|
||||
- Cite sources whenever possible at the end, not inline
|
||||
- When you provide multiple solutions, provide the recommended solution first, and note it as `Recommended`
|
||||
- Express uncertainty when there might not be a correct answer
|
||||
- Admit when you don't know something instead of guessing
|
||||
|
||||
## Code Implementation
|
||||
|
||||
- Write correct, up-to-date, bug-free, fully functional, secure, maintainable and efficient code
|
||||
- First, think step-by-step: describe your plan in detailed pseudocode before implementation
|
||||
- Confirm the plan before writing code
|
||||
- Focus on maintainable over being performant
|
||||
- Leave NO TODOs, placeholders, or missing pieces
|
||||
- Be sure to reference file names
|
||||
- When you notice I have manually modified the code, that was definitely on purpose and do not revert them
|
||||
- If documentation links or required files are missing, ask for them before proceeding with the task rather than making assumptions
|
||||
- If you're unable to access or retrieve content from websites, please inform me immediately and request the specific information needed rather than making assumptions
|
||||
- You can use emojis, npm packages like `chalk`/`chalk-animation`/`terminal-link`/`gradient-string`/`log-symbols`/`boxen`/`consola`/`@clack/prompts` to create beautiful terminal output
|
||||
- Don't run `tsc --noEmit` to check ts syntax error, because our project is very large and the validate very slow
|
||||
|
||||
## Some logging rules
|
||||
|
||||
- Never log user private information like api key, etc
|
||||
- Don't use `import { log } from 'debug'` to log messages, because it will directly log the message to the console.
|
||||
@@ -1,453 +0,0 @@
|
||||
---
|
||||
globs: src/database/**/*.test.ts
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
## 🗃️ 数据库 Model 测试指南
|
||||
|
||||
### 测试环境选择 💡
|
||||
|
||||
数据库 Model 层通过环境变量控制数据库类型,在两种测试环境下有不同的数据库后端:客户端环境 (PGLite) 和 服务端环境 (PostgreSQL)
|
||||
|
||||
### ⚠️ 双环境验证要求
|
||||
|
||||
**对于所有 Model 测试,必须在两个环境下都验证通过**:
|
||||
|
||||
#### 完整验证流程
|
||||
|
||||
```bash
|
||||
# 1. 先在客户端环境测试(快速验证)
|
||||
npx vitest run --config vitest.config.ts src/database/models/__tests__/myModel.test.ts
|
||||
|
||||
# 2. 再在服务端环境测试(兼容性验证)
|
||||
npx vitest run --config vitest.config.server.ts src/database/models/__tests__/myModel.test.ts
|
||||
```
|
||||
|
||||
### 创建新 Model 测试的最佳实践 📋
|
||||
|
||||
#### 1. 参考现有实现和测试模板
|
||||
|
||||
创建新 Model 测试前,**必须先参考现有的实现模式**:
|
||||
|
||||
- **Model 实现参考**:
|
||||
- **测试模板参考**:
|
||||
- **复杂示例参考**:
|
||||
|
||||
#### 2. 用户权限检查 - 安全第一 🔒
|
||||
|
||||
这是**最关键的安全要求**。所有涉及用户数据的操作都必须包含用户权限检查:
|
||||
|
||||
**❌ 错误示例 - 存在安全漏洞**:
|
||||
|
||||
```typescript
|
||||
// 危险:缺少用户权限检查,任何用户都能操作任何数据
|
||||
update = async (id: string, data: Partial<MyModel>) => {
|
||||
return this.db
|
||||
.update(myTable)
|
||||
.set(data)
|
||||
.where(eq(myTable.id, id)) // ❌ 只检查 ID,没有检查 userId
|
||||
.returning();
|
||||
};
|
||||
```
|
||||
|
||||
**✅ 正确示例 - 安全的实现**:
|
||||
|
||||
```typescript
|
||||
// 安全:必须同时匹配 ID 和 userId
|
||||
update = async (id: string, data: Partial<MyModel>) => {
|
||||
return this.db
|
||||
.update(myTable)
|
||||
.set(data)
|
||||
.where(
|
||||
and(
|
||||
eq(myTable.id, id),
|
||||
eq(myTable.userId, this.userId), // ✅ 用户权限检查
|
||||
),
|
||||
)
|
||||
.returning();
|
||||
};
|
||||
```
|
||||
|
||||
**必须进行用户权限检查的方法**:
|
||||
|
||||
- `update()` - 更新操作
|
||||
- `delete()` - 删除操作
|
||||
- `findById()` - 查找特定记录
|
||||
- 任何涉及特定记录的查询或修改操作
|
||||
|
||||
#### 3. 测试文件结构和必测场景
|
||||
|
||||
**基本测试结构**:
|
||||
|
||||
```typescript
|
||||
// @vitest-environment node
|
||||
describe('MyModel', () => {
|
||||
describe('create', () => {
|
||||
it('should create a new record');
|
||||
it('should handle edge cases');
|
||||
});
|
||||
|
||||
describe('queryAll', () => {
|
||||
it('should return records for current user only');
|
||||
it('should handle empty results');
|
||||
});
|
||||
|
||||
describe('update', () => {
|
||||
it('should update own records');
|
||||
it('should NOT update other users records'); // 🔒 安全测试
|
||||
});
|
||||
|
||||
describe('delete', () => {
|
||||
it('should delete own records');
|
||||
it('should NOT delete other users records'); // 🔒 安全测试
|
||||
});
|
||||
|
||||
describe('user isolation', () => {
|
||||
it('should enforce user data isolation'); // 🔒 核心安全测试
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**必须测试的安全场景** 🔒:
|
||||
|
||||
```typescript
|
||||
it('should not update records of other users', async () => {
|
||||
// 创建其他用户的记录
|
||||
const [otherUserRecord] = await serverDB
|
||||
.insert(myTable)
|
||||
.values({ userId: 'other-user', data: 'original' })
|
||||
.returning();
|
||||
|
||||
// 尝试更新其他用户的记录
|
||||
const result = await myModel.update(otherUserRecord.id, { data: 'hacked' });
|
||||
|
||||
// 应该返回 undefined 或空数组(因为权限检查失败)
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
// 验证原始数据未被修改
|
||||
const unchanged = await serverDB.query.myTable.findFirst({
|
||||
where: eq(myTable.id, otherUserRecord.id),
|
||||
});
|
||||
expect(unchanged?.data).toBe('original'); // 数据应该保持不变
|
||||
});
|
||||
```
|
||||
|
||||
#### 4. Mock 外部依赖服务
|
||||
|
||||
如果 Model 依赖外部服务(如 FileService),需要正确 Mock:
|
||||
|
||||
**设置 Mock**:
|
||||
|
||||
```typescript
|
||||
// 在文件顶部设置 Mock
|
||||
const mockGetFullFileUrl = vi.fn();
|
||||
vi.mock('@/server/services/file', () => ({
|
||||
FileService: vi.fn().mockImplementation(() => ({
|
||||
getFullFileUrl: mockGetFullFileUrl,
|
||||
})),
|
||||
}));
|
||||
|
||||
// 在 beforeEach 中重置和配置 Mock
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
mockGetFullFileUrl.mockImplementation((url: string) => `https://example.com/${url}`);
|
||||
});
|
||||
```
|
||||
|
||||
**验证 Mock 调用**:
|
||||
|
||||
```typescript
|
||||
it('should process URLs through FileService', async () => {
|
||||
// ... 测试逻辑
|
||||
|
||||
// 验证 Mock 被正确调用
|
||||
expect(mockGetFullFileUrl).toHaveBeenCalledWith('expected-url');
|
||||
expect(mockGetFullFileUrl).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
```
|
||||
|
||||
#### 5. 数据库状态管理
|
||||
|
||||
**正确的数据清理模式**:
|
||||
|
||||
```typescript
|
||||
const userId = 'test-user';
|
||||
const otherUserId = 'other-user';
|
||||
|
||||
beforeEach(async () => {
|
||||
// 清理用户表(级联删除相关数据)
|
||||
await serverDB.delete(users);
|
||||
|
||||
// 创建测试用户
|
||||
await serverDB.insert(users).values([{ id: userId }, { id: otherUserId }]);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// 清理测试数据
|
||||
await serverDB.delete(users);
|
||||
});
|
||||
```
|
||||
|
||||
#### 6. 测试数据类型和外键约束处理 ⚠️
|
||||
|
||||
**必须使用 Schema 导出的类型**:
|
||||
|
||||
```typescript
|
||||
// ✅ 正确:使用 schema 导出的类型
|
||||
import { NewGeneration, NewGenerationBatch } from '../../schemas';
|
||||
|
||||
const testBatch: NewGenerationBatch = {
|
||||
userId,
|
||||
generationTopicId: 'test-topic-id',
|
||||
provider: 'test-provider',
|
||||
model: 'test-model',
|
||||
prompt: 'Test prompt for image generation',
|
||||
width: 1024,
|
||||
height: 1024,
|
||||
config: {
|
||||
/* ... */
|
||||
},
|
||||
};
|
||||
|
||||
const testGeneration: NewGeneration = {
|
||||
id: 'test-gen-id',
|
||||
generationBatchId: 'test-batch-id',
|
||||
asyncTaskId: null, // 处理外键约束
|
||||
fileId: null, // 处理外键约束
|
||||
seed: 12345,
|
||||
userId,
|
||||
};
|
||||
```
|
||||
|
||||
```typescript
|
||||
// ❌ 错误:没有类型声明或使用错误类型
|
||||
const testBatch = {
|
||||
// 缺少类型声明
|
||||
generationTopicId: 'test-topic-id',
|
||||
// ...
|
||||
};
|
||||
|
||||
const testGeneration = {
|
||||
// 缺少类型声明
|
||||
asyncTaskId: 'invalid-uuid', // 外键约束错误
|
||||
fileId: 'non-existent-file', // 外键约束错误
|
||||
// ...
|
||||
};
|
||||
```
|
||||
|
||||
**外键约束处理策略**:
|
||||
|
||||
1. **使用 null 值**: 对于可选的外键字段,使用 null 避免约束错误
|
||||
2. **创建关联记录**: 如果需要测试关联关系,先创建被引用的记录
|
||||
3. **理解约束关系**: 了解哪些字段有外键约束,避免引用不存在的记录
|
||||
|
||||
```typescript
|
||||
// 外键约束处理示例
|
||||
beforeEach(async () => {
|
||||
// 清理数据库
|
||||
await serverDB.delete(users);
|
||||
|
||||
// 创建测试用户
|
||||
await serverDB.insert(users).values([{ id: userId }]);
|
||||
|
||||
// 如果需要测试文件关联,创建文件记录
|
||||
if (needsFileAssociation) {
|
||||
await serverDB.insert(files).values({
|
||||
id: 'test-file-id',
|
||||
userId,
|
||||
name: 'test.jpg',
|
||||
url: 'test-url',
|
||||
size: 1024,
|
||||
fileType: 'image/jpeg',
|
||||
});
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
**排序测试的可预测性**:
|
||||
|
||||
```typescript
|
||||
// ✅ 正确:使用明确的时间戳确保排序结果可预测
|
||||
it('should find batches by topic id in correct order', async () => {
|
||||
const oldDate = new Date('2024-01-01T10:00:00Z');
|
||||
const newDate = new Date('2024-01-02T10:00:00Z');
|
||||
|
||||
const batch1 = { ...testBatch, prompt: 'First batch', userId, createdAt: oldDate };
|
||||
const batch2 = { ...testBatch, prompt: 'Second batch', userId, createdAt: newDate };
|
||||
|
||||
await serverDB.insert(generationBatches).values([batch1, batch2]);
|
||||
|
||||
const results = await generationBatchModel.findByTopicId(testTopic.id);
|
||||
|
||||
expect(results[0].prompt).toBe('Second batch'); // 最新优先 (desc order)
|
||||
expect(results[1].prompt).toBe('First batch');
|
||||
});
|
||||
```
|
||||
|
||||
```typescript
|
||||
// ❌ 错误:依赖数据库的默认时间戳,结果不可预测
|
||||
it('should find batches by topic id', async () => {
|
||||
const batch1 = { ...testBatch, prompt: 'First batch', userId };
|
||||
const batch2 = { ...testBatch, prompt: 'Second batch', userId };
|
||||
|
||||
await serverDB.insert(generationBatches).values([batch1, batch2]);
|
||||
|
||||
// 插入顺序和数据库时间戳可能不一致,导致测试不稳定
|
||||
const results = await generationBatchModel.findByTopicId(testTopic.id);
|
||||
expect(results[0].prompt).toBe('Second batch'); // 可能失败
|
||||
});
|
||||
```
|
||||
|
||||
### 常见问题和解决方案 💡
|
||||
|
||||
#### 问题 1:权限检查缺失导致安全漏洞
|
||||
|
||||
**现象**: 测试失败,用户能修改其他用户的数据 **解决**: 在 Model 的 `update` 和 `delete` 方法中添加 `and(eq(table.id, id), eq(table.userId, this.userId))`
|
||||
|
||||
#### 问题 2:Mock 未生效或验证失败
|
||||
|
||||
**现象**: `undefined is not a spy` 错误 **解决**: 检查 Mock 设置位置和方式,确保在测试文件顶部设置,在 `beforeEach` 中重置
|
||||
|
||||
#### 问题 3:测试数据污染
|
||||
|
||||
**现象**: 测试间相互影响,结果不稳定 **解决**: 在 `beforeEach` 和 `afterEach` 中正确清理数据库状态
|
||||
|
||||
#### 问题 4:外部依赖导致测试失败
|
||||
|
||||
**现象**: 因为真实的外部服务调用导致测试不稳定 **解决**: Mock 所有外部依赖,使测试更可控和快速
|
||||
|
||||
#### 问题 5:外键约束违反导致测试失败
|
||||
|
||||
**现象**: `insert or update on table "xxx" violates foreign key constraint` **解决**:
|
||||
|
||||
- 将可选外键字段设为 `null` 而不是无效的字符串值
|
||||
- 或者先创建被引用的记录,再创建当前记录
|
||||
|
||||
```typescript
|
||||
// ❌ 错误:无效的外键值
|
||||
const testData = {
|
||||
asyncTaskId: 'invalid-uuid', // 表中不存在此记录
|
||||
fileId: 'non-existent-file', // 表中不存在此记录
|
||||
};
|
||||
|
||||
// ✅ 正确:使用 null 值
|
||||
const testData = {
|
||||
asyncTaskId: null, // 避免外键约束
|
||||
fileId: null, // 避免外键约束
|
||||
};
|
||||
|
||||
// ✅ 或者:先创建被引用的记录
|
||||
beforeEach(async () => {
|
||||
const [asyncTask] = await serverDB.insert(asyncTasks).values({
|
||||
id: 'valid-task-id',
|
||||
status: 'pending',
|
||||
type: 'generation',
|
||||
}).returning();
|
||||
|
||||
const testData = {
|
||||
asyncTaskId: asyncTask.id, // 使用有效的外键值
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
#### 问题 6:排序测试结果不一致
|
||||
|
||||
**现象**: 相同的测试有时通过,有时失败,特别是涉及排序的测试 **解决**: 使用明确的时间戳,不要依赖数据库的默认时间戳
|
||||
|
||||
```typescript
|
||||
// ❌ 错误:依赖插入顺序和默认时间戳
|
||||
await serverDB.insert(table).values([data1, data2]); // 时间戳不可预测
|
||||
|
||||
// ✅ 正确:明确指定时间戳
|
||||
const oldDate = new Date('2024-01-01T10:00:00Z');
|
||||
const newDate = new Date('2024-01-02T10:00:00Z');
|
||||
await serverDB.insert(table).values([
|
||||
{ ...data1, createdAt: oldDate },
|
||||
{ ...data2, createdAt: newDate },
|
||||
]);
|
||||
```
|
||||
|
||||
#### 问题 7:Mock 验证失败或调用次数不匹配
|
||||
|
||||
**现象**: `expect(mockFunction).toHaveBeenCalledWith(...)` 失败 **解决**:
|
||||
|
||||
- 检查 Mock 函数的实际调用参数和期望参数是否完全匹配
|
||||
- 确认 Mock 在正确的时机被重置和配置
|
||||
- 使用 `toHaveBeenCalledTimes()` 验证调用次数
|
||||
|
||||
```typescript
|
||||
// 在 beforeEach 中正确配置 Mock
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks(); // 重置所有 Mock
|
||||
|
||||
mockGetFullFileUrl.mockImplementation((url: string) => `https://example.com/${url}`);
|
||||
mockTransformGeneration.mockResolvedValue({
|
||||
id: 'test-id',
|
||||
// ... 其他字段
|
||||
});
|
||||
});
|
||||
|
||||
// 测试中验证 Mock 调用
|
||||
it('should call FileService with correct parameters', async () => {
|
||||
await model.someMethod();
|
||||
|
||||
// 验证调用参数
|
||||
expect(mockGetFullFileUrl).toHaveBeenCalledWith('expected-url');
|
||||
// 验证调用次数
|
||||
expect(mockGetFullFileUrl).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
```
|
||||
|
||||
### Model 测试检查清单 ✅
|
||||
|
||||
创建 Model 测试时,请确保以下各项都已完成:
|
||||
|
||||
#### 🔧 基础配置
|
||||
|
||||
- [ ] **双环境验证** - 在客户端环境 (vitest.config.ts) 和服务端环境 (vitest.config.server.ts) 下都测试通过
|
||||
- [ ] 参考了 `_template.ts` 和现有 Model 的实现模式
|
||||
- [ ] **使用正确的 Schema 类型** - 测试数据使用 `NewXxx` 类型声明,如 `NewGenerationBatch`、`NewGeneration`
|
||||
|
||||
#### 🔒 安全测试
|
||||
|
||||
- [ ] **所有涉及用户数据的操作都包含用户权限检查**
|
||||
- [ ] 包含了用户权限隔离的安全测试
|
||||
- [ ] 测试了用户无法访问其他用户数据的场景
|
||||
|
||||
#### 🗃️ 数据处理
|
||||
|
||||
- [ ] **正确处理外键约束** - 使用 `null` 值或先创建被引用记录
|
||||
- [ ] **排序测试使用明确时间戳** - 不依赖数据库默认时间,确保结果可预测
|
||||
- [ ] 在 `beforeEach` 和 `afterEach` 中正确管理数据库状态
|
||||
- [ ] 所有测试都能独立运行且互不干扰
|
||||
|
||||
#### 🎭 Mock 和外部依赖
|
||||
|
||||
- [ ] 正确 Mock 了外部依赖服务 (如 FileService、GenerationModel)
|
||||
- [ ] 在 `beforeEach` 中重置和配置 Mock
|
||||
- [ ] 验证了 Mock 服务的调用参数和次数
|
||||
- [ ] 测试了外部服务错误场景的处理
|
||||
|
||||
#### 📋 测试覆盖
|
||||
|
||||
- [ ] 测试覆盖了所有主要方法 (create, query, update, delete)
|
||||
- [ ] 测试了边界条件和错误场景
|
||||
- [ ] 包含了空结果处理的测试
|
||||
- [ ] **确认两个环境下的测试结果一致**
|
||||
|
||||
#### 🚨 常见问题检查
|
||||
|
||||
- [ ] 没有外键约束违反错误
|
||||
- [ ] 排序测试结果稳定可预测
|
||||
- [ ] Mock 验证无失败
|
||||
- [ ] 无测试数据污染问题
|
||||
|
||||
### 安全警告 ⚠️
|
||||
|
||||
**数据库 Model 层是安全的第一道防线**。如果 Model 层缺少用户权限检查:
|
||||
|
||||
1. **任何用户都能访问和修改其他用户的数据**
|
||||
2. **即使上层有权限检查,也可能被绕过**
|
||||
3. **可能导致严重的数据泄露和安全事故**
|
||||
|
||||
因此,**每个涉及用户数据的 Model 方法都必须包含用户权限检查,且必须有对应的安全测试来验证这些检查的有效性**。
|
||||
@@ -1,80 +0,0 @@
|
||||
---
|
||||
description: Electron IPC 接口测试策略
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
### Electron IPC 接口测试策略 🖥️
|
||||
|
||||
对于涉及 Electron IPC 接口的测试,由于提供真实的 Electron 环境比较复杂,采用 **Mock 返回值** 的方式进行测试。
|
||||
|
||||
#### 基本 Mock 设置
|
||||
|
||||
```typescript
|
||||
import { vi } from 'vitest';
|
||||
|
||||
import { electronIpcClient } from '@/server/modules/ElectronIPCClient';
|
||||
|
||||
// Mock Electron IPC 客户端
|
||||
vi.mock('@/server/modules/ElectronIPCClient', () => ({
|
||||
electronIpcClient: {
|
||||
getFilePathById: vi.fn(),
|
||||
deleteFiles: vi.fn(),
|
||||
// 根据需要添加其他 IPC 方法
|
||||
},
|
||||
}));
|
||||
```
|
||||
|
||||
#### 在测试中设置 Mock 行为
|
||||
|
||||
```typescript
|
||||
beforeEach(() => {
|
||||
// 重置所有 Mock
|
||||
vi.resetAllMocks();
|
||||
|
||||
// 设置默认的 Mock 返回值
|
||||
vi.mocked(electronIpcClient.getFilePathById).mockResolvedValue('/path/to/file.txt');
|
||||
vi.mocked(electronIpcClient.deleteFiles).mockResolvedValue({
|
||||
success: true,
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
#### 测试不同场景的示例
|
||||
|
||||
```typescript
|
||||
it('应该处理文件删除成功的情况', async () => {
|
||||
// 设置成功场景的 Mock
|
||||
vi.mocked(electronIpcClient.deleteFiles).mockResolvedValue({
|
||||
success: true,
|
||||
});
|
||||
|
||||
const result = await service.deleteFiles(['desktop://file1.txt']);
|
||||
|
||||
expect(electronIpcClient.deleteFiles).toHaveBeenCalledWith(['desktop://file1.txt']);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('应该处理文件删除失败的情况', async () => {
|
||||
// 设置失败场景的 Mock
|
||||
vi.mocked(electronIpcClient.deleteFiles).mockRejectedValue(new Error('删除失败'));
|
||||
|
||||
const result = await service.deleteFiles(['desktop://file1.txt']);
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.errors).toBeDefined();
|
||||
});
|
||||
```
|
||||
|
||||
#### Mock 策略的优势
|
||||
|
||||
1. **环境简化**: 避免了复杂的 Electron 环境搭建
|
||||
2. **测试可控**: 可以精确控制 IPC 调用的返回值和行为
|
||||
3. **场景覆盖**: 容易测试各种成功/失败场景
|
||||
4. **执行速度**: Mock 调用比真实 IPC 调用更快
|
||||
|
||||
#### 注意事项
|
||||
|
||||
- **Mock 准确性**: 确保 Mock 的行为与真实 IPC 接口行为一致
|
||||
- **类型安全**: 使用 `vi.mocked()` 确保类型安全
|
||||
- **Mock 重置**: 在 `beforeEach` 中重置 Mock 状态,避免测试间干扰
|
||||
- **调用验证**: 不仅要验证返回值,还要验证 IPC 方法是否被正确调用
|
||||
@@ -1,496 +0,0 @@
|
||||
---
|
||||
globs: *.test.ts,*.test.tsx
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# 测试指南 - LobeChat Testing Guide
|
||||
|
||||
## 🧪 测试环境概览
|
||||
|
||||
LobeChat 项目使用 Vitest 测试库,配置了两种不同的测试环境:
|
||||
|
||||
### 客户端测试环境 (DOM Environment)
|
||||
|
||||
- **配置文件**: [vitest.config.ts](mdc:vitest.config.ts)
|
||||
- **环境**: Happy DOM (浏览器环境模拟)
|
||||
- **数据库**: PGLite (浏览器环境的 PostgreSQL)
|
||||
- **用途**: 测试前端组件、客户端逻辑、React 组件等
|
||||
- **设置文件**: [tests/setup.ts](mdc:tests/setup.ts)
|
||||
|
||||
### 服务端测试环境 (Node Environment)
|
||||
|
||||
- **配置文件**: [vitest.config.server.ts](mdc:vitest.config.server.ts)
|
||||
- **环境**: Node.js
|
||||
- **数据库**: 真实的 PostgreSQL 数据库
|
||||
- **并发限制**: 单线程运行 (`singleFork: true`)
|
||||
- **用途**: 测试数据库模型、服务端逻辑、API 端点等
|
||||
- **设置文件**: [tests/setup-db.ts](mdc:tests/setup-db.ts)
|
||||
|
||||
## 🚀 测试运行命令
|
||||
|
||||
**🚨 性能警告**: 项目包含 3000+ 测试用例,完整运行需要约 10 分钟。务必使用文件过滤或测试名称过滤。
|
||||
|
||||
### ✅ 正确的命令格式
|
||||
|
||||
```bash
|
||||
# 运行所有客户端/服务端测试
|
||||
npx vitest run --config vitest.config.ts # 客户端测试
|
||||
npx vitest run --config vitest.config.server.ts # 服务端测试
|
||||
|
||||
# 运行特定测试文件 (支持模糊匹配)
|
||||
npx vitest run --config vitest.config.ts user.test.ts
|
||||
|
||||
# 运行特定测试用例名称 (使用 -t 参数)
|
||||
npx vitest run --config vitest.config.ts -t "test case name"
|
||||
|
||||
# 组合使用文件和测试名称过滤
|
||||
npx vitest run --config vitest.config.ts filename.test.ts -t "specific test"
|
||||
|
||||
# 生成覆盖率报告 (使用 --coverage 参数)
|
||||
npx vitest run --config vitest.config.ts --coverage
|
||||
```
|
||||
|
||||
### ❌ 避免的命令格式
|
||||
|
||||
```bash
|
||||
# ❌ 这些命令会运行所有 3000+ 测试用例,耗时约 10 分钟!
|
||||
npm test
|
||||
npm test some-file.test.ts
|
||||
|
||||
# ❌ 不要使用裸 vitest (会进入 watch 模式)
|
||||
vitest test-file.test.ts
|
||||
```
|
||||
|
||||
## 🔧 测试修复原则
|
||||
|
||||
### 核心原则 ⚠️
|
||||
|
||||
1. **充分阅读测试代码**: 在修复测试之前,必须完整理解测试的意图和实现
|
||||
2. **测试优先修复**: 如果是测试本身写错了,修改测试而不是实现代码
|
||||
3. **专注单一问题**: 只修复指定的测试,不要添加额外测试或功能
|
||||
4. **不自作主张**: 不要因为发现其他问题就直接修改,先提出再讨论
|
||||
|
||||
### 测试协作最佳实践 🤝
|
||||
|
||||
基于实际开发经验总结的重要协作原则:
|
||||
|
||||
#### 1. 失败处理策略
|
||||
|
||||
**核心原则**: 避免盲目重试,快速识别问题并寻求帮助。
|
||||
|
||||
- **失败阈值**: 当连续尝试修复测试 1-2 次都失败后,应立即停止继续尝试
|
||||
- **问题总结**: 分析失败原因,整理已尝试的解决方案及其失败原因
|
||||
- **寻求帮助**: 带着清晰的问题摘要和尝试记录向团队寻求帮助
|
||||
- **避免陷阱**: 不要陷入"不断尝试相同或类似方法"的循环
|
||||
|
||||
```typescript
|
||||
// ❌ 错误做法:连续失败后继续盲目尝试
|
||||
// 第3次、第4次仍在用相似的方法修复同一个问题
|
||||
|
||||
// ✅ 正确做法:失败1-2次后总结问题
|
||||
/*
|
||||
问题总结:
|
||||
1. 尝试过的方法:修改 mock 数据结构
|
||||
2. 失败原因:仍然提示类型不匹配
|
||||
3. 具体错误:Expected 'UserData' but received 'UserProfile'
|
||||
4. 需要帮助:不确定最新的 UserData 接口定义
|
||||
*/
|
||||
```
|
||||
|
||||
#### 2. 测试用例命名规范
|
||||
|
||||
**核心原则**: 测试应该关注"行为",而不是"实现细节"。
|
||||
|
||||
- **描述业务场景**: `describe` 和 `it` 的标题应该描述具体的业务场景和预期行为
|
||||
- **避免实现绑定**: 不要在测试名称中提及具体的代码行号、覆盖率目标或实现细节
|
||||
- **保持稳定性**: 测试名称应该在代码重构后仍然有意义
|
||||
|
||||
```typescript
|
||||
// ❌ 错误的测试命名
|
||||
describe('User component coverage', () => {
|
||||
it('covers line 45-50 in getUserData', () => {
|
||||
// 为了覆盖第45-50行而写的测试
|
||||
});
|
||||
|
||||
it('tests the else branch', () => {
|
||||
// 仅为了测试某个分支而存在
|
||||
});
|
||||
});
|
||||
|
||||
// ✅ 正确的测试命名
|
||||
describe('<UserAvatar />', () => {
|
||||
it('should render fallback icon when image url is not provided', () => {
|
||||
// 测试具体的业务场景,自然会覆盖相关代码分支
|
||||
});
|
||||
|
||||
it('should display user initials when avatar image fails to load', () => {
|
||||
// 描述用户行为和预期结果
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**覆盖率提升的正确思路**:
|
||||
|
||||
- ✅ 通过设计各种业务场景(正常流程、边缘情况、错误处理)来自然提升覆盖率
|
||||
- ❌ 不要为了达到覆盖率数字而写测试,更不要在测试中注释"为了覆盖 xxx 行"
|
||||
|
||||
#### 3. 测试组织结构
|
||||
|
||||
**核心原则**: 维护清晰的测试层次结构,避免冗余的顶级测试块。
|
||||
|
||||
- **复用现有结构**: 添加新测试时,优先在现有的 `describe` 块中寻找合适的位置
|
||||
- **逻辑分组**: 相关的测试用例应该组织在同一个 `describe` 块内
|
||||
- **避免碎片化**: 不要为了单个测试用例就创建新的顶级 `describe` 块
|
||||
|
||||
```typescript
|
||||
// ❌ 错误的组织方式:创建过多顶级块
|
||||
describe('<UserProfile />', () => {
|
||||
it('should render user name', () => {});
|
||||
});
|
||||
|
||||
describe('UserProfile new prop test', () => {
|
||||
// 不必要的新块
|
||||
it('should handle email display', () => {});
|
||||
});
|
||||
|
||||
describe('UserProfile edge cases', () => {
|
||||
// 不必要的新块
|
||||
it('should handle missing avatar', () => {});
|
||||
});
|
||||
|
||||
// ✅ 正确的组织方式:合并相关测试
|
||||
describe('<UserProfile />', () => {
|
||||
it('should render user name', () => {});
|
||||
|
||||
it('should handle email display', () => {});
|
||||
|
||||
it('should handle missing avatar', () => {});
|
||||
|
||||
describe('when user data is incomplete', () => {
|
||||
// 只有在有多个相关子场景时才创建子组
|
||||
it('should show placeholder for missing name', () => {});
|
||||
it('should hide email section when email is undefined', () => {});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**组织决策流程**:
|
||||
|
||||
1. 是否存在逻辑相关的现有 `describe` 块? → 如果有,添加到其中
|
||||
2. 是否有多个(3个以上)相关的测试用例? → 如果有,可以考虑创建新的子 `describe`
|
||||
3. 是否是独立的、无关联的功能模块? → 如果是,才考虑创建新的顶级 `describe`
|
||||
|
||||
### 测试修复流程
|
||||
|
||||
1. **复现问题**: 定位并运行失败的测试,确认能在本地复现
|
||||
2. **分析原因**: 阅读测试代码、错误日志和相关文件的 Git 修改历史
|
||||
3. **建立假设**: 判断问题出在测试逻辑、实现代码还是环境配置
|
||||
4. **修复验证**: 根据假设进行修复,重新运行测试确认通过
|
||||
5. **扩大验证**: 运行当前文件内所有测试,确保没有引入新问题
|
||||
6. **撰写总结**: 说明错误原因和修复方法
|
||||
|
||||
### 修复完成后的总结
|
||||
|
||||
测试修复完成后,应该提供简要说明,包括:
|
||||
|
||||
1. **错误原因分析**: 说明测试失败的根本原因
|
||||
- 测试逻辑错误
|
||||
- 实现代码bug
|
||||
- 环境配置问题
|
||||
- 依赖变更导致的问题
|
||||
|
||||
2. **修复方法说明**: 简述采用的修复方式
|
||||
- 修改了哪些文件
|
||||
- 采用了什么解决方案
|
||||
- 为什么选择这种修复方式
|
||||
|
||||
**示例格式**:
|
||||
|
||||
```markdown
|
||||
## 测试修复总结
|
||||
|
||||
**错误原因**: 测试中的 mock 数据格式与实际 API 返回格式不匹配,导致断言失败。
|
||||
|
||||
**修复方法**: 更新了测试文件中的 mock 数据结构,使其与最新的 API 响应格式保持一致。具体修改了 `user.test.ts` 中的 `mockUserData` 对象结构。
|
||||
```
|
||||
|
||||
## 🎯 测试编写最佳实践
|
||||
|
||||
### Mock 数据策略:追求"低成本的真实性" 📋
|
||||
|
||||
**核心原则**: 测试数据应默认追求真实性,只有在引入"高昂的测试成本"时才进行简化。
|
||||
|
||||
#### 什么是"高昂的测试成本"?
|
||||
|
||||
"高成本"指的是测试中引入了外部依赖,使测试变慢、不稳定或复杂:
|
||||
|
||||
- **文件 I/O 操作**:读写硬盘文件
|
||||
- **网络请求**:HTTP 调用、数据库连接
|
||||
- **系统调用**:获取系统时间、环境变量等
|
||||
|
||||
#### ✅ 推荐做法:Mock 依赖,保留真实数据
|
||||
|
||||
```typescript
|
||||
// ✅ 好的做法:Mock I/O 操作,但使用真实的文件内容格式
|
||||
describe('parseContentType', () => {
|
||||
beforeEach(() => {
|
||||
// Mock 文件读取操作(避免真实 I/O)
|
||||
vi.spyOn(fs, 'readFileSync').mockImplementation((path) => {
|
||||
// 但返回真实的文件内容格式
|
||||
if (path.includes('.pdf')) return '%PDF-1.4\n%âãÏÓ'; // 真实 PDF 文件头
|
||||
if (path.includes('.png')) return '\x89PNG\r\n\x1a\n'; // 真实 PNG 文件头
|
||||
return '';
|
||||
});
|
||||
});
|
||||
|
||||
it('should detect PDF content type correctly', () => {
|
||||
const result = parseContentType('/path/to/file.pdf');
|
||||
expect(result).toBe('application/pdf');
|
||||
});
|
||||
});
|
||||
|
||||
// ❌ 过度简化:使用不真实的数据
|
||||
describe('parseContentType', () => {
|
||||
it('should detect PDF content type correctly', () => {
|
||||
// 这种简化数据没有测试价值
|
||||
const result = parseContentType('fake-pdf-content');
|
||||
expect(result).toBe('application/pdf');
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
#### 🎯 真实标识符的价值
|
||||
|
||||
```typescript
|
||||
// ✅ 使用真实的提供商标识符
|
||||
it('should parse OpenAI model list correctly', () => {
|
||||
const result = parseModelString('openai', '+gpt-4,+gpt-3.5-turbo');
|
||||
expect(result.add).toHaveLength(2);
|
||||
expect(result.add[0].id).toBe('gpt-4');
|
||||
});
|
||||
|
||||
// ❌ 使用占位符标识符(价值较低)
|
||||
it('should parse model list correctly', () => {
|
||||
const result = parseModelString('test-provider', '+model1,+model2');
|
||||
expect(result.add).toHaveLength(2);
|
||||
// 这种测试对理解真实场景帮助不大
|
||||
});
|
||||
```
|
||||
|
||||
### 错误处理测试:测试"行为"而非"文本" ⚠️
|
||||
|
||||
**核心原则**: 测试应该验证程序在错误发生时的行为是可预测的,而不是验证易变的错误信息文本。
|
||||
|
||||
#### ✅ 推荐的错误测试方式
|
||||
|
||||
```typescript
|
||||
// ✅ 测试是否抛出错误
|
||||
it('should throw error when invalid input provided', () => {
|
||||
expect(() => processInput(null)).toThrow();
|
||||
});
|
||||
|
||||
// ✅ 测试错误类型(最推荐)
|
||||
it('should throw ValidationError for invalid data', () => {
|
||||
expect(() => validateUser({})).toThrow(ValidationError);
|
||||
});
|
||||
|
||||
// ✅ 测试错误属性而非消息文本
|
||||
it('should throw error with correct error code', () => {
|
||||
expect(() => processPayment({})).toThrow(
|
||||
expect.objectContaining({
|
||||
code: 'INVALID_PAYMENT_DATA',
|
||||
statusCode: 400,
|
||||
}),
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
#### ❌ 应避免的做法
|
||||
|
||||
```typescript
|
||||
// ❌ 过度依赖具体错误信息文本
|
||||
it('should throw specific error message', () => {
|
||||
expect(() => processUser({})).toThrow('用户数据不能为空,请检查输入参数');
|
||||
// 这种测试很脆弱,错误文案稍有修改就会失败
|
||||
});
|
||||
```
|
||||
|
||||
#### 🎯 例外情况:何时可以测试错误信息
|
||||
|
||||
```typescript
|
||||
// ✅ 测试标准 API 错误(这是契约的一部分)
|
||||
it('should return proper HTTP error for API', () => {
|
||||
expect(response.statusCode).toBe(400);
|
||||
expect(response.error).toBe('Bad Request');
|
||||
});
|
||||
|
||||
// ✅ 测试错误信息的关键部分(使用正则)
|
||||
it('should include field name in validation error', () => {
|
||||
expect(() => validateField('email', '')).toThrow(/email/i);
|
||||
});
|
||||
```
|
||||
|
||||
### 疑难解答:警惕模块污染 🚨
|
||||
|
||||
**识别信号**: 当你的测试出现以下"灵异"现象时,优先怀疑模块污染:
|
||||
|
||||
- 单独运行某个测试通过,但和其他测试一起运行就失败
|
||||
- 测试的执行顺序影响结果
|
||||
- Mock 设置看起来正确,但实际使用的是旧的 Mock 版本
|
||||
|
||||
#### 典型场景:动态 Mock 同一模块
|
||||
|
||||
```typescript
|
||||
// ❌ 容易出现模块污染的写法
|
||||
describe('ConfigService', () => {
|
||||
it('should work in development mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: true }));
|
||||
const { getSettings } = await import('./configService'); // 第一次加载
|
||||
expect(getSettings().debugMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should work in production mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: false }));
|
||||
const { getSettings } = await import('./configService'); // 可能使用缓存的旧版本!
|
||||
expect(getSettings().debugMode).toBe(false); // ❌ 可能失败
|
||||
});
|
||||
});
|
||||
|
||||
// ✅ 使用 resetModules 解决模块污染
|
||||
describe('ConfigService', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetModules(); // 清除模块缓存,确保每个测试都是干净的环境
|
||||
});
|
||||
|
||||
it('should work in development mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: true }));
|
||||
const { getSettings } = await import('./configService');
|
||||
expect(getSettings().debugMode).toBe(true);
|
||||
});
|
||||
|
||||
it('should work in production mode', async () => {
|
||||
vi.doMock('./config', () => ({ isDev: false }));
|
||||
const { getSettings } = await import('./configService');
|
||||
expect(getSettings().debugMode).toBe(false); // ✅ 测试通过
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
#### 🔧 排查和解决步骤
|
||||
|
||||
1. **识别问题**: 测试失败时,首先问自己:"是否有多个测试在 Mock 同一个模块?"
|
||||
2. **添加隔离**: 在 `beforeEach` 中添加 `vi.resetModules()`
|
||||
3. **验证修复**: 重新运行测试,确认问题解决
|
||||
|
||||
**记住**: `vi.resetModules()` 是解决测试"灵异"失败的终极武器,当常规调试方法都无效时,它往往能一针见血地解决问题。
|
||||
|
||||
## 📂 测试文件组织
|
||||
|
||||
### 文件命名约定
|
||||
|
||||
- **客户端测试**: `*.test.ts`, `*.test.tsx` (任意位置)
|
||||
- **服务端测试**: `src/database/models/**/*.test.ts`, `src/database/server/**/*.test.ts` (限定路径)
|
||||
|
||||
### 测试文件组织风格
|
||||
|
||||
项目采用 **测试文件与源文件同目录** 的组织风格:
|
||||
|
||||
- 测试文件放在对应源文件的同一目录下
|
||||
- 命名格式:`原文件名.test.ts` 或 `原文件名.test.tsx`
|
||||
|
||||
例如:
|
||||
|
||||
```plaintext
|
||||
src/components/Button/
|
||||
├── index.tsx # 源文件
|
||||
└── index.test.tsx # 测试文件
|
||||
```
|
||||
|
||||
## 🛠️ 测试调试技巧
|
||||
|
||||
### 测试调试步骤
|
||||
|
||||
1. **确定测试环境**: 根据文件路径选择正确的配置文件
|
||||
2. **隔离问题**: 使用 `-t` 参数只运行失败的测试用例
|
||||
3. **分析错误**: 仔细阅读错误信息、堆栈跟踪和最近的文件修改记录
|
||||
4. **添加调试**: 在测试中添加 `console.log` 了解执行流程
|
||||
|
||||
### TypeScript 类型处理 📝
|
||||
|
||||
在测试中,为了提高编写效率和可读性,可以适当放宽 TypeScript 类型检测:
|
||||
|
||||
#### ✅ 推荐的类型放宽策略
|
||||
|
||||
```typescript
|
||||
// ✅ 使用非空断言访问测试中确定存在的属性
|
||||
const result = await someFunction();
|
||||
expect(result!.data).toBeDefined();
|
||||
expect(result!.status).toBe('success');
|
||||
|
||||
// ✅ 使用 any 类型简化复杂的 Mock 设置
|
||||
const mockStream = new ReadableStream() as any;
|
||||
mockStream.toReadableStream = () => mockStream;
|
||||
```
|
||||
|
||||
#### 🎯 适用场景
|
||||
|
||||
- **Mock 对象**: 对于测试用的 Mock 数据,使用 `as any` 避免复杂的类型定义
|
||||
- **第三方库**: 处理复杂的第三方库类型时,适当使用 `any` 提高效率
|
||||
- **测试断言**: 在确定对象存在的测试场景中,使用 `!` 非空断言
|
||||
- **临时调试**: 快速编写测试时,先用 `any` 保证功能,后续可选择性地优化类型
|
||||
|
||||
#### ⚠️ 注意事项
|
||||
|
||||
- **适度使用**: 不要过度依赖 `any`,核心业务逻辑的类型仍应保持严格
|
||||
- **文档说明**: 对于使用 `any` 的复杂场景,添加注释说明原因
|
||||
- **测试覆盖**: 确保即使使用了 `any`,测试仍能有效验证功能正确性
|
||||
|
||||
### 检查最近修改记录 🔍
|
||||
|
||||
系统性地检查相关文件的修改历史是问题定位的关键步骤。
|
||||
|
||||
#### 三步检查法
|
||||
|
||||
**Step 1: 查看当前状态**
|
||||
|
||||
```bash
|
||||
git status # 查看未提交的修改
|
||||
git diff path/to/component.test.ts | cat # 查看测试文件修改
|
||||
git diff path/to/component.ts | cat # 查看实现文件修改
|
||||
```
|
||||
|
||||
**Step 2: 查看提交历史**
|
||||
|
||||
```bash
|
||||
git log --pretty=format:"%h %ad %s" --date=relative -3 path/to/component.ts | cat
|
||||
```
|
||||
|
||||
**Step 3: 查看具体修改内容**
|
||||
|
||||
```bash
|
||||
git show HEAD -- path/to/component.ts | cat # 查看最新提交的修改
|
||||
```
|
||||
|
||||
#### 时间相关性判断
|
||||
|
||||
- **24小时内的提交**: 🔴 **高度相关** - 很可能是直接原因
|
||||
- **1-7天内的提交**: 🟡 **中等相关** - 需要仔细分析
|
||||
- **超过1周的提交**: ⚪ **低相关性** - 除非重大重构
|
||||
|
||||
## 特殊场景的测试
|
||||
|
||||
针对一些特殊场景的测试,需要阅读相关 rules:
|
||||
|
||||
- [Electron IPC 接口测试策略](mdc:./electron-ipc-test.mdc)
|
||||
- [数据库 Model 测试指南](mdc:./db-model-test.mdc)
|
||||
|
||||
## 🎯 核心要点
|
||||
|
||||
- **命令格式**: 使用 `npx vitest run --config [config-file]` 并指定文件过滤
|
||||
- **修复原则**: 失败1-2次后寻求帮助,测试命名关注行为而非实现细节
|
||||
- **调试流程**: 复现 → 分析 → 假设 → 修复 → 验证 → 总结
|
||||
- **文件组织**: 优先在现有 `describe` 块中添加测试,避免创建冗余顶级块
|
||||
- **数据策略**: 默认追求真实性,只有高成本(I/O、网络等)时才简化
|
||||
- **错误测试**: 测试错误类型和行为,避免依赖具体的错误信息文本
|
||||
- **模块污染**: 测试"灵异"失败时,优先怀疑模块污染,使用 `vi.resetModules()` 解决
|
||||
- **安全要求**: Model 测试必须包含权限检查,并在双环境下验证通过
|
||||
@@ -1,21 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: *.ts,*.tsx,*.mts
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
TypeScript Code Style Guide:
|
||||
|
||||
- Avoid explicit type annotations when TypeScript can infer types.
|
||||
- Avoid defining `any` type variables (e.g., `let a: number;` instead of `let a;`).
|
||||
- Use the most accurate type possible (e.g., use `Record<PropertyKey, unknown>` instead of `object`).
|
||||
- Prefer `interface` over `type` (e.g., define react component props).
|
||||
- Use `as const satisfies XyzInterface` instead of `as const` when suitable
|
||||
- import index.ts module(directory module) like `@/db/index` instead of `@/db`
|
||||
- Instead of calling Date.now() multiple times, assign it to a constant once and reuse it. This ensures consistency and improves readability
|
||||
- Always refactor repeated logic into a reusable function
|
||||
- Don't remove meaningful code comments, be sure to keep original comments when providing applied code
|
||||
- Update the code comments when needed after you modify the related code
|
||||
- Please respect my prettier preferences when you provide code
|
||||
- Prefer object destructuring when accessing and using properties
|
||||
- Prefer async version api than sync version, eg: use readFile from 'fs/promises' instead of 'fs'
|
||||
@@ -1,360 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: src/store/**
|
||||
alwaysApply: false
|
||||
---
|
||||
# LobeChat Zustand Action 组织模式
|
||||
|
||||
本文档详细说明了 LobeChat 项目中 Zustand Action 的组织方式、命名规范和实现模式,特别关注乐观更新与后端服务的集成。
|
||||
|
||||
## Action 类型分层
|
||||
|
||||
LobeChat 的 Action 采用分层架构,明确区分不同职责:
|
||||
|
||||
### 1. Public Actions
|
||||
对外暴露的主要接口,供 UI 组件调用:
|
||||
- 命名:动词形式(`createTopic`, `sendMessage`, `updateTopicTitle`)
|
||||
- 职责:参数验证、流程编排、调用 internal actions
|
||||
- 示例:[src/store/chat/slices/topic/action.ts](mdc:src/store/chat/slices/topic/action.ts)
|
||||
|
||||
```typescript
|
||||
// Public Action 示例
|
||||
createTopic: async () => {
|
||||
const { activeId, internal_createTopic } = get();
|
||||
const messages = chatSelectors.activeBaseChats(get());
|
||||
|
||||
if (messages.length === 0) return;
|
||||
|
||||
const topicId = await internal_createTopic({
|
||||
sessionId: activeId,
|
||||
title: t('defaultTitle', { ns: 'topic' }),
|
||||
messages: messages.map((m) => m.id),
|
||||
});
|
||||
|
||||
return topicId;
|
||||
},
|
||||
```
|
||||
|
||||
### 2. Internal Actions (`internal_*`)
|
||||
内部实现细节,处理核心业务逻辑:
|
||||
- 命名:`internal_` 前缀 + 动词(`internal_createTopic`, `internal_updateMessageContent`)
|
||||
- 职责:乐观更新、服务调用、错误处理、状态同步
|
||||
- 不应该被 UI 组件直接调用
|
||||
|
||||
```typescript
|
||||
// Internal Action 示例 - 乐观更新模式
|
||||
internal_createTopic: async (params) => {
|
||||
const tmpId = Date.now().toString();
|
||||
|
||||
// 1. 立即更新前端状态(乐观更新)
|
||||
get().internal_dispatchTopic(
|
||||
{ type: 'addTopic', value: { ...params, id: tmpId } },
|
||||
'internal_createTopic',
|
||||
);
|
||||
get().internal_updateTopicLoading(tmpId, true);
|
||||
|
||||
// 2. 调用后端服务
|
||||
const topicId = await topicService.createTopic(params);
|
||||
get().internal_updateTopicLoading(tmpId, false);
|
||||
|
||||
// 3. 刷新数据确保一致性
|
||||
get().internal_updateTopicLoading(topicId, true);
|
||||
await get().refreshTopic();
|
||||
get().internal_updateTopicLoading(topicId, false);
|
||||
|
||||
return topicId;
|
||||
},
|
||||
```
|
||||
|
||||
### 3. Dispatch Methods (`internal_dispatch*`)
|
||||
专门处理状态更新的方法:
|
||||
- 命名:`internal_dispatch` + 实体名(`internal_dispatchTopic`, `internal_dispatchMessage`)
|
||||
- 职责:调用 reducer、更新 Zustand store、处理状态对比
|
||||
|
||||
```typescript
|
||||
// Dispatch Method 示例
|
||||
internal_dispatchTopic: (payload, action) => {
|
||||
const nextTopics = topicReducer(topicSelectors.currentTopics(get()), payload);
|
||||
const nextMap = { ...get().topicMaps, [get().activeId]: nextTopics };
|
||||
|
||||
if (isEqual(nextMap, get().topicMaps)) return;
|
||||
|
||||
set({ topicMaps: nextMap }, false, action ?? n(`dispatchTopic/${payload.type}`));
|
||||
},
|
||||
```
|
||||
|
||||
## 何时使用 Reducer 模式 vs. 简单 `set`
|
||||
|
||||
### 使用 Reducer 模式的场景
|
||||
|
||||
适用于复杂的数据结构管理,特别是:
|
||||
- 管理对象列表或映射(如 `messagesMap`, `topicMaps`)
|
||||
- 需要乐观更新的场景
|
||||
- 状态转换逻辑复杂
|
||||
- 需要类型安全的 action payload
|
||||
|
||||
```typescript
|
||||
// Reducer 模式示例 - 复杂消息状态管理
|
||||
export const messagesReducer = (state: ChatMessage[], payload: MessageDispatch): ChatMessage[] => {
|
||||
switch (payload.type) {
|
||||
case 'updateMessage': {
|
||||
return produce(state, (draftState) => {
|
||||
const index = draftState.findIndex((i) => i.id === payload.id);
|
||||
if (index < 0) return;
|
||||
draftState[index] = merge(draftState[index], {
|
||||
...payload.value,
|
||||
updatedAt: Date.now()
|
||||
});
|
||||
});
|
||||
}
|
||||
case 'createMessage': {
|
||||
return produce(state, (draftState) => {
|
||||
draftState.push({
|
||||
...payload.value,
|
||||
id: payload.id,
|
||||
createdAt: Date.now(),
|
||||
updatedAt: Date.now(),
|
||||
meta: {}
|
||||
});
|
||||
});
|
||||
}
|
||||
// ...其他复杂状态转换
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 使用简单 `set` 的场景
|
||||
|
||||
适用于简单状态更新:
|
||||
- 切换布尔值
|
||||
- 更新简单字符串/数字
|
||||
- 设置单一状态字段
|
||||
|
||||
```typescript
|
||||
// 简单 set 示例
|
||||
updateInputMessage: (message) => {
|
||||
if (isEqual(message, get().inputMessage)) return;
|
||||
set({ inputMessage: message }, false, n('updateInputMessage'));
|
||||
},
|
||||
|
||||
togglePortal: (open?: boolean) => {
|
||||
set({ showPortal: open ?? !get().showPortal }, false, 'togglePortal');
|
||||
},
|
||||
```
|
||||
|
||||
## 乐观更新实现模式
|
||||
|
||||
乐观更新是 LobeChat 中的核心模式,用于提供流畅的用户体验:
|
||||
|
||||
### 标准乐观更新流程
|
||||
|
||||
```typescript
|
||||
// 完整的乐观更新示例
|
||||
internal_updateMessageContent: async (id, content, extra) => {
|
||||
const { internal_dispatchMessage, refreshMessages } = get();
|
||||
|
||||
// 1. 立即更新前端状态(乐观更新)
|
||||
internal_dispatchMessage({
|
||||
id,
|
||||
type: 'updateMessage',
|
||||
value: { content },
|
||||
});
|
||||
|
||||
// 2. 调用后端服务
|
||||
await messageService.updateMessage(id, {
|
||||
content,
|
||||
tools: extra?.toolCalls ? internal_transformToolCalls(extra.toolCalls) : undefined,
|
||||
// ...其他字段
|
||||
});
|
||||
|
||||
// 3. 刷新确保数据一致性
|
||||
await refreshMessages();
|
||||
},
|
||||
```
|
||||
|
||||
### 创建操作的乐观更新
|
||||
|
||||
```typescript
|
||||
internal_createMessage: async (message, context) => {
|
||||
const { internal_createTmpMessage, refreshMessages, internal_toggleMessageLoading } = get();
|
||||
|
||||
let tempId = context?.tempMessageId;
|
||||
if (!tempId) {
|
||||
// 创建临时消息用于乐观更新
|
||||
tempId = internal_createTmpMessage(message);
|
||||
internal_toggleMessageLoading(true, tempId);
|
||||
}
|
||||
|
||||
try {
|
||||
const id = await messageService.createMessage(message);
|
||||
if (!context?.skipRefresh) {
|
||||
await refreshMessages();
|
||||
}
|
||||
internal_toggleMessageLoading(false, tempId);
|
||||
return id;
|
||||
} catch (e) {
|
||||
internal_toggleMessageLoading(false, tempId);
|
||||
// 错误处理:更新消息错误状态
|
||||
internal_dispatchMessage({
|
||||
id: tempId,
|
||||
type: 'updateMessage',
|
||||
value: { error: { type: ChatErrorType.CreateMessageError, message: e.message } },
|
||||
});
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
### 删除操作模式(不使用乐观更新)
|
||||
|
||||
删除操作通常不适合乐观更新,因为:
|
||||
- 删除是破坏性操作,错误恢复复杂
|
||||
- 用户对删除操作的即时反馈期望较低
|
||||
- 删除失败时恢复原状态会造成困惑
|
||||
|
||||
```typescript
|
||||
// 删除操作的标准模式 - 无乐观更新
|
||||
removeGenerationTopic: async (id: string) => {
|
||||
const { internal_removeGenerationTopic } = get();
|
||||
await internal_removeGenerationTopic(id);
|
||||
},
|
||||
|
||||
internal_removeGenerationTopic: async (id: string) => {
|
||||
// 1. 显示加载状态
|
||||
get().internal_updateGenerationTopicLoading(id, true);
|
||||
|
||||
try {
|
||||
// 2. 直接调用后端服务
|
||||
await generationTopicService.deleteTopic(id);
|
||||
|
||||
// 3. 刷新数据获取最新状态
|
||||
await get().refreshGenerationTopics();
|
||||
} finally {
|
||||
// 4. 确保清除加载状态(无论成功或失败)
|
||||
get().internal_updateGenerationTopicLoading(id, false);
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
删除操作的特点:
|
||||
- 直接调用服务,不预先更新状态
|
||||
- 依赖 loading 状态提供用户反馈
|
||||
- 操作完成后刷新整个列表确保一致性
|
||||
- 使用 `try/finally` 确保 loading 状态总是被清理
|
||||
|
||||
## 加载状态管理模式
|
||||
|
||||
LobeChat 使用统一的加载状态管理模式:
|
||||
|
||||
### 数组式加载状态
|
||||
|
||||
```typescript
|
||||
// 在 initialState.ts 中定义
|
||||
export interface ChatMessageState {
|
||||
messageLoadingIds: string[]; // 消息加载状态
|
||||
messageEditingIds: string[]; // 消息编辑状态
|
||||
chatLoadingIds: string[]; // 对话生成状态
|
||||
}
|
||||
|
||||
// 在 action 中管理
|
||||
internal_toggleMessageLoading: (loading, id) => {
|
||||
set({
|
||||
messageLoadingIds: toggleBooleanList(get().messageLoadingIds, id, loading),
|
||||
}, false, `internal_toggleMessageLoading/${loading ? 'start' : 'end'}`);
|
||||
},
|
||||
```
|
||||
|
||||
### 统一的加载状态工具
|
||||
|
||||
```typescript
|
||||
// 通用的加载状态切换工具
|
||||
internal_toggleLoadingArrays: (key, loading, id, action) => {
|
||||
const abortControllerKey = `${key}AbortController`;
|
||||
|
||||
if (loading) {
|
||||
const abortController = new AbortController();
|
||||
set({
|
||||
[abortControllerKey]: abortController,
|
||||
[key]: toggleBooleanList(get()[key] as string[], id!, loading),
|
||||
}, false, action);
|
||||
return abortController;
|
||||
} else {
|
||||
set({
|
||||
[abortControllerKey]: undefined,
|
||||
[key]: id ? toggleBooleanList(get()[key] as string[], id, loading) : [],
|
||||
}, false, action);
|
||||
}
|
||||
},
|
||||
```
|
||||
|
||||
## SWR 集成模式
|
||||
|
||||
LobeChat 使用 SWR 进行数据获取和缓存管理:
|
||||
|
||||
### Hook 式数据获取
|
||||
|
||||
```typescript
|
||||
// 在 action.ts 中定义 SWR hook
|
||||
useFetchMessages: (enable, sessionId, activeTopicId) =>
|
||||
useClientDataSWR<ChatMessage[]>(
|
||||
enable ? [SWR_USE_FETCH_MESSAGES, sessionId, activeTopicId] : null,
|
||||
async ([, sessionId, topicId]) => messageService.getMessages(sessionId, topicId),
|
||||
{
|
||||
onSuccess: (messages, key) => {
|
||||
const nextMap = {
|
||||
...get().messagesMap,
|
||||
[messageMapKey(sessionId, activeTopicId)]: messages,
|
||||
};
|
||||
|
||||
if (get().messagesInit && isEqual(nextMap, get().messagesMap)) return;
|
||||
|
||||
set({ messagesInit: true, messagesMap: nextMap }, false, n('useFetchMessages'));
|
||||
},
|
||||
},
|
||||
),
|
||||
```
|
||||
|
||||
### 缓存失效和刷新
|
||||
|
||||
```typescript
|
||||
// 刷新数据的标准模式
|
||||
refreshMessages: async () => {
|
||||
await mutate([SWR_USE_FETCH_MESSAGES, get().activeId, get().activeTopicId]);
|
||||
},
|
||||
|
||||
refreshTopic: async () => {
|
||||
return mutate([SWR_USE_FETCH_TOPIC, get().activeId]);
|
||||
},
|
||||
```
|
||||
|
||||
## 命名规范总结
|
||||
|
||||
### Action 命名模式
|
||||
- Public Actions: 动词形式,描述用户意图
|
||||
- `createTopic`, `sendMessage`, `regenerateMessage`
|
||||
- Internal Actions: `internal_` + 动词,描述内部操作
|
||||
- `internal_createTopic`, `internal_updateMessageContent`
|
||||
- Dispatch Methods: `internal_dispatch` + 实体名
|
||||
- `internal_dispatchTopic`, `internal_dispatchMessage`
|
||||
- Toggle Methods: `internal_toggle` + 状态名
|
||||
- `internal_toggleMessageLoading`, `internal_toggleChatLoading`
|
||||
|
||||
### 状态命名模式
|
||||
- ID 数组: `[entity]LoadingIds`, `[entity]EditingIds`
|
||||
- 映射结构: `[entity]Maps`, `[entity]Map`
|
||||
- 当前激活: `active[Entity]Id`
|
||||
- 初始化标记: `[entity]sInit`
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. 合理使用乐观更新:
|
||||
- ✅ 适用:创建、更新操作(用户交互频繁)
|
||||
- ❌ 避免:删除操作(破坏性操作,错误恢复复杂)
|
||||
2. 加载状态管理:使用统一的加载状态数组管理并发操作
|
||||
3. 类型安全:为所有 action payload 定义 TypeScript 接口
|
||||
4. SWR 集成:使用 SWR 管理数据获取和缓存失效
|
||||
5. AbortController:为长时间运行的操作提供取消能力
|
||||
6. 操作模式选择:
|
||||
- 创建/更新:乐观更新 + 最终一致性
|
||||
- 删除:加载状态 + 服务调用 + 数据刷新
|
||||
|
||||
这套 Action 组织模式确保了代码的一致性、可维护性,并提供了优秀的用户体验。
|
||||
@@ -1,300 +0,0 @@
|
||||
---
|
||||
description:
|
||||
globs: src/store/**
|
||||
alwaysApply: false
|
||||
---
|
||||
# LobeChat Zustand Store Slice 组织架构
|
||||
|
||||
本文档描述了 LobeChat 项目中 Zustand Store 的模块化 Slice 组织方式,展示如何通过分片架构管理复杂的应用状态。
|
||||
|
||||
## 顶层 Store 结构
|
||||
|
||||
LobeChat 的 `chat` store (`src/store/chat/`) 采用模块化的 slice 结构来组织状态和逻辑。
|
||||
|
||||
### 关键聚合文件
|
||||
|
||||
- `src/store/chat/initialState.ts`: 聚合所有 slice 的初始状态
|
||||
- `src/store/chat/store.ts`: 定义顶层的 `ChatStore`,组合所有 slice 的 actions
|
||||
- `src/store/chat/selectors.ts`: 统一导出所有 slice 的 selectors
|
||||
- `src/store/chat/helpers.ts`: 提供聊天相关的辅助函数
|
||||
|
||||
### Store 聚合模式
|
||||
|
||||
```typescript
|
||||
// src/store/chat/initialState.ts
|
||||
import { ChatTopicState, initialTopicState } from './slices/topic/initialState';
|
||||
import { ChatMessageState, initialMessageState } from './slices/message/initialState';
|
||||
import { ChatAIChatState, initialAiChatState } from './slices/aiChat/initialState';
|
||||
|
||||
export type ChatStoreState = ChatTopicState &
|
||||
ChatMessageState &
|
||||
ChatAIChatState &
|
||||
// ...其他 slice states
|
||||
|
||||
export const initialState: ChatStoreState = {
|
||||
...initialMessageState,
|
||||
...initialTopicState,
|
||||
...initialAiChatState,
|
||||
// ...其他 initial slice states
|
||||
};
|
||||
```
|
||||
|
||||
```typescript
|
||||
// src/store/chat/store.ts
|
||||
import { ChatMessageAction, chatMessage } from './slices/message/action';
|
||||
import { ChatTopicAction, chatTopic } from './slices/topic/action';
|
||||
import { ChatAIChatAction, chatAiChat } from './slices/aiChat/actions';
|
||||
|
||||
export interface ChatStoreAction
|
||||
extends ChatMessageAction,
|
||||
ChatTopicAction,
|
||||
ChatAIChatAction,
|
||||
// ...其他 slice actions
|
||||
|
||||
const createStore: StateCreator<ChatStore, [['zustand/devtools', never]]> = (...params) => ({
|
||||
...initialState,
|
||||
...chatMessage(...params),
|
||||
...chatTopic(...params),
|
||||
...chatAiChat(...params),
|
||||
// ...其他 slice action creators
|
||||
});
|
||||
|
||||
export const useChatStore = createWithEqualityFn<ChatStore>()(
|
||||
subscribeWithSelector(devtools(createStore)),
|
||||
shallow,
|
||||
);
|
||||
```
|
||||
|
||||
## 单个 Slice 的标准结构
|
||||
|
||||
每个 slice 位于 `src/store/chat/slices/[sliceName]/` 目录下:
|
||||
|
||||
```
|
||||
src/store/chat/slices/
|
||||
└── [sliceName]/ # 例如 message, topic, aiChat, builtinTool
|
||||
├── action.ts # 定义 actions (或者是一个 actions/ 目录)
|
||||
├── initialState.ts # 定义 state 结构和初始值
|
||||
├── reducer.ts # (可选) 如果使用 reducer 模式
|
||||
├── selectors.ts # 定义 selectors
|
||||
└── index.ts # (可选) 重新导出模块内容
|
||||
```
|
||||
|
||||
### 文件职责说明
|
||||
|
||||
1. `initialState.ts`:
|
||||
- 定义 slice 的 TypeScript 状态接口
|
||||
- 提供初始状态默认值
|
||||
|
||||
```typescript
|
||||
// 典型的 initialState.ts 结构
|
||||
export interface ChatTopicState {
|
||||
activeTopicId?: string;
|
||||
topicMaps: Record<string, ChatTopic[]>; // 核心数据结构
|
||||
topicsInit: boolean;
|
||||
topicLoadingIds: string[];
|
||||
// ...其他状态字段
|
||||
}
|
||||
|
||||
export const initialTopicState: ChatTopicState = {
|
||||
activeTopicId: undefined,
|
||||
topicMaps: {},
|
||||
topicsInit: false,
|
||||
topicLoadingIds: [],
|
||||
// ...其他初始值
|
||||
};
|
||||
```
|
||||
|
||||
2. `reducer.ts` (复杂状态使用):
|
||||
- 定义纯函数 reducer,处理同步状态转换
|
||||
- 使用 `immer` 确保不可变更新
|
||||
|
||||
```typescript
|
||||
// 典型的 reducer.ts 结构
|
||||
import { produce } from 'immer';
|
||||
|
||||
interface AddChatTopicAction {
|
||||
type: 'addTopic';
|
||||
value: CreateTopicParams & { id?: string };
|
||||
}
|
||||
|
||||
interface UpdateChatTopicAction {
|
||||
id: string;
|
||||
type: 'updateTopic';
|
||||
value: Partial<ChatTopic>;
|
||||
}
|
||||
|
||||
export type ChatTopicDispatch = AddChatTopicAction | UpdateChatTopicAction;
|
||||
|
||||
export const topicReducer = (state: ChatTopic[] = [], payload: ChatTopicDispatch): ChatTopic[] => {
|
||||
switch (payload.type) {
|
||||
case 'addTopic': {
|
||||
return produce(state, (draftState) => {
|
||||
draftState.unshift({
|
||||
...payload.value,
|
||||
id: payload.value.id ?? Date.now().toString(),
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
});
|
||||
}
|
||||
case 'updateTopic': {
|
||||
return produce(state, (draftState) => {
|
||||
const index = draftState.findIndex((topic) => topic.id === payload.id);
|
||||
if (index !== -1) {
|
||||
draftState[index] = { ...draftState[index], ...payload.value };
|
||||
}
|
||||
});
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
3. `selectors.ts`:
|
||||
- 提供状态查询和计算函数
|
||||
- 供 UI 组件使用的状态订阅接口
|
||||
- 重要: 使用 `export const xxxSelectors` 模式聚合所有 selectors
|
||||
|
||||
```typescript
|
||||
// 典型的 selectors.ts 结构
|
||||
import { ChatStoreState } from '../../initialState';
|
||||
|
||||
const currentTopics = (s: ChatStoreState): ChatTopic[] | undefined =>
|
||||
s.topicMaps[s.activeId];
|
||||
|
||||
const currentActiveTopic = (s: ChatStoreState): ChatTopic | undefined => {
|
||||
return currentTopics(s)?.find((topic) => topic.id === s.activeTopicId);
|
||||
};
|
||||
|
||||
const getTopicById = (id: string) => (s: ChatStoreState): ChatTopic | undefined =>
|
||||
currentTopics(s)?.find((topic) => topic.id === id);
|
||||
|
||||
// 核心模式:使用 xxxSelectors 聚合导出
|
||||
export const topicSelectors = {
|
||||
currentActiveTopic,
|
||||
currentTopics,
|
||||
getTopicById,
|
||||
// ...其他 selectors
|
||||
};
|
||||
```
|
||||
|
||||
## 特殊 Slice 组织模式
|
||||
|
||||
### 复杂 Actions 的子目录结构 (aiChat Slice)
|
||||
|
||||
当 slice 的 actions 过于复杂时,可以拆分到子目录:
|
||||
|
||||
```
|
||||
src/store/chat/slices/aiChat/
|
||||
├── actions/
|
||||
│ ├── generateAIChat.ts # AI 对话生成
|
||||
│ ├── rag.ts # RAG 检索增强生成
|
||||
│ ├── memory.ts # 对话记忆管理
|
||||
│ └── index.ts # 聚合所有 actions
|
||||
├── initialState.ts
|
||||
├── selectors.ts
|
||||
└── index.ts
|
||||
```
|
||||
|
||||
参考:`src/store/chat/slices/aiChat/actions/`
|
||||
|
||||
### 工具类 Slice (builtinTool)
|
||||
|
||||
管理多种内置工具的状态:
|
||||
|
||||
```
|
||||
src/store/chat/slices/builtinTool/
|
||||
├── actions/
|
||||
│ ├── dalle.ts # DALL-E 图像生成
|
||||
│ ├── search.ts # 搜索功能
|
||||
│ ├── localFile.ts # 本地文件操作
|
||||
│ └── index.ts
|
||||
├── initialState.ts
|
||||
├── selectors.ts
|
||||
└── index.ts
|
||||
```
|
||||
|
||||
参考:`src/store/chat/slices/builtinTool/`
|
||||
|
||||
## 状态设计模式
|
||||
|
||||
### 1. Map 结构用于关联数据
|
||||
```typescript
|
||||
// 以 sessionId 为 key,管理多个会话的数据
|
||||
topicMaps: Record<string, ChatTopic[]>
|
||||
messagesMap: Record<string, ChatMessage[]>
|
||||
```
|
||||
|
||||
### 2. 数组用于加载状态管理
|
||||
```typescript
|
||||
// 管理多个并发操作的加载状态
|
||||
messageLoadingIds: string[]
|
||||
topicLoadingIds: string[]
|
||||
chatLoadingIds: string[]
|
||||
```
|
||||
|
||||
### 3. 可选字段用于当前活动项
|
||||
```typescript
|
||||
// 当前激活的实体 ID
|
||||
activeId: string
|
||||
activeTopicId?: string
|
||||
activeThreadId?: string
|
||||
```
|
||||
|
||||
## Slice 集成到顶层 Store
|
||||
|
||||
### 1. 状态聚合
|
||||
```typescript
|
||||
// 在 initialState.ts 中
|
||||
export type ChatStoreState = ChatTopicState &
|
||||
ChatMessageState &
|
||||
ChatAIChatState &
|
||||
// ...其他 slice states
|
||||
```
|
||||
|
||||
### 2. Action 接口聚合
|
||||
```typescript
|
||||
// 在 store.ts 中
|
||||
export interface ChatStoreAction
|
||||
extends ChatMessageAction,
|
||||
ChatTopicAction,
|
||||
ChatAIChatAction,
|
||||
// ...其他 slice actions
|
||||
```
|
||||
|
||||
### 3. Selector 统一导出
|
||||
```typescript
|
||||
// 在 selectors.ts 中 - 统一聚合 selectors
|
||||
export { chatSelectors } from './slices/message/selectors';
|
||||
export { topicSelectors } from './slices/topic/selectors';
|
||||
export { aiChatSelectors } from './slices/aiChat/selectors';
|
||||
|
||||
// 每个 slice 的 selectors.ts 都使用 xxxSelectors 模式:
|
||||
// export const chatSelectors = { ... }
|
||||
// export const topicSelectors = { ... }
|
||||
// export const aiChatSelectors = { ... }
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. Slice 划分原则:
|
||||
- 按功能领域划分(message, topic, aiChat 等)
|
||||
- 每个 slice 管理相关的状态和操作
|
||||
- 避免 slice 之间的强耦合
|
||||
|
||||
2. 文件命名规范:
|
||||
- 使用小驼峰命名 slice 目录
|
||||
- 文件名使用一致的模式(action.ts, selectors.ts 等)
|
||||
- 复杂 actions 时使用 actions/ 子目录
|
||||
|
||||
3. 状态结构设计:
|
||||
- 扁平化的状态结构,避免深层嵌套
|
||||
- 使用 Map 结构管理列表数据
|
||||
- 分离加载状态和业务数据
|
||||
|
||||
4. 类型安全:
|
||||
- 为每个 slice 定义清晰的 TypeScript 接口
|
||||
- 使用 Zustand 的 StateCreator 确保类型一致性
|
||||
- 在顶层聚合时保持类型安全
|
||||
|
||||
这种模块化的 slice 组织方式使得大型应用的状态管理变得清晰、可维护,并且易于扩展。
|
||||
@@ -1,6 +0,0 @@
|
||||
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
|
||||
locales/
|
||||
apps/desktop/resources/locales/
|
||||
**/__snapshots__/
|
||||
**/fixtures/
|
||||
src/database/migrations/
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/typescript-node",
|
||||
"features": {
|
||||
"ghcr.io/devcontainer-community/devcontainer-features/bun.sh:1": {}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
npm-debug.log
|
||||
.next
|
||||
.git
|
||||
.github
|
||||
*.md
|
||||
.env.example
|
||||
@@ -1,16 +0,0 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
@@ -1,9 +0,0 @@
|
||||
# copy this file to .env when you want to develop the desktop app or you will fail
|
||||
APP_URL=http://localhost:3015
|
||||
FEATURE_FLAGS=-check_updates,+pin_list
|
||||
KEY_VAULTS_SECRET=oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE=
|
||||
DATABASE_URL=postgresql://postgres@localhost:5432/postgres
|
||||
SEARCH_PROVIDERS=search1api
|
||||
NEXT_PUBLIC_SERVICE_MODE='server'
|
||||
NEXT_PUBLIC_IS_DESKTOP_APP=1
|
||||
NEXT_PUBLIC_ENABLE_NEXT_AUTH=0
|
||||
-241
@@ -1,241 +0,0 @@
|
||||
# add a access code to lock your lobe-chat application, you can set a long password to avoid leaking. If this value contains a comma, it is a password array.
|
||||
# ACCESS_CODE=lobe66
|
||||
|
||||
# Specify your API Key selection method, currently supporting `random` and `turn`.
|
||||
# API_KEY_SELECT_MODE=random
|
||||
|
||||
|
||||
########################################
|
||||
########## AI Provider Service #########
|
||||
########################################
|
||||
|
||||
### OpenAI ###
|
||||
|
||||
# you openai api key
|
||||
OPENAI_API_KEY=sk-xxxxxxxxx
|
||||
|
||||
# use a proxy to connect to the OpenAI API
|
||||
# OPENAI_PROXY_URL=https://api.openai.com/v1
|
||||
|
||||
# add your custom model name, multi model separate by comma. for example gpt-3.5-1106,gpt-4-1106
|
||||
# OPENAI_MODEL_LIST=gpt-3.5-turbo
|
||||
|
||||
|
||||
### Azure OpenAI ###
|
||||
|
||||
# you can learn azure OpenAI Service on https://learn.microsoft.com/en-us/azure/ai-services/openai/overview
|
||||
# use Azure OpenAI Service by uncomment the following line
|
||||
|
||||
# The API key you applied for on the Azure OpenAI account page, which can be found in the "Keys and Endpoints" section.
|
||||
# AZURE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# The endpoint you applied for on the Azure OpenAI account page, which can be found in the "Keys and Endpoints" section.
|
||||
# AZURE_ENDPOINT=https://docs-test-001.openai.azure.com
|
||||
|
||||
# Azure's API version, follows the YYYY-MM-DD format
|
||||
# AZURE_API_VERSION=2024-10-21
|
||||
|
||||
|
||||
### Anthropic Service ####
|
||||
|
||||
# ANTHROPIC_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# use a proxy to connect to the Anthropic API
|
||||
# ANTHROPIC_PROXY_URL=https://api.anthropic.com
|
||||
|
||||
|
||||
### Google AI ####
|
||||
|
||||
# GOOGLE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
||||
### AWS Bedrock ###
|
||||
|
||||
# AWS_REGION=us-east-1
|
||||
# AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxx
|
||||
# AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
||||
### Ollama AI ####
|
||||
|
||||
# You can use ollama to get and run LLM locally, learn more about it via https://github.com/ollama/ollama
|
||||
|
||||
# The local/remote ollama service url
|
||||
# OLLAMA_PROXY_URL=http://127.0.0.1:11434
|
||||
|
||||
# OLLAMA_MODEL_LIST=your_ollama_model_names
|
||||
|
||||
|
||||
### OpenRouter Service ###
|
||||
|
||||
# OPENROUTER_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# OPENROUTER_MODEL_LIST=model1,model2,model3
|
||||
|
||||
|
||||
### Mistral AI ###
|
||||
|
||||
# MISTRAL_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Perplexity Service ###
|
||||
|
||||
# PERPLEXITY_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Groq Service ####
|
||||
|
||||
# GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
#### 01.AI Service ####
|
||||
|
||||
# ZEROONE_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### TogetherAI Service ###
|
||||
|
||||
# TOGETHERAI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### ZhiPu AI ###
|
||||
|
||||
# ZHIPU_API_KEY=xxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxx
|
||||
|
||||
### Moonshot AI ####
|
||||
|
||||
# MOONSHOT_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Minimax AI ####
|
||||
|
||||
# MINIMAX_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### DeepSeek AI ####
|
||||
|
||||
# DEEPSEEK_PROXY_URL=https://api.deepseek.com/v1
|
||||
# DEEPSEEK_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Qiniu AI ####
|
||||
|
||||
# QINIU_PROXY_URL=https://api.qnaigc.com/v1
|
||||
# QINIU_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Qwen AI ####
|
||||
|
||||
# QWEN_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### Cloudflare Workers AI ####
|
||||
|
||||
# CLOUDFLARE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### SiliconCloud AI ####
|
||||
|
||||
# SILICONCLOUD_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
||||
### TencentCloud AI ####
|
||||
|
||||
# TENCENT_CLOUD_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### PPIO ####
|
||||
|
||||
# PPIO_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
### INFINI-AI ###
|
||||
|
||||
# INFINIAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
########################################
|
||||
############ Market Service ############
|
||||
########################################
|
||||
|
||||
# The LobeChat agents market index url
|
||||
# AGENTS_INDEX_URL=https://chat-agents.lobehub.com
|
||||
|
||||
########################################
|
||||
############ Plugin Service ############
|
||||
########################################
|
||||
|
||||
# The LobeChat plugins store index url
|
||||
# PLUGINS_INDEX_URL=https://chat-plugins.lobehub.com
|
||||
|
||||
# set the plugin settings
|
||||
# the format is `plugin-identifier:key1=value1;key2=value2`, multiple settings fields are separated by semicolons `;`, multiple plugin settings are separated by commas `,`.
|
||||
# PLUGIN_SETTINGS=search-engine:SERPAPI_API_KEY=xxxxx
|
||||
|
||||
########################################
|
||||
####### Doc / Changelog Service ########
|
||||
########################################
|
||||
|
||||
# Use in Changelog / Document service cdn url prefix
|
||||
# DOC_S3_PUBLIC_DOMAIN=https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# Use in dev cdn workflow
|
||||
# DOC_S3_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# DOC_S3_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
||||
########################################
|
||||
##### S3 Object Storage Service ########
|
||||
########################################
|
||||
|
||||
# S3 keys
|
||||
# S3_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
# S3_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# Bucket name
|
||||
# S3_BUCKET=lobechat
|
||||
|
||||
# Bucket request endpoint
|
||||
# S3_ENDPOINT=https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.r2.cloudflarestorage.com
|
||||
|
||||
# Public access domain for the bucket
|
||||
# S3_PUBLIC_DOMAIN=https://s3-for-lobechat.your-domain.com
|
||||
|
||||
# Bucket region, such as us-west-1, generally not needed to add
|
||||
# but some service providers may require configuration
|
||||
# S3_REGION=us-west-1
|
||||
|
||||
|
||||
########################################
|
||||
############ Auth Service ##############
|
||||
########################################
|
||||
|
||||
|
||||
# Clerk related configurations
|
||||
|
||||
# Clerk public key and secret key
|
||||
#NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxx
|
||||
#CLERK_SECRET_KEY=sk_live_xxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
# you need to config the clerk webhook secret key if you want to use the clerk with database
|
||||
#CLERK_WEBHOOK_SECRET=whsec_xxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
||||
# NextAuth related configurations
|
||||
# NEXT_PUBLIC_ENABLE_NEXT_AUTH=1
|
||||
# NEXT_AUTH_SECRET=
|
||||
|
||||
# Auth0 configurations
|
||||
# AUTH_AUTH0_ID=
|
||||
# AUTH_AUTH0_SECRET=
|
||||
# AUTH_AUTH0_ISSUER=https://your-domain.auth0.com
|
||||
|
||||
########################################
|
||||
########## Server Database #############
|
||||
########################################
|
||||
|
||||
# Specify the service mode as server if you want to use the server database
|
||||
# NEXT_PUBLIC_SERVICE_MODE=server
|
||||
|
||||
# Postgres database URL
|
||||
# DATABASE_URL=postgres://username:password@host:port/database
|
||||
|
||||
# use `openssl rand -base64 32` to generate a key for the encryption of the database
|
||||
# we use this key to encrypt the user api key and proxy url
|
||||
#KEY_VAULTS_SECRET=xxxxx/xxxxxxxxxxxxxx=
|
||||
|
||||
# Specify the Embedding model and Reranker model(unImplemented)
|
||||
# DEFAULT_FILES_CONFIG="embedding_model=openai/embedding-text-3-small,reranker_model=cohere/rerank-english-v3.0,query_mode=full_text"
|
||||
|
||||
########################################
|
||||
########## MCP Service Config ##########
|
||||
########################################
|
||||
|
||||
# MCP tool call timeout (milliseconds)
|
||||
# MCP_TOOL_TIMEOUT=60000
|
||||
@@ -1,31 +0,0 @@
|
||||
# Eslintignore for LobeHub
|
||||
################################################################
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
|
||||
# ci
|
||||
coverage
|
||||
.coverage
|
||||
|
||||
# test
|
||||
jest*
|
||||
*.test.ts
|
||||
*.test.tsx
|
||||
|
||||
# umi
|
||||
.umi
|
||||
.umi-production
|
||||
.umi-test
|
||||
.dumi/tmp*
|
||||
!.dumirc.ts
|
||||
|
||||
# production
|
||||
dist
|
||||
es
|
||||
lib
|
||||
logs
|
||||
|
||||
# misc
|
||||
# add other ignore file below
|
||||
.next
|
||||
@@ -1,51 +0,0 @@
|
||||
const config = require('@lobehub/lint').eslint;
|
||||
|
||||
config.extends.push('plugin:@next/next/recommended');
|
||||
|
||||
config.rules['unicorn/no-negated-condition'] = 0;
|
||||
config.rules['unicorn/prefer-type-error'] = 0;
|
||||
config.rules['unicorn/prefer-logical-operator-over-ternary'] = 0;
|
||||
config.rules['unicorn/no-null'] = 0;
|
||||
config.rules['unicorn/no-typeof-undefined'] = 0;
|
||||
config.rules['unicorn/explicit-length-check'] = 0;
|
||||
config.rules['unicorn/prefer-code-point'] = 0;
|
||||
config.rules['no-extra-boolean-cast'] = 0;
|
||||
config.rules['unicorn/no-useless-undefined'] = 0;
|
||||
config.rules['react/no-unknown-property'] = 0;
|
||||
config.rules['unicorn/prefer-ternary'] = 0;
|
||||
config.rules['unicorn/prefer-spread'] = 0;
|
||||
config.rules['unicorn/catch-error-name'] = 0;
|
||||
config.rules['unicorn/no-array-for-each'] = 0;
|
||||
config.rules['unicorn/prefer-number-properties'] = 0;
|
||||
config.rules['unicorn/prefer-query-selector'] = 0;
|
||||
config.rules['unicorn/no-array-callback-reference'] = 0;
|
||||
// FIXME: Linting error in src/app/[variants]/(main)/chat/features/Migration/DBReader.ts, the fundamental solution should be upgrading typescript-eslint
|
||||
config.rules['@typescript-eslint/no-useless-constructor'] = 0;
|
||||
|
||||
config.overrides = [
|
||||
{
|
||||
extends: ['plugin:mdx/recommended'],
|
||||
files: ['*.mdx'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': 1,
|
||||
'no-undef': 0,
|
||||
'react/jsx-no-undef': 0,
|
||||
'react/no-unescaped-entities': 0,
|
||||
},
|
||||
settings: {
|
||||
'mdx/code-blocks': false,
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
files: ['src/store/image/**/*', 'src/types/generation/**/*'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
'sort-keys-fix/sort-keys-fix': 0,
|
||||
'typescript-sort-keys/interface': 0,
|
||||
'typescript-sort-keys/string-enum': 0,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = config;
|
||||
@@ -1,13 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: lobehub
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: lobehub
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: lobehub/lobe-chat
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -1,80 +0,0 @@
|
||||
name: '🐛 Bug Report'
|
||||
description: 'Report an bug'
|
||||
labels: ['unconfirm']
|
||||
type: Bug
|
||||
body:
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '📦 Platform'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Official Preview'
|
||||
- 'Official Cloud'
|
||||
- 'Vercel'
|
||||
- 'Zeabur'
|
||||
- 'Sealos'
|
||||
- 'Netlify'
|
||||
- 'Self hosting Docker'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '📦 Deploymenet mode'
|
||||
multiple: true
|
||||
options:
|
||||
- 'client db (lobe-chat image)'
|
||||
- 'client pgelite db (lobe-chat-pglite image)'
|
||||
- 'server db(lobe-chat-database image)'
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: '📌 Version'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '💻 Operating System'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Windows'
|
||||
- 'macOS'
|
||||
- 'Ubuntu'
|
||||
- 'Other Linux'
|
||||
- 'iOS'
|
||||
- 'Android'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '🌐 Browser'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Chrome'
|
||||
- 'Edge'
|
||||
- 'Safari'
|
||||
- 'Firefox'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🐛 Bug Description'
|
||||
description: A clear and concise description of the bug, if the above option is `Other`, please also explain in detail.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📷 Recurrence Steps'
|
||||
description: A clear and concise description of how to recurrence.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🚦 Expected Behavior'
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📝 Additional Information'
|
||||
description: If your problem needs further explanation, or if the issue you're seeing cannot be reproduced in a gist, please add more information here.
|
||||
@@ -1,87 +0,0 @@
|
||||
name: '🐛 反馈缺陷'
|
||||
description: '反馈一个问题缺陷'
|
||||
labels: ['unconfirm']
|
||||
type: Bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
在创建新的 Issue 之前,请先[搜索已有问题](https://github.com/lobehub/lobe-chat/issues),如果发现已有类似的问题,请给它 **👍 点赞**,这样可以帮助我们更快地解决问题。
|
||||
如果你在使用过程中遇到问题,可以尝试以下方式获取帮助:
|
||||
- 在 [GitHub Discussions](https://github.com/lobehub/lobe-chat/discussions) 的版块发起讨论。
|
||||
- 在 [LobeChat 社区](https://discord.gg/AYFPHvv2jT) 提问,与其他用户交流。
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '📦 部署环境'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Official Preview'
|
||||
- 'Official Cloud'
|
||||
- 'Vercel'
|
||||
- 'Zeabur'
|
||||
- 'Sealos'
|
||||
- 'Netlify'
|
||||
- 'Docker'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '📦 部署模式'
|
||||
multiple: true
|
||||
options:
|
||||
- '客户端模式(lobe-chat 镜像)'
|
||||
- '客户端 Pglite 模式(lobe-chat-pglite 镜像)'
|
||||
- '服务端模式(lobe-chat-database 镜像)'
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: '📌 软件版本'
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '💻 系统环境'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Windows'
|
||||
- 'macOS'
|
||||
- 'Ubuntu'
|
||||
- 'Other Linux'
|
||||
- 'iOS'
|
||||
- 'Android'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: '🌐 浏览器'
|
||||
multiple: true
|
||||
options:
|
||||
- 'Chrome'
|
||||
- 'Edge'
|
||||
- 'Safari'
|
||||
- 'Firefox'
|
||||
- 'Other'
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🐛 问题描述'
|
||||
description: 请提供一个清晰且简洁的问题描述,若上述选项为`Other`,也请详细说明。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📷 复现步骤'
|
||||
description: 请提供一个清晰且简洁的描述,说明如何复现问题。
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🚦 期望结果'
|
||||
description: 请提供一个清晰且简洁的描述,说明您期望发生什么。
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📝 补充信息'
|
||||
description: 如果您的问题需要进一步说明,或者您遇到的问题无法在一个简单的示例中复现,请在这里添加更多信息。
|
||||
@@ -1,21 +0,0 @@
|
||||
name: '🌠 Feature Request'
|
||||
description: 'Suggest an idea'
|
||||
title: '[Request] '
|
||||
type: Feature
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🥰 Feature Description'
|
||||
description: Please add a clear and concise description of the problem you are seeking to solve with this feature request.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🧐 Proposed Solution'
|
||||
description: Describe the solution you'd like in a clear and concise manner.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📝 Additional Information'
|
||||
description: Add any other context about the problem here.
|
||||
@@ -1,21 +0,0 @@
|
||||
name: '🌠 功能需求'
|
||||
description: '提出需求或建议'
|
||||
title: '[Request] '
|
||||
type: Feature
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🥰 需求描述'
|
||||
description: 请添加一个清晰且简洁的问题描述,阐述您希望通过这个功能需求解决的问题。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '🧐 解决方案'
|
||||
description: 请清晰且简洁地描述您想要的解决方案。
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: '📝 补充信息'
|
||||
description: 在这里添加关于问题的任何其他背景信息。
|
||||
@@ -1,7 +0,0 @@
|
||||
contact_links:
|
||||
- name: Ask a question for self-hosting | 咨询自部署问题
|
||||
url: https://github.com/lobehub/lobe-chat/discussions/new?category=self-hosting-%E7%A7%81%E6%9C%89%E5%8C%96%E9%83%A8%E7%BD%B2
|
||||
about: Please post questions, and ideas in discussions. | 请在讨论区发布问题和想法。
|
||||
- name: Questions and ideas | 其他问题和想法
|
||||
url: https://github.com/lobehub/lobe-chat/discussions/new/choose
|
||||
about: Please post questions, and ideas in discussions. | 请在讨论区发布问题和想法。
|
||||
@@ -1,20 +0,0 @@
|
||||
#### 💻 变更类型 | Change Type
|
||||
|
||||
<!-- For change type, change [ ] to [x]. -->
|
||||
|
||||
- [ ] ✨ feat
|
||||
- [ ] 🐛 fix
|
||||
- [ ] ♻️ refactor
|
||||
- [ ] 💄 style
|
||||
- [ ] 👷 build
|
||||
- [ ] ⚡️ perf
|
||||
- [ ] 📝 docs
|
||||
- [ ] 🔨 chore
|
||||
|
||||
#### 🔀 变更说明 | Description of Change
|
||||
|
||||
<!-- Thank you for your Pull Request. Please provide a description above. -->
|
||||
|
||||
#### 📝 补充信息 | Additional Information
|
||||
|
||||
<!-- Add any other context about the Pull Request here. -->
|
||||
@@ -1,256 +0,0 @@
|
||||
/**
|
||||
* Create or update GitHub issue when i18n workflow fails
|
||||
* Usage: node create-failure-issue.js
|
||||
*/
|
||||
|
||||
module.exports = async ({ github, context, core }) => {
|
||||
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
|
||||
const timestamp = new Date().toISOString();
|
||||
const date = timestamp.split('T')[0];
|
||||
|
||||
// Get error details from environment variables
|
||||
const errorDetails = {
|
||||
validateEnv: process.env.ERROR_VALIDATE_ENV || '',
|
||||
rebaseAttempt: process.env.ERROR_REBASE_ATTEMPT || '',
|
||||
createBranch: process.env.ERROR_CREATE_BRANCH || '',
|
||||
installDeps: process.env.ERROR_INSTALL_DEPS || '',
|
||||
runI18n: process.env.ERROR_RUN_I18N || '',
|
||||
commitPush: process.env.ERROR_COMMIT_PUSH || '',
|
||||
};
|
||||
|
||||
// Get step conclusions from environment variables
|
||||
const stepStatus = {
|
||||
validateEnv: process.env.STEP_VALIDATE_ENV || 'Not run',
|
||||
checkBranch: process.env.STEP_CHECK_BRANCH || 'Not run',
|
||||
rebaseAttempt: process.env.STEP_REBASE_ATTEMPT || 'Not run',
|
||||
createBranch: process.env.STEP_CREATE_BRANCH || 'Not run',
|
||||
installDeps: process.env.STEP_INSTALL_DEPS || 'Not run',
|
||||
runI18n: process.env.STEP_RUN_I18N || 'Not run',
|
||||
commitPush: process.env.STEP_COMMIT_PUSH || 'Not run',
|
||||
createPr: process.env.STEP_CREATE_PR || 'Not run',
|
||||
};
|
||||
|
||||
// Find the first non-empty error
|
||||
const mainError =
|
||||
Object.values(errorDetails).find((error) => error && error.trim()) || 'Unknown error occurred';
|
||||
|
||||
// Determine error category for better troubleshooting
|
||||
const getErrorCategory = (error) => {
|
||||
if (error.includes('API') || error.includes('authentication')) return 'API/Authentication';
|
||||
if (error.includes('network') || error.includes('timeout')) return 'Network/Connectivity';
|
||||
if (error.includes('dependencies') || error.includes('bun')) return 'Dependencies';
|
||||
if (error.includes('git') || error.includes('branch') || error.includes('rebase'))
|
||||
return 'Git Operations';
|
||||
if (error.includes('permission') || error.includes('token')) return 'Permissions';
|
||||
return 'General';
|
||||
};
|
||||
|
||||
const errorCategory = getErrorCategory(mainError);
|
||||
|
||||
const issueTitle = `🚨 Daily i18n Update Failed - ${date}`;
|
||||
|
||||
const issueBody = `## 🚨 Automated i18n Update Failure
|
||||
|
||||
**Timestamp:** ${timestamp}
|
||||
**Workflow Run:** [#${context.runNumber}](${runUrl})
|
||||
**Repository:** ${context.repo.owner}/${context.repo.repo}
|
||||
**Branch:** ${context.ref}
|
||||
**Commit:** ${context.sha}
|
||||
|
||||
## ❌ Error Details
|
||||
**Primary Error:** ${mainError}
|
||||
**Category:** ${errorCategory}
|
||||
|
||||
## 🔍 Step Status
|
||||
| Step | Status |
|
||||
|------|--------|
|
||||
| Environment Validation | ${stepStatus.validateEnv} |
|
||||
| Branch Check | ${stepStatus.checkBranch} |
|
||||
| Rebase Attempt | ${stepStatus.rebaseAttempt} |
|
||||
| Branch Creation | ${stepStatus.createBranch} |
|
||||
| Dependencies | ${stepStatus.installDeps} |
|
||||
| i18n Update | ${stepStatus.runI18n} |
|
||||
| Git Operations | ${stepStatus.commitPush} |
|
||||
| PR Creation | ${stepStatus.createPr} |
|
||||
|
||||
## 🔧 Environment Info
|
||||
- **Runner OS:** ${process.env.RUNNER_OS || 'Unknown'}
|
||||
- **Bun Version:** ${process.env.BUN_VERSION || 'Default'}
|
||||
- **Workflow:** \`${context.workflow}\`
|
||||
|
||||
## 📋 Debug Information
|
||||
Debug logs have been uploaded as artifacts and will be available for 7 days.
|
||||
|
||||
${getErrorCategoryHelp(errorCategory)}
|
||||
|
||||
## 🛠️ General Troubleshooting Steps
|
||||
1. Check if all required secrets are properly configured
|
||||
2. Verify OpenAI API quota and billing status
|
||||
3. Review the workflow run logs for detailed error messages
|
||||
4. Check if there are any ongoing GitHub API issues
|
||||
5. Manually trigger the workflow to retry
|
||||
|
||||
## 📊 Workflow Statistics
|
||||
- **Run Number:** ${context.runNumber}
|
||||
- **Run ID:** ${context.runId}
|
||||
- **Event:** ${context.eventName}
|
||||
|
||||
---
|
||||
**Auto-generated by:** [\`${context.workflow}\`](${runUrl})
|
||||
**Labels:** automated, bug, i18n, workflow-failure, ${errorCategory.toLowerCase().replace(/[^a-z0-9]/g, '-')}`;
|
||||
|
||||
try {
|
||||
// Search for existing open issues with similar title
|
||||
const existingIssues = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels: 'automated,workflow-failure',
|
||||
state: 'open',
|
||||
per_page: 50,
|
||||
});
|
||||
|
||||
const todayPrefix = `🚨 Daily i18n Update Failed - ${date}`;
|
||||
const existingIssue = existingIssues.data.find((issue) => issue.title.startsWith(todayPrefix));
|
||||
|
||||
if (existingIssue) {
|
||||
// Update existing issue with comment
|
||||
const commentBody = `## 🔄 Additional Failure
|
||||
|
||||
**Timestamp:** ${timestamp}
|
||||
**Workflow Run:** [#${context.runNumber}](${runUrl})
|
||||
**Error Category:** ${errorCategory}
|
||||
**Error:** ${mainError}
|
||||
|
||||
Same issue occurred again. Please investigate the recurring problem.
|
||||
|
||||
### Quick Actions
|
||||
- [ ] Check API quotas and billing
|
||||
- [ ] Verify network connectivity
|
||||
- [ ] Review recent changes that might cause conflicts
|
||||
- [ ] Consider manual intervention
|
||||
|
||||
---
|
||||
*This is failure #${(await getFailureCount(github, context, existingIssue.number)) + 1} for today.*`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: existingIssue.number,
|
||||
body: commentBody,
|
||||
});
|
||||
|
||||
// Add priority label if this is a recurring issue
|
||||
const failureCount = await getFailureCount(github, context, existingIssue.number);
|
||||
if (failureCount >= 2) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: existingIssue.number,
|
||||
labels: ['priority-high', 'recurring'],
|
||||
});
|
||||
}
|
||||
|
||||
core.info(`✅ Updated existing issue #${existingIssue.number}`);
|
||||
core.setOutput('issue-number', existingIssue.number);
|
||||
core.setOutput('issue-url', existingIssue.html_url);
|
||||
core.setOutput('action', 'updated');
|
||||
} else {
|
||||
// Create new issue
|
||||
const labels = [
|
||||
'automated',
|
||||
'bug',
|
||||
'i18n',
|
||||
'workflow-failure',
|
||||
errorCategory.toLowerCase().replace(/[^a-z0-9]/g, '-'),
|
||||
];
|
||||
|
||||
const issue = await github.rest.issues.create({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
title: issueTitle,
|
||||
body: issueBody,
|
||||
labels: labels,
|
||||
});
|
||||
|
||||
core.info(`✅ Created new issue #${issue.data.number}`);
|
||||
core.setOutput('issue-number', issue.data.number);
|
||||
core.setOutput('issue-url', issue.data.html_url);
|
||||
core.setOutput('action', 'created');
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(`Failed to create or update issue: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get category-specific help text
|
||||
*/
|
||||
function getErrorCategoryHelp(category) {
|
||||
const helpTexts = {
|
||||
'API/Authentication': `
|
||||
### 🔑 API/Authentication Issues
|
||||
- Verify \`OPENAI_API_KEY\` is correctly set and valid
|
||||
- Check if API key has sufficient quota/credits
|
||||
- Ensure \`GH_TOKEN\` has necessary permissions
|
||||
- Test API connectivity manually`,
|
||||
|
||||
'Network/Connectivity': `
|
||||
### 🌐 Network/Connectivity Issues
|
||||
- Check if OpenAI API is experiencing outages
|
||||
- Verify proxy settings if using \`OPENAI_PROXY_URL\`
|
||||
- Retry the workflow as this might be temporary
|
||||
- Check GitHub Actions service status`,
|
||||
|
||||
'Dependencies': `
|
||||
### 📦 Dependencies Issues
|
||||
- Verify \`bun\` version compatibility
|
||||
- Check for package.json changes that might affect dependencies
|
||||
- Clear cache and retry installation
|
||||
- Review recent dependency updates`,
|
||||
|
||||
'Git Operations': `
|
||||
### 🔧 Git Operations Issues
|
||||
- Check for conflicting changes in target branch
|
||||
- Verify repository permissions
|
||||
- Review recent commits that might cause conflicts
|
||||
- Manual branch cleanup might be required`,
|
||||
|
||||
'Permissions': `
|
||||
### 🔐 Permissions Issues
|
||||
- Verify \`GH_TOKEN\` has \`repo\` and \`issues\` permissions
|
||||
- Check if token can create/update PRs and branches
|
||||
- Ensure token hasn't expired
|
||||
- Review repository settings and branch protection rules`,
|
||||
|
||||
'General': `
|
||||
### 🔍 General Issues
|
||||
- Review detailed error logs in workflow run
|
||||
- Check for recent changes in codebase
|
||||
- Verify all environment variables are set
|
||||
- Consider running workflow manually with debug enabled`,
|
||||
};
|
||||
|
||||
return helpTexts[category] || helpTexts['General'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many times this issue has failed today
|
||||
*/
|
||||
async function getFailureCount(github, context, issueNumber) {
|
||||
try {
|
||||
const comments = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
});
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
return comments.data.filter(
|
||||
(comment) =>
|
||||
comment.body.includes('Additional Failure') && comment.created_at.startsWith(today),
|
||||
).length;
|
||||
} catch (error) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* Generate PR comment with download links for desktop builds
|
||||
* and handle comment creation/update logic
|
||||
*/
|
||||
module.exports = async ({ github, context, releaseUrl, version, tag }) => {
|
||||
// 用于识别构建评论的标识符
|
||||
const COMMENT_IDENTIFIER = '<!-- DESKTOP-BUILD-COMMENT -->';
|
||||
|
||||
/**
|
||||
* 生成评论内容
|
||||
*/
|
||||
const generateCommentBody = async () => {
|
||||
try {
|
||||
// Get release assets to create download links
|
||||
const release = await github.rest.repos.getReleaseByTag({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
tag,
|
||||
});
|
||||
|
||||
// Organize assets by platform
|
||||
const macAssets = release.data.assets.filter(
|
||||
(asset) =>
|
||||
(asset.name.includes('.dmg') || asset.name.includes('.zip')) &&
|
||||
!asset.name.includes('.blockmap'),
|
||||
);
|
||||
|
||||
const winAssets = release.data.assets.filter(
|
||||
(asset) => asset.name.includes('.exe') && !asset.name.includes('.blockmap'),
|
||||
);
|
||||
|
||||
const linuxAssets = release.data.assets.filter(
|
||||
(asset) => asset.name.includes('.AppImage') && !asset.name.includes('.blockmap'),
|
||||
);
|
||||
|
||||
// Generate combined download table
|
||||
let assetTable = '| Platform | File | Size |\n| --- | --- | --- |\n';
|
||||
|
||||
// Add macOS assets
|
||||
macAssets.forEach((asset) => {
|
||||
const sizeInMB = (asset.size / (1024 * 1024)).toFixed(2);
|
||||
assetTable += `| macOS | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
|
||||
});
|
||||
|
||||
// Add Windows assets
|
||||
winAssets.forEach((asset) => {
|
||||
const sizeInMB = (asset.size / (1024 * 1024)).toFixed(2);
|
||||
assetTable += `| Windows | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
|
||||
});
|
||||
|
||||
// Add Linux assets
|
||||
linuxAssets.forEach((asset) => {
|
||||
const sizeInMB = (asset.size / (1024 * 1024)).toFixed(2);
|
||||
assetTable += `| Linux | [${asset.name}](${asset.browser_download_url}) | ${sizeInMB} MB |\n`;
|
||||
});
|
||||
|
||||
return `${COMMENT_IDENTIFIER}
|
||||
### 🚀 Desktop App Build Completed!
|
||||
|
||||
**Version**: \`${version}\`
|
||||
**Build Time**: \`${new Date().toISOString()}\`
|
||||
|
||||
📦 [View All Build Artifacts](${releaseUrl})
|
||||
|
||||
|
||||
## Build Artifacts
|
||||
|
||||
${assetTable}
|
||||
|
||||
> [!Warning]
|
||||
>
|
||||
> Note: This is a temporary build for testing purposes only.`;
|
||||
} catch (error) {
|
||||
console.error('Error generating PR comment:', error);
|
||||
// Fallback to a simple comment if error occurs
|
||||
return `${COMMENT_IDENTIFIER}
|
||||
### 🚀 Desktop App Build Completed!
|
||||
|
||||
**Version**: \`${version}\`
|
||||
**Build Time**: \`${new Date().toISOString()}\`
|
||||
|
||||
## 📦 [View All Build Artifacts](${releaseUrl})
|
||||
|
||||
> Note: This is a temporary build for testing purposes only.
|
||||
`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 查找并更新或创建PR评论
|
||||
*/
|
||||
const updateOrCreateComment = async () => {
|
||||
// 生成评论内容
|
||||
const body = await generateCommentBody();
|
||||
|
||||
// 查找我们之前可能创建的评论
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
|
||||
// 查找包含我们标识符的评论
|
||||
const buildComment = comments.find((comment) => comment.body.includes(COMMENT_IDENTIFIER));
|
||||
|
||||
if (buildComment) {
|
||||
// 如果找到现有评论,则更新它
|
||||
await github.rest.issues.updateComment({
|
||||
comment_id: buildComment.id,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body,
|
||||
});
|
||||
console.log(`已更新现有评论 ID: ${buildComment.id}`);
|
||||
return { updated: true, id: buildComment.id };
|
||||
} else {
|
||||
// 如果没有找到现有评论,则创建新评论
|
||||
const result = await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body,
|
||||
});
|
||||
console.log(`已创建新评论 ID: ${result.data.id}`);
|
||||
return { updated: false, id: result.data.id };
|
||||
}
|
||||
};
|
||||
|
||||
// 执行评论更新或创建
|
||||
return await updateOrCreateComment();
|
||||
};
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Generate PR pre-release body content
|
||||
* This script generates the description text for PR pre-releases
|
||||
*/
|
||||
module.exports = ({ version, prNumber, branch }) => {
|
||||
const prLink = `https://github.com/lobehub/lobe-chat/pull/${prNumber}`;
|
||||
|
||||
return `
|
||||
## PR Build Information
|
||||
|
||||
**Version**: \`${version}\`
|
||||
**Release Time**: \`${new Date().toISOString()}\`
|
||||
**PR**: [#${prNumber}](${prLink})
|
||||
|
||||
|
||||
## ⚠️ Important Notice
|
||||
|
||||
This is a **development build** specifically created for testing purposes. Please note:
|
||||
|
||||
- This build is **NOT** intended for production use
|
||||
- Features may be incomplete or unstable
|
||||
- Use only for validating PR changes in a desktop environment
|
||||
- May contain experimental code that hasn't been fully reviewed
|
||||
- No guarantees are provided regarding stability or reliability
|
||||
|
||||
### Intended Use
|
||||
|
||||
- Focused testing of specific PR changes
|
||||
- Verification of desktop-specific behaviors
|
||||
- UI/UX validation on desktop platforms
|
||||
- Performance testing on target devices
|
||||
|
||||
Please report any issues found in this build directly in the PR discussion.
|
||||
|
||||
---
|
||||
|
||||
## PR 构建信息
|
||||
|
||||
**版本**: \`${version}\`
|
||||
**发布时间**: \`${new Date().toISOString()}\`
|
||||
**PR**: [#${prNumber}](${prLink})
|
||||
|
||||
## ⚠️ 重要提示
|
||||
|
||||
这是专为测试目的创建的**开发构建版本**。请注意:
|
||||
|
||||
- 本构建**不适用于**生产环境
|
||||
- 功能可能不完整或不稳定
|
||||
- 仅用于在桌面环境中验证 PR 更改
|
||||
- 可能包含尚未完全审核的实验性代码
|
||||
- 不对稳定性或可靠性提供任何保证
|
||||
|
||||
### 适用场景
|
||||
|
||||
- 针对性测试特定 PR 变更
|
||||
- 验证桌面特定的行为表现
|
||||
- 在桌面平台上进行 UI/UX 验证
|
||||
- 在目标设备上进行性能测试
|
||||
|
||||
如发现任何问题,请直接在 PR 讨论中报告。
|
||||
`;
|
||||
};
|
||||
@@ -1,71 +0,0 @@
|
||||
name: Daily i18n Update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
# Add permissions configuration
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
update-i18n:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.name "lobehubbot"
|
||||
git config --global user.email "i@lobehub.com"
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Update i18n
|
||||
run: bun run i18n
|
||||
env:
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
OPENAI_PROXY_URL: ${{ secrets.OPENAI_PROXY_URL }}
|
||||
|
||||
- name: create pull request
|
||||
id: cpr
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
add-paths: |
|
||||
locales/**/*.json
|
||||
labels: |
|
||||
i18n
|
||||
automated
|
||||
style
|
||||
branch: style/auto-i18n
|
||||
delete-branch: true
|
||||
title: '🤖 style: update i18n'
|
||||
commit-message: '💄 style: update i18n'
|
||||
body: |
|
||||
This PR was automatically generated by the i18n update workflow.
|
||||
Please review the changes and merge if everything looks good.
|
||||
|
||||
## 🤖 Automation Info
|
||||
- Workflow: `${{ github.workflow }}`
|
||||
- Run ID: `${{ github.run_id }}`
|
||||
- Commit: `${{ github.sha }}`
|
||||
|
||||
<details>
|
||||
<summary>i18n Update Log</summary>
|
||||
```bash
|
||||
$(cat i18n_update.log)
|
||||
```
|
||||
</details>
|
||||
@@ -1,268 +0,0 @@
|
||||
name: Desktop PR Build
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [synchronize, labeled, unlabeled] # PR 更新或标签变化时触发
|
||||
|
||||
# 确保同一时间只运行一个相同的 workflow,取消正在进行的旧的运行
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Add default permissions
|
||||
permissions: read-all
|
||||
|
||||
env:
|
||||
PR_TAG_PREFIX: pr- # PR 构建版本的前缀标识
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Code quality check
|
||||
# 添加 PR label 触发条件,只有添加了 Build Desktop 标签的 PR 才会触发构建
|
||||
if: contains(github.event.pull_request.labels.*.name, 'Build Desktop')
|
||||
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install deps
|
||||
run: pnpm install
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
version:
|
||||
name: Determine version
|
||||
# 与 test job 相同的触发条件
|
||||
if: contains(github.event.pull_request.labels.*.name, 'Build Desktop')
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
# 输出版本信息,供后续 job 使用
|
||||
version: ${{ steps.set_version.outputs.version }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
# 主要逻辑:确定构建版本号
|
||||
- name: Set version
|
||||
id: set_version
|
||||
run: |
|
||||
# 从 apps/desktop/package.json 读取基础版本号
|
||||
base_version=$(node -p "require('./apps/desktop/package.json').version")
|
||||
|
||||
# PR 构建:在基础版本号上添加 PR 信息
|
||||
pr_number="${{ github.event.pull_request.number }}"
|
||||
ci_build_number="${{ github.run_number }}" # CI 构建编号
|
||||
version="0.0.0-nightly.pr${pr_number}.${ci_build_number}"
|
||||
echo "version=${version}" >> $GITHUB_OUTPUT
|
||||
echo "📦 Release Version: ${version} (based on base version ${base_version})"
|
||||
|
||||
env:
|
||||
NODE_OPTIONS: --max-old-space-size=6144
|
||||
|
||||
# 输出版本信息总结,方便在 GitHub Actions 界面查看
|
||||
- name: Version Summary
|
||||
run: |
|
||||
echo "🚦 Release Version: ${{ steps.set_version.outputs.version }}"
|
||||
|
||||
build:
|
||||
needs: [version, test]
|
||||
name: Build Desktop App
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-2025, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
|
||||
# node-linker=hoisted 模式将可以确保 asar 压缩可用
|
||||
- name: Install deps
|
||||
run: pnpm install --node-linker=hoisted
|
||||
|
||||
- name: Install deps on Desktop
|
||||
run: npm run install-isolated --prefix=./apps/desktop
|
||||
|
||||
# 设置 package.json 的版本号
|
||||
- name: Set package version
|
||||
run: npm run workflow:set-desktop-version ${{ needs.version.outputs.version }} nightly
|
||||
|
||||
# macOS 构建处理
|
||||
- name: Build artifact on macOS
|
||||
if: runner.os == 'macOS'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
# 设置更新通道,PR构建为nightly,否则为stable
|
||||
UPDATE_CHANNEL: 'nightly'
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
# 默认添加一个加密 SECRET
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
# macOS 签名和公证配置
|
||||
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
|
||||
|
||||
# allow provisionally
|
||||
CSC_FOR_PULL_REQUEST: true
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
|
||||
# Windows 平台构建处理
|
||||
- name: Build artifact on Windows
|
||||
if: runner.os == 'Windows'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
# 设置更新通道,PR构建为nightly,否则为stable
|
||||
UPDATE_CHANNEL: 'nightly'
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
|
||||
# 将 TEMP 和 TMP 目录设置到 C 盘
|
||||
TEMP: C:\temp
|
||||
TMP: C:\temp
|
||||
|
||||
# Linux 平台构建处理
|
||||
- name: Build artifact on Linux
|
||||
if: runner.os == 'Linux'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
# 设置更新通道,PR构建为nightly,否则为stable
|
||||
UPDATE_CHANNEL: 'nightly'
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
|
||||
|
||||
# 上传构建产物
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-${{ matrix.os }}
|
||||
path: |
|
||||
apps/desktop/release/latest*
|
||||
apps/desktop/release/*.dmg*
|
||||
apps/desktop/release/*.zip*
|
||||
apps/desktop/release/*.exe*
|
||||
apps/desktop/release/*.AppImage
|
||||
retention-days: 5
|
||||
|
||||
publish-pr:
|
||||
needs: [build, version]
|
||||
name: Publish PR Build
|
||||
runs-on: ubuntu-latest
|
||||
# Grant write permissions for creating release and commenting on PR
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
artifact_path: ${{ steps.set_path.outputs.path }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# 下载所有平台的构建产物
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: release
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
# 列出所有构建产物
|
||||
- name: List artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 生成PR发布描述
|
||||
- name: Generate PR Release Body
|
||||
id: pr_release_body
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const generateReleaseBody = require('${{ github.workspace }}/.github/scripts/pr-release-body.js');
|
||||
|
||||
const body = generateReleaseBody({
|
||||
version: "${{ needs.version.outputs.version }}",
|
||||
prNumber: "${{ github.event.pull_request.number }}",
|
||||
branch: "${{ github.head_ref }}"
|
||||
});
|
||||
|
||||
return body;
|
||||
|
||||
- name: Create Temporary Release for PR
|
||||
id: create_release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: PR Build v${{ needs.version.outputs.version }}
|
||||
tag_name: v${{ needs.version.outputs.version }}
|
||||
# tag_name: pr-build-${{ github.event.pull_request.number }}-${{ github.sha }}
|
||||
body: ${{ steps.pr_release_body.outputs.result }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
files: |
|
||||
release/latest*
|
||||
release/*.dmg*
|
||||
release/*.zip*
|
||||
release/*.exe*
|
||||
release/*.AppImage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# 在 PR 上添加评论,包含构建信息和下载链接
|
||||
- name: Comment on PR
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const releaseUrl = "${{ steps.create_release.outputs.url }}";
|
||||
const prCommentGenerator = require('${{ github.workspace }}/.github/scripts/pr-comment.js');
|
||||
|
||||
const result = await prCommentGenerator({
|
||||
github,
|
||||
context,
|
||||
releaseUrl,
|
||||
version: "${{ needs.version.outputs.version }}",
|
||||
tag: "v${{ needs.version.outputs.version }}"
|
||||
});
|
||||
|
||||
console.log(`评论状态: ${result.updated ? '已更新' : '已创建'}, ID: ${result.id}`);
|
||||
@@ -1,161 +0,0 @@
|
||||
name: Publish Database Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
pull_request:
|
||||
types: [synchronize, labeled, unlabeled]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: lobehub/lobe-chat-database
|
||||
PR_TAG_PREFIX: pr-
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# 添加 PR label 触发条件
|
||||
if: |
|
||||
(github.event_name == 'pull_request' &&
|
||||
contains(github.event.pull_request.labels.*.name, 'Build Docker')) ||
|
||||
github.event_name != 'pull_request'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: Build ${{ matrix.platform }} Image
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 PR 生成特殊的 tag
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
# PR 构建使用特殊的 tag
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
# release 构建使用版本号
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
if: github.ref == 'refs/heads/main'
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
file: ./Dockerfile.database
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
rm -rf /tmp/digests
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
name: Merge
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digest-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 merge job 添加 PR metadata 生成
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
@@ -1,161 +0,0 @@
|
||||
name: Publish Docker Pglite Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
pull_request:
|
||||
types: [synchronize, labeled, unlabeled]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: lobehub/lobe-chat-pglite
|
||||
PR_TAG_PREFIX: pr-
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# 添加 PR label 触发条件
|
||||
if: |
|
||||
(github.event_name == 'pull_request' &&
|
||||
contains(github.event.pull_request.labels.*.name, 'Build Docker')) ||
|
||||
github.event_name != 'pull_request'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: Build ${{ matrix.platform }} Image
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 PR 生成特殊的 tag
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
# PR 构建使用特殊的 tag
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
# release 构建使用版本号
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
if: github.ref == 'refs/heads/main'
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
file: ./Dockerfile.pglite
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
rm -rf /tmp/digests
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
name: Merge
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digest-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 merge job 添加 PR metadata 生成
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
@@ -1,161 +0,0 @@
|
||||
name: Publish Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types: [published]
|
||||
pull_request:
|
||||
types: [synchronize, labeled, unlabeled]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY_IMAGE: lobehub/lobe-chat
|
||||
PR_TAG_PREFIX: pr-
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# 添加 PR label 触发条件
|
||||
if: |
|
||||
(github.event_name == 'pull_request' &&
|
||||
contains(github.event.pull_request.labels.*.name, 'Build Docker')) ||
|
||||
github.event_name != 'pull_request'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- platform: linux/amd64
|
||||
os: ubuntu-latest
|
||||
- platform: linux/arm64
|
||||
os: ubuntu-24.04-arm
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: Build ${{ matrix.platform }} Image
|
||||
steps:
|
||||
- name: Prepare
|
||||
run: |
|
||||
platform=${{ matrix.platform }}
|
||||
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 PR 生成特殊的 tag
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
# PR 构建使用特殊的 tag
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
# release 构建使用版本号
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Get commit SHA
|
||||
if: github.ref == 'refs/heads/main'
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and export
|
||||
id: build
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
platforms: ${{ matrix.platform }}
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
SHA=${{ steps.vars.outputs.sha_short }}
|
||||
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
|
||||
|
||||
- name: Export digest
|
||||
run: |
|
||||
rm -rf /tmp/digests
|
||||
mkdir -p /tmp/digests
|
||||
digest="${{ steps.build.outputs.digest }}"
|
||||
touch "/tmp/digests/${digest#sha256:}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: digest-${{ env.PLATFORM_PAIR }}
|
||||
path: /tmp/digests/*
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
merge:
|
||||
name: Merge
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: /tmp/digests
|
||||
pattern: digest-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# 为 merge job 添加 PR metadata 生成
|
||||
- name: Generate PR metadata
|
||||
if: github.event_name == 'pull_request'
|
||||
id: pr_meta
|
||||
run: |
|
||||
branch_name="${{ github.head_ref }}"
|
||||
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
|
||||
echo "pr_tag=${sanitized_branch}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY_IMAGE }}
|
||||
tags: |
|
||||
type=raw,value=${{ env.PR_TAG_PREFIX }}${{ steps.pr_meta.outputs.pr_tag }},enable=${{ github.event_name == 'pull_request' }}
|
||||
type=semver,pattern={{version}},enable=${{ github.event_name != 'pull_request' }}
|
||||
type=raw,value=latest,enable=${{ github.event_name != 'pull_request' }}
|
||||
|
||||
- name: Docker login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
||||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Create manifest list and push
|
||||
working-directory: /tmp/digests
|
||||
run: |
|
||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
|
||||
|
||||
- name: Inspect image
|
||||
run: |
|
||||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||
@@ -1,73 +0,0 @@
|
||||
name: Issue Auto Comment
|
||||
on:
|
||||
issues:
|
||||
types:
|
||||
- opened
|
||||
- closed
|
||||
- assigned
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- closed
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run:
|
||||
permissions:
|
||||
issues: write # for actions-cool/issues-helper to update issues
|
||||
pull-requests: write # for actions-cool/issues-helper to update PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Auto Comment on Issues Opened
|
||||
uses: wow-actions/auto-comment@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
|
||||
issuesOpened: |
|
||||
👀 @{{ author }}
|
||||
|
||||
Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
|
||||
Please make sure you have given us as much context as possible.\
|
||||
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。
|
||||
- name: Auto Comment on Issues Closed
|
||||
uses: wow-actions/auto-comment@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
|
||||
issuesClosed: |
|
||||
✅ @{{ author }}
|
||||
|
||||
This issue is closed, If you have any questions, you can comment and reply.\
|
||||
此问题已经关闭。如果您有任何问题,可以留言并回复。
|
||||
- name: Auto Comment on Pull Request Opened
|
||||
uses: wow-actions/auto-comment@v1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
|
||||
pullRequestOpened: |
|
||||
👍 @{{ author }}
|
||||
|
||||
Thank you for raising your pull request and contributing to our Community
|
||||
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
|
||||
If you encounter any problems, please feel free to connect with us.\
|
||||
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
|
||||
如果您遇到任何问题,请随时与我们联系。
|
||||
- name: Auto Comment on Pull Request Merged
|
||||
uses: actions-cool/pr-welcome@main
|
||||
if: github.event.pull_request.merged == true
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
comment: |
|
||||
❤️ Great PR @${{ github.event.pull_request.user.login }} ❤️
|
||||
|
||||
The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our [discord](https://discord.com/invite/AYFPHvv2jT) and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.\
|
||||
项目的成长离不开用户反馈和贡献,感谢您的贡献! 如果您对 LobeHub 开发者社区感兴趣,请加入我们的 [discord](https://discord.com/invite/AYFPHvv2jT),然后私信 @arvinxx 或 @canisminor1990。他们会邀请您加入我们的私密开发者频道。我们将会讨论关于 Lobe Chat 的开发,分享和讨论全球范围内的 AI 消息。
|
||||
emoji: 'hooray'
|
||||
pr-emoji: '+1, heart'
|
||||
- name: Remove inactive
|
||||
if: github.event.issue.state == 'open' && github.actor == github.event.issue.user.login
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'remove-labels'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: 'Inactive'
|
||||
@@ -1,66 +0,0 @@
|
||||
name: Issue Close Require
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
issue-check-inactive:
|
||||
permissions:
|
||||
issues: write # for actions-cool/issues-helper to update issues
|
||||
pull-requests: write # for actions-cool/issues-helper to update PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: check-inactive
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'check-inactive'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
inactive-label: 'Inactive'
|
||||
inactive-day: 60
|
||||
|
||||
issue-close-require:
|
||||
permissions:
|
||||
issues: write # for actions-cool/issues-helper to update issues
|
||||
pull-requests: write # for actions-cool/issues-helper to update PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: need reproduce
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
labels: '✅ Fixed'
|
||||
inactive-day: 3
|
||||
body: |
|
||||
👋 @{{ author }}
|
||||
<br/>
|
||||
Since the issue was labeled with `✅ Fixed`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
|
||||
由于该 issue 被标记为已修复,同时 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
|
||||
- name: need reproduce
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
labels: '🤔 Need Reproduce'
|
||||
inactive-day: 3
|
||||
body: |
|
||||
👋 @{{ author }}
|
||||
<br/>
|
||||
Since the issue was labeled with `🤔 Need Reproduce`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
|
||||
由于该 issue 被标记为需要更多信息,却 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
|
||||
- name: need reproduce
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
labels: "🙅🏻♀️ WON'T DO"
|
||||
inactive-day: 3
|
||||
body: |
|
||||
👋 @{{ github.event.issue.user.login }}
|
||||
<br/>
|
||||
Since the issue was labeled with `🙅🏻♀️ WON'T DO`, and no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
|
||||
由于该 issue 被标记为暂不处理,同时 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
|
||||
@@ -1,14 +0,0 @@
|
||||
name: Issue Translate
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: usthe/issues-translate-action@v2.7
|
||||
with:
|
||||
BOT_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
@@ -0,0 +1,92 @@
|
||||
# Lighthouse-Badger-Advanced | GitHub Action Workflow
|
||||
#
|
||||
# Description: Generates, adds & updates manually/automatically Lighthouse badges & reports from one/multiple input URL-group(s) to one/multiple target repo(s)/branch(es) in parallel
|
||||
# Author: Sitdisch
|
||||
# Source: https://github.com/myactionway/lighthouse-badger-workflows
|
||||
# License: MIT
|
||||
# Copyright (c) 2021 Sitdisch
|
||||
|
||||
name: 'Lighthouse-Badger-Advanced'
|
||||
|
||||
########################################################################
|
||||
# DEFINE YOUR DEFAULTS (INPUTS & TRIGGERS) IN THE FOLLOWING
|
||||
########################################################################
|
||||
|
||||
# INPUTS as environmental variables (env)
|
||||
env:
|
||||
TOKEN_NAME: 'GH_TOKEN' # target token name; insert only the name never the real value e.g. 'LIGHTHOUSE_BADGER_TOKEN'
|
||||
# To change predefined values, just override them
|
||||
REPO_BRANCH: 'lobehub/lobe-chat lighthouse' # target repository & branch (predefined: repo with this file and master branch)
|
||||
USER_NAME: 'lobehubbot' # user who should commit
|
||||
USER_EMAIL: 'i@lobehub.com'
|
||||
AUDIT_TYPE: 'both' # 'mobile', 'desktop', 'both' or 'both_p'
|
||||
MOBILE_LIGHTHOUSE_PARAMS: '--throttling.cpuSlowdownMultiplier=2' # Lighthouse parameters mobile audit
|
||||
DESKTOP_LIGHTHOUSE_PARAMS: '--preset=desktop --throttling.cpuSlowdownMultiplier=1' # Lighthouse parameters desktop audit
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results Refreshed'
|
||||
|
||||
# TRIGGERS
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
########################################################################
|
||||
# YOU CAN JUMP TO THE FIRST URL-GROUP DEFINITION BELOW
|
||||
########################################################################
|
||||
|
||||
# Jobs
|
||||
jobs:
|
||||
lighthouse-badger-advanced:
|
||||
name: ${{ matrix.NAME }}
|
||||
runs-on: ubuntu-22.04
|
||||
timeout-minutes: 8
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- NAME: 'LobeChat | Welcome'
|
||||
URLS: 'https://chat.lobehub.com/welcome'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/welcome -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Welcome'
|
||||
- NAME: 'LobeChat | Chat'
|
||||
URLS: 'https://chat.lobehub.com/chat'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/chat -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Chat'
|
||||
- NAME: 'LobeChat | Market'
|
||||
URLS: 'https://chat.lobehub.com/market'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/market -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Market'
|
||||
- NAME: 'LobeChat | Settings'
|
||||
URLS: 'https://chat.lobehub.com/settings'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/settings -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Settings'
|
||||
####################################################################
|
||||
# THAT'S IT; YOU DON'T HAVE TO DEFINE ANYTHING IN THE FOLLOWING
|
||||
####################################################################
|
||||
steps:
|
||||
- name: Preparatory Tasks
|
||||
run: |
|
||||
REPOSITORY=`expr "${{ env.REPO_BRANCH }}" : "\([^ ]*\)"`
|
||||
BRANCH=`expr "${{ env.REPO_BRANCH }}" : ".* \([^ ]*\)"`
|
||||
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
|
||||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||
env:
|
||||
REPO_BRANCH: ${{ matrix.REPO_BRANCH || env.REPO_BRANCH }}
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ${{ env.REPOSITORY }}
|
||||
token: ${{ secrets[matrix.TOKEN_NAME] || secrets[env.TOKEN_NAME] }}
|
||||
ref: ${{ env.BRANCH }}
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: 'myactionway/lighthouse-badges'
|
||||
path: temp_lighthouse_badges_nested
|
||||
- uses: myactionway/lighthouse-badger-action@v2.2
|
||||
with:
|
||||
urls: ${{ matrix.URLS }}
|
||||
badges_args: ${{ matrix.BADGES_ARGS }}
|
||||
audit_type: ${{ matrix.AUDIT_TYPE || env.AUDIT_TYPE }}
|
||||
mobile_lighthouse_params: ${{ matrix.MOBILE_LIGHTHOUSE_PARAMS || env.MOBILE_LIGHTHOUSE_PARAMS }}
|
||||
desktop_lighthouse_params: ${{ matrix.DESKTOP_LIGHTHOUSE_PARAMS || env.DESKTOP_LIGHTHOUSE_PARAMS }}
|
||||
user_name: ${{ matrix.USER_NAME || env.USER_NAME }}
|
||||
user_email: ${{ matrix.USER_EMAIL || env.USER_EMAIL }}
|
||||
commit_message: ${{ matrix.COMMIT_MESSAGE || env.COMMIT_MESSAGE }}
|
||||
max_push_attempts: 5
|
||||
@@ -1,64 +0,0 @@
|
||||
name: Lighthouse Badger
|
||||
|
||||
env:
|
||||
TOKEN_NAME: 'GH_TOKEN'
|
||||
REPO_BRANCH: 'lobehub/lobe-chat lighthouse'
|
||||
USER_NAME: 'lobehubbot'
|
||||
USER_EMAIL: 'i@lobehub.com'
|
||||
AUDIT_TYPE: 'both'
|
||||
MOBILE_LIGHTHOUSE_PARAMS: '--throttling.cpuSlowdownMultiplier=2'
|
||||
DESKTOP_LIGHTHOUSE_PARAMS: '--preset=desktop --throttling.cpuSlowdownMultiplier=1'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results Refreshed'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # every day
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
lighthouse-badger-advanced:
|
||||
name: ${{ matrix.NAME }}
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 8
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- NAME: 'LobeChat | Chat'
|
||||
URLS: 'https://lobechat.com/chat'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/chat -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Chat'
|
||||
- NAME: 'LobeChat | Market'
|
||||
URLS: 'https://lobechat.com/discover'
|
||||
BADGES_ARGS: '-b pagespeed -o lighthouse/discover -r'
|
||||
COMMIT_MESSAGE: '🤖 chore: Lighthouse Results | Discover'
|
||||
|
||||
steps:
|
||||
- name: Preparatory Tasks
|
||||
run: |
|
||||
REPOSITORY=`expr "${{ env.REPO_BRANCH }}" : "\([^ ]*\)"`
|
||||
BRANCH=`expr "${{ env.REPO_BRANCH }}" : ".* \([^ ]*\)"`
|
||||
echo "REPOSITORY=$REPOSITORY" >> $GITHUB_ENV
|
||||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
|
||||
env:
|
||||
REPO_BRANCH: ${{ matrix.REPO_BRANCH || env.REPO_BRANCH }}
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: ${{ env.REPOSITORY }}
|
||||
token: ${{ secrets[matrix.TOKEN_NAME] || secrets[env.TOKEN_NAME] }}
|
||||
ref: ${{ env.BRANCH }}
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: 'myactionway/lighthouse-badges'
|
||||
path: temp_lighthouse_badges_nested
|
||||
- uses: myactionway/lighthouse-badger-action@v2.2
|
||||
with:
|
||||
urls: ${{ matrix.URLS }}
|
||||
badges_args: ${{ matrix.BADGES_ARGS }}
|
||||
audit_type: ${{ matrix.AUDIT_TYPE || env.AUDIT_TYPE }}
|
||||
mobile_lighthouse_params: ${{ matrix.MOBILE_LIGHTHOUSE_PARAMS || env.MOBILE_LIGHTHOUSE_PARAMS }}
|
||||
desktop_lighthouse_params: ${{ matrix.DESKTOP_LIGHTHOUSE_PARAMS || env.DESKTOP_LIGHTHOUSE_PARAMS }}
|
||||
user_name: ${{ matrix.USER_NAME || env.USER_NAME }}
|
||||
user_email: ${{ matrix.USER_EMAIL || env.USER_EMAIL }}
|
||||
commit_message: ${{ matrix.COMMIT_MESSAGE || env.COMMIT_MESSAGE }}
|
||||
max_push_attempts: 5
|
||||
@@ -1,205 +0,0 @@
|
||||
name: Release Desktop Beta
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published] # 发布 release 时触发构建
|
||||
|
||||
# 确保同一时间只运行一个相同的 workflow,取消正在进行的旧的运行
|
||||
concurrency:
|
||||
group: ${{ github.ref }}-${{ github.workflow }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Add default permissions
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Code quality check
|
||||
# 添加 PR label 触发条件,只有添加了 Build Desktop 标签的 PR 才会触发构建
|
||||
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
|
||||
steps:
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Install deps
|
||||
run: pnpm install
|
||||
|
||||
- name: Lint
|
||||
run: pnpm run lint
|
||||
|
||||
version:
|
||||
name: Determine version
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
# 输出版本信息,供后续 job 使用
|
||||
version: ${{ steps.set_version.outputs.version }}
|
||||
is_pr_build: ${{ steps.set_version.outputs.is_pr_build }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
# 主要逻辑:确定构建版本号
|
||||
- name: Set version
|
||||
id: set_version
|
||||
run: |
|
||||
# 从 apps/desktop/package.json 读取基础版本号
|
||||
base_version=$(node -p "require('./apps/desktop/package.json').version")
|
||||
|
||||
# Release 事件直接使用 release tag 作为版本号,去掉可能的 v 前缀
|
||||
version="${{ github.event.release.tag_name }}"
|
||||
version="${version#v}"
|
||||
echo "version=${version}" >> $GITHUB_OUTPUT
|
||||
echo "📦 Release Version: ${version}"
|
||||
|
||||
# 输出版本信息总结,方便在 GitHub Actions 界面查看
|
||||
- name: Version Summary
|
||||
run: |
|
||||
echo "🚦 Release Version: ${{ steps.set_version.outputs.version }}"
|
||||
|
||||
build:
|
||||
needs: [version, test]
|
||||
name: Build Desktop App
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, windows-2025, ubuntu-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 9
|
||||
|
||||
# node-linker=hoisted 模式将可以确保 asar 压缩可用
|
||||
- name: Install deps
|
||||
run: pnpm install --node-linker=hoisted
|
||||
|
||||
- name: Install deps on Desktop
|
||||
run: npm run install-isolated --prefix=./apps/desktop
|
||||
|
||||
# 设置 package.json 的版本号
|
||||
- name: Set package version
|
||||
run: npm run workflow:set-desktop-version ${{ needs.version.outputs.version }} beta
|
||||
|
||||
# macOS 构建处理
|
||||
- name: Build artifact on macOS
|
||||
if: runner.os == 'macOS'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
# 默认添加一个加密 SECRET
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
# macOS 签名和公证配置
|
||||
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
|
||||
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||
# allow provisionally
|
||||
CSC_FOR_PULL_REQUEST: true
|
||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_BETA_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_BETA_DESKTOP_BASE_URL }}
|
||||
|
||||
# Windows 平台构建处理
|
||||
- name: Build artifact on Windows
|
||||
if: runner.os == 'Windows'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_BETA_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_BETA_DESKTOP_BASE_URL }}
|
||||
|
||||
# 将 TEMP 和 TMP 目录设置到 C 盘
|
||||
TEMP: C:\temp
|
||||
TMP: C:\temp
|
||||
|
||||
# Linux 平台构建处理
|
||||
- name: Build artifact on Linux
|
||||
if: runner.os == 'Linux'
|
||||
run: npm run desktop:build
|
||||
env:
|
||||
APP_URL: http://localhost:3015
|
||||
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
|
||||
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
|
||||
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_BETA_DESKTOP_PROJECT_ID }}
|
||||
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_BETA_DESKTOP_BASE_URL }}
|
||||
|
||||
# 上传构建产物,移除了 zip 相关部分
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-${{ matrix.os }}
|
||||
path: |
|
||||
apps/desktop/release/latest*
|
||||
apps/desktop/release/*.dmg*
|
||||
apps/desktop/release/*.zip*
|
||||
apps/desktop/release/*.exe*
|
||||
apps/desktop/release/*.AppImage
|
||||
retention-days: 5
|
||||
|
||||
# 正式版发布 job
|
||||
publish-release:
|
||||
needs: [build, version]
|
||||
name: Publish Beta Release
|
||||
runs-on: ubuntu-latest
|
||||
# Grant write permission to contents for uploading release assets
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
artifact_path: ${{ steps.set_path.outputs.path }}
|
||||
steps:
|
||||
# 下载所有平台的构建产物
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: release
|
||||
pattern: release-*
|
||||
merge-multiple: true
|
||||
|
||||
# 列出所有构建产物
|
||||
- name: List artifacts
|
||||
run: ls -R release
|
||||
|
||||
# 将构建产物上传到现有 release
|
||||
- name: Upload to Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: ${{ github.event.release.tag_name }}
|
||||
files: |
|
||||
release/latest*
|
||||
release/*.dmg*
|
||||
release/*.zip*
|
||||
release/*.exe*
|
||||
release/*.AppImage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,72 +0,0 @@
|
||||
name: Release CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: pgvector/pgvector:pg16
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Lint
|
||||
run: bun run lint
|
||||
|
||||
- name: Test Server Coverage
|
||||
run: bun run test-server:coverage
|
||||
env:
|
||||
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
||||
DATABASE_DRIVER: node
|
||||
NEXT_PUBLIC_SERVICE_MODE: server
|
||||
KEY_VAULTS_SECRET: LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=
|
||||
S3_PUBLIC_DOMAIN: https://example.com
|
||||
APP_URL: https://home.com
|
||||
|
||||
- name: Test App Coverage
|
||||
run: bun run test-app:coverage
|
||||
|
||||
- name: Release
|
||||
run: bun run release
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Workflow
|
||||
run: bun run workflow:readme
|
||||
|
||||
- name: Commit changes
|
||||
run: |-
|
||||
git diff
|
||||
git config --global user.name "lobehubbot"
|
||||
git config --global user.email "i@lobehub.com"
|
||||
git add .
|
||||
git commit -m "📝 docs(bot): Auto sync agents & plugin to readme" || exit 0
|
||||
git push
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
@@ -1,25 +0,0 @@
|
||||
name: Database Schema Visualization CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'docs/development/database-schema.dbml'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dbdocs
|
||||
run: sudo npm install -g dbdocs
|
||||
|
||||
- name: Check dbdocs
|
||||
run: dbdocs
|
||||
|
||||
- name: sync database schema to dbdocs
|
||||
env:
|
||||
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
|
||||
run: npm run db:visualize
|
||||
@@ -1,54 +0,0 @@
|
||||
name: Upstream Sync
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
actions: write
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 */6 * * *' # every 6 hours
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
sync_latest_from_upstream:
|
||||
name: Sync latest commits from upstream repo
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.repository.fork }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Clean issue notice
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'close-issues'
|
||||
labels: '🚨 Sync Fail'
|
||||
|
||||
- name: Sync upstream changes
|
||||
id: sync
|
||||
uses: aormsby/Fork-Sync-With-Upstream-action@v3.4
|
||||
with:
|
||||
upstream_sync_repo: lobehub/lobe-chat
|
||||
upstream_sync_branch: main
|
||||
target_sync_branch: main
|
||||
target_repo_token: ${{ secrets.GITHUB_TOKEN }} # automatically generated, no need to set
|
||||
test_mode: false
|
||||
|
||||
- name: Sync check
|
||||
if: failure()
|
||||
uses: actions-cool/issues-helper@v3
|
||||
with:
|
||||
actions: 'create-issue'
|
||||
title: '🚨 同步失败 | Sync Fail'
|
||||
labels: '🚨 Sync Fail'
|
||||
body: |
|
||||
Due to a change in the workflow file of the [LobeChat][lobechat] upstream repository, GitHub has automatically suspended the scheduled automatic update. You need to manually sync your fork. Please refer to the detailed [Tutorial][tutorial-en-US] for instructions.
|
||||
|
||||
由于 [LobeChat][lobechat] 上游仓库的 workflow 文件变更,导致 GitHub 自动暂停了本次自动更新,你需要手动 Sync Fork 一次,请查看 [详细教程][tutorial-zh-CN]
|
||||
|
||||

|
||||
|
||||
[lobechat]: https://github.com/lobehub/lobe-chat
|
||||
[tutorial-zh-CN]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN
|
||||
[tutorial-en-US]: https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync
|
||||
@@ -1,65 +0,0 @@
|
||||
name: Test CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: paradedb/paradedb:latest
|
||||
env:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
options: >-
|
||||
--health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
|
||||
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: ${{ secrets.BUN_VERSION }}
|
||||
|
||||
- name: Install deps
|
||||
run: bun i
|
||||
|
||||
- name: Lint
|
||||
run: bun run lint
|
||||
|
||||
- name: Test Server Coverage
|
||||
run: bun run test-server:coverage
|
||||
env:
|
||||
DATABASE_TEST_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
||||
DATABASE_DRIVER: node
|
||||
NEXT_PUBLIC_SERVICE_MODE: server
|
||||
KEY_VAULTS_SECRET: LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=
|
||||
S3_PUBLIC_DOMAIN: https://example.com
|
||||
APP_URL: https://home.com
|
||||
|
||||
- name: Upload Server coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage/server/lcov.info
|
||||
flags: server
|
||||
|
||||
- name: Test App Coverage
|
||||
run: bun run test-app:coverage
|
||||
|
||||
- name: Upload App Coverage to Codecov
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: ./coverage/app/lcov.info
|
||||
flags: app
|
||||
@@ -1,19 +0,0 @@
|
||||
name: Wiki Sync
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
paths:
|
||||
- 'docs/wiki/**'
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
update-wiki:
|
||||
runs-on: ubuntu-latest
|
||||
name: Wiki sync
|
||||
steps:
|
||||
- uses: OrlovM/Wiki-Action@v1
|
||||
with:
|
||||
path: 'docs/wiki'
|
||||
token: ${{ secrets.GH_TOKEN }}
|
||||
+4
-23
@@ -11,7 +11,6 @@
|
||||
venv
|
||||
temp
|
||||
tmp
|
||||
.windsurfrules
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
@@ -41,6 +40,9 @@ test-output
|
||||
# husky
|
||||
.husky/prepare-commit-msg
|
||||
|
||||
# misc
|
||||
# add other ignore file below
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
@@ -53,25 +55,4 @@ next-env.d.ts
|
||||
.next
|
||||
.env
|
||||
public/*.js
|
||||
public/sitemap.xml
|
||||
public/sitemap-index.xml
|
||||
bun.lockb
|
||||
sitemap*.xml
|
||||
robots.txt
|
||||
|
||||
# Serwist
|
||||
public/sw*
|
||||
public/swe-worker*
|
||||
|
||||
*.patch
|
||||
*.pdf
|
||||
vertex-ai-key.json
|
||||
.pnpm-store
|
||||
./packages/lobe-ui
|
||||
|
||||
|
||||
# local use ai coding files
|
||||
docs/.prd
|
||||
.claude
|
||||
.mcp.json
|
||||
CLAUDE.md
|
||||
bun.lockb
|
||||
@@ -1,2 +0,0 @@
|
||||
npm run type-check
|
||||
npx --no-install lint-staged
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
const { defineConfig } = require('@lobehub/i18n-cli');
|
||||
|
||||
module.exports = defineConfig({
|
||||
entry: 'locales/zh-CN',
|
||||
entryLocale: 'zh-CN',
|
||||
output: 'locales',
|
||||
outputLocales: [
|
||||
'ar',
|
||||
'bg-BG',
|
||||
'zh-TW',
|
||||
'en-US',
|
||||
'ru-RU',
|
||||
'ja-JP',
|
||||
'ko-KR',
|
||||
'fr-FR',
|
||||
'tr-TR',
|
||||
'es-ES',
|
||||
'pt-BR',
|
||||
'de-DE',
|
||||
'it-IT',
|
||||
'nl-NL',
|
||||
'pl-PL',
|
||||
'vi-VN',
|
||||
'fa-IR',
|
||||
],
|
||||
temperature: 0,
|
||||
saveImmediately: true,
|
||||
modelName: 'gpt-4.1-mini',
|
||||
experimental: {
|
||||
jsonMode: true,
|
||||
},
|
||||
markdown: {
|
||||
reference: '你需要保持 mdx 的组件格式,输出文本不需要在最外层包裹任何代码块语法',
|
||||
entry: ['./README.zh-CN.md', './contributing/**/*.zh-CN.md', './docs/**/*.zh-CN.mdx'],
|
||||
entryLocale: 'zh-CN',
|
||||
outputLocales: ['en-US'],
|
||||
includeMatter: true,
|
||||
exclude: [
|
||||
'./src/**/*',
|
||||
'./contributing/_Sidebar.md',
|
||||
'./contributing/_Footer.md',
|
||||
'./contributing/Home.md',
|
||||
],
|
||||
outputExtensions: (locale, { filePath }) => {
|
||||
if (filePath.includes('.mdx')) {
|
||||
if (locale === 'en-US') return '.mdx';
|
||||
return `.${locale}.mdx`;
|
||||
} else {
|
||||
if (locale === 'en-US') return '.md';
|
||||
return `.${locale}.md`;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,20 +0,0 @@
|
||||
lockfile=false
|
||||
resolution-mode=highest
|
||||
|
||||
ignore-workspace-root-check=true
|
||||
enable-pre-post-scripts=true
|
||||
|
||||
public-hoist-pattern[]=*@umijs/lint*
|
||||
public-hoist-pattern[]=*changelog*
|
||||
public-hoist-pattern[]=*commitlint*
|
||||
public-hoist-pattern[]=*eslint*
|
||||
public-hoist-pattern[]=*postcss*
|
||||
public-hoist-pattern[]=*prettier*
|
||||
public-hoist-pattern[]=*remark*
|
||||
public-hoist-pattern[]=*semantic-release*
|
||||
public-hoist-pattern[]=*stylelint*
|
||||
|
||||
public-hoist-pattern[]=@auth/core
|
||||
public-hoist-pattern[]=@clerk/backend
|
||||
public-hoist-pattern[]=@clerk/types
|
||||
public-hoist-pattern[]=pdfjs-dist
|
||||
@@ -1,63 +0,0 @@
|
||||
# Prettierignore for LobeHub
|
||||
################################################################
|
||||
|
||||
# general
|
||||
.DS_Store
|
||||
.editorconfig
|
||||
.idea
|
||||
.vscode
|
||||
.history
|
||||
.temp
|
||||
.env.local
|
||||
.husky
|
||||
.npmrc
|
||||
.gitkeep
|
||||
venv
|
||||
temp
|
||||
tmp
|
||||
LICENSE
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
*.log
|
||||
*.lock
|
||||
package-lock.json
|
||||
|
||||
# ci
|
||||
coverage
|
||||
.coverage
|
||||
.eslintcache
|
||||
.stylelintcache
|
||||
test-output
|
||||
__snapshots__
|
||||
*.snap
|
||||
|
||||
# production
|
||||
dist
|
||||
es
|
||||
lib
|
||||
logs
|
||||
|
||||
# umi
|
||||
.umi
|
||||
.umi-production
|
||||
.umi-test
|
||||
.dumi/tmp*
|
||||
|
||||
# ignore files
|
||||
.*ignore
|
||||
|
||||
# docker
|
||||
docker
|
||||
Dockerfile*
|
||||
|
||||
# image
|
||||
*.webp
|
||||
*.gif
|
||||
*.png
|
||||
*.jpg
|
||||
*.svg
|
||||
|
||||
# misc
|
||||
# add other ignore file below
|
||||
.next
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@lobehub/lint').prettier;
|
||||
@@ -1,10 +0,0 @@
|
||||
const config = require('@lobehub/lint').semanticRelease;
|
||||
|
||||
config.plugins.push([
|
||||
'@semantic-release/exec',
|
||||
{
|
||||
prepareCmd: 'npm run workflow:changelog',
|
||||
},
|
||||
]);
|
||||
|
||||
module.exports = config;
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = require('@lobehub/lint').remarklint;
|
||||
@@ -1,6 +0,0 @@
|
||||
const config = require('@lobehub/lint').remarklint;
|
||||
|
||||
module.exports = {
|
||||
...config,
|
||||
plugins: ['remark-mdx', ...config.plugins],
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
const { defineConfig } = require('@lobehub/seo-cli');
|
||||
|
||||
module.exports = defineConfig({
|
||||
entry: ['./docs/**/*.mdx'],
|
||||
modelName: 'gpt-4o-mini',
|
||||
experimental: {
|
||||
jsonMode: true,
|
||||
},
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
const config = require('@lobehub/lint').stylelint;
|
||||
|
||||
module.exports = {
|
||||
...config,
|
||||
rules: {
|
||||
'selector-id-pattern': null,
|
||||
...config.rules,
|
||||
},
|
||||
};
|
||||
-24937
File diff suppressed because it is too large
Load Diff
@@ -1,128 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to participate in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community includes:
|
||||
|
||||
- Demonstrating empathy and kindness toward other people
|
||||
- Being respectful of differing opinions, viewpoints, and experiences
|
||||
- Giving and gracefully accepting constructive feedback
|
||||
- Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
- Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
## Examples of unacceptable behavior include:
|
||||
|
||||
- The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
- Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
- Public or private harassment
|
||||
- Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
- Other conduct that could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
<https://www.contributor-covenant.org/faq>. Translations are available at
|
||||
<https://www.contributor-covenant.org/translations>.
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
@@ -1,88 +0,0 @@
|
||||
# Lobe Chat - Contributing Guide 🌟
|
||||
|
||||
We're thrilled that you want to contribute to Lobe Chat, the future of communication! 😄
|
||||
|
||||
Lobe Chat is an open-source project, and we welcome your collaboration. Before you jump in, let's make sure you're all set to contribute effectively and have loads of fun along the way!
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Fork the Repository](#fork-the-repository)
|
||||
- [Clone Your Fork](#clone-your-fork)
|
||||
- [Create a New Branch](#create-a-new-branch)
|
||||
- [Code Like a Wizard](#code-like-a-wizard)
|
||||
- [Committing Your Work](#committing-your-work)
|
||||
- [Sync with Upstream](#sync-with-upstream)
|
||||
- [Open a Pull Request](#open-a-pull-request)
|
||||
- [Review and Collaboration](#review-and-collaboration)
|
||||
- [Celebrate 🎉](#celebrate-)
|
||||
|
||||
## Fork the Repository
|
||||
|
||||
🍴 Fork this repository to your GitHub account by clicking the "Fork" button at the top right. This creates a personal copy of the project you can work on.
|
||||
|
||||
## Clone Your Fork
|
||||
|
||||
📦 Clone your forked repository to your local machine using the `git clone` command:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/YourUsername/lobe-chat.git
|
||||
```
|
||||
|
||||
## Create a New Branch
|
||||
|
||||
🌿 Create a new branch for your contribution. This helps keep your work organized and separate from the main codebase.
|
||||
|
||||
```bash
|
||||
git checkout -b your-branch-name
|
||||
```
|
||||
|
||||
Choose a meaningful branch name related to your work. It makes collaboration easier!
|
||||
|
||||
## Code Like a Wizard
|
||||
|
||||
🧙♀️ Time to work your magic! Write your code, fix bugs, or add new features. Be sure to follow our project's coding style. You can check if your code adheres to our style using:
|
||||
|
||||
```bash
|
||||
pnpm lint
|
||||
```
|
||||
|
||||
This adds a bit of enchantment to your coding experience! ✨
|
||||
|
||||
## Committing Your Work
|
||||
|
||||
📝 Ready to save your progress? Commit your changes to your branch.
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Your meaningful commit message"
|
||||
```
|
||||
|
||||
Please keep your commits focused and clear. And remember to be kind to your fellow contributors; keep your commits concise.
|
||||
|
||||
## Sync with Upstream
|
||||
|
||||
⚙️ Periodically, sync your forked repository with the original (upstream) repository to stay up-to-date with the latest changes.
|
||||
|
||||
```bash
|
||||
git remote add upstream https://github.com/lobehub/lobe-chat.git
|
||||
git fetch upstream
|
||||
git merge upstream/main
|
||||
```
|
||||
|
||||
This ensures you're working on the most current version of Lobe Chat. Stay fresh! 💨
|
||||
|
||||
## Open a Pull Request
|
||||
|
||||
🚀 Time to share your contribution! Head over to the original Lobe Chat repository and open a Pull Request (PR). Our maintainers will review your work.
|
||||
|
||||
## Review and Collaboration
|
||||
|
||||
👓 Your PR will undergo thorough review and testing. The maintainers will provide feedback, and you can collaborate to make your contribution even better. We value teamwork!
|
||||
|
||||
## Celebrate 🎉
|
||||
|
||||
🎈 Congratulations! Your contribution is now part of Lobe Chat. 🥳
|
||||
|
||||
Thank you for making Lobe Chat even more magical. We can't wait to see what you create! 🌠
|
||||
|
||||
Happy Coding! 🚀🦄
|
||||
-256
@@ -1,256 +0,0 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" "/etc/apt/sources.list.d/debian.sources"; \
|
||||
fi \
|
||||
# Add required package
|
||||
&& apt update \
|
||||
&& apt install ca-certificates proxychains-ng -qy \
|
||||
# Prepare required package to distroless
|
||||
&& mkdir -p /distroless/bin /distroless/etc /distroless/etc/ssl/certs /distroless/lib \
|
||||
# Copy proxychains to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libproxychains.so.4 /distroless/lib/libproxychains.so.4 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libdl.so.2 /distroless/lib/libdl.so.2 \
|
||||
&& cp /usr/bin/proxychains4 /distroless/bin/proxychains \
|
||||
&& cp /etc/proxychains4.conf /distroless/etc/proxychains4.conf \
|
||||
# Copy node to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libstdc++.so.6 /distroless/lib/libstdc++.so.6 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libgcc_s.so.1 /distroless/lib/libgcc_s.so.1 \
|
||||
&& cp /usr/local/bin/node /distroless/bin/node \
|
||||
# Copy CA certificates to distroless
|
||||
&& cp /etc/ssl/certs/ca-certificates.crt /distroless/etc/ssl/certs/ca-certificates.crt \
|
||||
# Cleanup temp files
|
||||
&& rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
|
||||
|
||||
## Builder image, install all the dependencies and build the app
|
||||
FROM base AS builder
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
ARG NEXT_PUBLIC_BASE_PATH
|
||||
ARG NEXT_PUBLIC_SENTRY_DSN
|
||||
ARG NEXT_PUBLIC_ANALYTICS_POSTHOG
|
||||
ARG NEXT_PUBLIC_POSTHOG_HOST
|
||||
ARG NEXT_PUBLIC_POSTHOG_KEY
|
||||
ARG NEXT_PUBLIC_ANALYTICS_UMAMI
|
||||
ARG NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
||||
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||
ARG FEATURE_FLAGS
|
||||
|
||||
ENV NEXT_PUBLIC_BASE_PATH="${NEXT_PUBLIC_BASE_PATH}" \
|
||||
FEATURE_FLAGS="${FEATURE_FLAGS}"
|
||||
# Sentry
|
||||
ENV NEXT_PUBLIC_SENTRY_DSN="${NEXT_PUBLIC_SENTRY_DSN}" \
|
||||
SENTRY_ORG="" \
|
||||
SENTRY_PROJECT=""
|
||||
|
||||
ENV APP_URL="http://app.com"
|
||||
|
||||
# Posthog
|
||||
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG="${NEXT_PUBLIC_ANALYTICS_POSTHOG}" \
|
||||
NEXT_PUBLIC_POSTHOG_HOST="${NEXT_PUBLIC_POSTHOG_HOST}" \
|
||||
NEXT_PUBLIC_POSTHOG_KEY="${NEXT_PUBLIC_POSTHOG_KEY}"
|
||||
|
||||
# Umami
|
||||
ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL="${NEXT_PUBLIC_UMAMI_SCRIPT_URL}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json pnpm-workspace.yaml ./
|
||||
COPY .npmrc ./
|
||||
COPY packages ./packages
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \
|
||||
npm config set registry "https://registry.npmmirror.com/"; \
|
||||
echo 'canvas_binary_host_mirror=https://npmmirror.com/mirrors/canvas' >> .npmrc; \
|
||||
fi \
|
||||
# Set the registry for corepack
|
||||
&& export COREPACK_NPM_REGISTRY=$(npm config get registry | sed 's/\/$//') \
|
||||
# Update corepack to latest (nodejs/corepack#612)
|
||||
&& npm i -g corepack@latest \
|
||||
# Enable corepack
|
||||
&& corepack enable \
|
||||
# Use pnpm for corepack
|
||||
&& corepack use $(sed -n 's/.*"packageManager": "\(.*\)".*/\1/p' package.json) \
|
||||
# Install the dependencies
|
||||
&& pnpm i
|
||||
|
||||
COPY . .
|
||||
|
||||
# run build standalone for docker version
|
||||
RUN npm run build:docker
|
||||
|
||||
## Application image, copy all the files for production
|
||||
FROM busybox:latest AS app
|
||||
|
||||
COPY --from=base /distroless/ /
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder /app/.next/standalone /app/
|
||||
|
||||
# Copy server launcher
|
||||
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
|
||||
|
||||
RUN \
|
||||
# Add nextjs:nodejs to run the app
|
||||
addgroup -S -g 1001 nodejs \
|
||||
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
|
||||
# Set permission for nextjs:nodejs
|
||||
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
|
||||
|
||||
## Production image, copy all the files and run next
|
||||
FROM scratch
|
||||
|
||||
# Copy all the files from app, set the correct permission for prerender cache
|
||||
COPY --from=app / /
|
||||
|
||||
ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
ENV MIDDLEWARE_REWRITE_THROUGH_LOCAL="1"
|
||||
|
||||
# set hostname to localhost
|
||||
ENV HOSTNAME="0.0.0.0" \
|
||||
PORT="3210"
|
||||
|
||||
# General Variables
|
||||
ENV ACCESS_CODE="" \
|
||||
API_KEY_SELECT_MODE="" \
|
||||
DEFAULT_AGENT_CONFIG="" \
|
||||
SYSTEM_AGENT="" \
|
||||
FEATURE_FLAGS="" \
|
||||
PROXY_URL=""
|
||||
|
||||
# Model Variables
|
||||
ENV \
|
||||
# AI21
|
||||
AI21_API_KEY="" AI21_MODEL_LIST="" \
|
||||
# Ai360
|
||||
AI360_API_KEY="" AI360_MODEL_LIST="" \
|
||||
# Anthropic
|
||||
ANTHROPIC_API_KEY="" ANTHROPIC_MODEL_LIST="" ANTHROPIC_PROXY_URL="" \
|
||||
# Amazon Bedrock
|
||||
AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_REGION="" AWS_BEDROCK_MODEL_LIST="" \
|
||||
# Azure OpenAI
|
||||
AZURE_API_KEY="" AZURE_API_VERSION="" AZURE_ENDPOINT="" AZURE_MODEL_LIST="" \
|
||||
# Baichuan
|
||||
BAICHUAN_API_KEY="" BAICHUAN_MODEL_LIST="" \
|
||||
# Cloudflare
|
||||
CLOUDFLARE_API_KEY="" CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID="" CLOUDFLARE_MODEL_LIST="" \
|
||||
# Cohere
|
||||
COHERE_API_KEY="" COHERE_MODEL_LIST="" COHERE_PROXY_URL="" \
|
||||
# DeepSeek
|
||||
DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \
|
||||
# Fireworks AI
|
||||
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
|
||||
# Gitee AI
|
||||
GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \
|
||||
# GitHub
|
||||
GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \
|
||||
# Google
|
||||
GOOGLE_API_KEY="" GOOGLE_MODEL_LIST="" GOOGLE_PROXY_URL="" \
|
||||
# Groq
|
||||
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
|
||||
# Higress
|
||||
HIGRESS_API_KEY="" HIGRESS_MODEL_LIST="" HIGRESS_PROXY_URL="" \
|
||||
# HuggingFace
|
||||
HUGGINGFACE_API_KEY="" HUGGINGFACE_MODEL_LIST="" HUGGINGFACE_PROXY_URL="" \
|
||||
# Hunyuan
|
||||
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
|
||||
# InternLM
|
||||
INTERNLM_API_KEY="" INTERNLM_MODEL_LIST="" \
|
||||
# Jina
|
||||
JINA_API_KEY="" JINA_MODEL_LIST="" JINA_PROXY_URL="" \
|
||||
# Minimax
|
||||
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
|
||||
# Mistral
|
||||
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
|
||||
# ModelScope
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
NVIDIA_API_KEY="" NVIDIA_MODEL_LIST="" NVIDIA_PROXY_URL="" \
|
||||
# Ollama
|
||||
ENABLED_OLLAMA="" OLLAMA_MODEL_LIST="" OLLAMA_PROXY_URL="" \
|
||||
# OpenAI
|
||||
OPENAI_API_KEY="" OPENAI_MODEL_LIST="" OPENAI_PROXY_URL="" \
|
||||
# OpenRouter
|
||||
OPENROUTER_API_KEY="" OPENROUTER_MODEL_LIST="" \
|
||||
# Perplexity
|
||||
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
|
||||
# PPIO
|
||||
PPIO_API_KEY="" PPIO_MODEL_LIST="" \
|
||||
# Qiniu
|
||||
QINIU_API_KEY="" QINIU_MODEL_LIST="" QINIU_PROXY_URL="" \
|
||||
# Qwen
|
||||
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
|
||||
# SambaNova
|
||||
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
|
||||
# Search1API
|
||||
SEARCH1API_API_KEY="" SEARCH1API_MODEL_LIST="" \
|
||||
# SenseNova
|
||||
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
|
||||
# SiliconCloud
|
||||
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
|
||||
# Spark
|
||||
SPARK_API_KEY="" SPARK_MODEL_LIST="" SPARK_PROXY_URL="" SPARK_SEARCH_MODE="" \
|
||||
# Stepfun
|
||||
STEPFUN_API_KEY="" STEPFUN_MODEL_LIST="" \
|
||||
# Taichu
|
||||
TAICHU_API_KEY="" TAICHU_MODEL_LIST="" \
|
||||
# TogetherAI
|
||||
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \
|
||||
# Upstage
|
||||
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
|
||||
# v0 (Vercel)
|
||||
V0_API_KEY="" V0_MODEL_LIST="" \
|
||||
# vLLM
|
||||
VLLM_API_KEY="" VLLM_MODEL_LIST="" VLLM_PROXY_URL="" \
|
||||
# Wenxin
|
||||
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
|
||||
# xAI
|
||||
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
|
||||
# Xinference
|
||||
XINFERENCE_API_KEY="" XINFERENCE_MODEL_LIST="" XINFERENCE_PROXY_URL="" \
|
||||
# 01.AI
|
||||
ZEROONE_API_KEY="" ZEROONE_MODEL_LIST="" \
|
||||
# Zhipu
|
||||
ZHIPU_API_KEY="" ZHIPU_MODEL_LIST="" \
|
||||
# Tencent Cloud
|
||||
TENCENT_CLOUD_API_KEY="" TENCENT_CLOUD_MODEL_LIST="" \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3210/tcp
|
||||
|
||||
ENTRYPOINT ["/bin/node"]
|
||||
|
||||
CMD ["/app/startServer.js"]
|
||||
@@ -1,298 +0,0 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" "/etc/apt/sources.list.d/debian.sources"; \
|
||||
fi \
|
||||
# Add required package
|
||||
&& apt update \
|
||||
&& apt install ca-certificates proxychains-ng -qy \
|
||||
# Prepare required package to distroless
|
||||
&& mkdir -p /distroless/bin /distroless/etc /distroless/etc/ssl/certs /distroless/lib \
|
||||
# Copy proxychains to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libproxychains.so.4 /distroless/lib/libproxychains.so.4 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libdl.so.2 /distroless/lib/libdl.so.2 \
|
||||
&& cp /usr/bin/proxychains4 /distroless/bin/proxychains \
|
||||
&& cp /etc/proxychains4.conf /distroless/etc/proxychains4.conf \
|
||||
# Copy node to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libstdc++.so.6 /distroless/lib/libstdc++.so.6 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libgcc_s.so.1 /distroless/lib/libgcc_s.so.1 \
|
||||
&& cp /usr/local/bin/node /distroless/bin/node \
|
||||
# Copy CA certificates to distroless
|
||||
&& cp /etc/ssl/certs/ca-certificates.crt /distroless/etc/ssl/certs/ca-certificates.crt \
|
||||
# Cleanup temp files
|
||||
&& rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
|
||||
|
||||
## Builder image, install all the dependencies and build the app
|
||||
FROM base AS builder
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
ARG NEXT_PUBLIC_BASE_PATH
|
||||
ARG NEXT_PUBLIC_SERVICE_MODE
|
||||
ARG NEXT_PUBLIC_ENABLE_NEXT_AUTH
|
||||
ARG NEXT_PUBLIC_SENTRY_DSN
|
||||
ARG NEXT_PUBLIC_ANALYTICS_POSTHOG
|
||||
ARG NEXT_PUBLIC_POSTHOG_HOST
|
||||
ARG NEXT_PUBLIC_POSTHOG_KEY
|
||||
ARG NEXT_PUBLIC_ANALYTICS_UMAMI
|
||||
ARG NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
||||
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||
ARG FEATURE_FLAGS
|
||||
|
||||
ENV NEXT_PUBLIC_BASE_PATH="${NEXT_PUBLIC_BASE_PATH}" \
|
||||
FEATURE_FLAGS="${FEATURE_FLAGS}"
|
||||
|
||||
ENV NEXT_PUBLIC_SERVICE_MODE="${NEXT_PUBLIC_SERVICE_MODE:-server}" \
|
||||
NEXT_PUBLIC_ENABLE_NEXT_AUTH="${NEXT_PUBLIC_ENABLE_NEXT_AUTH:-1}" \
|
||||
APP_URL="http://app.com" \
|
||||
DATABASE_DRIVER="node" \
|
||||
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres" \
|
||||
KEY_VAULTS_SECRET="use-for-build"
|
||||
|
||||
# Sentry
|
||||
ENV NEXT_PUBLIC_SENTRY_DSN="${NEXT_PUBLIC_SENTRY_DSN}" \
|
||||
SENTRY_ORG="" \
|
||||
SENTRY_PROJECT=""
|
||||
|
||||
# Posthog
|
||||
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG="${NEXT_PUBLIC_ANALYTICS_POSTHOG}" \
|
||||
NEXT_PUBLIC_POSTHOG_HOST="${NEXT_PUBLIC_POSTHOG_HOST}" \
|
||||
NEXT_PUBLIC_POSTHOG_KEY="${NEXT_PUBLIC_POSTHOG_KEY}"
|
||||
|
||||
# Umami
|
||||
ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL="${NEXT_PUBLIC_UMAMI_SCRIPT_URL}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json pnpm-workspace.yaml ./
|
||||
COPY .npmrc ./
|
||||
COPY packages ./packages
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \
|
||||
npm config set registry "https://registry.npmmirror.com/"; \
|
||||
echo 'canvas_binary_host_mirror=https://npmmirror.com/mirrors/canvas' >> .npmrc; \
|
||||
fi \
|
||||
# Set the registry for corepack
|
||||
&& export COREPACK_NPM_REGISTRY=$(npm config get registry | sed 's/\/$//') \
|
||||
# Update corepack to latest (nodejs/corepack#612)
|
||||
&& npm i -g corepack@latest \
|
||||
# Enable corepack
|
||||
&& corepack enable \
|
||||
# Use pnpm for corepack
|
||||
&& corepack use $(sed -n 's/.*"packageManager": "\(.*\)".*/\1/p' package.json) \
|
||||
# Install the dependencies
|
||||
&& pnpm i \
|
||||
# Add db migration dependencies
|
||||
&& mkdir -p /deps \
|
||||
&& cd /deps \
|
||||
&& pnpm init \
|
||||
&& pnpm add pg drizzle-orm
|
||||
|
||||
COPY . .
|
||||
|
||||
# run build standalone for docker version
|
||||
RUN npm run build:docker
|
||||
|
||||
## Application image, copy all the files for production
|
||||
FROM busybox:latest AS app
|
||||
|
||||
COPY --from=base /distroless/ /
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder /app/.next/standalone /app/
|
||||
|
||||
# Copy database migrations
|
||||
COPY --from=builder /app/src/database/migrations /app/migrations
|
||||
COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
|
||||
COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
|
||||
|
||||
# copy dependencies
|
||||
COPY --from=builder /deps/node_modules/.pnpm /app/node_modules/.pnpm
|
||||
COPY --from=builder /deps/node_modules/pg /app/node_modules/pg
|
||||
COPY --from=builder /deps/node_modules/drizzle-orm /app/node_modules/drizzle-orm
|
||||
|
||||
# Copy server launcher
|
||||
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
|
||||
|
||||
RUN \
|
||||
# Add nextjs:nodejs to run the app
|
||||
addgroup -S -g 1001 nodejs \
|
||||
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
|
||||
# Set permission for nextjs:nodejs
|
||||
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
|
||||
|
||||
## Production image, copy all the files and run next
|
||||
FROM scratch
|
||||
|
||||
# Copy all the files from app, set the correct permission for prerender cache
|
||||
COPY --from=app / /
|
||||
|
||||
ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
ENV MIDDLEWARE_REWRITE_THROUGH_LOCAL="1"
|
||||
|
||||
# set hostname to localhost
|
||||
ENV HOSTNAME="0.0.0.0" \
|
||||
PORT="3210"
|
||||
|
||||
# General Variables
|
||||
ENV ACCESS_CODE="" \
|
||||
APP_URL="" \
|
||||
API_KEY_SELECT_MODE="" \
|
||||
DEFAULT_AGENT_CONFIG="" \
|
||||
SYSTEM_AGENT="" \
|
||||
FEATURE_FLAGS="" \
|
||||
PROXY_URL=""
|
||||
|
||||
# Database
|
||||
ENV KEY_VAULTS_SECRET="" \
|
||||
DATABASE_DRIVER="node" \
|
||||
DATABASE_URL=""
|
||||
|
||||
# Next Auth
|
||||
ENV NEXT_AUTH_SECRET="" \
|
||||
NEXT_AUTH_SSO_PROVIDERS="" \
|
||||
NEXTAUTH_URL=""
|
||||
|
||||
# S3
|
||||
ENV NEXT_PUBLIC_S3_DOMAIN="" \
|
||||
S3_PUBLIC_DOMAIN="" \
|
||||
S3_ACCESS_KEY_ID="" \
|
||||
S3_BUCKET="" \
|
||||
S3_ENDPOINT="" \
|
||||
S3_SECRET_ACCESS_KEY=""
|
||||
|
||||
# Model Variables
|
||||
ENV \
|
||||
# AI21
|
||||
AI21_API_KEY="" AI21_MODEL_LIST="" \
|
||||
# Ai360
|
||||
AI360_API_KEY="" AI360_MODEL_LIST="" \
|
||||
# Anthropic
|
||||
ANTHROPIC_API_KEY="" ANTHROPIC_MODEL_LIST="" ANTHROPIC_PROXY_URL="" \
|
||||
# Amazon Bedrock
|
||||
AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_REGION="" AWS_BEDROCK_MODEL_LIST="" \
|
||||
# Azure OpenAI
|
||||
AZURE_API_KEY="" AZURE_API_VERSION="" AZURE_ENDPOINT="" AZURE_MODEL_LIST="" \
|
||||
# Baichuan
|
||||
BAICHUAN_API_KEY="" BAICHUAN_MODEL_LIST="" \
|
||||
# Cloudflare
|
||||
CLOUDFLARE_API_KEY="" CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID="" CLOUDFLARE_MODEL_LIST="" \
|
||||
# Cohere
|
||||
COHERE_API_KEY="" COHERE_MODEL_LIST="" COHERE_PROXY_URL="" \
|
||||
# DeepSeek
|
||||
DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \
|
||||
# Fireworks AI
|
||||
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
|
||||
# Gitee AI
|
||||
GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \
|
||||
# GitHub
|
||||
GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \
|
||||
# Google
|
||||
GOOGLE_API_KEY="" GOOGLE_MODEL_LIST="" GOOGLE_PROXY_URL="" \
|
||||
# Groq
|
||||
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
|
||||
# Higress
|
||||
HIGRESS_API_KEY="" HIGRESS_MODEL_LIST="" HIGRESS_PROXY_URL="" \
|
||||
# HuggingFace
|
||||
HUGGINGFACE_API_KEY="" HUGGINGFACE_MODEL_LIST="" HUGGINGFACE_PROXY_URL="" \
|
||||
# Hunyuan
|
||||
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
|
||||
# InternLM
|
||||
INTERNLM_API_KEY="" INTERNLM_MODEL_LIST="" \
|
||||
# Jina
|
||||
JINA_API_KEY="" JINA_MODEL_LIST="" JINA_PROXY_URL="" \
|
||||
# Minimax
|
||||
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
|
||||
# Mistral
|
||||
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
|
||||
# ModelScope
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
NVIDIA_API_KEY="" NVIDIA_MODEL_LIST="" NVIDIA_PROXY_URL="" \
|
||||
# Ollama
|
||||
ENABLED_OLLAMA="" OLLAMA_MODEL_LIST="" OLLAMA_PROXY_URL="" \
|
||||
# OpenAI
|
||||
OPENAI_API_KEY="" OPENAI_MODEL_LIST="" OPENAI_PROXY_URL="" \
|
||||
# OpenRouter
|
||||
OPENROUTER_API_KEY="" OPENROUTER_MODEL_LIST="" \
|
||||
# Perplexity
|
||||
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
|
||||
# PPIO
|
||||
PPIO_API_KEY="" PPIO_MODEL_LIST="" \
|
||||
# Qiniu
|
||||
QINIU_API_KEY="" QINIU_MODEL_LIST="" QINIU_PROXY_URL="" \
|
||||
# Qwen
|
||||
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
|
||||
# SambaNova
|
||||
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
|
||||
# Search1API
|
||||
SEARCH1API_API_KEY="" SEARCH1API_MODEL_LIST="" \
|
||||
# SenseNova
|
||||
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
|
||||
# SiliconCloud
|
||||
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
|
||||
# Spark
|
||||
SPARK_API_KEY="" SPARK_MODEL_LIST="" SPARK_PROXY_URL="" SPARK_SEARCH_MODE="" \
|
||||
# Stepfun
|
||||
STEPFUN_API_KEY="" STEPFUN_MODEL_LIST="" \
|
||||
# Taichu
|
||||
TAICHU_API_KEY="" TAICHU_MODEL_LIST="" \
|
||||
# TogetherAI
|
||||
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \
|
||||
# Upstage
|
||||
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
|
||||
# v0 (Vercel)
|
||||
V0_API_KEY="" V0_MODEL_LIST="" \
|
||||
# vLLM
|
||||
VLLM_API_KEY="" VLLM_MODEL_LIST="" VLLM_PROXY_URL="" \
|
||||
# Wenxin
|
||||
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
|
||||
# xAI
|
||||
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
|
||||
# Xinference
|
||||
XINFERENCE_API_KEY="" XINFERENCE_MODEL_LIST="" XINFERENCE_PROXY_URL="" \
|
||||
# 01.AI
|
||||
ZEROONE_API_KEY="" ZEROONE_MODEL_LIST="" \
|
||||
# Zhipu
|
||||
ZHIPU_API_KEY="" ZHIPU_MODEL_LIST="" \
|
||||
# Tencent Cloud
|
||||
TENCENT_CLOUD_API_KEY="" TENCENT_CLOUD_MODEL_LIST="" \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3210/tcp
|
||||
|
||||
ENTRYPOINT ["/bin/node"]
|
||||
|
||||
CMD ["/app/startServer.js"]
|
||||
@@ -1,254 +0,0 @@
|
||||
## Set global build ENV
|
||||
ARG NODEJS_VERSION="22"
|
||||
|
||||
## Base image for all building stages
|
||||
FROM node:${NODEJS_VERSION}-slim AS base
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
|
||||
ENV DEBIAN_FRONTEND="noninteractive"
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" "/etc/apt/sources.list.d/debian.sources"; \
|
||||
fi \
|
||||
# Add required package
|
||||
&& apt update \
|
||||
&& apt install ca-certificates proxychains-ng -qy \
|
||||
# Prepare required package to distroless
|
||||
&& mkdir -p /distroless/bin /distroless/etc /distroless/etc/ssl/certs /distroless/lib \
|
||||
# Copy proxychains to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libproxychains.so.4 /distroless/lib/libproxychains.so.4 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libdl.so.2 /distroless/lib/libdl.so.2 \
|
||||
&& cp /usr/bin/proxychains4 /distroless/bin/proxychains \
|
||||
&& cp /etc/proxychains4.conf /distroless/etc/proxychains4.conf \
|
||||
# Copy node to distroless
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libstdc++.so.6 /distroless/lib/libstdc++.so.6 \
|
||||
&& cp /usr/lib/$(arch)-linux-gnu/libgcc_s.so.1 /distroless/lib/libgcc_s.so.1 \
|
||||
&& cp /usr/local/bin/node /distroless/bin/node \
|
||||
# Copy CA certificates to distroless
|
||||
&& cp /etc/ssl/certs/ca-certificates.crt /distroless/etc/ssl/certs/ca-certificates.crt \
|
||||
# Cleanup temp files
|
||||
&& rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
|
||||
|
||||
## Builder image, install all the dependencies and build the app
|
||||
FROM base AS builder
|
||||
|
||||
ARG USE_CN_MIRROR
|
||||
ARG NEXT_PUBLIC_BASE_PATH
|
||||
ARG NEXT_PUBLIC_SENTRY_DSN
|
||||
ARG NEXT_PUBLIC_ANALYTICS_POSTHOG
|
||||
ARG NEXT_PUBLIC_POSTHOG_HOST
|
||||
ARG NEXT_PUBLIC_POSTHOG_KEY
|
||||
ARG NEXT_PUBLIC_ANALYTICS_UMAMI
|
||||
ARG NEXT_PUBLIC_UMAMI_SCRIPT_URL
|
||||
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
||||
ARG FEATURE_FLAGS
|
||||
|
||||
ENV NEXT_PUBLIC_CLIENT_DB="pglite"
|
||||
ENV NEXT_PUBLIC_BASE_PATH="${NEXT_PUBLIC_BASE_PATH}" \
|
||||
FEATURE_FLAGS="${FEATURE_FLAGS}"
|
||||
|
||||
# Sentry
|
||||
ENV NEXT_PUBLIC_SENTRY_DSN="${NEXT_PUBLIC_SENTRY_DSN}" \
|
||||
SENTRY_ORG="" \
|
||||
SENTRY_PROJECT=""
|
||||
|
||||
ENV APP_URL="http://app.com"
|
||||
|
||||
# Posthog
|
||||
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG="${NEXT_PUBLIC_ANALYTICS_POSTHOG}" \
|
||||
NEXT_PUBLIC_POSTHOG_HOST="${NEXT_PUBLIC_POSTHOG_HOST}" \
|
||||
NEXT_PUBLIC_POSTHOG_KEY="${NEXT_PUBLIC_POSTHOG_KEY}"
|
||||
|
||||
# Umami
|
||||
ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
|
||||
NEXT_PUBLIC_UMAMI_SCRIPT_URL="${NEXT_PUBLIC_UMAMI_SCRIPT_URL}" \
|
||||
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
|
||||
|
||||
# Node
|
||||
ENV NODE_OPTIONS="--max-old-space-size=8192"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json pnpm-workspace.yaml ./
|
||||
COPY .npmrc ./
|
||||
COPY packages ./packages
|
||||
|
||||
RUN \
|
||||
# If you want to build docker in China, build with --build-arg USE_CN_MIRROR=true
|
||||
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
|
||||
export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \
|
||||
npm config set registry "https://registry.npmmirror.com/"; \
|
||||
echo 'canvas_binary_host_mirror=https://npmmirror.com/mirrors/canvas' >> .npmrc; \
|
||||
fi \
|
||||
# Set the registry for corepack
|
||||
&& export COREPACK_NPM_REGISTRY=$(npm config get registry | sed 's/\/$//') \
|
||||
# Update corepack to latest (nodejs/corepack#612)
|
||||
&& npm i -g corepack@latest \
|
||||
# Enable corepack
|
||||
&& corepack enable \
|
||||
# Use pnpm for corepack
|
||||
&& corepack use $(sed -n 's/.*"packageManager": "\(.*\)".*/\1/p' package.json) \
|
||||
# Install the dependencies
|
||||
&& pnpm i
|
||||
|
||||
COPY . .
|
||||
|
||||
# run build standalone for docker version
|
||||
RUN npm run build:docker
|
||||
|
||||
## Application image, copy all the files for production
|
||||
FROM busybox:latest AS app
|
||||
|
||||
COPY --from=base /distroless/ /
|
||||
|
||||
# Automatically leverage output traces to reduce image size
|
||||
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
||||
COPY --from=builder /app/.next/standalone /app/
|
||||
|
||||
# Copy server launcher
|
||||
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
|
||||
|
||||
RUN \
|
||||
# Add nextjs:nodejs to run the app
|
||||
addgroup -S -g 1001 nodejs \
|
||||
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
|
||||
# Set permission for nextjs:nodejs
|
||||
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
|
||||
|
||||
## Production image, copy all the files and run next
|
||||
FROM scratch
|
||||
|
||||
# Copy all the files from app, set the correct permission for prerender cache
|
||||
COPY --from=app / /
|
||||
|
||||
ENV NODE_ENV="production" \
|
||||
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
|
||||
NODE_EXTRA_CA_CERTS="" \
|
||||
NODE_TLS_REJECT_UNAUTHORIZED="" \
|
||||
SSL_CERT_DIR="/etc/ssl/certs/ca-certificates.crt"
|
||||
|
||||
# Make the middleware rewrite through local as default
|
||||
# refs: https://github.com/lobehub/lobe-chat/issues/5876
|
||||
ENV MIDDLEWARE_REWRITE_THROUGH_LOCAL="1"
|
||||
|
||||
# set hostname to localhost
|
||||
ENV HOSTNAME="0.0.0.0" \
|
||||
PORT="3210"
|
||||
|
||||
# General Variables
|
||||
ENV ACCESS_CODE="" \
|
||||
API_KEY_SELECT_MODE="" \
|
||||
DEFAULT_AGENT_CONFIG="" \
|
||||
SYSTEM_AGENT="" \
|
||||
FEATURE_FLAGS="" \
|
||||
PROXY_URL=""
|
||||
|
||||
# Model Variables
|
||||
ENV \
|
||||
# AI21
|
||||
AI21_API_KEY="" AI21_MODEL_LIST="" \
|
||||
# Ai360
|
||||
AI360_API_KEY="" AI360_MODEL_LIST="" \
|
||||
# Anthropic
|
||||
ANTHROPIC_API_KEY="" ANTHROPIC_MODEL_LIST="" ANTHROPIC_PROXY_URL="" \
|
||||
# Amazon Bedrock
|
||||
AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_REGION="" AWS_BEDROCK_MODEL_LIST="" \
|
||||
# Azure OpenAI
|
||||
AZURE_API_KEY="" AZURE_API_VERSION="" AZURE_ENDPOINT="" AZURE_MODEL_LIST="" \
|
||||
# Baichuan
|
||||
BAICHUAN_API_KEY="" BAICHUAN_MODEL_LIST="" \
|
||||
# Cloudflare
|
||||
CLOUDFLARE_API_KEY="" CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID="" CLOUDFLARE_MODEL_LIST="" \
|
||||
# Cohere
|
||||
COHERE_API_KEY="" COHERE_MODEL_LIST="" COHERE_PROXY_URL="" \
|
||||
# DeepSeek
|
||||
DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \
|
||||
# Fireworks AI
|
||||
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
|
||||
# Gitee AI
|
||||
GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \
|
||||
# GitHub
|
||||
GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \
|
||||
# Google
|
||||
GOOGLE_API_KEY="" GOOGLE_MODEL_LIST="" GOOGLE_PROXY_URL="" \
|
||||
# Groq
|
||||
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
|
||||
# Higress
|
||||
HIGRESS_API_KEY="" HIGRESS_MODEL_LIST="" HIGRESS_PROXY_URL="" \
|
||||
# HuggingFace
|
||||
HUGGINGFACE_API_KEY="" HUGGINGFACE_MODEL_LIST="" HUGGINGFACE_PROXY_URL="" \
|
||||
# Hunyuan
|
||||
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
|
||||
# InternLM
|
||||
INTERNLM_API_KEY="" INTERNLM_MODEL_LIST="" \
|
||||
# Jina
|
||||
JINA_API_KEY="" JINA_MODEL_LIST="" JINA_PROXY_URL="" \
|
||||
# Minimax
|
||||
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
|
||||
# Mistral
|
||||
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
|
||||
# ModelScope
|
||||
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
|
||||
# Moonshot
|
||||
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
|
||||
# Novita
|
||||
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
|
||||
# Nvidia NIM
|
||||
NVIDIA_API_KEY="" NVIDIA_MODEL_LIST="" NVIDIA_PROXY_URL="" \
|
||||
# Ollama
|
||||
ENABLED_OLLAMA="" OLLAMA_MODEL_LIST="" OLLAMA_PROXY_URL="" \
|
||||
# OpenAI
|
||||
OPENAI_API_KEY="" OPENAI_MODEL_LIST="" OPENAI_PROXY_URL="" \
|
||||
# OpenRouter
|
||||
OPENROUTER_API_KEY="" OPENROUTER_MODEL_LIST="" \
|
||||
# Perplexity
|
||||
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
|
||||
# Qiniu
|
||||
QINIU_API_KEY="" QINIU_MODEL_LIST="" QINIU_PROXY_URL="" \
|
||||
# Qwen
|
||||
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
|
||||
# SambaNova
|
||||
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
|
||||
# SenseNova
|
||||
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
|
||||
# SiliconCloud
|
||||
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
|
||||
# Spark
|
||||
SPARK_API_KEY="" SPARK_MODEL_LIST="" SPARK_PROXY_URL="" SPARK_SEARCH_MODE="" \
|
||||
# Stepfun
|
||||
STEPFUN_API_KEY="" STEPFUN_MODEL_LIST="" \
|
||||
# Taichu
|
||||
TAICHU_API_KEY="" TAICHU_MODEL_LIST="" \
|
||||
# TogetherAI
|
||||
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \
|
||||
# Upstage
|
||||
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
|
||||
# v0 (Vercel)
|
||||
V0_API_KEY="" V0_MODEL_LIST="" \
|
||||
# vLLM
|
||||
VLLM_API_KEY="" VLLM_MODEL_LIST="" VLLM_PROXY_URL="" \
|
||||
# Wenxin
|
||||
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
|
||||
# xAI
|
||||
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
|
||||
# Xinference
|
||||
XINFERENCE_API_KEY="" XINFERENCE_MODEL_LIST="" XINFERENCE_PROXY_URL="" \
|
||||
# 01.AI
|
||||
ZEROONE_API_KEY="" ZEROONE_MODEL_LIST="" \
|
||||
# Zhipu
|
||||
ZHIPU_API_KEY="" ZHIPU_MODEL_LIST="" \
|
||||
# Tencent Cloud
|
||||
TENCENT_CLOUD_API_KEY="" TENCENT_CLOUD_MODEL_LIST="" \
|
||||
# Infini-AI
|
||||
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST=""
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3210/tcp
|
||||
|
||||
ENTRYPOINT ["/bin/node"]
|
||||
|
||||
CMD ["/app/startServer.js"]
|
||||
@@ -1,38 +0,0 @@
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (c) 2024/06/17 - current LobeHub LLC. All rights reserved.
|
||||
|
||||
----------
|
||||
|
||||
From 1.0, LobeChat is licensed under the Apache License 2.0, with the following additional conditions:
|
||||
|
||||
1. The commercial usage of LobeChat:
|
||||
|
||||
a. LobeChat may be utilized commercially, including as a frontend and backend service without modifying the source code.
|
||||
|
||||
b. a commercial license must be obtained from the producer if you want to develop and distribute a derivative work based on LobeChat.
|
||||
|
||||
Please contact hello@lobehub.com by email to inquire about licensing matters.
|
||||
|
||||
|
||||
2. As a contributor, you should agree that:
|
||||
|
||||
a. The producer can adjust the open-source agreement to be more strict or relaxed as deemed necessary.
|
||||
|
||||
b. Your contributed code may be used for commercial purposes, including but not limited to its cloud edition.
|
||||
|
||||
Apart from the specific conditions mentioned above, all other rights and restrictions follow the Apache License 2.0. Detailed information about the Apache License 2.0 can be found at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
----------
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,975 +0,0 @@
|
||||
<div align="center"><a name="readme-top"></a>
|
||||
|
||||
[![][image-banner]][vercel-link]
|
||||
|
||||
# Lobe Chat
|
||||
|
||||
An open-source, modern design ChatGPT/LLMs UI/framework.<br/>
|
||||
Supports speech synthesis, multi-modal, and extensible ([function call][docs-function-call]) plugin system.<br/>
|
||||
One-click **FREE** deployment of your private OpenAI ChatGPT/Claude/Gemini/Groq/Ollama chat application.
|
||||
|
||||
**English** · [简体中文](./README.zh-CN.md) · [Official Site][official-site] · [Changelog][changelog] · [Documents][docs] · [Blog][blog] · [Feedback][github-issues-link]
|
||||
|
||||
<!-- SHIELD GROUP -->
|
||||
|
||||
[![][github-release-shield]][github-release-link]
|
||||
[![][docker-release-shield]][docker-release-link]
|
||||
[![][vercel-shield]][vercel-link]
|
||||
[![][discord-shield]][discord-link]<br/>
|
||||
[![][codecov-shield]][codecov-link]
|
||||
[![][github-action-test-shield]][github-action-test-link]
|
||||
[![][github-action-release-shield]][github-action-release-link]
|
||||
[![][github-releasedate-shield]][github-releasedate-link]<br/>
|
||||
[![][github-contributors-shield]][github-contributors-link]
|
||||
[![][github-forks-shield]][github-forks-link]
|
||||
[![][github-stars-shield]][github-stars-link]
|
||||
[![][github-issues-shield]][github-issues-link]
|
||||
[![][github-license-shield]][github-license-link]<br>
|
||||
[![][sponsor-shield]][sponsor-link]
|
||||
|
||||
**Share LobeChat Repository**
|
||||
|
||||
[![][share-x-shield]][share-x-link]
|
||||
[![][share-telegram-shield]][share-telegram-link]
|
||||
[![][share-whatsapp-shield]][share-whatsapp-link]
|
||||
[![][share-reddit-shield]][share-reddit-link]
|
||||
[![][share-weibo-shield]][share-weibo-link]
|
||||
[![][share-mastodon-shield]][share-mastodon-link]
|
||||
[![][share-linkedin-shield]][share-linkedin-link]
|
||||
|
||||
<sup>Pioneering the new age of thinking and creating. Built for you, the Super Individual.</sup>
|
||||
|
||||
[![][github-trending-shield]][github-trending-url] <br /> <br /> <a href="https://vercel.com/oss"> <img alt="Vercel OSS Program" src="https://vercel.com/oss/program-badge.svg" /> </a>
|
||||
|
||||
![][image-overview]
|
||||
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary><kbd>Table of contents</kbd></summary>
|
||||
|
||||
#### TOC
|
||||
|
||||
- [👋🏻 Getting Started & Join Our Community](#-getting-started--join-our-community)
|
||||
- [✨ Features](#-features)
|
||||
- [✨ MCP Plugin One-Click Installation](#-mcp-plugin-one-click-installation)
|
||||
- [🏪 MCP Marketplace](#-mcp-marketplace)
|
||||
- [🖥️ Desktop App](#️-desktop-app)
|
||||
- [🌐 Smart Internet Search](#-smart-internet-search)
|
||||
- [Chain of Thought](#chain-of-thought)
|
||||
- [Branching Conversations](#branching-conversations)
|
||||
- [Artifacts Support](#artifacts-support)
|
||||
- [File Upload /Knowledge Base](#file-upload-knowledge-base)
|
||||
- [Multi-Model Service Provider Support](#multi-model-service-provider-support)
|
||||
- [Local Large Language Model (LLM) Support](#local-large-language-model-llm-support)
|
||||
- [Model Visual Recognition](#model-visual-recognition)
|
||||
- [TTS & STT Voice Conversation](#tts--stt-voice-conversation)
|
||||
- [Text to Image Generation](#text-to-image-generation)
|
||||
- [Plugin System (Function Calling)](#plugin-system-function-calling)
|
||||
- [Agent Market (GPTs)](#agent-market-gpts)
|
||||
- [Support Local / Remote Database](#support-local--remote-database)
|
||||
- [Support Multi-User Management](#support-multi-user-management)
|
||||
- [Progressive Web App (PWA)](#progressive-web-app-pwa)
|
||||
- [Mobile Device Adaptation](#mobile-device-adaptation)
|
||||
- [Custom Themes](#custom-themes)
|
||||
- [`*` What's more](#-whats-more)
|
||||
- [⚡️ Performance](#️-performance)
|
||||
- [🛳 Self Hosting](#-self-hosting)
|
||||
- [`A` Deploying with Vercel, Zeabur , Sealos or Alibaba Cloud](#a-deploying-with-vercel-zeabur--sealos-or-alibaba-cloud)
|
||||
- [`B` Deploying with Docker](#b-deploying-with-docker)
|
||||
- [Environment Variable](#environment-variable)
|
||||
- [📦 Ecosystem](#-ecosystem)
|
||||
- [🧩 Plugins](#-plugins)
|
||||
- [⌨️ Local Development](#️-local-development)
|
||||
- [🤝 Contributing](#-contributing)
|
||||
- [❤️ Sponsor](#️-sponsor)
|
||||
- [🔗 More Products](#-more-products)
|
||||
|
||||
####
|
||||
|
||||
<br/>
|
||||
|
||||
</details>
|
||||
|
||||
## 👋🏻 Getting Started & Join Our Community
|
||||
|
||||
We are a group of e/acc design-engineers, hoping to provide modern design components and tools for AIGC.
|
||||
By adopting the Bootstrapping approach, we aim to provide developers and users with a more open, transparent, and user-friendly product ecosystem.
|
||||
|
||||
Whether for users or professional developers, LobeHub will be your AI Agent playground. Please be aware that LobeChat is currently under active development, and feedback is welcome for any [issues][issues-link] encountered.
|
||||
|
||||
| [![][vercel-shield-badge]][vercel-link] | No installation or registration necessary! Visit our website to experience it firsthand. |
|
||||
| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------- |
|
||||
| [![][discord-shield-badge]][discord-link] | Join our Discord community! This is where you can connect with developers and other enthusiastic users of LobeHub. |
|
||||
|
||||
> \[!IMPORTANT]
|
||||
>
|
||||
> **Star Us**, You will receive all release notifications from GitHub without any delay \~ ⭐️
|
||||
|
||||
[![][image-star]][github-stars-link]
|
||||
|
||||
<details>
|
||||
<summary><kbd>Star History</kbd></summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=lobehub%2Flobe-chat&theme=dark&type=Date">
|
||||
<img width="100%" src="https://api.star-history.com/svg?repos=lobehub%2Flobe-chat&type=Date">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
## ✨ Features
|
||||
|
||||
Transform your AI experience with LobeChat's powerful features designed for seamless connectivity, enhanced productivity, and unlimited creativity.
|
||||
|
||||
![][image-feat-mcp]
|
||||
|
||||
### ✨ MCP Plugin One-Click Installation
|
||||
|
||||
**Seamlessly Connect Your AI to the World**
|
||||
|
||||
Unlock the full potential of your AI by enabling smooth, secure, and dynamic interactions with external tools, data sources, and services. LobeChat's MCP (Model Context Protocol) plugin system breaks down the barriers between your AI and the digital ecosystem, allowing for unprecedented connectivity and functionality.
|
||||
|
||||
Transform your conversations into powerful workflows by connecting to databases, APIs, file systems, and more. Experience the freedom of AI that truly understands and interacts with your world.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
![][image-feat-mcp-market]
|
||||
|
||||
### 🏪 MCP Marketplace
|
||||
|
||||
**Discover, Connect, Extend**
|
||||
|
||||
Browse a growing library of MCP plugins to expand your AI's capabilities and streamline your workflows effortlessly. Visit [lobehub.com/mcp](https://lobehub.com/mcp) to explore the MCP Marketplace, which offers a curated collection of integrations that enhance your AI's ability to work with various tools and services.
|
||||
|
||||
From productivity tools to development environments, discover new ways to extend your AI's reach and effectiveness. Connect with the community and find the perfect plugins for your specific needs.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
![][image-feat-desktop]
|
||||
|
||||
### 🖥️ Desktop App
|
||||
|
||||
**Peak Performance, Zero Distractions**
|
||||
|
||||
Get the full LobeChat experience without browser limitations—lightweight, focused, and always ready to go. Our desktop application provides a dedicated environment for your AI interactions, ensuring optimal performance and minimal distractions.
|
||||
|
||||
Experience faster response times, better resource management, and a more stable connection to your AI assistant. The desktop app is designed for users who demand the best performance from their AI tools.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
![][image-feat-web-search]
|
||||
|
||||
### 🌐 Smart Internet Search
|
||||
|
||||
**Online Knowledge On Demand**
|
||||
|
||||
With real-time internet access, your AI keeps up with the world—news, data, trends, and more. Stay informed and get the most current information available, enabling your AI to provide accurate and up-to-date responses.
|
||||
|
||||
Access live information, verify facts, and explore current events without leaving your conversation. Your AI becomes a gateway to the world's knowledge, always current and comprehensive.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-cot]][docs-feat-cot]
|
||||
|
||||
### [Chain of Thought][docs-feat-cot]
|
||||
|
||||
Experience AI reasoning like never before. Watch as complex problems unfold step by step through our innovative Chain of Thought (CoT) visualization. This breakthrough feature provides unprecedented transparency into AI's decision-making process, allowing you to observe how conclusions are reached in real-time.
|
||||
|
||||
By breaking down complex reasoning into clear, logical steps, you can better understand and validate the AI's problem-solving approach. Whether you're debugging, learning, or simply curious about AI reasoning, CoT visualization transforms abstract thinking into an engaging, interactive experience.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-branch]][docs-feat-branch]
|
||||
|
||||
### [Branching Conversations][docs-feat-branch]
|
||||
|
||||
Introducing a more natural and flexible way to chat with AI. With Branch Conversations, your discussions can flow in multiple directions, just like human conversations do. Create new conversation branches from any message, giving you the freedom to explore different paths while preserving the original context.
|
||||
|
||||
Choose between two powerful modes:
|
||||
|
||||
- **Continuation Mode:** Seamlessly extend your current discussion while maintaining valuable context
|
||||
- **Standalone Mode:** Start fresh with a new topic based on any previous message
|
||||
|
||||
This groundbreaking feature transforms linear conversations into dynamic, tree-like structures, enabling deeper exploration of ideas and more productive interactions.
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-artifacts]][docs-feat-artifacts]
|
||||
|
||||
### [Artifacts Support][docs-feat-artifacts]
|
||||
|
||||
Experience the power of Claude Artifacts, now integrated into LobeChat. This revolutionary feature expands the boundaries of AI-human interaction, enabling real-time creation and visualization of diverse content formats.
|
||||
|
||||
Create and visualize with unprecedented flexibility:
|
||||
|
||||
- Generate and display dynamic SVG graphics
|
||||
- Build and render interactive HTML pages in real-time
|
||||
- Produce professional documents in multiple formats
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-knowledgebase]][docs-feat-knowledgebase]
|
||||
|
||||
### [File Upload /Knowledge Base][docs-feat-knowledgebase]
|
||||
|
||||
LobeChat supports file upload and knowledge base functionality. You can upload various types of files including documents, images, audio, and video, as well as create knowledge bases, making it convenient for users to manage and search for files. Additionally, you can utilize files and knowledge base features during conversations, enabling a richer dialogue experience.
|
||||
|
||||
<https://github.com/user-attachments/assets/faa8cf67-e743-4590-8bf6-ebf6ccc34175>
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> Learn more on [📘 LobeChat Knowledge Base Launch — From Now On, Every Step Counts](https://lobehub.com/blog/knowledge-base)
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-privoder]][docs-feat-provider]
|
||||
|
||||
### [Multi-Model Service Provider Support][docs-feat-provider]
|
||||
|
||||
In the continuous development of LobeChat, we deeply understand the importance of diversity in model service providers for meeting the needs of the community when providing AI conversation services. Therefore, we have expanded our support to multiple model service providers, rather than being limited to a single one, in order to offer users a more diverse and rich selection of conversations.
|
||||
|
||||
In this way, LobeChat can more flexibly adapt to the needs of different users, while also providing developers with a wider range of choices.
|
||||
|
||||
#### Supported Model Service Providers
|
||||
|
||||
We have implemented support for the following model service providers:
|
||||
|
||||
<!-- PROVIDER LIST -->
|
||||
|
||||
- **[OpenAI](https://lobechat.com/discover/provider/openai)**: OpenAI is a global leader in artificial intelligence research, with models like the GPT series pushing the frontiers of natural language processing. OpenAI is committed to transforming multiple industries through innovative and efficient AI solutions. Their products demonstrate significant performance and cost-effectiveness, widely used in research, business, and innovative applications.
|
||||
- **[Ollama](https://lobechat.com/discover/provider/ollama)**: Ollama provides models that cover a wide range of fields, including code generation, mathematical operations, multilingual processing, and conversational interaction, catering to diverse enterprise-level and localized deployment needs.
|
||||
- **[Anthropic](https://lobechat.com/discover/provider/anthropic)**: Anthropic is a company focused on AI research and development, offering a range of advanced language models such as Claude 3.5 Sonnet, Claude 3 Sonnet, Claude 3 Opus, and Claude 3 Haiku. These models achieve an ideal balance between intelligence, speed, and cost, suitable for various applications from enterprise workloads to rapid-response scenarios. Claude 3.5 Sonnet, as their latest model, has excelled in multiple evaluations while maintaining a high cost-performance ratio.
|
||||
- **[Bedrock](https://lobechat.com/discover/provider/bedrock)**: Bedrock is a service provided by Amazon AWS, focusing on delivering advanced AI language and visual models for enterprises. Its model family includes Anthropic's Claude series, Meta's Llama 3.1 series, and more, offering a range of options from lightweight to high-performance, supporting tasks such as text generation, conversation, and image processing for businesses of varying scales and needs.
|
||||
- **[Google](https://lobechat.com/discover/provider/google)**: Google's Gemini series represents its most advanced, versatile AI models, developed by Google DeepMind, designed for multimodal capabilities, supporting seamless understanding and processing of text, code, images, audio, and video. Suitable for various environments from data centers to mobile devices, it significantly enhances the efficiency and applicability of AI models.
|
||||
- **[DeepSeek](https://lobechat.com/discover/provider/deepseek)**: DeepSeek is a company focused on AI technology research and application, with its latest model DeepSeek-V2.5 integrating general dialogue and code processing capabilities, achieving significant improvements in human preference alignment, writing tasks, and instruction following.
|
||||
- **[HuggingFace](https://lobechat.com/discover/provider/huggingface)**: The HuggingFace Inference API provides a fast and free way for you to explore thousands of models for various tasks. Whether you are prototyping for a new application or experimenting with the capabilities of machine learning, this API gives you instant access to high-performance models across multiple domains.
|
||||
- **[OpenRouter](https://lobechat.com/discover/provider/openrouter)**: OpenRouter is a service platform providing access to various cutting-edge large model interfaces, supporting OpenAI, Anthropic, LLaMA, and more, suitable for diverse development and application needs. Users can flexibly choose the optimal model and pricing based on their requirements, enhancing the AI experience.
|
||||
- **[Cloudflare Workers AI](https://lobechat.com/discover/provider/cloudflare)**: Run serverless GPU-powered machine learning models on Cloudflare's global network.
|
||||
- **[GitHub](https://lobechat.com/discover/provider/github)**: With GitHub Models, developers can become AI engineers and leverage the industry's leading AI models.
|
||||
|
||||
<details><summary><kbd>See more providers (+31)</kbd></summary>
|
||||
|
||||
- **[Novita](https://lobechat.com/discover/provider/novita)**: Novita AI is a platform providing a variety of large language models and AI image generation API services, flexible, reliable, and cost-effective. It supports the latest open-source models like Llama3 and Mistral, offering a comprehensive, user-friendly, and auto-scaling API solution for generative AI application development, suitable for the rapid growth of AI startups.
|
||||
- **[PPIO](https://lobechat.com/discover/provider/ppio)**: PPIO supports stable and cost-efficient open-source LLM APIs, such as DeepSeek, Llama, Qwen etc.
|
||||
- **[Together AI](https://lobechat.com/discover/provider/togetherai)**: Together AI is dedicated to achieving leading performance through innovative AI models, offering extensive customization capabilities, including rapid scaling support and intuitive deployment processes to meet various enterprise needs.
|
||||
- **[Fireworks AI](https://lobechat.com/discover/provider/fireworksai)**: Fireworks AI is a leading provider of advanced language model services, focusing on functional calling and multimodal processing. Its latest model, Firefunction V2, is based on Llama-3, optimized for function calling, conversation, and instruction following. The visual language model FireLLaVA-13B supports mixed input of images and text. Other notable models include the Llama series and Mixtral series, providing efficient multilingual instruction following and generation support.
|
||||
- **[Groq](https://lobechat.com/discover/provider/groq)**: Groq's LPU inference engine has excelled in the latest independent large language model (LLM) benchmarks, redefining the standards for AI solutions with its remarkable speed and efficiency. Groq represents instant inference speed, demonstrating strong performance in cloud-based deployments.
|
||||
- **[Perplexity](https://lobechat.com/discover/provider/perplexity)**: Perplexity is a leading provider of conversational generation models, offering various advanced Llama 3.1 models that support both online and offline applications, particularly suited for complex natural language processing tasks.
|
||||
- **[Mistral](https://lobechat.com/discover/provider/mistral)**: Mistral provides advanced general, specialized, and research models widely used in complex reasoning, multilingual tasks, and code generation. Through functional calling interfaces, users can integrate custom functionalities for specific applications.
|
||||
- **[ModelScope](https://lobechat.com/discover/provider/modelscope)**: ModelScope is a model-as-a-service platform launched by Alibaba Cloud, offering a wide range of AI models and inference services.
|
||||
- **[Ai21Labs](https://lobechat.com/discover/provider/ai21)**: AI21 Labs builds foundational models and AI systems for enterprises, accelerating the application of generative AI in production.
|
||||
- **[Upstage](https://lobechat.com/discover/provider/upstage)**: Upstage focuses on developing AI models for various business needs, including Solar LLM and document AI, aiming to achieve artificial general intelligence (AGI) for work. It allows for the creation of simple conversational agents through Chat API and supports functional calling, translation, embedding, and domain-specific applications.
|
||||
- **[xAI (Grok)](https://lobechat.com/discover/provider/xai)**: xAI is a company dedicated to building artificial intelligence to accelerate human scientific discovery. Our mission is to advance our collective understanding of the universe.
|
||||
- **[Aliyun Bailian](https://lobechat.com/discover/provider/qwen)**: Tongyi Qianwen is a large-scale language model independently developed by Alibaba Cloud, featuring strong natural language understanding and generation capabilities. It can answer various questions, create written content, express opinions, and write code, playing a role in multiple fields.
|
||||
- **[Wenxin](https://lobechat.com/discover/provider/wenxin)**: An enterprise-level one-stop platform for large model and AI-native application development and services, providing the most comprehensive and user-friendly toolchain for the entire process of generative artificial intelligence model development and application development.
|
||||
- **[Hunyuan](https://lobechat.com/discover/provider/hunyuan)**: A large language model developed by Tencent, equipped with powerful Chinese creative capabilities, logical reasoning abilities in complex contexts, and reliable task execution skills.
|
||||
- **[ZhiPu](https://lobechat.com/discover/provider/zhipu)**: Zhipu AI offers an open platform for multimodal and language models, supporting a wide range of AI application scenarios, including text processing, image understanding, and programming assistance.
|
||||
- **[SiliconCloud](https://lobechat.com/discover/provider/siliconcloud)**: SiliconFlow is dedicated to accelerating AGI for the benefit of humanity, enhancing large-scale AI efficiency through an easy-to-use and cost-effective GenAI stack.
|
||||
- **[01.AI](https://lobechat.com/discover/provider/zeroone)**: 01.AI focuses on AI 2.0 era technologies, vigorously promoting the innovation and application of 'human + artificial intelligence', using powerful models and advanced AI technologies to enhance human productivity and achieve technological empowerment.
|
||||
- **[Spark](https://lobechat.com/discover/provider/spark)**: iFlytek's Spark model provides powerful AI capabilities across multiple domains and languages, utilizing advanced natural language processing technology to build innovative applications suitable for smart hardware, smart healthcare, smart finance, and other vertical scenarios.
|
||||
- **[SenseNova](https://lobechat.com/discover/provider/sensenova)**: SenseNova, backed by SenseTime's robust infrastructure, offers efficient and user-friendly full-stack large model services.
|
||||
- **[Stepfun](https://lobechat.com/discover/provider/stepfun)**: StepFun's large model possesses industry-leading multimodal and complex reasoning capabilities, supporting ultra-long text understanding and powerful autonomous scheduling search engine functions.
|
||||
- **[Moonshot](https://lobechat.com/discover/provider/moonshot)**: Moonshot is an open-source platform launched by Beijing Dark Side Technology Co., Ltd., providing various natural language processing models with a wide range of applications, including but not limited to content creation, academic research, intelligent recommendations, and medical diagnosis, supporting long text processing and complex generation tasks.
|
||||
- **[Baichuan](https://lobechat.com/discover/provider/baichuan)**: Baichuan Intelligence is a company focused on the research and development of large AI models, with its models excelling in domestic knowledge encyclopedias, long text processing, and generative creation tasks in Chinese, surpassing mainstream foreign models. Baichuan Intelligence also possesses industry-leading multimodal capabilities, performing excellently in multiple authoritative evaluations. Its models include Baichuan 4, Baichuan 3 Turbo, and Baichuan 3 Turbo 128k, each optimized for different application scenarios, providing cost-effective solutions.
|
||||
- **[Minimax](https://lobechat.com/discover/provider/minimax)**: MiniMax is a general artificial intelligence technology company established in 2021, dedicated to co-creating intelligence with users. MiniMax has independently developed general large models of different modalities, including trillion-parameter MoE text models, voice models, and image models, and has launched applications such as Conch AI.
|
||||
- **[InternLM](https://lobechat.com/discover/provider/internlm)**: An open-source organization dedicated to the research and development of large model toolchains. It provides an efficient and user-friendly open-source platform for all AI developers, making cutting-edge large models and algorithm technologies easily accessible.
|
||||
- **[Higress](https://lobechat.com/discover/provider/higress)**: Higress is a cloud-native API gateway that was developed internally at Alibaba to address the issues of Tengine reload affecting long-lived connections and the insufficient load balancing capabilities for gRPC/Dubbo.
|
||||
- **[Gitee AI](https://lobechat.com/discover/provider/giteeai)**: Gitee AI's Serverless API provides AI developers with an out of the box large model inference API service.
|
||||
- **[Taichu](https://lobechat.com/discover/provider/taichu)**: The Institute of Automation, Chinese Academy of Sciences, and Wuhan Artificial Intelligence Research Institute have launched a new generation of multimodal large models, supporting comprehensive question-answering tasks such as multi-turn Q\&A, text creation, image generation, 3D understanding, and signal analysis, with stronger cognitive, understanding, and creative abilities, providing a new interactive experience.
|
||||
- **[360 AI](https://lobechat.com/discover/provider/ai360)**: 360 AI is an AI model and service platform launched by 360 Company, offering various advanced natural language processing models, including 360GPT2 Pro, 360GPT Pro, 360GPT Turbo, and 360GPT Turbo Responsibility 8K. These models combine large-scale parameters and multimodal capabilities, widely applied in text generation, semantic understanding, dialogue systems, and code generation. With flexible pricing strategies, 360 AI meets diverse user needs, supports developer integration, and promotes the innovation and development of intelligent applications.
|
||||
- **[Search1API](https://lobechat.com/discover/provider/search1api)**: Search1API provides access to the DeepSeek series of models that can connect to the internet as needed, including standard and fast versions, supporting a variety of model sizes.
|
||||
- **[InfiniAI](https://lobechat.com/discover/provider/infiniai)**: Provides high-performance, easy-to-use, and secure large model services for application developers, covering the entire process from large model development to service deployment.
|
||||
- **[Qiniu](https://lobechat.com/discover/provider/qiniu)**: Qiniu, as a long-established cloud service provider, delivers cost-effective and reliable AI inference services for both real-time and batch processing, with a simple and user-friendly experience.
|
||||
|
||||
</details>
|
||||
|
||||
> 📊 Total providers: [<kbd>**41**</kbd>](https://lobechat.com/discover/providers)
|
||||
|
||||
<!-- PROVIDER LIST -->
|
||||
|
||||
At the same time, we are also planning to support more model service providers. If you would like LobeChat to support your favorite service provider, feel free to join our [💬 community discussion](https://github.com/lobehub/lobe-chat/discussions/1284).
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-local]][docs-feat-local]
|
||||
|
||||
### [Local Large Language Model (LLM) Support][docs-feat-local]
|
||||
|
||||
To meet the specific needs of users, LobeChat also supports the use of local models based on [Ollama](https://ollama.ai), allowing users to flexibly use their own or third-party models.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> Learn more about [📘 Using Ollama in LobeChat][docs-usage-ollama] by checking it out.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-vision]][docs-feat-vision]
|
||||
|
||||
### [Model Visual Recognition][docs-feat-vision]
|
||||
|
||||
LobeChat now supports OpenAI's latest [`gpt-4-vision`](https://platform.openai.com/docs/guides/vision) model with visual recognition capabilities,
|
||||
a multimodal intelligence that can perceive visuals. Users can easily upload or drag and drop images into the dialogue box,
|
||||
and the agent will be able to recognize the content of the images and engage in intelligent conversation based on this,
|
||||
creating smarter and more diversified chat scenarios.
|
||||
|
||||
This feature opens up new interactive methods, allowing communication to transcend text and include a wealth of visual elements.
|
||||
Whether it's sharing images in daily use or interpreting images within specific industries, the agent provides an outstanding conversational experience.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-tts]][docs-feat-tts]
|
||||
|
||||
### [TTS & STT Voice Conversation][docs-feat-tts]
|
||||
|
||||
LobeChat supports Text-to-Speech (TTS) and Speech-to-Text (STT) technologies, enabling our application to convert text messages into clear voice outputs,
|
||||
allowing users to interact with our conversational agent as if they were talking to a real person. Users can choose from a variety of voices to pair with the agent.
|
||||
|
||||
Moreover, TTS offers an excellent solution for those who prefer auditory learning or desire to receive information while busy.
|
||||
In LobeChat, we have meticulously selected a range of high-quality voice options (OpenAI Audio, Microsoft Edge Speech) to meet the needs of users from different regions and cultural backgrounds.
|
||||
Users can choose the voice that suits their personal preferences or specific scenarios, resulting in a personalized communication experience.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-t2i]][docs-feat-t2i]
|
||||
|
||||
### [Text to Image Generation][docs-feat-t2i]
|
||||
|
||||
With support for the latest text-to-image generation technology, LobeChat now allows users to invoke image creation tools directly within conversations with the agent. By leveraging the capabilities of AI tools such as [`DALL-E 3`](https://openai.com/dall-e-3), [`MidJourney`](https://www.midjourney.com/), and [`Pollinations`](https://pollinations.ai/), the agents are now equipped to transform your ideas into images.
|
||||
|
||||
This enables a more private and immersive creative process, allowing for the seamless integration of visual storytelling into your personal dialogue with the agent.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-plugin]][docs-feat-plugin]
|
||||
|
||||
### [Plugin System (Function Calling)][docs-feat-plugin]
|
||||
|
||||
The plugin ecosystem of LobeChat is an important extension of its core functionality, greatly enhancing the practicality and flexibility of the LobeChat assistant.
|
||||
|
||||
<video controls src="https://github.com/lobehub/lobe-chat/assets/28616219/f29475a3-f346-4196-a435-41a6373ab9e2" muted="false"></video>
|
||||
|
||||
By utilizing plugins, LobeChat assistants can obtain and process real-time information, such as searching for web information and providing users with instant and relevant news.
|
||||
|
||||
In addition, these plugins are not limited to news aggregation, but can also extend to other practical functions, such as quickly searching documents, generating images, obtaining data from various platforms like Bilibili, Steam, and interacting with various third-party services.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> Learn more about [📘 Plugin Usage][docs-usage-plugin] by checking it out.
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
| Recent Submits | Description |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
| [PortfolioMeta](https://lobechat.com/discover/plugin/StockData)<br/><sup>By **portfoliometa** on **2025-07-21**</sup> | Analyze stocks and get comprehensive real-time investment data and analytics.<br/>`stock` |
|
||||
| [Speak](https://lobechat.com/discover/plugin/speak)<br/><sup>By **speak** on **2025-07-18**</sup> | Learn how to say anything in another language with Speak, your AI-powered language tutor.<br/>`education` `language` |
|
||||
| [Web](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | Smart web search that reads and analyzes pages to deliver comprehensive answers from Google results.<br/>`web` `search` |
|
||||
| [Bing_websearch](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | Search for information from the internet base BingApi<br/>`bingsearch` |
|
||||
|
||||
> 📊 Total plugins: [<kbd>**43**</kbd>](https://lobechat.com/discover/plugins)
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-agent]][docs-feat-agent]
|
||||
|
||||
### [Agent Market (GPTs)][docs-feat-agent]
|
||||
|
||||
In LobeChat Agent Marketplace, creators can discover a vibrant and innovative community that brings together a multitude of well-designed agents,
|
||||
which not only play an important role in work scenarios but also offer great convenience in learning processes.
|
||||
Our marketplace is not just a showcase platform but also a collaborative space. Here, everyone can contribute their wisdom and share the agents they have developed.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> By [🤖/🏪 Submit Agents][submit-agents-link], you can easily submit your agent creations to our platform.
|
||||
> Importantly, LobeChat has established a sophisticated automated internationalization (i18n) workflow,
|
||||
> capable of seamlessly translating your agent into multiple language versions.
|
||||
> This means that no matter what language your users speak, they can experience your agent without barriers.
|
||||
|
||||
> \[!IMPORTANT]
|
||||
>
|
||||
> We welcome all users to join this growing ecosystem and participate in the iteration and optimization of agents.
|
||||
> Together, we can create more interesting, practical, and innovative agents, further enriching the diversity and practicality of the agent offerings.
|
||||
|
||||
<!-- AGENT LIST -->
|
||||
|
||||
| Recent Submits | Description |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| [Turtle Soup Host](https://lobechat.com/discover/assistant/lateral-thinking-puzzle)<br/><sup>By **[CSY2022](https://github.com/CSY2022)** on **2025-06-19**</sup> | A turtle soup host needs to provide the scenario, the complete story (truth of the event), and the key point (the condition for guessing correctly).<br/>`turtle-soup` `reasoning` `interaction` `puzzle` `role-playing` |
|
||||
| [Gourmet Reviewer🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | Food critique expert<br/>`gourmet` `review` `writing` |
|
||||
| [Academic Writing Assistant](https://lobechat.com/discover/assistant/academic-writing-assistant)<br/><sup>By **[swarfte](https://github.com/swarfte)** on **2025-06-17**</sup> | Expert in academic research paper writing and formal documentation<br/>`academic-writing` `research` `formal-style` |
|
||||
| [Minecraft Senior Developer](https://lobechat.com/discover/assistant/java-development)<br/><sup>By **[iamyuuk](https://github.com/iamyuuk)** on **2025-06-17**</sup> | Expert in advanced Java development and Minecraft mod and server plugin development<br/>`development` `programming` `minecraft` `java` |
|
||||
|
||||
> 📊 Total agents: [<kbd>**505**</kbd> ](https://lobechat.com/discover/assistants)
|
||||
|
||||
<!-- AGENT LIST -->
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-database]][docs-feat-database]
|
||||
|
||||
### [Support Local / Remote Database][docs-feat-database]
|
||||
|
||||
LobeChat supports the use of both server-side and local databases. Depending on your needs, you can choose the appropriate deployment solution:
|
||||
|
||||
- **Local database**: suitable for users who want more control over their data and privacy protection. LobeChat uses CRDT (Conflict-Free Replicated Data Type) technology to achieve multi-device synchronization. This is an experimental feature aimed at providing a seamless data synchronization experience.
|
||||
- **Server-side database**: suitable for users who want a more convenient user experience. LobeChat supports PostgreSQL as a server-side database. For detailed documentation on how to configure the server-side database, please visit [Configure Server-side Database](https://lobehub.com/docs/self-hosting/advanced/server-database).
|
||||
|
||||
Regardless of which database you choose, LobeChat can provide you with an excellent user experience.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-auth]][docs-feat-auth]
|
||||
|
||||
### [Support Multi-User Management][docs-feat-auth]
|
||||
|
||||
LobeChat supports multi-user management and provides two main user authentication and management solutions to meet different needs:
|
||||
|
||||
- **next-auth**: LobeChat integrates `next-auth`, a flexible and powerful identity verification library that supports multiple authentication methods, including OAuth, email login, credential login, etc. With `next-auth`, you can easily implement user registration, login, session management, social login, and other functions to ensure the security and privacy of user data.
|
||||
|
||||
- [**Clerk**](https://go.clerk.com/exgqLG0): For users who need more advanced user management features, LobeChat also supports `Clerk`, a modern user management platform. `Clerk` provides richer functions, such as multi-factor authentication (MFA), user profile management, login activity monitoring, etc. With `Clerk`, you can get higher security and flexibility, and easily cope with complex user management needs.
|
||||
|
||||
Regardless of which user management solution you choose, LobeChat can provide you with an excellent user experience and powerful functional support.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-pwa]][docs-feat-pwa]
|
||||
|
||||
### [Progressive Web App (PWA)][docs-feat-pwa]
|
||||
|
||||
We deeply understand the importance of providing a seamless experience for users in today's multi-device environment.
|
||||
Therefore, we have adopted Progressive Web Application ([PWA](https://support.google.com/chrome/answer/9658361)) technology,
|
||||
a modern web technology that elevates web applications to an experience close to that of native apps.
|
||||
|
||||
Through PWA, LobeChat can offer a highly optimized user experience on both desktop and mobile devices while maintaining its lightweight and high-performance characteristics.
|
||||
Visually and in terms of feel, we have also meticulously designed the interface to ensure it is indistinguishable from native apps,
|
||||
providing smooth animations, responsive layouts, and adapting to different device screen resolutions.
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> If you are unfamiliar with the installation process of PWA, you can add LobeChat as your desktop application (also applicable to mobile devices) by following these steps:
|
||||
>
|
||||
> - Launch the Chrome or Edge browser on your computer.
|
||||
> - Visit the LobeChat webpage.
|
||||
> - In the upper right corner of the address bar, click on the <kbd>Install</kbd> icon.
|
||||
> - Follow the instructions on the screen to complete the PWA Installation.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-mobile]][docs-feat-mobile]
|
||||
|
||||
### [Mobile Device Adaptation][docs-feat-mobile]
|
||||
|
||||
We have carried out a series of optimization designs for mobile devices to enhance the user's mobile experience. Currently, we are iterating on the mobile user experience to achieve smoother and more intuitive interactions. If you have any suggestions or ideas, we welcome you to provide feedback through GitHub Issues or Pull Requests.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-theme]][docs-feat-theme]
|
||||
|
||||
### [Custom Themes][docs-feat-theme]
|
||||
|
||||
As a design-engineering-oriented application, LobeChat places great emphasis on users' personalized experiences,
|
||||
hence introducing flexible and diverse theme modes, including a light mode for daytime and a dark mode for nighttime.
|
||||
Beyond switching theme modes, a range of color customization options allow users to adjust the application's theme colors according to their preferences.
|
||||
Whether it's a desire for a sober dark blue, a lively peach pink, or a professional gray-white, users can find their style of color choices in LobeChat.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> The default configuration can intelligently recognize the user's system color mode and automatically switch themes to ensure a consistent visual experience with the operating system.
|
||||
> For users who like to manually control details, LobeChat also offers intuitive setting options and a choice between chat bubble mode and document mode for conversation scenarios.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
### `*` What's more
|
||||
|
||||
Beside these features, LobeChat also have much better basic technique underground:
|
||||
|
||||
- [x] 💨 **Quick Deployment**: Using the Vercel platform or docker image, you can deploy with just one click and complete the process within 1 minute without any complex configuration.
|
||||
- [x] 🌐 **Custom Domain**: If users have their own domain, they can bind it to the platform for quick access to the dialogue agent from anywhere.
|
||||
- [x] 🔒 **Privacy Protection**: All data is stored locally in the user's browser, ensuring user privacy.
|
||||
- [x] 💎 **Exquisite UI Design**: With a carefully designed interface, it offers an elegant appearance and smooth interaction. It supports light and dark themes and is mobile-friendly. PWA support provides a more native-like experience.
|
||||
- [x] 🗣️ **Smooth Conversation Experience**: Fluid responses ensure a smooth conversation experience. It fully supports Markdown rendering, including code highlighting, LaTex formulas, Mermaid flowcharts, and more.
|
||||
|
||||
> ✨ more features will be added when LobeChat evolve.
|
||||
|
||||
---
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> You can find our upcoming [Roadmap][github-project-link] plans in the Projects section.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ⚡️ Performance
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> The complete list of reports can be found in the [📘 Lighthouse Reports][docs-lighthouse]
|
||||
|
||||
| Desktop | Mobile |
|
||||
| :-----------------------------------------: | :----------------------------------------: |
|
||||
| ![][chat-desktop] | ![][chat-mobile] |
|
||||
| [📑 Lighthouse Report][chat-desktop-report] | [📑 Lighthouse Report][chat-mobile-report] |
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🛳 Self Hosting
|
||||
|
||||
LobeChat provides Self-Hosted Version with Vercel, Alibaba Cloud, and [Docker Image][docker-release-link]. This allows you to deploy your own chatbot within a few minutes without any prior knowledge.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> Learn more about [📘 Build your own LobeChat][docs-self-hosting] by checking it out.
|
||||
|
||||
### `A` Deploying with Vercel, Zeabur , Sealos or Alibaba Cloud
|
||||
|
||||
"If you want to deploy this service yourself on Vercel, Zeabur or Alibaba Cloud, you can follow these steps:
|
||||
|
||||
- Prepare your [OpenAI API Key](https://platform.openai.com/account/api-keys).
|
||||
- Click the button below to start deployment: Log in directly with your GitHub account, and remember to fill in the `OPENAI_API_KEY`(required) and `ACCESS_CODE` (recommended) on the environment variable section.
|
||||
- After deployment, you can start using it.
|
||||
- Bind a custom domain (optional): The DNS of the domain assigned by Vercel is polluted in some areas; binding a custom domain can connect directly.
|
||||
|
||||
<div align="center">
|
||||
|
||||
| Deploy with Vercel | Deploy with Zeabur | Deploy with Sealos | Deploy with RepoCloud | Deploy with Alibaba Cloud |
|
||||
| :-------------------------------------: | :---------------------------------------------------------: | :---------------------------------------------------------: | :---------------------------------------------------------------: | :-----------------------------------------------------------------------: |
|
||||
| [![][deploy-button-image]][deploy-link] | [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link] | [![][deploy-on-sealos-button-image]][deploy-on-sealos-link] | [![][deploy-on-repocloud-button-image]][deploy-on-repocloud-link] | [![][deploy-on-alibaba-cloud-button-image]][deploy-on-alibaba-cloud-link] |
|
||||
|
||||
</div>
|
||||
|
||||
#### After Fork
|
||||
|
||||
After fork, only retain the upstream sync action and disable other actions in your repository on GitHub.
|
||||
|
||||
#### Keep Updated
|
||||
|
||||
If you have deployed your own project following the one-click deployment steps in the README, you might encounter constant prompts indicating "updates available." This is because Vercel defaults to creating a new project instead of forking this one, resulting in an inability to detect updates accurately.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> We suggest you redeploy using the following steps, [📘 Auto Sync With Latest][docs-upstream-sync]
|
||||
|
||||
<br/>
|
||||
|
||||
### `B` Deploying with Docker
|
||||
|
||||
[![][docker-release-shield]][docker-release-link]
|
||||
[![][docker-size-shield]][docker-size-link]
|
||||
[![][docker-pulls-shield]][docker-pulls-link]
|
||||
|
||||
We provide a Docker image for deploying the LobeChat service on your own private device. Use the following command to start the LobeChat service:
|
||||
|
||||
1. create a folder to for storage files
|
||||
|
||||
```fish
|
||||
$ mkdir lobe-chat-db && cd lobe-chat-db
|
||||
```
|
||||
|
||||
2. init the LobeChat infrastructure
|
||||
|
||||
```fish
|
||||
bash <(curl -fsSL https://lobe.li/setup.sh)
|
||||
```
|
||||
|
||||
3. Start the LobeChat service
|
||||
|
||||
```fish
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> For detailed instructions on deploying with Docker, please refer to the [📘 Docker Deployment Guide][docs-docker]
|
||||
|
||||
<br/>
|
||||
|
||||
### Environment Variable
|
||||
|
||||
This project provides some additional configuration items set with environment variables:
|
||||
|
||||
| Environment Variable | Required | Description | Example |
|
||||
| -------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||
| `OPENAI_API_KEY` | Yes | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
|
||||
| `OPENAI_PROXY_URL` | No | If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL | `https://api.chatanywhere.cn` or `https://aihubmix.com/v1` <br/>The default value is<br/>`https://api.openai.com/v1` |
|
||||
| `ACCESS_CODE` | No | Add a password to access this service; you can set a long password to avoid leaking. If this value contains a comma, it is a password array. | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
|
||||
| `OPENAI_MODEL_LIST` | No | Used to control the model list. Use `+` to add a model, `-` to hide a model, and `model_name=display_name` to customize the display name of a model, separated by commas. | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> The complete list of environment variables can be found in the [📘 Environment Variables][docs-env-var]
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 📦 Ecosystem
|
||||
|
||||
| NPM | Repository | Description | Version |
|
||||
| --------------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
||||
| [@lobehub/ui][lobe-ui-link] | [lobehub/lobe-ui][lobe-ui-github] | Open-source UI component library dedicated to building AIGC web applications. | [![][lobe-ui-shield]][lobe-ui-link] |
|
||||
| [@lobehub/icons][lobe-icons-link] | [lobehub/lobe-icons][lobe-icons-github] | Popular AI / LLM Model Brand SVG Logo and Icon Collection. | [![][lobe-icons-shield]][lobe-icons-link] |
|
||||
| [@lobehub/tts][lobe-tts-link] | [lobehub/lobe-tts][lobe-tts-github] | High-quality & reliable TTS/STT React Hooks library | [![][lobe-tts-shield]][lobe-tts-link] |
|
||||
| [@lobehub/lint][lobe-lint-link] | [lobehub/lobe-lint][lobe-lint-github] | Configurations for ESlint, Stylelint, Commitlint, Prettier, Remark, and Semantic Release for LobeHub. | [![][lobe-lint-shield]][lobe-lint-link] |
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🧩 Plugins
|
||||
|
||||
Plugins provide a means to extend the [Function Calling][docs-function-call] capabilities of LobeChat. They can be used to introduce new function calls and even new ways to render message results. If you are interested in plugin development, please refer to our [📘 Plugin Development Guide][docs-plugin-dev] in the Wiki.
|
||||
|
||||
- [lobe-chat-plugins][lobe-chat-plugins]: This is the plugin index for LobeChat. It accesses index.json from this repository to display a list of available plugins for LobeChat to the user.
|
||||
- [chat-plugin-template][chat-plugin-template]: This is the plugin template for LobeChat plugin development.
|
||||
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]: The LobeChat Plugin SDK assists you in creating exceptional chat plugins for Lobe Chat.
|
||||
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]: The LobeChat Plugins Gateway is a backend service that provides a gateway for LobeChat plugins. We deploy this service using Vercel. The primary API POST /api/v1/runner is deployed as an Edge Function.
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> The plugin system is currently undergoing major development. You can learn more in the following issues:
|
||||
>
|
||||
> - [x] [**Plugin Phase 1**](https://github.com/lobehub/lobe-chat/issues/73): Implement separation of the plugin from the main body, split the plugin into an independent repository for maintenance, and realize dynamic loading of the plugin.
|
||||
> - [x] [**Plugin Phase 2**](https://github.com/lobehub/lobe-chat/issues/97): The security and stability of the plugin's use, more accurately presenting abnormal states, the maintainability of the plugin architecture, and developer-friendly.
|
||||
> - [x] [**Plugin Phase 3**](https://github.com/lobehub/lobe-chat/issues/149): Higher-level and more comprehensive customization capabilities, support for plugin authentication, and examples.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ⌨️ Local Development
|
||||
|
||||
You can use GitHub Codespaces for online development:
|
||||
|
||||
[![][codespaces-shield]][codespaces-link]
|
||||
|
||||
Or clone it for local development:
|
||||
|
||||
```fish
|
||||
$ git clone https://github.com/lobehub/lobe-chat.git
|
||||
$ cd lobe-chat
|
||||
$ pnpm install
|
||||
$ pnpm dev
|
||||
```
|
||||
|
||||
If you would like to learn more details, please feel free to look at our [📘 Development Guide][docs-dev-guide].
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions of all types are more than welcome; if you are interested in contributing code, feel free to check out our GitHub [Issues][github-issues-link] and [Projects][github-project-link] to get stuck in to show us what you're made of.
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> We are creating a technology-driven forum, fostering knowledge interaction and the exchange of ideas that may culminate in mutual inspiration and collaborative innovation.
|
||||
>
|
||||
> Help us make LobeChat better. Welcome to provide product design feedback, user experience discussions directly to us.
|
||||
>
|
||||
> **Principal Maintainers:** [@arvinxx](https://github.com/arvinxx) [@canisminor1990](https://github.com/canisminor1990)
|
||||
|
||||
[![][pr-welcome-shield]][pr-welcome-link]
|
||||
[![][submit-agents-shield]][submit-agents-link]
|
||||
[![][submit-plugin-shield]][submit-plugin-link]
|
||||
|
||||
<a href="https://github.com/lobehub/lobe-chat/graphs/contributors" target="_blank">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<br><img src="https://contrib.rocks/image?repo=lobehub/lobe-chat"><br><br>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
<td rowspan="2">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-participants-growth/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=4x7&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-participants-growth/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=4x7&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=new&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=new&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</a>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ❤️ Sponsor
|
||||
|
||||
Every bit counts and your one-time donation sparkles in our galaxy of support! You're a shooting star, making a swift and bright impact on our journey. Thank you for believing in us – your generosity guides us toward our mission, one brilliant flash at a time.
|
||||
|
||||
<a href="https://opencollective.com/lobehub" target="_blank">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/lobehub/.github/blob/main/static/sponsor-dark.png?raw=true">
|
||||
<img src="https://github.com/lobehub/.github/blob/main/static/sponsor-light.png?raw=true">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🔗 More Products
|
||||
|
||||
- **[🅰️ Lobe SD Theme][lobe-theme]:** Modern theme for Stable Diffusion WebUI, exquisite interface design, highly customizable UI, and efficiency-boosting features.
|
||||
- **[⛵️ Lobe Midjourney WebUI][lobe-midjourney-webui]:** WebUI for Midjourney, leverages AI to quickly generate a wide array of rich and diverse images from text prompts, sparking creativity and enhancing conversations.
|
||||
- **[🌏 Lobe i18n][lobe-i18n] :** Lobe i18n is an automation tool for the i18n (internationalization) translation process, powered by ChatGPT. It supports features such as automatic splitting of large files, incremental updates, and customization options for the OpenAI model, API proxy, and temperature.
|
||||
- **[💌 Lobe Commit][lobe-commit]:** Lobe Commit is a CLI tool that leverages Langchain/ChatGPT to generate Gitmoji-based commit messages.
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<details><summary><h4>📝 License</h4></summary>
|
||||
|
||||
[![][fossa-license-shield]][fossa-license-link]
|
||||
|
||||
</details>
|
||||
|
||||
Copyright © 2025 [LobeHub][profile-link]. <br />
|
||||
This project is [Apache 2.0](./LICENSE) licensed.
|
||||
|
||||
<!-- LINK GROUP -->
|
||||
|
||||
[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
|
||||
[blog]: https://lobehub.com/blog
|
||||
[changelog]: https://lobehub.com/changelog
|
||||
[chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
|
||||
[chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/chat_preview_lobehub_com_chat.html
|
||||
[chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
|
||||
[chat-mobile-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/mobile/chat_preview_lobehub_com_chat.html
|
||||
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
||||
[chat-plugin-template]: https://github.com/lobehub/chat-plugin-template
|
||||
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
||||
[codecov-link]: https://codecov.io/gh/lobehub/lobe-chat
|
||||
[codecov-shield]: https://img.shields.io/codecov/c/github/lobehub/lobe-chat?labelColor=black&style=flat-square&logo=codecov&logoColor=white
|
||||
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
|
||||
[codespaces-shield]: https://github.com/codespaces/badge.svg
|
||||
[deploy-button-image]: https://vercel.com/button
|
||||
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY,ACCESS_CODE&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%7C%20Access%20Code%20can%20protect%20your%20website&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
|
||||
[deploy-on-alibaba-cloud-button-image]: https://service-info-public.oss-cn-hangzhou.aliyuncs.com/computenest-en.svg
|
||||
[deploy-on-alibaba-cloud-link]: https://computenest.console.aliyun.com/service/instance/create/default?type=user&ServiceName=LobeChat%E7%A4%BE%E5%8C%BA%E7%89%88
|
||||
[deploy-on-repocloud-button-image]: https://d16t0pc4846x52.cloudfront.net/deploylobe.svg
|
||||
[deploy-on-repocloud-link]: https://repocloud.io/details/?app_id=248
|
||||
[deploy-on-sealos-button-image]: https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg
|
||||
[deploy-on-sealos-link]: https://template.usw.sealos.io/deploy?templateName=lobe-chat-db
|
||||
[deploy-on-zeabur-button-image]: https://zeabur.com/button.svg
|
||||
[deploy-on-zeabur-link]: https://zeabur.com/templates/VZGGTI
|
||||
[discord-link]: https://discord.gg/AYFPHvv2jT
|
||||
[discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
|
||||
[discord-shield-badge]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=for-the-badge
|
||||
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square&sort=semver
|
||||
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat-database?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square&sort=semver
|
||||
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat-database?color=369eff&labelColor=black&style=flat-square&sort=semver
|
||||
[docs]: https://lobehub.com/docs/usage/start
|
||||
[docs-dev-guide]: https://github.com/lobehub/lobe-chat/wiki/index
|
||||
[docs-docker]: https://lobehub.com/docs/self-hosting/server-database/docker-compose
|
||||
[docs-env-var]: https://lobehub.com/docs/self-hosting/environment-variables
|
||||
[docs-feat-agent]: https://lobehub.com/docs/usage/features/agent-market
|
||||
[docs-feat-artifacts]: https://lobehub.com/docs/usage/features/artifacts
|
||||
[docs-feat-auth]: https://lobehub.com/docs/usage/features/auth
|
||||
[docs-feat-branch]: https://lobehub.com/docs/usage/features/branching-conversations
|
||||
[docs-feat-cot]: https://lobehub.com/docs/usage/features/cot
|
||||
[docs-feat-database]: https://lobehub.com/docs/usage/features/database
|
||||
[docs-feat-knowledgebase]: https://lobehub.com/blog/knowledge-base
|
||||
[docs-feat-local]: https://lobehub.com/docs/usage/features/local-llm
|
||||
[docs-feat-mobile]: https://lobehub.com/docs/usage/features/mobile
|
||||
[docs-feat-plugin]: https://lobehub.com/docs/usage/features/plugin-system
|
||||
[docs-feat-provider]: https://lobehub.com/docs/usage/features/multi-ai-providers
|
||||
[docs-feat-pwa]: https://lobehub.com/docs/usage/features/pwa
|
||||
[docs-feat-t2i]: https://lobehub.com/docs/usage/features/text-to-image
|
||||
[docs-feat-theme]: https://lobehub.com/docs/usage/features/theme
|
||||
[docs-feat-tts]: https://lobehub.com/docs/usage/features/tts
|
||||
[docs-feat-vision]: https://lobehub.com/docs/usage/features/vision
|
||||
[docs-function-call]: https://lobehub.com/blog/openai-function-call
|
||||
[docs-lighthouse]: https://github.com/lobehub/lobe-chat/wiki/Lighthouse
|
||||
[docs-plugin-dev]: https://lobehub.com/docs/usage/plugins/development
|
||||
[docs-self-hosting]: https://lobehub.com/docs/self-hosting/start
|
||||
[docs-upstream-sync]: https://lobehub.com/docs/self-hosting/advanced/upstream-sync
|
||||
[docs-usage-ollama]: https://lobehub.com/docs/usage/providers/ollama
|
||||
[docs-usage-plugin]: https://lobehub.com/docs/usage/plugins/basic
|
||||
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
||||
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
||||
[github-action-release-link]: https://github.com/actions/workflows/lobehub/lobe-chat/release.yml
|
||||
[github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-chat/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
||||
[github-action-test-link]: https://github.com/actions/workflows/lobehub/lobe-chat/test.yml
|
||||
[github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-chat/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
||||
[github-contributors-link]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
||||
[github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-chat?color=c4f042&labelColor=black&style=flat-square
|
||||
[github-forks-link]: https://github.com/lobehub/lobe-chat/network/members
|
||||
[github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-chat?color=8ae8ff&labelColor=black&style=flat-square
|
||||
[github-issues-link]: https://github.com/lobehub/lobe-chat/issues
|
||||
[github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-chat?color=ff80eb&labelColor=black&style=flat-square
|
||||
[github-license-link]: https://github.com/lobehub/lobe-chat/blob/main/LICENSE
|
||||
[github-license-shield]: https://img.shields.io/badge/license-apache%202.0-white?labelColor=black&style=flat-square
|
||||
[github-project-link]: https://github.com/lobehub/lobe-chat/projects
|
||||
[github-release-link]: https://github.com/lobehub/lobe-chat/releases
|
||||
[github-release-shield]: https://img.shields.io/github/v/release/lobehub/lobe-chat?color=369eff&labelColor=black&logo=github&style=flat-square
|
||||
[github-releasedate-link]: https://github.com/lobehub/lobe-chat/releases
|
||||
[github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?labelColor=black&style=flat-square
|
||||
[github-stars-link]: https://github.com/lobehub/lobe-chat/network/stargazers
|
||||
[github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat?color=ffcb47&labelColor=black&style=flat-square
|
||||
[github-trending-shield]: https://trendshift.io/api/badge/repositories/2256
|
||||
[github-trending-url]: https://trendshift.io/repositories/2256
|
||||
[image-banner]: https://github.com/user-attachments/assets/6f293c7f-47b4-47eb-9202-fe68a942d35b
|
||||
[image-feat-agent]: https://github.com/user-attachments/assets/b3ab6e35-4fbc-468d-af10-e3e0c687350f
|
||||
[image-feat-artifacts]: https://github.com/user-attachments/assets/7f95fad6-b210-4e6e-84a0-7f39e96f3a00
|
||||
[image-feat-auth]: https://github.com/user-attachments/assets/80bb232e-19d1-4f97-98d6-e291f3585e6d
|
||||
[image-feat-branch]: https://github.com/user-attachments/assets/92f72082-02bd-4835-9c54-b089aad7fd41
|
||||
[image-feat-cot]: https://github.com/user-attachments/assets/f74f1139-d115-4e9c-8c43-040a53797a5e
|
||||
[image-feat-database]: https://github.com/user-attachments/assets/f1697c8b-d1fb-4dac-ba05-153c6295d91d
|
||||
[image-feat-desktop]: https://github.com/user-attachments/assets/a7bac8d3-ea96-4000-bb39-fadc9b610f96
|
||||
[image-feat-knowledgebase]: https://github.com/user-attachments/assets/7da7a3b2-92fd-4630-9f4e-8560c74955ae
|
||||
[image-feat-local]: https://github.com/user-attachments/assets/1239da50-d832-4632-a7ef-bd754c0f3850
|
||||
[image-feat-mcp]: https://github.com/user-attachments/assets/1be85d36-3975-4413-931f-27e05e440995
|
||||
[image-feat-mcp-market]: https://github.com/user-attachments/assets/bb114f9f-24c5-4000-a984-c10d187da5a0
|
||||
[image-feat-mobile]: https://github.com/user-attachments/assets/32cf43c4-96bd-4a4c-bfb6-59acde6fe380
|
||||
[image-feat-plugin]: https://github.com/user-attachments/assets/66a891ac-01b6-4e3f-b978-2eb07b489b1b
|
||||
[image-feat-privoder]: https://github.com/user-attachments/assets/e553e407-42de-4919-977d-7dbfcf44a821
|
||||
[image-feat-pwa]: https://github.com/user-attachments/assets/9647f70f-b71b-43b6-9564-7cdd12d1c24d
|
||||
[image-feat-t2i]: https://github.com/user-attachments/assets/708274a7-2458-494b-a6ec-b73dfa1fa7c2
|
||||
[image-feat-theme]: https://github.com/user-attachments/assets/b47c39f1-806f-492b-8fcb-b0fa973937c1
|
||||
[image-feat-tts]: https://github.com/user-attachments/assets/50189597-2cc3-4002-b4c8-756a52ad5c0a
|
||||
[image-feat-vision]: https://github.com/user-attachments/assets/18574a1f-46c2-4cbc-af2c-35a86e128a07
|
||||
[image-feat-web-search]: https://github.com/user-attachments/assets/cfdc48ac-b5f8-4a00-acee-db8f2eba09ad
|
||||
[image-overview]: https://github.com/user-attachments/assets/dbfaa84a-2c82-4dd9-815c-5be616f264a4
|
||||
[image-star]: https://github.com/user-attachments/assets/c3b482e7-cef5-4e94-bef9-226900ecfaab
|
||||
[issues-link]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
||||
[lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
|
||||
[lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
|
||||
[lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
|
||||
[lobe-icons-github]: https://github.com/lobehub/lobe-icons
|
||||
[lobe-icons-link]: https://www.npmjs.com/package/@lobehub/icons
|
||||
[lobe-icons-shield]: https://img.shields.io/npm/v/@lobehub/icons?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
||||
[lobe-lint-link]: https://www.npmjs.com/package/@lobehub/lint
|
||||
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-midjourney-webui]: https://github.com/lobehub/lobe-midjourney-webui
|
||||
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
||||
[lobe-tts-github]: https://github.com/lobehub/lobe-tts
|
||||
[lobe-tts-link]: https://www.npmjs.com/package/@lobehub/tts
|
||||
[lobe-tts-shield]: https://img.shields.io/npm/v/@lobehub/tts?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
||||
[lobe-ui-link]: https://www.npmjs.com/package/@lobehub/ui
|
||||
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[official-site]: https://lobehub.com
|
||||
[pr-welcome-link]: https://github.com/lobehub/lobe-chat/pulls
|
||||
[pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
|
||||
[profile-link]: https://github.com/lobehub
|
||||
[share-linkedin-link]: https://linkedin.com/feed
|
||||
[share-linkedin-shield]: https://img.shields.io/badge/-share%20on%20linkedin-black?labelColor=black&logo=linkedin&logoColor=white&style=flat-square
|
||||
[share-mastodon-link]: https://mastodon.social/share?text=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source,%20extensible%20%28Function%20Calling%29,%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.%20https://github.com/lobehub/lobe-chat%20#chatbot%20#chatGPT%20#openAI
|
||||
[share-mastodon-shield]: https://img.shields.io/badge/-share%20on%20mastodon-black?labelColor=black&logo=mastodon&logoColor=white&style=flat-square
|
||||
[share-reddit-link]: https://www.reddit.com/submit?title=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source%2C%20extensible%20%28Function%20Calling%29%2C%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-reddit-shield]: https://img.shields.io/badge/-share%20on%20reddit-black?labelColor=black&logo=reddit&logoColor=white&style=flat-square
|
||||
[share-telegram-link]: https://t.me/share/url"?text=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source%2C%20extensible%20%28Function%20Calling%29%2C%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-telegram-shield]: https://img.shields.io/badge/-share%20on%20telegram-black?labelColor=black&logo=telegram&logoColor=white&style=flat-square
|
||||
[share-weibo-link]: http://service.weibo.com/share/share.php?sharesource=weibo&title=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source%2C%20extensible%20%28Function%20Calling%29%2C%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-weibo-shield]: https://img.shields.io/badge/-share%20on%20weibo-black?labelColor=black&logo=sinaweibo&logoColor=white&style=flat-square
|
||||
[share-whatsapp-link]: https://api.whatsapp.com/send?text=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source%2C%20extensible%20%28Function%20Calling%29%2C%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.%20https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat%20%23chatbot%20%23chatGPT%20%23openAI
|
||||
[share-whatsapp-shield]: https://img.shields.io/badge/-share%20on%20whatsapp-black?labelColor=black&logo=whatsapp&logoColor=white&style=flat-square
|
||||
[share-x-link]: https://x.com/intent/tweet?hashtags=chatbot%2CchatGPT%2CopenAI&text=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source%2C%20extensible%20%28Function%20Calling%29%2C%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT%2FLLM%20web%20application.&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-x-shield]: https://img.shields.io/badge/-share%20on%20x-black?labelColor=black&logo=x&logoColor=white&style=flat-square
|
||||
[sponsor-link]: https://opencollective.com/lobehub 'Become ❤️ LobeHub Sponsor'
|
||||
[sponsor-shield]: https://img.shields.io/badge/-Sponsor%20LobeHub-f04f88?logo=opencollective&logoColor=white&style=flat-square
|
||||
[submit-agents-link]: https://github.com/lobehub/lobe-chat-agents
|
||||
[submit-agents-shield]: https://img.shields.io/badge/🤖/🏪_submit_agent-%E2%86%92-c4f042?labelColor=black&style=for-the-badge
|
||||
[submit-plugin-link]: https://github.com/lobehub/lobe-chat-plugins
|
||||
[submit-plugin-shield]: https://img.shields.io/badge/🧩/🏪_submit_plugin-%E2%86%92-95f3d9?labelColor=black&style=for-the-badge
|
||||
[vercel-link]: https://chat-preview.lobehub.com
|
||||
[vercel-shield]: https://img.shields.io/badge/vercel-online-55b467?labelColor=black&logo=vercel&style=flat-square
|
||||
[vercel-shield-badge]: https://img.shields.io/badge/TRY%20LOBECHAT-ONLINE-55b467?labelColor=black&logo=vercel&style=for-the-badge
|
||||
-993
@@ -1,993 +0,0 @@
|
||||
<div align="center"><a name="readme-top"></a>
|
||||
|
||||
[![][image-banner]][vercel-link]
|
||||
|
||||
<h1>Lobe Chat</h1>
|
||||
|
||||
现代化设计的开源 ChatGPT/LLMs 聊天应用与开发框架<br/>
|
||||
支持语音合成、多模态、可扩展的([function call][docs-functionc-call])插件系统<br/>
|
||||
一键**免费**拥有你自己的 ChatGPT/Gemini/Claude/Ollama 应用
|
||||
|
||||
[English](./README.md) · **简体中文** · [官网][official-site] · [更新日志][changelog] · [文档][docs] · [博客][blog] · [反馈问题][github-issues-link]
|
||||
|
||||
<!-- SHIELD GROUP -->
|
||||
|
||||
[![][github-release-shield]][github-release-link]
|
||||
[![][docker-release-shield]][docker-release-link]
|
||||
[![][vercel-shield]][vercel-link]
|
||||
[![][discord-shield]][discord-link]<br/>
|
||||
[![][codecov-shield]][codecov-link]
|
||||
[![][github-action-test-shield]][github-action-test-link]
|
||||
[![][github-action-release-shield]][github-action-release-link]
|
||||
[![][github-releasedate-shield]][github-releasedate-link]<br/>
|
||||
[![][github-contributors-shield]][github-contributors-link]
|
||||
[![][github-forks-shield]][github-forks-link]
|
||||
[![][github-stars-shield]][github-stars-link]
|
||||
[![][github-issues-shield]][github-issues-link]
|
||||
[![][github-license-shield]][github-license-link]<br>
|
||||
[![][sponsor-shield]][sponsor-link]
|
||||
|
||||
**分享 LobeChat 给你的好友**
|
||||
|
||||
[![][share-x-shield]][share-x-link]
|
||||
[![][share-telegram-shield]][share-telegram-link]
|
||||
[![][share-whatsapp-shield]][share-whatsapp-link]
|
||||
[![][share-reddit-shield]][share-reddit-link]
|
||||
[![][share-weibo-shield]][share-weibo-link]
|
||||
[![][share-mastodon-shield]][share-mastodon-link]
|
||||
|
||||
<sup>探索私人生产力的未来。在个体崛起的时代中为你打造.</sup>
|
||||
|
||||
[![][github-trending-shield]][github-trending-url]
|
||||
[![][github-hello-shield]][github-hello-url]
|
||||
|
||||
![][image-overview]
|
||||
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary><kbd>目录树</kbd></summary>
|
||||
|
||||
#### TOC
|
||||
|
||||
- [👋🏻 开始使用 & 交流](#-开始使用--交流)
|
||||
- [✨ 特性一览](#-特性一览)
|
||||
- [✨ MCP 插件一键安装](#-mcp-插件一键安装)
|
||||
- [🏪 MCP 市场](#-mcp-市场)
|
||||
- [🖥️ 桌面应用](#️-桌面应用)
|
||||
- [🌐 智能联网搜索](#-智能联网搜索)
|
||||
- [思维链 (CoT)](#思维链-cot)
|
||||
- [分支对话](#分支对话)
|
||||
- [支持白板 (Artifacts)](#支持白板-artifacts)
|
||||
- [文件上传 / 知识库](#文件上传--知识库)
|
||||
- [多模型服务商支持](#多模型服务商支持)
|
||||
- [支持本地大语言模型 (LLM)](#支持本地大语言模型-llm)
|
||||
- [模型视觉识别 (Model Visual)](#模型视觉识别-model-visual)
|
||||
- [TTS & STT 语音会话](#tts--stt-语音会话)
|
||||
- [Text to Image 文生图](#text-to-image-文生图)
|
||||
- [插件系统 (Tools Calling)](#插件系统-tools-calling)
|
||||
- [助手市场 (GPTs)](#助手市场-gpts)
|
||||
- [支持本地 / 远程数据库](#支持本地--远程数据库)
|
||||
- [支持多用户管理](#支持多用户管理)
|
||||
- [渐进式 Web 应用 (PWA)](#渐进式-web-应用-pwa)
|
||||
- [移动设备适配](#移动设备适配)
|
||||
- [自定义主题](#自定义主题)
|
||||
- [`*` 更多特性](#-更多特性)
|
||||
- [⚡️ 性能测试](#️-性能测试)
|
||||
- [🛳 开箱即用](#-开箱即用)
|
||||
- [`A` 使用 Vercel、Zeabur 、Sealos 或 阿里云计算巢 部署](#a-使用-vercelzeabur-sealos-或-阿里云计算巢-部署)
|
||||
- [`B` 使用 Docker 部署](#b-使用-docker-部署)
|
||||
- [环境变量](#环境变量)
|
||||
- [获取 OpenAI API Key](#获取-openai-api-key)
|
||||
- [📦 生态系统](#-生态系统)
|
||||
- [🧩 插件体系](#-插件体系)
|
||||
- [⌨️ 本地开发](#️-本地开发)
|
||||
- [🤝 参与贡献](#-参与贡献)
|
||||
- [❤ 社区赞助](#-社区赞助)
|
||||
- [🔗 更多工具](#-更多工具)
|
||||
|
||||
####
|
||||
|
||||
<br/>
|
||||
|
||||
</details>
|
||||
|
||||
## 👋🏻 开始使用 & 交流
|
||||
|
||||
我们是一群充满热情的设计工程师,希望为 AIGC 提供现代化的设计组件和工具,并以开源的方式分享。
|
||||
同时通过 Bootstrapping 的方式,我们希望能够为开发者和用户提供一个更加开放、更加透明友好的产品生态。
|
||||
|
||||
不论普通用户与专业开发者,LobeHub 旨在成为所有人的 AI Agent 实验场。LobeChat 目前正在积极开发中,有任何需求或者问题,欢迎提交 [issues][issues-link]
|
||||
|
||||
| [![][vercel-shield-badge]][vercel-link] | 无需安装或注册!访问我们的网站,快速体验 |
|
||||
| :---------------------------------------- | :--------------------------------------------------------------------------- |
|
||||
| [![][discord-shield-badge]][discord-link] | 加入我们的 Discord 社区!这是你可以与开发者和其他 LobeHub 热衷用户交流的地方 |
|
||||
|
||||
> \[!IMPORTANT]
|
||||
>
|
||||
> **收藏项目**,你将从 GitHub 上无延迟地接收所有发布通知~⭐️
|
||||
|
||||
[![][image-star]][github-stars-link]
|
||||
|
||||
<details><summary><kbd>Star History</kbd></summary>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=lobehub%2Flobe-chat&theme=dark&type=Date">
|
||||
<img src="https://api.star-history.com/svg?repos=lobehub%2Flobe-chat&type=Date">
|
||||
</picture>
|
||||
</details>
|
||||
|
||||
## ✨ 特性一览
|
||||
|
||||
通过 LobeChat 的强大功能,体验为无缝连接、提升效率和无限创意而设计的全新 AI 体验。
|
||||
|
||||
### ✨ MCP 插件一键安装
|
||||
|
||||
[](https://lobehub.com/mcp)
|
||||
|
||||
**无缝连接你的 AI 与世界**
|
||||
|
||||
通过启用与外部工具、数据源和服务的平滑、安全和动态交互,释放你的 AI 的全部潜力。基于 MCP(模型上下文协议)的插件系统打破了 AI 与数字生态系统之间的壁垒,实现了前所未有的连接性和功能性。
|
||||
|
||||
将对话转化为强大的工作流程,连接数据库、API、文件系统等。体验真正理解并与你的世界互动的 AI Agent。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
### 🏪 MCP 市场
|
||||
|
||||
![][image-feat-mcp-market]
|
||||
|
||||
**发现、连接、扩展**
|
||||
|
||||
浏览不断增长的 MCP 插件库,轻松扩展你的 AI 能力并简化工作流程。访问 [lobehub.com/mcp](https://lobehub.com/mcp) 探索 MCP 市场,提供精选的集成集合,增强你的 AI 与各种工具和服务协作的能力。
|
||||
|
||||
从生产力工具到开发环境,发现扩展 AI 覆盖范围和效率的新方式。与社区连接,找到满足特定需求的完美插件。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
### 🖥️ 桌面应用
|
||||
|
||||
![][image-feat-desktop]
|
||||
|
||||
**巅峰性能,零干扰**
|
||||
|
||||
获得完整的 LobeChat 体验,摆脱浏览器限制 —— 轻量级、专注且随时就绪。我们的桌面应用程序为你的 AI 交互提供专用环境,确保最佳性能和最小干扰。
|
||||
|
||||
体验更快的响应时间、更好的资源管理和与 AI 助手的更稳定连接。桌面应用专为要求 AI 工具最佳性能的用户设计。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
### 🌐 智能联网搜索
|
||||
|
||||
![][image-feat-web-search]
|
||||
|
||||
**在线知识,按需获取**
|
||||
|
||||
通过实时联网访问,你的 AI 与世界保持同步 —— 新闻、数据、趋势等。保持信息更新,获取最新可用信息,使你的 AI 能够提供准确和最新的回复。
|
||||
|
||||
访问实时信息,验证事实,探索当前事件,无需离开对话。你的 AI 成为通向世界知识的门户,始终保持最新和全面。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-cot]][docs-feat-cot]
|
||||
|
||||
### [思维链 (CoT)][docs-feat-cot]
|
||||
|
||||
体验前所未有的 AI 推理过程。通过创新的思维链(CoT)可视化功能,您可以实时观察复杂问题是如何一步步被解析的。这项突破性的功能为 AI 的决策过程提供了前所未有的透明度,让您能够清晰地了解结论是如何得出的。
|
||||
|
||||
通过将复杂的推理过程分解为清晰的逻辑步骤,您可以更好地理解和验证 AI 的解题思路。无论您是在调试问题、学习知识,还是单纯对 AI 推理感兴趣,思维链可视化都能将抽象思维转化为一种引人入胜的互动体验。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-branch]][docs-feat-branch]
|
||||
|
||||
### [分支对话][docs-feat-branch]
|
||||
|
||||
为您带来更自然、更灵活的 AI 对话方式。通过分支对话功能,您的讨论可以像人类对话一样自然延伸。在任意消息处创建新的对话分支,让您在保留原有上下文的同时,自由探索不同的对话方向。
|
||||
|
||||
两种强大模式任您选择:
|
||||
|
||||
- **延续模式**:无缝延展当前讨论,保持宝贵的对话上下文
|
||||
- **独立模式**:基于任意历史消息,开启全新话题探讨
|
||||
|
||||
这项突破性功能将线性对话转变为动态的树状结构,让您能够更深入地探索想法,实现更高效的互动体验。
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-artifacts]][docs-feat-artifacts]
|
||||
|
||||
### [支持白板 (Artifacts)][docs-feat-artifacts]
|
||||
|
||||
体验集成于 LobeChat 的 Claude Artifacts 能力。这项革命性功能突破了 AI 人机交互的边界,让您能够实时创建和可视化各种格式的内容。
|
||||
|
||||
以前所未有的灵活度进行创作与可视化:
|
||||
|
||||
- 生成并展示动态 SVG 图形
|
||||
- 实时构建与渲染交互式 HTML 页面
|
||||
- 输出多种格式的专业文档
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
[![][image-feat-knowledgebase]][docs-feat-knowledgebase]
|
||||
|
||||
### [文件上传 / 知识库][docs-feat-knowledgebase]
|
||||
|
||||
LobeChat 支持文件上传与知识库功能,你可以上传文件、图片、音频、视频等多种类型的文件,以及创建知识库,方便用户管理和查找文件。同时在对话中使用文件和知识库功能,实现更加丰富的对话体验。
|
||||
|
||||
<https://github.com/user-attachments/assets/faa8cf67-e743-4590-8bf6-ebf6ccc34175>
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 查阅 [📘 LobeChat 知识库上线 —— 此刻起,跬步千里](https://lobehub.com/zh/blog/knowledge-base) 了解详情。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-privoder]][docs-feat-provider]
|
||||
|
||||
### [多模型服务商支持][docs-feat-provider]
|
||||
|
||||
在 LobeChat 的不断发展过程中,我们深刻理解到在提供 AI 会话服务时模型服务商的多样性对于满足社区需求的重要性。因此,我们不再局限于单一的模型服务商,而是拓展了对多种模型服务商的支持,以便为用户提供更为丰富和多样化的会话选择。
|
||||
|
||||
通过这种方式,LobeChat 能够更灵活地适应不同用户的需求,同时也为开发者提供了更为广泛的选择空间。
|
||||
|
||||
#### 已支持的模型服务商
|
||||
|
||||
我们已经实现了对以下模型服务商的支持:
|
||||
|
||||
<!-- PROVIDER LIST -->
|
||||
|
||||
- **[OpenAI](https://lobechat.com/discover/provider/openai)**: OpenAI 是全球领先的人工智能研究机构,其开发的模型如 GPT 系列推动了自然语言处理的前沿。OpenAI 致力于通过创新和高效的 AI 解决方案改变多个行业。他们的产品具有显著的性能和经济性,广泛用于研究、商业和创新应用。
|
||||
- **[Ollama](https://lobechat.com/discover/provider/ollama)**: Ollama 提供的模型广泛涵盖代码生成、数学运算、多语种处理和对话互动等领域,支持企业级和本地化部署的多样化需求。
|
||||
- **[Anthropic](https://lobechat.com/discover/provider/anthropic)**: Anthropic 是一家专注于人工智能研究和开发的公司,提供了一系列先进的语言模型,如 Claude 3.5 Sonnet、Claude 3 Sonnet、Claude 3 Opus 和 Claude 3 Haiku。这些模型在智能、速度和成本之间取得了理想的平衡,适用于从企业级工作负载到快速响应的各种应用场景。Claude 3.5 Sonnet 作为其最新模型,在多项评估中表现优异,同时保持了较高的性价比。
|
||||
- **[Bedrock](https://lobechat.com/discover/provider/bedrock)**: Bedrock 是亚马逊 AWS 提供的一项服务,专注于为企业提供先进的 AI 语言模型和视觉模型。其模型家族包括 Anthropic 的 Claude 系列、Meta 的 Llama 3.1 系列等,涵盖从轻量级到高性能的多种选择,支持文本生成、对话、图像处理等多种任务,适用于不同规模和需求的企业应用。
|
||||
- **[Google](https://lobechat.com/discover/provider/google)**: Google 的 Gemini 系列是其最先进、通用的 AI 模型,由 Google DeepMind 打造,专为多模态设计,支持文本、代码、图像、音频和视频的无缝理解与处理。适用于从数据中心到移动设备的多种环境,极大提升了 AI 模型的效率与应用广泛性。
|
||||
- **[DeepSeek](https://lobechat.com/discover/provider/deepseek)**: DeepSeek 是一家专注于人工智能技术研究和应用的公司,其最新模型 DeepSeek-V3 多项评测成绩超越 Qwen2.5-72B 和 Llama-3.1-405B 等开源模型,性能对齐领军闭源模型 GPT-4o 与 Claude-3.5-Sonnet。
|
||||
- **[HuggingFace](https://lobechat.com/discover/provider/huggingface)**: HuggingFace Inference API 提供了一种快速且免费的方式,让您可以探索成千上万种模型,适用于各种任务。无论您是在为新应用程序进行原型设计,还是在尝试机器学习的功能,这个 API 都能让您即时访问多个领域的高性能模型。
|
||||
- **[OpenRouter](https://lobechat.com/discover/provider/openrouter)**: OpenRouter 是一个提供多种前沿大模型接口的服务平台,支持 OpenAI、Anthropic、LLaMA 及更多,适合多样化的开发和应用需求。用户可根据自身需求灵活选择最优的模型和价格,助力 AI 体验的提升。
|
||||
- **[Cloudflare Workers AI](https://lobechat.com/discover/provider/cloudflare)**: 在 Cloudflare 的全球网络上运行由无服务器 GPU 驱动的机器学习模型。
|
||||
- **[GitHub](https://lobechat.com/discover/provider/github)**: 通过 GitHub 模型,开发人员可以成为 AI 工程师,并使用行业领先的 AI 模型进行构建。
|
||||
|
||||
<details><summary><kbd>See more providers (+31)</kbd></summary>
|
||||
|
||||
- **[Novita](https://lobechat.com/discover/provider/novita)**: Novita AI 是一个提供多种大语言模型与 AI 图像生成的 API 服务的平台,灵活、可靠且具有成本效益。它支持 Llama3、Mistral 等最新的开源模型,并为生成式 AI 应用开发提供了全面、用户友好且自动扩展的 API 解决方案,适合 AI 初创公司的快速发展。
|
||||
- **[PPIO](https://lobechat.com/discover/provider/ppio)**: PPIO 派欧云提供稳定、高性价比的开源模型 API 服务,支持 DeepSeek 全系列、Llama、Qwen 等行业领先大模型。
|
||||
- **[Together AI](https://lobechat.com/discover/provider/togetherai)**: Together AI 致力于通过创新的 AI 模型实现领先的性能,提供广泛的自定义能力,包括快速扩展支持和直观的部署流程,满足企业的各种需求。
|
||||
- **[Fireworks AI](https://lobechat.com/discover/provider/fireworksai)**: Fireworks AI 是一家领先的高级语言模型服务商,专注于功能调用和多模态处理。其最新模型 Firefunction V2 基于 Llama-3,优化用于函数调用、对话及指令跟随。视觉语言模型 FireLLaVA-13B 支持图像和文本混合输入。其他 notable 模型包括 Llama 系列和 Mixtral 系列,提供高效的多语言指令跟随与生成支持。
|
||||
- **[Groq](https://lobechat.com/discover/provider/groq)**: Groq 的 LPU 推理引擎在最新的独立大语言模型(LLM)基准测试中表现卓越,以其惊人的速度和效率重新定义了 AI 解决方案的标准。Groq 是一种即时推理速度的代表,在基于云的部署中展现了良好的性能。
|
||||
- **[Perplexity](https://lobechat.com/discover/provider/perplexity)**: Perplexity 是一家领先的对话生成模型提供商,提供多种先进的 Llama 3.1 模型,支持在线和离线应用,特别适用于复杂的自然语言处理任务。
|
||||
- **[Mistral](https://lobechat.com/discover/provider/mistral)**: Mistral 提供先进的通用、专业和研究型模型,广泛应用于复杂推理、多语言任务、代码生成等领域,通过功能调用接口,用户可以集成自定义功能,实现特定应用。
|
||||
- **[ModelScope](https://lobechat.com/discover/provider/modelscope)**: ModelScope 是阿里云推出的模型即服务平台,提供丰富的 AI 模型和推理服务。
|
||||
- **[Ai21Labs](https://lobechat.com/discover/provider/ai21)**: AI21 Labs 为企业构建基础模型和人工智能系统,加速生成性人工智能在生产中的应用。
|
||||
- **[Upstage](https://lobechat.com/discover/provider/upstage)**: Upstage 专注于为各种商业需求开发 AI 模型,包括 Solar LLM 和文档 AI,旨在实现工作的人造通用智能(AGI)。通过 Chat API 创建简单的对话代理,并支持功能调用、翻译、嵌入以及特定领域应用。
|
||||
- **[xAI (Grok)](https://lobechat.com/discover/provider/xai)**: xAI 是一家致力于构建人工智能以加速人类科学发现的公司。我们的使命是推动我们对宇宙的共同理解。
|
||||
- **[Aliyun Bailian](https://lobechat.com/discover/provider/qwen)**: 通义千问是阿里云自主研发的超大规模语言模型,具有强大的自然语言理解和生成能力。它可以回答各种问题、创作文字内容、表达观点看法、撰写代码等,在多个领域发挥作用。
|
||||
- **[Wenxin](https://lobechat.com/discover/provider/wenxin)**: 企业级一站式大模型与 AI 原生应用开发及服务平台,提供最全面易用的生成式人工智能模型开发、应用开发全流程工具链
|
||||
- **[Hunyuan](https://lobechat.com/discover/provider/hunyuan)**: 由腾讯研发的大语言模型,具备强大的中文创作能力,复杂语境下的逻辑推理能力,以及可靠的任务执行能力
|
||||
- **[ZhiPu](https://lobechat.com/discover/provider/zhipu)**: 智谱 AI 提供多模态与语言模型的开放平台,支持广泛的 AI 应用场景,包括文本处理、图像理解与编程辅助等。
|
||||
- **[SiliconCloud](https://lobechat.com/discover/provider/siliconcloud)**: SiliconCloud,基于优秀开源基础模型的高性价比 GenAI 云服务
|
||||
- **[01.AI](https://lobechat.com/discover/provider/zeroone)**: 零一万物致力于推动以人为本的 AI 2.0 技术革命,旨在通过大语言模型创造巨大的经济和社会价值,并开创新的 AI 生态与商业模式。
|
||||
- **[Spark](https://lobechat.com/discover/provider/spark)**: 科大讯飞星火大模型提供多领域、多语言的强大 AI 能力,利用先进的自然语言处理技术,构建适用于智能硬件、智慧医疗、智慧金融等多种垂直场景的创新应用。
|
||||
- **[SenseNova](https://lobechat.com/discover/provider/sensenova)**: 商汤日日新,依托商汤大装置的强大的基础支撑,提供高效易用的全栈大模型服务。
|
||||
- **[Stepfun](https://lobechat.com/discover/provider/stepfun)**: 阶级星辰大模型具备行业领先的多模态及复杂推理能力,支持超长文本理解和强大的自主调度搜索引擎功能。
|
||||
- **[Moonshot](https://lobechat.com/discover/provider/moonshot)**: Moonshot 是由北京月之暗面科技有限公司推出的开源平台,提供多种自然语言处理模型,应用领域广泛,包括但不限于内容创作、学术研究、智能推荐、医疗诊断等,支持长文本处理和复杂生成任务。
|
||||
- **[Baichuan](https://lobechat.com/discover/provider/baichuan)**: 百川智能是一家专注于人工智能大模型研发的公司,其模型在国内知识百科、长文本处理和生成创作等中文任务上表现卓越,超越了国外主流模型。百川智能还具备行业领先的多模态能力,在多项权威评测中表现优异。其模型包括 Baichuan 4、Baichuan 3 Turbo 和 Baichuan 3 Turbo 128k 等,分别针对不同应用场景进行优化,提供高性价比的解决方案。
|
||||
- **[Minimax](https://lobechat.com/discover/provider/minimax)**: MiniMax 是 2021 年成立的通用人工智能科技公司,致力于与用户共创智能。MiniMax 自主研发了不同模态的通用大模型,其中包括万亿参数的 MoE 文本大模型、语音大模型以及图像大模型。并推出了海螺 AI 等应用。
|
||||
- **[InternLM](https://lobechat.com/discover/provider/internlm)**: 致力于大模型研究与开发工具链的开源组织。为所有 AI 开发者提供高效、易用的开源平台,让最前沿的大模型与算法技术触手可及
|
||||
- **[Higress](https://lobechat.com/discover/provider/higress)**: Higress 是一款云原生 API 网关,在阿里内部为解决 Tengine reload 对长连接业务有损,以及 gRPC/Dubbo 负载均衡能力不足而诞生。
|
||||
- **[Gitee AI](https://lobechat.com/discover/provider/giteeai)**: Gitee AI 的 Serverless API 为 AI 开发者提供开箱即用的大模型推理 API 服务。
|
||||
- **[Taichu](https://lobechat.com/discover/provider/taichu)**: 中科院自动化研究所和武汉人工智能研究院推出新一代多模态大模型,支持多轮问答、文本创作、图像生成、3D 理解、信号分析等全面问答任务,拥有更强的认知、理解、创作能力,带来全新互动体验。
|
||||
- **[360 AI](https://lobechat.com/discover/provider/ai360)**: 360 AI 是 360 公司推出的 AI 模型和服务平台,提供多种先进的自然语言处理模型,包括 360GPT2 Pro、360GPT Pro、360GPT Turbo 和 360GPT Turbo Responsibility 8K。这些模型结合了大规模参数和多模态能力,广泛应用于文本生成、语义理解、对话系统与代码生成等领域。通过灵活的定价策略,360 AI 满足多样化用户需求,支持开发者集成,推动智能化应用的革新和发展。
|
||||
- **[Search1API](https://lobechat.com/discover/provider/search1api)**: Search1API 提供可根据需要自行联网的 DeepSeek 系列模型的访问,包括标准版和快速版本,支持多种参数规模的模型选择。
|
||||
- **[InfiniAI](https://lobechat.com/discover/provider/infiniai)**: 为应用开发者提供高性能、易上手、安全可靠的大模型服务,覆盖从大模型开发到大模型服务化部署的全流程。
|
||||
- **[Qiniu](https://lobechat.com/discover/provider/qiniu)**: 七牛作为老牌云服务厂商,提供高性价比稳定的实时、批量 AI 推理服务,简单易用。
|
||||
|
||||
</details>
|
||||
|
||||
> 📊 Total providers: [<kbd>**41**</kbd>](https://lobechat.com/discover/providers)
|
||||
|
||||
<!-- PROVIDER LIST -->
|
||||
|
||||
同时,我们也在计划支持更多的模型服务商,以进一步丰富我们的服务商库。如果你希望让 LobeChat 支持你喜爱的服务商,欢迎加入我们的 [💬 社区讨论](https://github.com/lobehub/lobe-chat/discussions/6157)。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-local]][docs-feat-local]
|
||||
|
||||
### [支持本地大语言模型 (LLM)][docs-feat-local]
|
||||
|
||||
为了满足特定用户的需求,LobeChat 还基于 [Ollama](https://ollama.ai) 支持了本地模型的使用,让用户能够更灵活地使用自己的或第三方的模型。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 查阅 [📘 在 LobeChat 中使用 Ollama][docs-usage-ollama] 获得更多信息
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-vision]][docs-feat-vision]
|
||||
|
||||
### [模型视觉识别 (Model Visual)][docs-feat-vision]
|
||||
|
||||
LobeChat 已经支持 OpenAI 最新的 [`gpt-4-vision`](https://platform.openai.com/docs/guides/vision) 支持视觉识别的模型,这是一个具备视觉识别能力的多模态应用。
|
||||
用户可以轻松上传图片或者拖拽图片到对话框中,助手将能够识别图片内容,并在此基础上进行智能对话,构建更智能、更多元化的聊天场景。
|
||||
|
||||
这一特性打开了新的互动方式,使得交流不再局限于文字,而是可以涵盖丰富的视觉元素。无论是日常使用中的图片分享,还是在特定行业内的图像解读,助手都能提供出色的对话体验。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-tts]][docs-feat-tts]
|
||||
|
||||
### [TTS & STT 语音会话][docs-feat-tts]
|
||||
|
||||
LobeChat 支持文字转语音(Text-to-Speech,TTS)和语音转文字(Speech-to-Text,STT)技术,这使得我们的应用能够将文本信息转化为清晰的语音输出,用户可以像与真人交谈一样与我们的对话助手进行交流。
|
||||
用户可以从多种声音中选择,给助手搭配合适的音源。 同时,对于那些倾向于听觉学习或者想要在忙碌中获取信息的用户来说,TTS 提供了一个极佳的解决方案。
|
||||
|
||||
在 LobeChat 中,我们精心挑选了一系列高品质的声音选项 (OpenAI Audio, Microsoft Edge Speech),以满足不同地域和文化背景用户的需求。用户可以根据个人喜好或者特定场景来选择合适的语音,从而获得个性化的交流体验。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-t2i]][docs-feat-t2i]
|
||||
|
||||
### [Text to Image 文生图][docs-feat-t2i]
|
||||
|
||||
支持最新的文本到图片生成技术,LobeChat 现在能够让用户在与助手对话中直接调用文生图工具进行创作。
|
||||
通过利用 [`DALL-E 3`](https://openai.com/dall-e-3)、[`MidJourney`](https://www.midjourney.com/) 和 [`Pollinations`](https://pollinations.ai/) 等 AI 工具的能力, 助手们现在可以将你的想法转化为图像。
|
||||
同时可以更私密和沉浸式地完成你的创作过程。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-plugin]][docs-feat-plugin]
|
||||
|
||||
### [插件系统 (Tools Calling)][docs-feat-plugin]
|
||||
|
||||
LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地增强了 ChatGPT 的实用性和灵活性。
|
||||
|
||||
<video controls src="https://github.com/lobehub/lobe-chat/assets/28616219/f29475a3-f346-4196-a435-41a6373ab9e2" muted="false"></video>
|
||||
|
||||
通过利用插件,ChatGPT 能够实现实时信息的获取和处理,例如自动获取最新新闻头条,为用户提供即时且相关的资讯。
|
||||
|
||||
此外,这些插件不仅局限于新闻聚合,还可以扩展到其他实用的功能,如快速检索文档、生成图象、获取电商平台数据,以及其他各式各样的第三方服务。
|
||||
|
||||
> 通过文档了解更多 [📘 插件使用][docs-usage-plugin]
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
| 最近新增 | 描述 |
|
||||
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| [PortfolioMeta](https://lobechat.com/discover/plugin/StockData)<br/><sup>By **portfoliometa** on **2025-07-21**</sup> | 分析股票并获取全面的实时投资数据和分析。<br/>`股票` |
|
||||
| [Speak](https://lobechat.com/discover/plugin/speak)<br/><sup>By **speak** on **2025-07-18**</sup> | 使用 Speak,您的 AI 语言导师,学习如何用另一种语言说任何事情。<br/>`教育` `语言` |
|
||||
| [网页](https://lobechat.com/discover/plugin/web)<br/><sup>By **Proghit** on **2025-01-24**</sup> | 智能网页搜索,读取和分析页面,以提供来自 Google 结果的全面答案。<br/>`网页` `搜索` |
|
||||
| [必应网页搜索](https://lobechat.com/discover/plugin/Bingsearch-identifier)<br/><sup>By **FineHow** on **2024-12-22**</sup> | 通过 BingApi 搜索互联网上的信息<br/>`bingsearch` |
|
||||
|
||||
> 📊 Total plugins: [<kbd>**43**</kbd>](https://lobechat.com/discover/plugins)
|
||||
|
||||
<!-- PLUGIN LIST -->
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-agent]][docs-feat-agent]
|
||||
|
||||
### [助手市场 (GPTs)][docs-feat-agent]
|
||||
|
||||
在 LobeChat 的助手市场中,创作者们可以发现一个充满活力和创新的社区,它汇聚了众多精心设计的助手,这些助手不仅在工作场景中发挥着重要作用,也在学习过程中提供了极大的便利。
|
||||
我们的市场不仅是一个展示平台,更是一个协作的空间。在这里,每个人都可以贡献自己的智慧,分享个人开发的助手。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 通过 [🤖/🏪 提交助手][submit-agents-link] ,你可以轻松地将你的助手作品提交到我们的平台。我们特别强调的是,LobeChat 建立了一套精密的自动化国际化(i18n)工作流程, 它的强大之处在于能够无缝地将你的助手转化为多种语言版本。
|
||||
> 这意味着,不论你的用户使用何种语言,他们都能无障碍地体验到你的助手。
|
||||
|
||||
> \[!IMPORTANT]
|
||||
>
|
||||
> 我欢迎所有用户加入这个不断成长的生态系统,共同参与到助手的迭代与优化中来。共同创造出更多有趣、实用且具有创新性的助手,进一步丰富助手的多样性和实用性。
|
||||
|
||||
<!-- AGENT LIST -->
|
||||
|
||||
| 最近新增 | 描述 |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
||||
| [海龟汤主持人](https://lobechat.com/discover/assistant/lateral-thinking-puzzle)<br/><sup>By **[CSY2022](https://github.com/CSY2022)** on **2025-06-19**</sup> | 一个海龟汤主持人,需要自己提供汤面,汤底与关键点(猜中的判定条件)。<br/>`海龟汤` `推理` `互动` `谜题` `角色扮演` |
|
||||
| [美食评论员🍟](https://lobechat.com/discover/assistant/food-reviewer)<br/><sup>By **[renhai-lab](https://github.com/renhai-lab)** on **2025-06-17**</sup> | 美食评价专家<br/>`美食` `评价` `写作` |
|
||||
| [学术写作助手](https://lobechat.com/discover/assistant/academic-writing-assistant)<br/><sup>By **[swarfte](https://github.com/swarfte)** on **2025-06-17**</sup> | 专业的学术研究论文写作和正式文档编写专家<br/>`学术写作` `研究` `正式风格` |
|
||||
| [Minecraft 资深开发者](https://lobechat.com/discover/assistant/java-development)<br/><sup>By **[iamyuuk](https://github.com/iamyuuk)** on **2025-06-17**</sup> | 擅长高级 Java 开发及 Minecraft 开发<br/>`开发` `编程` `minecraft` `java` |
|
||||
|
||||
> 📊 Total agents: [<kbd>**505**</kbd> ](https://lobechat.com/discover/assistants)
|
||||
|
||||
<!-- AGENT LIST -->
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-database]][docs-feat-database]
|
||||
|
||||
### [支持本地 / 远程数据库][docs-feat-database]
|
||||
|
||||
LobeChat 支持同时使用服务端数据库和本地数据库。根据您的需求,您可以选择合适的部署方案:
|
||||
|
||||
- 本地数据库:适合希望对数据有更多掌控感和隐私保护的用户。LobeChat 采用了 CRDT (Conflict-Free Replicated Data Type) 技术,实现了多端同步功能。这是一项实验性功能,旨在提供无缝的数据同步体验。
|
||||
- 服务端数据库:适合希望更便捷使用体验的用户。LobeChat 支持 PostgreSQL 作为服务端数据库。关于如何配置服务端数据库的详细文档,请前往 [配置服务端数据库](https://lobehub.com/zh/docs/self-hosting/advanced/server-database)。
|
||||
|
||||
无论您选择哪种数据库,LobeChat 都能为您提供卓越的用户体验。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-auth]][docs-feat-auth]
|
||||
|
||||
### [支持多用户管理][docs-feat-auth]
|
||||
|
||||
LobeChat 支持多用户管理,提供了两种主要的用户认证和管理方案,以满足不同需求:
|
||||
|
||||
- **next-auth**:LobeChat 集成了 `next-auth`,一个灵活且强大的身份验证库,支持多种身份验证方式,包括 OAuth、邮件登录、凭证登录等。通过 `next-auth`,您可以轻松实现用户的注册、登录、会话管理以及社交登录等功能,确保用户数据的安全性和隐私性。
|
||||
|
||||
- [**Clerk**](https://go.clerk.com/exgqLG0):对于需要更高级用户管理功能的用户,LobeChat 还支持 `Clerk`,一个现代化的用户管理平台。`Clerk` 提供了更丰富的功能,如多因素认证 (MFA)、白名单、用户管理、登录活动监控等。通过 `Clerk`,您可以获得更高的安全性和灵活性,轻松应对生产级的用户管理需求。
|
||||
|
||||
您可以根据自己的需求,选择合适的用户管理方案。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-pwa]][docs-feat-pwa]
|
||||
|
||||
### [渐进式 Web 应用 (PWA)][docs-feat-pwa]
|
||||
|
||||
我们深知在当今多设备环境下为用户提供无缝体验的重要性。为此,我们采用了渐进式 Web 应用 [PWA](https://support.google.com/chrome/answer/9658361) 技术,
|
||||
这是一种能够将网页应用提升至接近原生应用体验的现代 Web 技术。通过 PWA,LobeChat 能够在桌面和移动设备上提供高度优化的用户体验,同时保持轻量级和高性能的特点。
|
||||
在视觉和感觉上,我们也经过精心设计,以确保它的界面与原生应用无差别,提供流畅的动画、响应式布局和适配不同设备的屏幕分辨率。
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 若您未熟悉 PWA 的安装过程,您可以按照以下步骤将 LobeChat 添加为您的桌面应用(也适用于移动设备):
|
||||
>
|
||||
> - 在电脑上运行 Chrome 或 Edge 浏览器 .
|
||||
> - 访问 LobeChat 网页 .
|
||||
> - 在地址栏的右上角,单击 <kbd>安装</kbd> 图标 .
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-mobile]][docs-feat-mobile]
|
||||
|
||||
### [移动设备适配][docs-feat-mobile]
|
||||
|
||||
针对移动设备进行了一系列的优化设计,以提升用户的移动体验。目前,我们正在对移动端的用户体验进行版本迭代,以实现更加流畅和直观的交互。如果您有任何建议或想法,我们非常欢迎您通过 GitHub Issues 或者 Pull Requests 提供反馈。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
[![][image-feat-theme]][docs-feat-theme]
|
||||
|
||||
### [自定义主题][docs-feat-theme]
|
||||
|
||||
作为设计工程师出身,LobeChat 在界面设计上充分考虑用户的个性化体验,因此引入了灵活多变的主题模式,其中包括日间的亮色模式和夜间的深色模式。
|
||||
除了主题模式的切换,还提供了一系列的颜色定制选项,允许用户根据自己的喜好来调整应用的主题色彩。无论是想要沉稳的深蓝,还是希望活泼的桃粉,或者是专业的灰白,用户都能够在 LobeChat 中找到匹配自己风格的颜色选择。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 默认配置能够智能地识别用户系统的颜色模式,自动进行主题切换,以确保应用界面与操作系统保持一致的视觉体验。对于喜欢手动调控细节的用户,LobeChat 同样提供了直观的设置选项,针对聊天场景也提供了对话气泡模式和文档模式的选择。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
### `*` 更多特性
|
||||
|
||||
除了上述功能特性以外,LobeChat 所具有的设计和技术能力将为你带来更多使用保障:
|
||||
|
||||
- [x] 💎 **精致 UI 设计**:经过精心设计的界面,具有优雅的外观和流畅的交互效果,支持亮暗色主题,适配移动端。支持 PWA,提供更加接近原生应用的体验。
|
||||
- [x] 🗣️ **流畅的对话体验**:流式响应带来流畅的对话体验,并且支持完整的 Markdown 渲染,包括代码高亮、LaTex 公式、Mermaid 流程图等。
|
||||
- [x] 💨 **快速部署**:使用 Vercel 平台或者我们的 Docker 镜像,只需点击一键部署按钮,即可在 1 分钟内完成部署,无需复杂的配置过程。
|
||||
- [x] 🔒 **隐私安全**:所有数据保存在用户浏览器本地,保证用户的隐私安全。
|
||||
- [x] 🌐 **自定义域名**:如果用户拥有自己的域名,可以将其绑定到平台上,方便在任何地方快速访问对话助手。
|
||||
|
||||
> ✨ 随着产品迭代持续更新,我们将会带来更多更多令人激动的功能!
|
||||
|
||||
---
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 你可以在 Projects 中找到我们后续的 [Roadmap][github-project-link] 计划
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ⚡️ 性能测试
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 完整测试报告可见 [📘 Lighthouse 性能测试][docs-lighthouse]
|
||||
|
||||
| Desktop | Mobile |
|
||||
| :-------------------------------------------: | :------------------------------------------: |
|
||||
| ![][chat-desktop] | ![][chat-mobile] |
|
||||
| [📑 Lighthouse 测试报告][chat-desktop-report] | [📑 Lighthouse 测试报告][chat-mobile-report] |
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🛳 开箱即用
|
||||
|
||||
LobeChat 提供了 Vercel 的 自托管版本 和 [Docker 镜像][docker-release-link],这使你可以在几分钟内构建自己的聊天机器人,无需任何基础知识。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 完整教程请查阅 [📘 构建属于自己的 Lobe Chat][docs-self-hosting]
|
||||
|
||||
### `A` 使用 Vercel、Zeabur 、Sealos 或 阿里云计算巢 部署
|
||||
|
||||
如果想在 Vercel 、 Zeabur 或 阿里云 上部署该服务,可以按照以下步骤进行操作:
|
||||
|
||||
- 准备好你的 [OpenAI API Key](https://platform.openai.com/account/api-keys) 。
|
||||
- 点击下方按钮开始部署: 直接使用 GitHub 账号登录即可,记得在环境变量页填入 `OPENAI_API_KEY` (必填) and `ACCESS_CODE`(推荐);
|
||||
- 部署完毕后,即可开始使用;
|
||||
- 绑定自定义域名(可选):Vercel 分配的域名 DNS 在某些区域被污染了,绑定自定义域名即可直连。目前 Zeabur 提供的域名还未被污染,大多数地区都可以直连。
|
||||
|
||||
<div align="center">
|
||||
|
||||
| 使用 Vercel 部署 | 使用 Zeabur 部署 | 使用 Sealos 部署 | 使用阿里云计算巢部署 |
|
||||
| :-------------------------------------: | :---------------------------------------------------------: | :---------------------------------------------------------: | :-----------------------------------------------------------------------: |
|
||||
| [![][deploy-button-image]][deploy-link] | [![][deploy-on-zeabur-button-image]][deploy-on-zeabur-link] | [![][deploy-on-sealos-button-image]][deploy-on-sealos-link] | [![][deploy-on-alibaba-cloud-button-image]][deploy-on-alibaba-cloud-link] |
|
||||
|
||||
</div>
|
||||
|
||||
#### Fork 之后
|
||||
|
||||
在 Fork 后,请只保留 "upstream sync" Action 并在你 fork 的 GitHub Repo 中禁用其他 Action。
|
||||
|
||||
#### 保持更新
|
||||
|
||||
如果你根据 README 中的一键部署步骤部署了自己的项目,你可能会发现总是被提示 "有可用更新"。这是因为 Vercel 默认为你创建新项目而非 fork 本项目,这将导致无法准确检测更新。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 我们建议按照 [📘 自动同步更新][docs-upstream-sync] 步骤重新部署。
|
||||
|
||||
<br/>
|
||||
|
||||
### `B` 使用 Docker 部署
|
||||
|
||||
[![][docker-release-shield]][docker-release-link]
|
||||
[![][docker-size-shield]][docker-size-link]
|
||||
[![][docker-pulls-shield]][docker-pulls-link]
|
||||
|
||||
我们提供了一个用于在您自己的私有设备上部署 LobeChat 服务的 Docker 镜像。请使用以下命令启动 LobeChat 服务:
|
||||
|
||||
1. 创建一个用于存储文件的文件夹
|
||||
|
||||
```fish
|
||||
$ mkdir lobe-chat-db && cd lobe-chat-db
|
||||
```
|
||||
|
||||
2. 启动一键脚本
|
||||
|
||||
```fish
|
||||
bash <(curl -fsSL https://lobe.li/setup.sh) -l zh_CN
|
||||
```
|
||||
|
||||
3. 启动 LobeChat
|
||||
|
||||
```fish
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 有关 Docker 部署的详细说明,详见 [📘 使用 Docker 部署][docs-docker]
|
||||
|
||||
<br/>
|
||||
|
||||
### 环境变量
|
||||
|
||||
本项目提供了一些额外的配置项,使用环境变量进行设置:
|
||||
|
||||
| 环境变量 | 类型 | 描述 | 示例 |
|
||||
| ------------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| `OPENAI_API_KEY` | 必选 | 这是你在 OpenAI 账户页面申请的 API 密钥 | `sk-xxxxxx...xxxxxx` |
|
||||
| `OPENAI_PROXY_URL` | 可选 | 如果你手动配置了 OpenAI 接口代理,可以使用此配置项来覆盖默认的 OpenAI API 请求基础 URL | `https://api.chatanywhere.cn` 或 `https://aihubmix.com/v1`<br/>默认值:<br/>`https://api.openai.com/v1` |
|
||||
| `ACCESS_CODE` | 可选 | 添加访问此服务的密码,你可以设置一个长密码以防被爆破,该值用逗号分隔时为密码数组 | `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3` |
|
||||
| `OPENAI_MODEL_LIST` | 可选 | 用来控制模型列表,使用 `+` 增加一个模型,使用 `-` 来隐藏一个模型,使用 `模型名=展示名` 来自定义模型的展示名,用英文逗号隔开。 | `qwen-7b-chat,+glm-6b,-gpt-3.5-turbo` |
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 完整环境变量可见 [📘 环境变量][docs-env-var]
|
||||
|
||||
<br/>
|
||||
|
||||
### 获取 OpenAI API Key
|
||||
|
||||
API Key 是使用 LobeChat 进行大语言模型会话的必要信息,本节以 OpenAI 模型服务商为例,简要介绍获取 API Key 的方式。
|
||||
|
||||
#### `A` 通过 OpenAI 官方渠道
|
||||
|
||||
- 注册一个 [OpenAI 账户](https://platform.openai.com/signup),你需要使用国际手机号、非大陆邮箱进行注册;
|
||||
- 注册完毕后,前往 [API Keys](https://platform.openai.com/api-keys) 页面,点击 `Create new secret key` 创建新的 API Key:
|
||||
|
||||
| 步骤 1:打开创建窗口 | 步骤 2:创建 API Key | 步骤 3:获取 API Key |
|
||||
| -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| <img src="https://github-production-user-asset-6210df.s3.amazonaws.com/28616219/296253192-ff2193dd-f125-4e58-82e8-91bc376c0d68.png" height="200"/> | <img src="https://github-production-user-asset-6210df.s3.amazonaws.com/28616219/296254170-803bacf0-4471-4171-ae79-0eab08d621d1.png" height="200"/> | <img src="https://github-production-user-asset-6210df.s3.amazonaws.com/28616219/296255167-f2745f2b-f083-4ba8-bc78-9b558e0002de.png" height="200"/> |
|
||||
|
||||
- 将此 API Key 填写到 LobeChat 的 API Key 配置中,即可开始使用。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 账户注册后,一般有 5 美元的免费额度,但有效期只有三个月。
|
||||
> 如果你希望长期使用你的 API Key,你需要完成支付的信用卡绑定。由于 OpenAI 只支持外币信用卡,因此你需要找到合适的支付渠道,此处不再详细展开。
|
||||
|
||||
<br/>
|
||||
|
||||
#### `B` 通过 OpenAI 第三方代理商
|
||||
|
||||
如果你发现注册 OpenAI 账户或者绑定外币信用卡比较麻烦,可以考虑借助一些知名的 OpenAI 第三方代理商来获取 API Key,这可以有效降低获取 OpenAI API Key 的门槛。但与此同时,一旦使用三方服务,你可能也需要承担潜在的风险,
|
||||
请根据你自己的实际情况自行决策。以下是常见的第三方模型代理商列表,供你参考:
|
||||
|
||||
| | 服务商 | 特性说明 | Proxy 代理地址 | 链接 |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | --------------------------------------------------------------- | ------------------------- | ------------------------------- |
|
||||
| <img src="https://github-production-user-asset-6210df.s3.amazonaws.com/17870709/296272721-c3ac0bf3-e433-4496-89c4-ebdc20689c17.jpg" width="48" /> | **AiHubMix** | 使用 OpenAI 企业接口,全站模型价格为官方 **86 折**(含 GPT-4 ) | `https://aihubmix.com/v1` | [获取](https://lobe.li/XHnZIUP) |
|
||||
|
||||
> \[!WARNING]
|
||||
>
|
||||
> **免责申明**: 在此推荐的 OpenAI API Key 由第三方代理商提供,所以我们不对 API Key 的 **有效性** 和 **安全性** 负责,请你自行承担购买和使用 API Key 的风险。
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 如果你是模型服务商,并认为自己的服务足够稳定且价格实惠,欢迎联系我们,我们会在自行体验和测试后酌情推荐。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 📦 生态系统
|
||||
|
||||
| NPM | 仓库 | 描述 | 版本 |
|
||||
| --------------------------------- | --------------------------------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------- |
|
||||
| [@lobehub/ui][lobe-ui-link] | [lobehub/lobe-ui][lobe-ui-github] | 构建 AIGC 网页应用程序而设计的开源 UI 组件库 | [![][lobe-ui-shield]][lobe-ui-link] |
|
||||
| [@lobehub/icons][lobe-icons-link] | [lobehub/lobe-icons][lobe-icons-github] | 主流 AI / LLM 模型和公司 SVG Logo 与 Icon 合集 | [![][lobe-icons-shield]][lobe-icons-link] |
|
||||
| [@lobehub/tts][lobe-tts-link] | [lobehub/lobe-tts][lobe-tts-github] | AI TTS / STT 语音合成 / 识别 React Hooks 库 | [![][lobe-tts-shield]][lobe-tts-link] |
|
||||
| [@lobehub/lint][lobe-lint-link] | [lobehub/lobe-lint][lobe-lint-github] | LobeHub 代码样式规范 ESlint,Stylelint,Commitlint,Prettier,Remark 和 Semantic Release | [![][lobe-lint-shield]][lobe-lint-link] |
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🧩 插件体系
|
||||
|
||||
插件提供了扩展 LobeChat [Function Calling][docs-functionc-call] 能力的方法。可以用于引入新的 Function Calling,甚至是新的消息结果渲染方式。如果你对插件开发感兴趣,请在 Wiki 中查阅我们的 [📘 插件开发指引][docs-plugin-dev] 。
|
||||
|
||||
- [lobe-chat-plugins][lobe-chat-plugins]:插件索引从该仓库的 index.json 中获取插件列表并显示给用户。
|
||||
- [chat-plugin-template][chat-plugin-template]:插件开发模版,你可以通过项目模版快速新建插件项目。
|
||||
- [@lobehub/chat-plugin-sdk][chat-plugin-sdk]:插件 SDK 可帮助您创建出色的 Lobe Chat 插件。
|
||||
- [@lobehub/chat-plugins-gateway][chat-plugins-gateway]:插件网关是一个后端服务,作为 LobeChat 插件的网关。我们使用 Vercel 部署此服务。主要的 API POST /api/v1/runner 被部署为 Edge Function。
|
||||
|
||||
> \[!NOTE]
|
||||
>
|
||||
> 插件系统目前正在进行重大开发。您可以在以下 Issues 中了解更多信息:
|
||||
>
|
||||
> - [x] [**插件一期**](https://github.com/lobehub/lobe-chat/issues/73): 实现插件与主体分离,将插件拆分为独立仓库维护,并实现插件的动态加载
|
||||
> - [x] [**插件二期**](https://github.com/lobehub/lobe-chat/issues/97): 插件的安全性与使用的稳定性,更加精准地呈现异常状态,插件架构的可维护性与开发者友好
|
||||
> - [x] [**插件三期**](https://github.com/lobehub/lobe-chat/issues/149):更高阶与完善的自定义能力,支持插件鉴权与示例
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ⌨️ 本地开发
|
||||
|
||||
可以使用 GitHub Codespaces 进行在线开发:
|
||||
|
||||
[![][codespaces-shield]][codespaces-link]
|
||||
|
||||
或者使用以下命令进行本地开发:
|
||||
|
||||
```fish
|
||||
$ git clone https://github.com/lobehub/lobe-chat.git
|
||||
$ cd lobe-chat
|
||||
$ pnpm install
|
||||
$ pnpm run dev
|
||||
```
|
||||
|
||||
如果你希望了解更多详情,欢迎可以查阅我们的 [📘 开发指南][docs-dev-guide]
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🤝 参与贡献
|
||||
|
||||
我们非常欢迎各种形式的贡献。如果你对贡献代码感兴趣,可以查看我们的 GitHub [Issues][github-issues-link] 和 [Projects][github-project-link],大展身手,向我们展示你的奇思妙想。
|
||||
|
||||
> \[!TIP]
|
||||
>
|
||||
> 我们希望创建一个技术分享型社区,一个可以促进知识共享、想法交流,激发彼此鼓励和协作的环境。
|
||||
> 同时欢迎联系我们提供产品功能和使用体验反馈,帮助我们将 LobeChat 建设得更好。
|
||||
>
|
||||
> **组织维护者:** [@arvinxx](https://github.com/arvinxx) [@canisminor1990](https://github.com/canisminor1990)
|
||||
|
||||
[![][pr-welcome-shield]][pr-welcome-link]
|
||||
[![][submit-agents-shield]][submit-agents-link]
|
||||
[![][submit-plugin-shield]][submit-plugin-link]
|
||||
|
||||
<a href="https://github.com/lobehub/lobe-chat/graphs/contributors" target="_blank">
|
||||
<table>
|
||||
<tr>
|
||||
<th colspan="2">
|
||||
<br><img src="https://contrib.rocks/image?repo=lobehub/lobe-chat"><br><br>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
<td rowspan="2">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-participants-growth/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=4x7&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-participants-growth/thumbnail.png?activity=active&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=4x7&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=new&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=dark">
|
||||
<img src="https://next.ossinsight.io/widgets/official/compose-org-active-contributors/thumbnail.png?activity=new&period=past_28_days&owner_id=131470832&repo_ids=643445235&image_size=2x3&color_scheme=light">
|
||||
</picture>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</a>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## ❤ 社区赞助
|
||||
|
||||
每一分支持都珍贵无比,汇聚成我们支持的璀璨银河!你就像一颗划破夜空的流星,瞬间点亮我们前行的道路。感谢你对我们的信任 —— 你的支持笔就像星辰导航,一次又一次地为项目指明前进的光芒。
|
||||
|
||||
<a href="https://opencollective.com/lobehub" target="_blank">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/lobehub/.github/blob/main/static/sponsor-dark.png?raw=true">
|
||||
<img src="https://github.com/lobehub/.github/blob/main/static/sponsor-light.png?raw=true">
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
## 🔗 更多工具
|
||||
|
||||
- **[🅰️ Lobe SD Theme][lobe-theme]:** Stable Diffusion WebUI 的现代主题,精致的界面设计,高度可定制的 UI,以及提高效率的功能。
|
||||
- **[⛵️ Lobe Midjourney WebUI][lobe-midjourney-webui]:** Midjourney WebUI, 能够根据文本提示快速生成丰富多样的图像,激发创造力,增强对话交流。
|
||||
- **[🌏 Lobe i18n][lobe-i18n]:** Lobe i18n 是一个由 ChatGPT 驱动的 i18n(国际化)翻译过程的自动化工具。它支持自动分割大文件、增量更新,以及为 OpenAI 模型、API 代理和温度提供定制选项的功能。
|
||||
- **[💌 Lobe Commit][lobe-commit]:** Lobe Commit 是一个 CLI 工具,它利用 Langchain/ChatGPT 生成基于 Gitmoji 的提交消息。
|
||||
|
||||
<div align="right">
|
||||
|
||||
[![][back-to-top]](#readme-top)
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
<details><summary><h4>📝 License</h4></summary>
|
||||
|
||||
[![][fossa-license-shield]][fossa-license-link]
|
||||
|
||||
</details>
|
||||
|
||||
Copyright © 2025 [LobeHub][profile-link]. <br />
|
||||
This project is [Apache 2.0](./LICENSE) licensed.
|
||||
|
||||
<!-- LINK GROUP -->
|
||||
|
||||
[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
|
||||
[blog]: https://lobehub.com/zh/blog
|
||||
[changelog]: https://lobehub.com/changelog
|
||||
[chat-desktop]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/desktop/pagespeed.svg
|
||||
[chat-desktop-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/desktop/lobechat_com_chat.html
|
||||
[chat-mobile]: https://raw.githubusercontent.com/lobehub/lobe-chat/lighthouse/lighthouse/chat/mobile/pagespeed.svg
|
||||
[chat-mobile-report]: https://lobehub.github.io/lobe-chat/lighthouse/chat/mobile/lobechat_com_chat.html
|
||||
[chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
|
||||
[chat-plugin-template]: https://github.com/lobehub/chat-plugin-template
|
||||
[chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
|
||||
[codecov-link]: https://codecov.io/gh/lobehub/lobe-chat
|
||||
[codecov-shield]: https://img.shields.io/codecov/c/github/lobehub/lobe-chat?labelColor=black&style=flat-square&logo=codecov&logoColor=white
|
||||
[codespaces-link]: https://codespaces.new/lobehub/lobe-chat
|
||||
[codespaces-shield]: https://github.com/codespaces/badge.svg
|
||||
[deploy-button-image]: https://vercel.com/button
|
||||
[deploy-link]: https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat&env=OPENAI_API_KEY,ACCESS_CODE&envDescription=Find%20your%20OpenAI%20API%20Key%20by%20click%20the%20right%20Learn%20More%20button.%20%7C%20Access%20Code%20can%20protect%20your%20website&envLink=https%3A%2F%2Fplatform.openai.com%2Faccount%2Fapi-keys&project-name=lobe-chat&repository-name=lobe-chat
|
||||
[deploy-on-alibaba-cloud-button-image]: https://service-info-public.oss-cn-hangzhou.aliyuncs.com/computenest-en.svg
|
||||
[deploy-on-alibaba-cloud-link]: https://computenest.console.aliyun.com/service/instance/create/default?type=user&ServiceName=LobeChat%E7%A4%BE%E5%8C%BA%E7%89%88
|
||||
[deploy-on-sealos-button-image]: https://raw.githubusercontent.com/labring-actions/templates/main/Deploy-on-Sealos.svg
|
||||
[deploy-on-sealos-link]: https://template.hzh.sealos.run/deploy?templateName=lobe-chat-db
|
||||
[deploy-on-zeabur-button-image]: https://zeabur.com/button.svg
|
||||
[deploy-on-zeabur-link]: https://zeabur.com/templates/VZGGTI
|
||||
[discord-link]: https://discord.gg/AYFPHvv2jT
|
||||
[discord-shield]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=flat-square
|
||||
[discord-shield-badge]: https://img.shields.io/discord/1127171173982154893?color=5865F2&label=discord&labelColor=black&logo=discord&logoColor=white&style=for-the-badge
|
||||
[docker-pulls-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-pulls-shield]: https://img.shields.io/docker/pulls/lobehub/lobe-chat?color=45cc11&labelColor=black&style=flat-square&sort=semver
|
||||
[docker-release-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-release-shield]: https://img.shields.io/docker/v/lobehub/lobe-chat-database?color=369eff&label=docker&labelColor=black&logo=docker&logoColor=white&style=flat-square&sort=semver
|
||||
[docker-size-link]: https://hub.docker.com/r/lobehub/lobe-chat-database
|
||||
[docker-size-shield]: https://img.shields.io/docker/image-size/lobehub/lobe-chat-database?color=369eff&labelColor=black&style=flat-square&sort=semver
|
||||
[docs]: https://lobehub.com/zh/docs/usage/start
|
||||
[docs-dev-guide]: https://github.com/lobehub/lobe-chat/wiki/index
|
||||
[docs-docker]: https://lobehub.com/zh/docs/self-hosting/server-database/docker-compose
|
||||
[docs-env-var]: https://lobehub.com/docs/self-hosting/environment-variables
|
||||
[docs-feat-agent]: https://lobehub.com/docs/usage/features/agent-market
|
||||
[docs-feat-artifacts]: https://lobehub.com/docs/usage/features/artifacts
|
||||
[docs-feat-auth]: https://lobehub.com/docs/usage/features/auth
|
||||
[docs-feat-branch]: https://lobehub.com/docs/usage/features/branching-conversations
|
||||
[docs-feat-cot]: https://lobehub.com/docs/usage/features/cot
|
||||
[docs-feat-database]: https://lobehub.com/docs/usage/features/database
|
||||
[docs-feat-knowledgebase]: https://lobehub.com/blog/knowledge-base
|
||||
[docs-feat-local]: https://lobehub.com/docs/usage/features/local-llm
|
||||
[docs-feat-mobile]: https://lobehub.com/docs/usage/features/mobile
|
||||
[docs-feat-plugin]: https://lobehub.com/docs/usage/features/plugin-system
|
||||
[docs-feat-provider]: https://lobehub.com/docs/usage/features/multi-ai-providers
|
||||
[docs-feat-pwa]: https://lobehub.com/docs/usage/features/pwa
|
||||
[docs-feat-t2i]: https://lobehub.com/docs/usage/features/text-to-image
|
||||
[docs-feat-theme]: https://lobehub.com/docs/usage/features/theme
|
||||
[docs-feat-tts]: https://lobehub.com/docs/usage/features/tts
|
||||
[docs-feat-vision]: https://lobehub.com/docs/usage/features/vision
|
||||
[docs-functionc-call]: https://lobehub.com/zh/blog/openai-function-call
|
||||
[docs-lighthouse]: https://github.com/lobehub/lobe-chat/wiki/Lighthouse.zh-CN
|
||||
[docs-plugin-dev]: https://lobehub.com/docs/usage/plugins/development
|
||||
[docs-self-hosting]: https://lobehub.com/docs/self-hosting/start
|
||||
[docs-upstream-sync]: https://lobehub.com/docs/self-hosting/advanced/upstream-sync
|
||||
[docs-usage-ollama]: https://lobehub.com/docs/usage/providers/ollama
|
||||
[docs-usage-plugin]: https://lobehub.com/docs/usage/plugins/basic
|
||||
[fossa-license-link]: https://app.fossa.com/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat
|
||||
[fossa-license-shield]: https://app.fossa.com/api/projects/git%2Bgithub.com%2Flobehub%2Flobe-chat.svg?type=large
|
||||
[github-action-release-link]: https://github.com/lobehub/lobe-chat/actions/workflows/release.yml
|
||||
[github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-chat/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
||||
[github-action-test-link]: https://github.com/lobehub/lobe-chat/actions/workflows/test.yml
|
||||
[github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/lobe-chat/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
|
||||
[github-contributors-link]: https://github.com/lobehub/lobe-chat/graphs/contributors
|
||||
[github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-chat?color=c4f042&labelColor=black&style=flat-square
|
||||
[github-forks-link]: https://github.com/lobehub/lobe-chat/network/members
|
||||
[github-forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-chat?color=8ae8ff&labelColor=black&style=flat-square
|
||||
[github-hello-shield]: https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=39701baf5a734cb894ec812248a5655a&claim_uid=HxYvFN34htJzGCD&theme=dark&theme=neutral&theme=dark&theme=neutral
|
||||
[github-hello-url]: https://hellogithub.com/repository/39701baf5a734cb894ec812248a5655a
|
||||
[github-issues-link]: https://github.com/lobehub/lobe-chat/issues
|
||||
[github-issues-shield]: https://img.shields.io/github/issues/lobehub/lobe-chat?color=ff80eb&labelColor=black&style=flat-square
|
||||
[github-license-link]: https://github.com/lobehub/lobe-chat/blob/main/LICENSE
|
||||
[github-license-shield]: https://img.shields.io/badge/license-apache%202.0-white?labelColor=black&style=flat-square
|
||||
[github-project-link]: https://github.com/lobehub/lobe-chat/projects
|
||||
[github-release-link]: https://github.com/lobehub/lobe-chat/releases
|
||||
[github-release-shield]: https://img.shields.io/github/v/release/lobehub/lobe-chat?color=369eff&labelColor=black&logo=github&style=flat-square
|
||||
[github-releasedate-link]: https://github.com/lobehub/lobe-chat/releases
|
||||
[github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/lobe-chat?labelColor=black&style=flat-square
|
||||
[github-stars-link]: https://github.com/lobehub/lobe-chat/network/stargazers
|
||||
[github-stars-shield]: https://img.shields.io/github/stars/lobehub/lobe-chat?color=ffcb47&labelColor=black&style=flat-square
|
||||
[github-trending-shield]: https://trendshift.io/api/badge/repositories/2256
|
||||
[github-trending-url]: https://trendshift.io/repositories/2256
|
||||
[image-banner]: https://github.com/user-attachments/assets/6f293c7f-47b4-47eb-9202-fe68a942d35b
|
||||
[image-feat-agent]: https://github.com/user-attachments/assets/b3ab6e35-4fbc-468d-af10-e3e0c687350f
|
||||
[image-feat-artifacts]: https://github.com/user-attachments/assets/7f95fad6-b210-4e6e-84a0-7f39e96f3a00
|
||||
[image-feat-auth]: https://github.com/user-attachments/assets/80bb232e-19d1-4f97-98d6-e291f3585e6d
|
||||
[image-feat-branch]: https://github.com/user-attachments/assets/92f72082-02bd-4835-9c54-b089aad7fd41
|
||||
[image-feat-cot]: https://github.com/user-attachments/assets/f74f1139-d115-4e9c-8c43-040a53797a5e
|
||||
[image-feat-database]: https://github.com/user-attachments/assets/f1697c8b-d1fb-4dac-ba05-153c6295d91d
|
||||
[image-feat-desktop]: https://github.com/user-attachments/assets/a7bac8d3-ea96-4000-bb39-fadc9b610f96
|
||||
[image-feat-knowledgebase]: https://github.com/user-attachments/assets/7da7a3b2-92fd-4630-9f4e-8560c74955ae
|
||||
[image-feat-local]: https://github.com/user-attachments/assets/1239da50-d832-4632-a7ef-bd754c0f3850
|
||||
[image-feat-mcp-market]: https://github.com/user-attachments/assets/bb114f9f-24c5-4000-a984-c10d187da5a0
|
||||
[image-feat-mobile]: https://github.com/user-attachments/assets/32cf43c4-96bd-4a4c-bfb6-59acde6fe380
|
||||
[image-feat-plugin]: https://github.com/user-attachments/assets/66a891ac-01b6-4e3f-b978-2eb07b489b1b
|
||||
[image-feat-privoder]: https://github.com/user-attachments/assets/e553e407-42de-4919-977d-7dbfcf44a821
|
||||
[image-feat-pwa]: https://github.com/user-attachments/assets/9647f70f-b71b-43b6-9564-7cdd12d1c24d
|
||||
[image-feat-t2i]: https://github.com/user-attachments/assets/708274a7-2458-494b-a6ec-b73dfa1fa7c2
|
||||
[image-feat-theme]: https://github.com/user-attachments/assets/b47c39f1-806f-492b-8fcb-b0fa973937c1
|
||||
[image-feat-tts]: https://github.com/user-attachments/assets/50189597-2cc3-4002-b4c8-756a52ad5c0a
|
||||
[image-feat-vision]: https://github.com/user-attachments/assets/18574a1f-46c2-4cbc-af2c-35a86e128a07
|
||||
[image-feat-web-search]: https://github.com/user-attachments/assets/cfdc48ac-b5f8-4a00-acee-db8f2eba09ad
|
||||
[image-overview]: https://github.com/user-attachments/assets/dbfaa84a-2c82-4dd9-815c-5be616f264a4
|
||||
[image-star]: https://github.com/user-attachments/assets/c3b482e7-cef5-4e94-bef9-226900ecfaab
|
||||
[issues-link]: https://img.shields.io/github/issues/lobehub/lobe-chat.svg?style=flat
|
||||
[lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
|
||||
[lobe-commit]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-commit
|
||||
[lobe-i18n]: https://github.com/lobehub/lobe-commit/tree/master/packages/lobe-i18n
|
||||
[lobe-icons-github]: https://github.com/lobehub/lobe-icons
|
||||
[lobe-icons-link]: https://www.npmjs.com/package/@lobehub/icons
|
||||
[lobe-icons-shield]: https://img.shields.io/npm/v/@lobehub/icons?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-lint-github]: https://github.com/lobehub/lobe-lint
|
||||
[lobe-lint-link]: https://www.npmjs.com/package/@lobehub/lint
|
||||
[lobe-lint-shield]: https://img.shields.io/npm/v/@lobehub/lint?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-midjourney-webui]: https://github.com/lobehub/lobe-midjourney-webui
|
||||
[lobe-theme]: https://github.com/lobehub/sd-webui-lobe-theme
|
||||
[lobe-tts-github]: https://github.com/lobehub/lobe-tts
|
||||
[lobe-tts-link]: https://www.npmjs.com/package/@lobehub/tts
|
||||
[lobe-tts-shield]: https://img.shields.io/npm/v/@lobehub/tts?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[lobe-ui-github]: https://github.com/lobehub/lobe-ui
|
||||
[lobe-ui-link]: https://www.npmjs.com/package/@lobehub/ui
|
||||
[lobe-ui-shield]: https://img.shields.io/npm/v/@lobehub/ui?color=369eff&labelColor=black&logo=npm&logoColor=white&style=flat-square
|
||||
[official-site]: https://lobehub.com
|
||||
[pr-welcome-link]: https://github.com/lobehub/lobe-chat/pulls
|
||||
[pr-welcome-shield]: https://img.shields.io/badge/🤯_pr_welcome-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
|
||||
[profile-link]: https://github.com/lobehub
|
||||
[share-mastodon-link]: https://mastodon.social/share?text=Check%20this%20GitHub%20repository%20out%20%F0%9F%A4%AF%20LobeChat%20-%20An%20open-source,%20extensible%20(Function%20Calling),%20high-performance%20chatbot%20framework.%20It%20supports%20one-click%20free%20deployment%20of%20your%20private%20ChatGPT/LLM%20web%20application.%20https://github.com/lobehub/lobe-chat%20#chatbot%20#chatGPT%20#openAI
|
||||
[share-mastodon-shield]: https://img.shields.io/badge/-share%20on%20mastodon-black?labelColor=black&logo=mastodon&logoColor=white&style=flat-square
|
||||
[share-reddit-link]: https://www.reddit.com/submit?title=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-reddit-shield]: https://img.shields.io/badge/-share%20on%20reddit-black?labelColor=black&logo=reddit&logoColor=white&style=flat-square
|
||||
[share-telegram-link]: https://t.me/share/url"?text=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-telegram-shield]: https://img.shields.io/badge/-share%20on%20telegram-black?labelColor=black&logo=telegram&logoColor=white&style=flat-square
|
||||
[share-weibo-link]: http://service.weibo.com/share/share.php?sharesource=weibo&title=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20%23chatbot%20%23chatGPT%20%23openAI&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-weibo-shield]: https://img.shields.io/badge/-share%20on%20weibo-black?labelColor=black&logo=sinaweibo&logoColor=white&style=flat-square
|
||||
[share-whatsapp-link]: https://api.whatsapp.com/send?text=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%20https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat%20%23chatbot%20%23chatGPT%20%23openAI
|
||||
[share-whatsapp-shield]: https://img.shields.io/badge/-share%20on%20whatsapp-black?labelColor=black&logo=whatsapp&logoColor=white&style=flat-square
|
||||
[share-x-link]: https://x.com/intent/tweet?hashtags=chatbot%2CchatGPT%2CopenAI&text=%E6%8E%A8%E8%8D%90%E4%B8%80%E4%B8%AA%20GitHub%20%E5%BC%80%E6%BA%90%E9%A1%B9%E7%9B%AE%20%F0%9F%A4%AF%20LobeChat%20-%20%E5%BC%80%E6%BA%90%E7%9A%84%E3%80%81%E5%8F%AF%E6%89%A9%E5%B1%95%E7%9A%84%EF%BC%88Function%20Calling%EF%BC%89%E9%AB%98%E6%80%A7%E8%83%BD%E8%81%8A%E5%A4%A9%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%A1%86%E6%9E%B6%E3%80%82%0A%E5%AE%83%E6%94%AF%E6%8C%81%E4%B8%80%E9%94%AE%E5%85%8D%E8%B4%B9%E9%83%A8%E7%BD%B2%E7%A7%81%E4%BA%BA%20ChatGPT%2FLLM%20%E7%BD%91%E9%A1%B5%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F&url=https%3A%2F%2Fgithub.com%2Flobehub%2Flobe-chat
|
||||
[share-x-shield]: https://img.shields.io/badge/-share%20on%20x-black?labelColor=black&logo=x&logoColor=white&style=flat-square
|
||||
[sponsor-link]: https://opencollective.com/lobehub 'Become ❤ LobeHub Sponsor'
|
||||
[sponsor-shield]: https://img.shields.io/badge/-Sponsor%20LobeHub-f04f88?logo=opencollective&logoColor=white&style=flat-square
|
||||
[submit-agents-link]: https://github.com/lobehub/lobe-chat-agents
|
||||
[submit-agents-shield]: https://img.shields.io/badge/🤖/🏪_submit_agent-%E2%86%92-c4f042?labelColor=black&style=for-the-badge
|
||||
[submit-plugin-link]: https://github.com/lobehub/lobe-chat-plugins
|
||||
[submit-plugin-shield]: https://img.shields.io/badge/🧩/🏪_submit_plugin-%E2%86%92-95f3d9?labelColor=black&style=for-the-badge
|
||||
[vercel-link]: https://chat-preview.lobehub.com
|
||||
[vercel-shield]: https://img.shields.io/badge/vercel-online-55b467?labelColor=black&logo=vercel&style=flat-square
|
||||
[vercel-shield-badge]: https://img.shields.io/badge/TRY%20LOBECHAT-ONLINE-55b467?labelColor=black&logo=vercel&style=for-the-badge
|
||||
@@ -1,25 +0,0 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { beforeEach } from 'vitest';
|
||||
import { createWithEqualityFn as actualCreate } from 'zustand/traditional';
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set<() => void>();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
const createImpl = (createState: any) => {
|
||||
const store = actualCreate(createState, Object.is);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => {
|
||||
for (const resetFn of storeResetFns) {
|
||||
resetFn();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const createWithEqualityFn = (f: any) => (f === undefined ? createImpl : createImpl(f));
|
||||
@@ -1,8 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
out
|
||||
.DS_Store
|
||||
.eslintcache
|
||||
*.log*
|
||||
standalone
|
||||
release
|
||||
@@ -1,31 +0,0 @@
|
||||
const { defineConfig } = require('@lobehub/i18n-cli');
|
||||
|
||||
module.exports = defineConfig({
|
||||
entry: 'resources/locales/zh-CN',
|
||||
entryLocale: 'zh-CN',
|
||||
output: 'resources/locales',
|
||||
outputLocales: [
|
||||
'ar',
|
||||
'bg-BG',
|
||||
'zh-TW',
|
||||
'en-US',
|
||||
'ru-RU',
|
||||
'ja-JP',
|
||||
'ko-KR',
|
||||
'fr-FR',
|
||||
'tr-TR',
|
||||
'es-ES',
|
||||
'pt-BR',
|
||||
'de-DE',
|
||||
'it-IT',
|
||||
'nl-NL',
|
||||
'pl-PL',
|
||||
'vi-VN',
|
||||
'fa-IR',
|
||||
],
|
||||
temperature: 0,
|
||||
modelName: 'gpt-4o-mini',
|
||||
experimental: {
|
||||
jsonMode: true,
|
||||
},
|
||||
});
|
||||
@@ -1,6 +0,0 @@
|
||||
lockfile=false
|
||||
shamefully-hoist=true
|
||||
ignore-workspace-root-check=true
|
||||
|
||||
electron_mirror=https://npmmirror.com/mirrors/electron/
|
||||
electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
|
||||
@@ -1,495 +0,0 @@
|
||||
## 核心框架组件目录架构
|
||||
|
||||
### 主进程核心组件
|
||||
|
||||
```
|
||||
apps/desktop/src/main/
|
||||
├── core/ // 核心功能
|
||||
│ ├── App.ts // 应用核心类,整合所有管理器
|
||||
│ ├── Browser.ts // 浏览器窗口类
|
||||
│ ├── BrowserManager.ts // 浏览器窗口管理
|
||||
│ ├── I18nManager.ts // 国际化管理
|
||||
│ ├── IoCContainer.ts // 依赖注入容器
|
||||
│ ├── MenuManager.ts // 菜单管理核心类,负责选择和协调平台实现
|
||||
│ ├── ShortcutManager.ts // 快捷键管理
|
||||
│ ├── StoreManager.ts // 存储管理
|
||||
│ └── UpdaterManager.ts // 更新管理
|
||||
├── controllers/ // 控制器层,处理渲染进程调用
|
||||
│ ├── AuthCtr.ts // 认证控制器
|
||||
│ ├── BrowserWindowsCtr.ts // 浏览器窗口控制器
|
||||
│ ├── DevtoolsCtr.ts // 开发工具控制器
|
||||
│ ├── LocalFileCtr.ts // 本地文件控制器
|
||||
│ ├── MenuCtr.ts // 菜单控制器
|
||||
│ ├── RemoteServerConfigCtr.ts // 远程服务器配置控制器
|
||||
│ ├── RemoteServerSyncCtr.ts // 远程服务器同步控制器
|
||||
│ ├── ShortcutCtr.ts // 快捷键控制器
|
||||
│ ├── SystemCtr.ts // 系统控制器
|
||||
│ ├── UpdaterCtr.ts // 更新控制器
|
||||
│ ├── UploadFileCtr.ts // 文件上传控制器
|
||||
│ └── index.ts // 控制器导出
|
||||
├── services/ // 服务层
|
||||
│ ├── fileSearchSrv.ts // 文件搜索服务
|
||||
│ ├── fileSrv.ts // 文件服务
|
||||
│ └── index.ts // 服务导出
|
||||
├── modules/ // 功能模块
|
||||
│ ├── fileSearch/ // 文件搜索模块
|
||||
│ └── updater/ // 更新模块
|
||||
├── menus/ // 菜单实现目录
|
||||
│ ├── index.ts // 导出平台实现和接口
|
||||
│ ├── types.ts // 定义菜单平台接口 IMenuPlatform
|
||||
│ └── impl/ // 平台特定实现目录
|
||||
│ ├── BaseMenuPlatform.ts // 基础平台类,注入App
|
||||
│ ├── DarwinMenu.ts // macOS 充血模型实现
|
||||
│ ├── WindowsMenu.ts // Windows 充血模型实现
|
||||
│ └── LinuxMenu.ts // Linux 充血模型实现
|
||||
├── shortcuts/ // 快捷键实现
|
||||
│ ├── config.ts // 快捷键配置
|
||||
│ └── index.ts // 快捷键导出
|
||||
├── utils/ // 工具函数
|
||||
│ ├── file-system.ts // 文件系统工具
|
||||
│ ├── logger.ts // 日志工具
|
||||
│ └── next-electron-rsc.ts // Next.js Electron RSC 工具
|
||||
├── types/ // 类型定义
|
||||
│ ├── fileSearch.ts // 文件搜索类型
|
||||
│ └── store.ts // 存储类型
|
||||
├── const/ // 常量定义
|
||||
│ ├── dir.ts // 目录常量
|
||||
│ ├── env.ts // 环境常量
|
||||
│ └── store.ts // 存储常量
|
||||
├── locales/ // 国际化资源
|
||||
│ ├── index.ts // 导出 i18n 相关功能
|
||||
│ ├── resources.ts // 资源加载逻辑
|
||||
│ └── default/ // 默认中文翻译源文件
|
||||
│ ├── index.ts // 导出所有翻译
|
||||
│ ├── menu.ts // 菜单翻译
|
||||
│ ├── dialog.ts // 对话框翻译
|
||||
│ └── common.ts // 通用翻译
|
||||
└── index.ts // 主进程入口文件
|
||||
```
|
||||
|
||||
### 预加载脚本
|
||||
|
||||
```
|
||||
apps/desktop/src/preload/
|
||||
├── index.ts // 预加载脚本入口
|
||||
└── apis/ // 预加载 API
|
||||
└── ... // 各种 API 实现
|
||||
```
|
||||
|
||||
### 共享代码
|
||||
|
||||
```
|
||||
apps/desktop/src/common/
|
||||
├── constants/ // 共享常量
|
||||
├── types/ // 共享类型
|
||||
└── utils/ // 共享工具函数
|
||||
```
|
||||
|
||||
## 功能模块实现
|
||||
|
||||
### 菜单实现框架
|
||||
|
||||
```
|
||||
apps/desktop/src/main/
|
||||
├── core/
|
||||
│ ├── App.ts // 应用核心类
|
||||
│ ├── BrowserManager.ts // 浏览器窗口管理
|
||||
│ └── MenuManager.ts // 菜单管理核心类,负责选择和协调平台实现
|
||||
├── menus/ // 菜单实现目录
|
||||
│ ├── index.ts // 导出平台实现和接口
|
||||
│ ├── types.ts // 定义菜单平台接口 IMenuPlatform
|
||||
│ └── impl/ // 平台特定实现目录
|
||||
│ ├── BaseMenuPlatform.ts // 基础平台类,注入App
|
||||
│ ├── DarwinMenu.ts // macOS 充血模型实现
|
||||
│ ├── WindowsMenu.ts // Windows 充血模型实现
|
||||
│ └── LinuxMenu.ts // Linux 充血模型实现
|
||||
├── controllers/
|
||||
│ └── MenuCtr.ts // 菜单控制器,处理渲染进程调用
|
||||
```
|
||||
|
||||
### 国际化 (i18n) 实现
|
||||
|
||||
```
|
||||
apps/desktop/src/main/
|
||||
├── core/
|
||||
│ ├── I18nManager.ts // i18n 管理器
|
||||
│ └── App.ts // 应用主类,集成 i18n
|
||||
├── locales/
|
||||
│ ├── index.ts // 导出 i18n 相关功能
|
||||
│ ├── resources.ts // 资源加载逻辑
|
||||
│ └── default/ // 默认中文翻译源文件
|
||||
│ ├── index.ts // 导出所有翻译
|
||||
│ ├── menu.ts // 菜单翻译
|
||||
│ ├── dialog.ts // 对话框翻译
|
||||
│ └── common.ts // 通用翻译
|
||||
```
|
||||
|
||||
主进程 i18n 国际化管理使用方式:
|
||||
|
||||
1. 直接导入 i18nManager 实例:
|
||||
|
||||
```typescript
|
||||
import i18nManager from '@/locales';
|
||||
```
|
||||
|
||||
2. 使用翻译函数:
|
||||
|
||||
```typescript
|
||||
import { t } from '@/locales';
|
||||
|
||||
const translated = t('key');
|
||||
```
|
||||
|
||||
3. 添加新翻译:
|
||||
在 locales/default/ 目录下添加翻译源文件
|
||||
|
||||
## 核心模块详细说明
|
||||
|
||||
### 认证模块 (Auth)
|
||||
|
||||
认证模块负责处理用户身份验证和授权流程,主要包括:
|
||||
|
||||
1. **AuthCtr 控制器**:实现 OAuth 授权流程
|
||||
- 请求授权:打开浏览器进行 OAuth 认证
|
||||
- 处理回调:接收授权码并交换访问令牌
|
||||
- 令牌刷新:自动刷新过期的访问令牌
|
||||
- 事件广播:向渲染进程通知授权状态变化
|
||||
|
||||
```typescript
|
||||
// 认证流程示例
|
||||
@ipcClientEvent('requestAuthorization')
|
||||
async requestAuthorization(config: DataSyncConfig) {
|
||||
// 生成状态参数防止 CSRF 攻击
|
||||
this.authRequestState = crypto.randomBytes(16).toString('hex');
|
||||
|
||||
// 构建授权 URL
|
||||
const authUrl = new URL('/oidc/auth', remoteUrl);
|
||||
authUrl.search = querystring.stringify({
|
||||
client_id: 'lobe-chat',
|
||||
response_type: 'code',
|
||||
redirect_uri: `${protocolPrefix}://auth/callback`,
|
||||
scope: 'openid profile',
|
||||
state: this.authRequestState,
|
||||
});
|
||||
|
||||
// 在默认浏览器中打开授权 URL
|
||||
await shell.openExternal(authUrl.toString());
|
||||
}
|
||||
```
|
||||
|
||||
2. **桌面端特定认证**:
|
||||
- 在桌面应用中使用固定的用户 ID
|
||||
- 支持与 Clerk 和 NextAuth 等认证系统集成
|
||||
|
||||
### 存储模块 (Store)
|
||||
|
||||
存储模块使用 electron-store 实现持久化数据存储:
|
||||
|
||||
1. **StoreManager 类**:
|
||||
- 提供统一的存储接口
|
||||
- 支持类型安全的存取操作
|
||||
- 管理应用配置和用户数据
|
||||
|
||||
```typescript
|
||||
// 存储管理器使用示例
|
||||
export class StoreManager {
|
||||
private store: Store<ElectronMainStore>;
|
||||
|
||||
// 获取配置项
|
||||
get<K extends StoreKey>(key: K, defaultValue?: ElectronMainStore[K]): ElectronMainStore[K] {
|
||||
return this.store.get(key, defaultValue as any);
|
||||
}
|
||||
|
||||
// 设置配置项
|
||||
set<K extends StoreKey>(key: K, value: ElectronMainStore[K]): void {
|
||||
this.store.set(key, value);
|
||||
}
|
||||
|
||||
// 删除配置项
|
||||
delete(key: StoreKey): void {
|
||||
this.store.delete(key);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **存储用途**:
|
||||
- 窗口状态保存
|
||||
- 用户偏好设置
|
||||
- 认证令牌存储
|
||||
- 快捷键配置
|
||||
- 国际化语言设置
|
||||
|
||||
### 快捷键模块 (Shortcuts)
|
||||
|
||||
快捷键模块管理全局键盘快捷键:
|
||||
|
||||
1. **ShortcutManager 类**:
|
||||
- 注册和管理全局快捷键
|
||||
- 支持自定义快捷键配置
|
||||
- 提供快捷键状态查询
|
||||
|
||||
```typescript
|
||||
// 快捷键管理器示例
|
||||
export class ShortcutManager {
|
||||
private shortcuts: Map<string, () => void> = new Map();
|
||||
private shortcutsConfig: Record<string, string> = {};
|
||||
|
||||
// 注册快捷键
|
||||
registerShortcut(accelerator: string, callback: () => void): boolean {
|
||||
const success = globalShortcut.register(accelerator, callback);
|
||||
if (success) {
|
||||
this.shortcuts.set(accelerator, callback);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
// 更新快捷键配置
|
||||
updateShortcutConfig(id: string, accelerator: string): boolean {
|
||||
this.shortcutsConfig[id] = accelerator;
|
||||
this.saveShortcutsConfig();
|
||||
this.registerConfiguredShortcuts();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **快捷键装饰器**:
|
||||
- 使用 `@shortcut` 装饰器简化快捷键注册
|
||||
- 通过 IoC 容器管理快捷键映射
|
||||
|
||||
### 控制框架 (Control Framework)
|
||||
|
||||
控制框架实现了主进程和渲染进程之间的通信:
|
||||
|
||||
1. **ControllerModule 基类**:
|
||||
- 所有控制器的基础类
|
||||
- 提供生命周期钩子 (beforeAppReady, afterAppReady)
|
||||
- 注入 App 实例
|
||||
|
||||
```typescript
|
||||
// 控制器基类和装饰器
|
||||
export class ControllerModule implements IControllerModule {
|
||||
constructor(public app: App) {
|
||||
this.app = app;
|
||||
}
|
||||
}
|
||||
|
||||
// IPC 客户端事件装饰器
|
||||
export const ipcClientEvent = (method: keyof ClientDispatchEvents) =>
|
||||
ipcDecorator(method, 'client');
|
||||
|
||||
// IPC 服务器事件装饰器
|
||||
export const ipcServerEvent = (method: keyof ServerDispatchEvents) =>
|
||||
ipcDecorator(method, 'server');
|
||||
```
|
||||
|
||||
2. **IoC 容器**:
|
||||
- 依赖注入容器管理控制器实例
|
||||
- 注册和解析 IPC 事件处理程序
|
||||
- 管理快捷键和控制器方法的映射
|
||||
|
||||
### 服务逻辑 (Service Logic)
|
||||
|
||||
服务层提供业务逻辑实现:
|
||||
|
||||
1. **ServiceModule 基类**:
|
||||
- 所有服务的基础类
|
||||
- 注入 App 实例
|
||||
- 提供业务逻辑封装
|
||||
|
||||
```typescript
|
||||
// 服务模块基类
|
||||
export class ServiceModule {
|
||||
constructor(public app: App) {
|
||||
this.app = app;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
2. **服务实现**:
|
||||
- fileSearchSrv:文件搜索服务
|
||||
- fileSrv:文件操作服务
|
||||
|
||||
### 数据存储 (Electron Settings)
|
||||
|
||||
Electron Settings 基于 electron-store 实现,提供类型安全的数据存储:
|
||||
|
||||
1. **存储配置**:
|
||||
- 使用 JSON 文件存储配置
|
||||
- 支持默认值设置
|
||||
- 自动创建存储目录
|
||||
|
||||
```typescript
|
||||
// 存储初始化
|
||||
this.store = new Store<ElectronMainStore>({
|
||||
defaults: STORE_DEFAULTS,
|
||||
name: STORE_NAME,
|
||||
});
|
||||
|
||||
// 确保存储目录存在
|
||||
const storagePath = this.store.get('storagePath');
|
||||
makeSureDirExist(storagePath);
|
||||
```
|
||||
|
||||
2. **存储操作**:
|
||||
- 类型安全的 get/set 方法
|
||||
- 支持删除和清除操作
|
||||
- 提供存储编辑器功能
|
||||
|
||||
### 主进程和渲染进程通信 (Main-Renderer Communication)
|
||||
|
||||
主进程和渲染进程通信基于 Electron IPC 机制:
|
||||
|
||||
1. **IPC 事件处理**:
|
||||
- 使用装饰器注册 IPC 事件处理程序
|
||||
- 支持客户端事件和服务器事件
|
||||
- 自动映射控制器方法到 IPC 事件
|
||||
|
||||
```typescript
|
||||
// IPC 事件初始化
|
||||
private initializeIPCEvents() {
|
||||
// 注册客户端事件处理程序
|
||||
this.ipcClientEventMap.forEach((eventInfo, key) => {
|
||||
ipcMain.handle(key, async (e, ...data) => {
|
||||
return await eventInfo.controller[eventInfo.methodName](...data);
|
||||
});
|
||||
});
|
||||
|
||||
// 注册服务器事件处理程序
|
||||
const ipcServerEvents = {} as ElectronIPCEventHandler;
|
||||
this.ipcServerEventMap.forEach((eventInfo, key) => {
|
||||
ipcServerEvents[key] = async (payload) => {
|
||||
return await eventInfo.controller[eventInfo.methodName](payload);
|
||||
};
|
||||
});
|
||||
|
||||
// 创建 IPC 服务器
|
||||
this.ipcServer = new ElectronIPCServer(name, ipcServerEvents);
|
||||
}
|
||||
```
|
||||
|
||||
2. **事件广播**:
|
||||
- 主进程向渲染进程广播事件
|
||||
- 支持向所有窗口或特定窗口发送消息
|
||||
|
||||
### 日志系统 (Logging)
|
||||
|
||||
日志系统提供统一的日志记录接口:
|
||||
|
||||
1. **日志工具**:
|
||||
- 基于 debug 和 electron-log 实现
|
||||
- 支持不同日志级别 (debug, info, warn, error, verbose)
|
||||
- 根据环境自动调整日志行为
|
||||
|
||||
```typescript
|
||||
// 创建日志记录器
|
||||
export const createLogger = (namespace: string) => {
|
||||
const debugLogger = debug(namespace);
|
||||
|
||||
return {
|
||||
debug: (message, ...args) => {
|
||||
debugLogger(message, ...args);
|
||||
},
|
||||
error: (message, ...args) => {
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
electronLog.error(message, ...args);
|
||||
}
|
||||
debugLogger(`ERROR: ${message}`, ...args);
|
||||
},
|
||||
// 其他日志级别...
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
2. **日志配置**:
|
||||
- 开发环境显示详细日志
|
||||
- 生产环境记录到文件
|
||||
- 支持命名空间隔离日志
|
||||
|
||||
### 自动更新 (Auto Updates)
|
||||
|
||||
自动更新模块基于 electron-updater 实现:
|
||||
|
||||
1. **UpdaterManager 类**:
|
||||
- 检查更新
|
||||
- 下载更新
|
||||
- 安装更新
|
||||
- 支持立即安装或下次启动安装
|
||||
|
||||
```typescript
|
||||
// 更新管理器示例
|
||||
export class UpdaterManager {
|
||||
// 检查更新
|
||||
public checkForUpdates = async ({ manual = false }: { manual?: boolean } = {}) => {
|
||||
if (this.checking || this.downloading) return;
|
||||
|
||||
this.checking = true;
|
||||
this.isManualCheck = manual;
|
||||
|
||||
try {
|
||||
await autoUpdater.checkForUpdates();
|
||||
} catch (error) {
|
||||
logger.error('Error checking for updates:', error.message);
|
||||
} finally {
|
||||
this.checking = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 下载更新
|
||||
public downloadUpdate = async (manual: boolean = false) => {
|
||||
if (this.downloading || !this.updateAvailable) return;
|
||||
|
||||
this.downloading = true;
|
||||
|
||||
try {
|
||||
await autoUpdater.downloadUpdate();
|
||||
} catch (error) {
|
||||
this.downloading = false;
|
||||
logger.error('Error downloading update:', error);
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
2. **更新配置**:
|
||||
- 支持多渠道发布 (stable, beta, nightly)
|
||||
- 自动检查更新
|
||||
- 更新事件通知
|
||||
|
||||
## 桌面端架构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ Electron Application │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌─────────────────┐ ┌──────────────────────────┐ │
|
||||
│ │ Main Process │ │ Renderer Process │ │
|
||||
│ │ │ │ │ │
|
||||
│ │ ┌─────────────┐│ │ ┌────────────────────┐ │ │
|
||||
│ │ │ Core ││ │ │ │ │ │
|
||||
│ │ │ Managers ││ │ │ │ │ │
|
||||
│ │ └─────────────┘│ │ │ Next.js App │ │ │
|
||||
│ │ │ │ │ │ │ │ │
|
||||
│ │ ┌─────▼─────┐ │ │ │ │ │ │
|
||||
│ │ │Controllers│ │◄──────────┼──┤ │ │ │
|
||||
│ │ └─────┬─────┘ │ IPC │ └────────────────────┘ │ │
|
||||
│ │ │ │Communication │ │
|
||||
│ │ ┌─────▼─────┐ │ │ │ │
|
||||
│ │ │ Services │ │ │ │ │
|
||||
│ │ └─────┬─────┘ │ │ │ │
|
||||
│ │ │ │ │ │ │
|
||||
│ │ ┌─────▼─────┐ │ │ │ │
|
||||
│ │ │ Modules │ │ │ │ │
|
||||
│ │ └───────────┘ │ │ │ │
|
||||
│ │ │ │ │ │
|
||||
│ └─────────────────┘ └──────────────────────────┘ │
|
||||
│ │
|
||||
│ ┌───────────────────┐ │
|
||||
│ │ Preload Script │ │
|
||||
│ │ (Bridge between │ │
|
||||
│ │ Main & Renderer) │ │
|
||||
│ └───────────────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
@@ -1,353 +0,0 @@
|
||||
# 🤯 LobeHub Desktop Application
|
||||
|
||||
LobeHub Desktop is a cross-platform desktop application for [LobeChat](https://github.com/lobehub/lobe-chat), built with Electron, providing a more native desktop experience and functionality.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
- **🌍 Cross-platform Support**: Supports macOS (Intel/Apple Silicon), Windows, and Linux systems
|
||||
- **🔄 Auto Updates**: Built-in update mechanism ensures you always have the latest version
|
||||
- **🌐 Multi-language Support**: Complete i18n support for 18+ languages with lazy loading
|
||||
- **🎨 Native Integration**: Deep OS integration with native menus, shortcuts, and notifications
|
||||
- **🔒 Secure & Reliable**: macOS notarized, encrypted token storage, secure OAuth flow
|
||||
- **📦 Multiple Release Channels**: Stable, beta, and nightly build versions
|
||||
- **⚡ Advanced Window Management**: Multi-window architecture with theme synchronization
|
||||
- **🔗 Remote Server Sync**: Secure data synchronization with remote LobeChat instances
|
||||
- **🎯 Developer Tools**: Built-in development panel and comprehensive debugging tools
|
||||
|
||||
## 🚀 Development Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Node.js** 22+
|
||||
- **pnpm** 10+
|
||||
- **Electron** compatible development environment
|
||||
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pnpm install-isolated
|
||||
|
||||
# Start development server
|
||||
pnpm electron:dev
|
||||
|
||||
# Type checking
|
||||
pnpm typecheck
|
||||
|
||||
# Run tests
|
||||
pnpm test
|
||||
```
|
||||
|
||||
### Environment Configuration
|
||||
|
||||
Copy `.env.desktop` to `.env` and configure as needed:
|
||||
|
||||
```bash
|
||||
cp .env.desktop .env
|
||||
```
|
||||
|
||||
> \[!WARNING]
|
||||
> Backup your `.env` file before making changes to avoid losing configurations.
|
||||
|
||||
### Build Commands
|
||||
|
||||
| Command | Description |
|
||||
| ------------------ | --------------------------------------- |
|
||||
| `pnpm build` | Build for all platforms |
|
||||
| `pnpm build:mac` | Build for macOS (Intel + Apple Silicon) |
|
||||
| `pnpm build:win` | Build for Windows |
|
||||
| `pnpm build:linux` | Build for Linux |
|
||||
| `pnpm build-local` | Local development build |
|
||||
|
||||
### Development Workflow
|
||||
|
||||
```bash
|
||||
# 1. Development
|
||||
pnpm electron:dev # Start with hot reload
|
||||
|
||||
# 2. Code Quality
|
||||
pnpm lint # ESLint checking
|
||||
pnpm format # Prettier formatting
|
||||
pnpm typecheck # TypeScript validation
|
||||
|
||||
# 3. Testing
|
||||
pnpm test # Run Vitest tests
|
||||
|
||||
# 4. Build & Package
|
||||
pnpm build # Production build
|
||||
pnpm build-local # Local testing build
|
||||
```
|
||||
|
||||
## 🎯 Release Channels
|
||||
|
||||
| Channel | Description | Stability | Auto-Updates |
|
||||
| ----------- | -------------------------------- | --------- | ------------ |
|
||||
| **Stable** | Thoroughly tested releases | 🟢 High | ✅ Yes |
|
||||
| **Beta** | Pre-release with new features | 🟡 Medium | ✅ Yes |
|
||||
| **Nightly** | Daily builds with latest changes | 🟠 Low | ✅ Yes |
|
||||
|
||||
## 🛠 Technology Stack
|
||||
|
||||
### Core Framework
|
||||
|
||||
- **Electron** `37.1.0` - Cross-platform desktop framework
|
||||
- **Node.js** `22+` - Backend runtime
|
||||
- **TypeScript** `5.7+` - Type-safe development
|
||||
- **Vite** `6.2+` - Build tooling
|
||||
|
||||
### Architecture & Patterns
|
||||
|
||||
- **Dependency Injection** - IoC container with decorator-based registration
|
||||
- **Event-Driven Architecture** - IPC communication between processes
|
||||
- **Module Federation** - Dynamic controller and service loading
|
||||
- **Observer Pattern** - State management and UI synchronization
|
||||
|
||||
### Development Tools
|
||||
|
||||
- **Vitest** - Unit testing framework
|
||||
- **ESLint** - Code linting
|
||||
- **Prettier** - Code formatting
|
||||
- **electron-builder** - Application packaging
|
||||
- **electron-updater** - Auto-update mechanism
|
||||
|
||||
### Security & Storage
|
||||
|
||||
- **Electron Safe Storage** - Encrypted token storage
|
||||
- **OAuth 2.0 + PKCE** - Secure authentication flow
|
||||
- **electron-store** - Persistent configuration
|
||||
- **Custom Protocol Handler** - Secure callback handling
|
||||
|
||||
## 🏗 Architecture
|
||||
|
||||
The desktop application uses a sophisticated dependency injection and event-driven architecture:
|
||||
|
||||
### 📁 Core Structure
|
||||
|
||||
```
|
||||
src/main/core/
|
||||
├── App.ts # 🎯 Main application orchestrator
|
||||
├── IoCContainer.ts # 🔌 Dependency injection container
|
||||
├── window/ # 🪟 Window management modules
|
||||
│ ├── WindowThemeManager.ts # 🎨 Theme synchronization
|
||||
│ ├── WindowPositionManager.ts # 📐 Position persistence
|
||||
│ ├── WindowErrorHandler.ts # ⚠️ Error boundaries
|
||||
│ └── WindowConfigBuilder.ts # ⚙️ Configuration builder
|
||||
├── browser/ # 🌐 Browser management modules
|
||||
│ ├── Browser.ts # 🪟 Individual window instances
|
||||
│ └── BrowserManager.ts # 👥 Multi-window coordinator
|
||||
├── ui/ # 🎨 UI system modules
|
||||
│ ├── Tray.ts # 📍 System tray integration
|
||||
│ ├── TrayManager.ts # 🔧 Tray management
|
||||
│ ├── MenuManager.ts # 📋 Native menu system
|
||||
│ └── ShortcutManager.ts # ⌨️ Global shortcuts
|
||||
└── infrastructure/ # 🔧 Infrastructure services
|
||||
├── StoreManager.ts # 💾 Configuration storage
|
||||
├── I18nManager.ts # 🌍 Internationalization
|
||||
├── UpdaterManager.ts # 📦 Auto-update system
|
||||
└── StaticFileServerManager.ts # 🗂️ Local file serving
|
||||
```
|
||||
|
||||
### 🔄 Application Lifecycle
|
||||
|
||||
The `App.ts` class orchestrates the entire application lifecycle through key phases:
|
||||
|
||||
#### 1. 🚀 Initialization Phase
|
||||
|
||||
- **System Information Logging** - Captures OS, CPU, RAM, and locale details
|
||||
- **Store Manager Setup** - Initializes persistent configuration storage
|
||||
- **Dynamic Module Loading** - Auto-discovers controllers and services via glob imports
|
||||
- **IPC Event Registration** - Sets up inter-process communication channels
|
||||
|
||||
#### 2. 🏃 Bootstrap Phase
|
||||
|
||||
- **Single Instance Check** - Ensures only one application instance runs
|
||||
- **IPC Server Launch** - Starts the communication server
|
||||
- **Core Manager Initialization** - Sequential initialization of all managers:
|
||||
- 🌍 I18n for internationalization
|
||||
- 📋 Menu system for native menus
|
||||
- 🗂️ Static file server for local assets
|
||||
- ⌨️ Global shortcuts registration
|
||||
- 🪟 Browser window management
|
||||
- 📍 System tray (Windows only)
|
||||
- 📦 Auto-updater system
|
||||
|
||||
### 🔧 Core Components Deep Dive
|
||||
|
||||
#### 🌐 Browser Management System
|
||||
|
||||
- **Multi-Window Architecture** - Supports chat, settings, and devtools windows
|
||||
- **Window State Management** - Handles positioning, theming, and lifecycle
|
||||
- **WebContents Mapping** - Bidirectional mapping between WebContents and identifiers
|
||||
- **Event Broadcasting** - Centralized event distribution to all or specific windows
|
||||
|
||||
#### 🔌 Dependency Injection & Event System
|
||||
|
||||
- **IoC Container** - WeakMap-based container for decorated controller methods
|
||||
- **Decorator Registration** - `@ipcClientEvent` and `@ipcServerEvent` decorators
|
||||
- **Automatic Event Mapping** - Events registered during controller loading
|
||||
- **Service Locator** - Type-safe service and controller retrieval
|
||||
|
||||
#### 🪟 Window Management
|
||||
|
||||
- **Theme-Aware Windows** - Automatic adaptation to system dark/light mode
|
||||
- **Platform-Specific Styling** - Windows title bar and overlay customization
|
||||
- **Position Persistence** - Save and restore window positions across sessions
|
||||
- **Error Boundaries** - Centralized error handling for window operations
|
||||
|
||||
#### 🔧 Infrastructure Services
|
||||
|
||||
##### 🌍 I18n Manager
|
||||
|
||||
- **18+ Language Support** with lazy loading and namespace organization
|
||||
- **System Integration** with Electron's locale detection
|
||||
- **Dynamic UI Refresh** on language changes
|
||||
- **Resource Management** with efficient loading strategies
|
||||
|
||||
##### 📦 Update Manager
|
||||
|
||||
- **Multi-Channel Support** (stable, beta, nightly) with configurable intervals
|
||||
- **Background Downloads** with progress tracking and user notifications
|
||||
- **Rollback Protection** with error handling and recovery mechanisms
|
||||
- **Channel Management** with automatic channel switching
|
||||
|
||||
##### 💾 Store Manager
|
||||
|
||||
- **Type-Safe Storage** using electron-store with TypeScript interfaces
|
||||
- **Encrypted Secrets** via Electron's Safe Storage API
|
||||
- **Configuration Validation** with default value management
|
||||
- **File System Integration** with automatic directory creation
|
||||
|
||||
##### 🗂️ Static File Server
|
||||
|
||||
- **Local HTTP Server** for serving application assets and user files
|
||||
- **Security Controls** with request filtering and access validation
|
||||
- **File Management** with upload, download, and deletion capabilities
|
||||
- **Path Resolution** with intelligent routing between storage locations
|
||||
|
||||
#### 🎨 UI System Integration
|
||||
|
||||
- **Global Shortcuts** - Platform-aware keyboard shortcut registration with conflict detection
|
||||
- **System Tray** - Native integration with context menus and notifications
|
||||
- **Native Menus** - Platform-specific application and context menus with i18n
|
||||
- **Theme Synchronization** - Automatic theme updates across all UI components
|
||||
|
||||
### 🏛 Controller & Service Architecture
|
||||
|
||||
#### 🎮 Controller Pattern
|
||||
|
||||
- **IPC Event Handling** - Processes events from renderer with decorator-based registration
|
||||
- **Lifecycle Hooks** - `beforeAppReady` and `afterAppReady` for initialization phases
|
||||
- **Type-Safe Communication** - Strong typing for all IPC events and responses
|
||||
- **Error Boundaries** - Comprehensive error handling with proper propagation
|
||||
|
||||
#### 🔧 Service Pattern
|
||||
|
||||
- **Business Logic Encapsulation** - Clean separation of concerns
|
||||
- **Dependency Management** - Managed through IoC container
|
||||
- **Cross-Controller Sharing** - Services accessible via service locator pattern
|
||||
- **Resource Management** - Proper initialization and cleanup
|
||||
|
||||
### 🔗 Inter-Process Communication
|
||||
|
||||
#### 📡 IPC System Features
|
||||
|
||||
- **Bidirectional Communication** - Main↔Renderer and Main↔Next.js server
|
||||
- **Type-Safe Events** - TypeScript interfaces for all event parameters
|
||||
- **Context Awareness** - Events include sender context for window-specific operations
|
||||
- **Error Propagation** - Centralized error handling with proper status codes
|
||||
|
||||
#### 🛡️ Security Features
|
||||
|
||||
- **OAuth 2.0 + PKCE** - Secure authentication with state parameter validation
|
||||
- **Encrypted Token Storage** - Using Electron's Safe Storage API when available
|
||||
- **Custom Protocol Handler** - Secure callback handling for OAuth flows
|
||||
- **Request Filtering** - Security controls for web requests and external links
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### Test Structure
|
||||
|
||||
```bash
|
||||
apps/desktop/src/main/controllers/__tests__/ # Controller unit tests
|
||||
tests/ # Integration tests
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
pnpm test # Run all tests
|
||||
pnpm test:watch # Watch mode
|
||||
pnpm typecheck # Type validation
|
||||
```
|
||||
|
||||
### Test Coverage
|
||||
|
||||
- **Controller Tests** - IPC event handling validation
|
||||
- **Service Tests** - Business logic verification
|
||||
- **Integration Tests** - End-to-end workflow testing
|
||||
- **Type Tests** - TypeScript interface validation
|
||||
|
||||
## 🔒 Security Features
|
||||
|
||||
### Authentication & Authorization
|
||||
|
||||
- **OAuth 2.0 Flow** with PKCE for secure token exchange
|
||||
- **State Parameter Validation** to prevent CSRF attacks
|
||||
- **Encrypted Token Storage** using platform-native secure storage
|
||||
- **Automatic Token Refresh** with fallback to re-authentication
|
||||
|
||||
### Application Security
|
||||
|
||||
- **Code Signing** - macOS notarization for enhanced security
|
||||
- **Sandboxing** - Controlled access to system resources
|
||||
- **CSP Controls** - Content Security Policy management
|
||||
- **Request Filtering** - Security controls for external requests
|
||||
|
||||
### Data Protection
|
||||
|
||||
- **Encrypted Configuration** - Sensitive data encrypted at rest
|
||||
- **Secure IPC** - Type-safe communication channels
|
||||
- **Path Validation** - Secure file system access controls
|
||||
- **Network Security** - HTTPS enforcement and proxy support
|
||||
|
||||
## 🤝 Contribution
|
||||
|
||||
Desktop application development involves complex cross-platform considerations and native integrations. We welcome community contributions to improve functionality, performance, and user experience. You can participate in improvements through:
|
||||
|
||||
### How to Contribute
|
||||
|
||||
1. **Platform Support**: Enhance cross-platform compatibility and native integrations
|
||||
2. **Performance Optimization**: Improve application startup time, memory usage, and responsiveness
|
||||
3. **Feature Development**: Add new desktop-specific features and capabilities
|
||||
4. **Bug Fixes**: Fix platform-specific issues and edge cases
|
||||
5. **Security Improvements**: Enhance security measures and authentication flows
|
||||
6. **UI/UX Enhancements**: Improve desktop user interface and experience
|
||||
|
||||
### Contribution Process
|
||||
|
||||
1. Fork the [LobeChat repository](https://github.com/lobehub/lobe-chat)
|
||||
2. Set up the desktop development environment following our setup guide
|
||||
3. Make your changes to the desktop application
|
||||
4. Submit a Pull Request describing:
|
||||
|
||||
- Platform compatibility testing results
|
||||
- Performance impact analysis
|
||||
- Security considerations
|
||||
- User experience improvements
|
||||
- Breaking changes (if any)
|
||||
|
||||
### Development Areas
|
||||
|
||||
- **Core Architecture**: Dependency injection, event system, and lifecycle management
|
||||
- **Window Management**: Multi-window support, theme synchronization, and state persistence
|
||||
- **IPC Communication**: Type-safe inter-process communication between main and renderer
|
||||
- **Platform Integration**: Native menus, shortcuts, notifications, and system tray
|
||||
- **Security Features**: OAuth flows, token encryption, and secure storage
|
||||
- **Auto-Update System**: Multi-channel updates and rollback mechanisms
|
||||
|
||||
## 📚 Additional Resources
|
||||
|
||||
- **Development Guide**: [`Development.md`](./Development.md) - Comprehensive development documentation
|
||||
- **Architecture Docs**: [`/docs`](../../docs/) - Detailed technical specifications
|
||||
- **Contributing**: [`CONTRIBUTING.md`](../../CONTRIBUTING.md) - Contribution guidelines
|
||||
- **Issues & Support**: [GitHub Issues](https://github.com/lobehub/lobe-chat/issues)
|
||||
@@ -1,353 +0,0 @@
|
||||
# 🤯 LobeHub 桌面应用程序
|
||||
|
||||
LobeHub Desktop 是 [LobeChat](https://github.com/lobehub/lobe-chat) 的跨平台桌面应用程序,使用 Electron 构建,提供了更加原生的桌面体验和功能。
|
||||
|
||||
## ✨ 功能特点
|
||||
|
||||
- **🌍 跨平台支持**:支持 macOS (Intel/Apple Silicon)、Windows 和 Linux 系统
|
||||
- **🔄 自动更新**:内置更新机制,确保您始终使用最新版本
|
||||
- **🌐 多语言支持**:完整的 i18n 支持,包含 18+ 种语言的懒加载
|
||||
- **🎨 原生集成**:与操作系统深度集成,提供原生菜单、快捷键和通知
|
||||
- **🔒 安全可靠**:macOS 公证认证,加密令牌存储,安全的 OAuth 流程
|
||||
- **📦 多渠道发布**:提供稳定版、测试版和每日构建版本
|
||||
- **⚡ 高级窗口管理**:多窗口架构,支持主题同步
|
||||
- **🔗 远程服务器同步**:与远程 LobeChat 实例的安全数据同步
|
||||
- **🎯 开发者工具**:内置开发面板和全面的调试工具
|
||||
|
||||
## 🚀 开发环境设置
|
||||
|
||||
### 前提条件
|
||||
|
||||
- **Node.js** 22+
|
||||
- **pnpm** 10+
|
||||
- **Electron** 兼容的开发环境
|
||||
|
||||
### 快速开始
|
||||
|
||||
```bash
|
||||
# 安装依赖
|
||||
pnpm install-isolated
|
||||
|
||||
# 启动开发服务器
|
||||
pnpm electron:dev
|
||||
|
||||
# 类型检查
|
||||
pnpm typecheck
|
||||
|
||||
# 运行测试
|
||||
pnpm test
|
||||
```
|
||||
|
||||
### 环境变量配置
|
||||
|
||||
复制 `.env.desktop` 到 `.env` 并根据需要配置:
|
||||
|
||||
```bash
|
||||
cp .env.desktop .env
|
||||
```
|
||||
|
||||
> \[!WARNING]
|
||||
> 在进行更改之前请备份您的 `.env` 文件,避免丢失配置。
|
||||
|
||||
### 构建命令
|
||||
|
||||
| 命令 | 描述 |
|
||||
| ------------------ | ---------------------------------- |
|
||||
| `pnpm build` | 构建所有平台 |
|
||||
| `pnpm build:mac` | 构建 macOS (Intel + Apple Silicon) |
|
||||
| `pnpm build:win` | 构建 Windows |
|
||||
| `pnpm build:linux` | 构建 Linux |
|
||||
| `pnpm build-local` | 本地开发构建 |
|
||||
|
||||
### 开发工作流
|
||||
|
||||
```bash
|
||||
# 1. 开发
|
||||
pnpm electron:dev # 启动热重载开发服务器
|
||||
|
||||
# 2. 代码质量
|
||||
pnpm lint # ESLint 检查
|
||||
pnpm format # Prettier 格式化
|
||||
pnpm typecheck # TypeScript 验证
|
||||
|
||||
# 3. 测试
|
||||
pnpm test # 运行 Vitest 测试
|
||||
|
||||
# 4. 构建和打包
|
||||
pnpm build # 生产构建
|
||||
pnpm build-local # 本地测试构建
|
||||
```
|
||||
|
||||
## 🎯 发布渠道
|
||||
|
||||
| 渠道 | 描述 | 稳定性 | 自动更新 |
|
||||
| ------------------------ | ---------------------- | ------ | -------- |
|
||||
| **稳定版** | 经过充分测试的正式版本 | 🟢 高 | ✅ 是 |
|
||||
| **测试版 (Beta)** | 包含新功能的预发布版本 | 🟡 中 | ✅ 是 |
|
||||
| **每日构建版 (Nightly)** | 包含最新更改的每日构建 | 🟠 低 | ✅ 是 |
|
||||
|
||||
## 🛠 技术栈
|
||||
|
||||
### 核心框架
|
||||
|
||||
- **Electron** `37.1.0` - 跨平台桌面框架
|
||||
- **Node.js** `22+` - 后端运行时
|
||||
- **TypeScript** `5.7+` - 类型安全开发
|
||||
- **Vite** `6.2+` - 构建工具
|
||||
|
||||
### 架构和模式
|
||||
|
||||
- **依赖注入** - 基于装饰器注册的 IoC 容器
|
||||
- **事件驱动架构** - 进程间 IPC 通信
|
||||
- **模块联邦** - 动态控制器和服务加载
|
||||
- **观察者模式** - 状态管理和 UI 同步
|
||||
|
||||
### 开发工具
|
||||
|
||||
- **Vitest** - 单元测试框架
|
||||
- **ESLint** - 代码检查
|
||||
- **Prettier** - 代码格式化
|
||||
- **electron-builder** - 应用程序打包
|
||||
- **electron-updater** - 自动更新机制
|
||||
|
||||
### 安全和存储
|
||||
|
||||
- **Electron Safe Storage** - 加密令牌存储
|
||||
- **OAuth 2.0 + PKCE** - 安全认证流程
|
||||
- **electron-store** - 持久化配置
|
||||
- **自定义协议处理器** - 安全回调处理
|
||||
|
||||
## 🏗 架构设计
|
||||
|
||||
桌面应用程序采用了复杂的依赖注入和事件驱动架构:
|
||||
|
||||
### 📁 核心结构
|
||||
|
||||
```
|
||||
src/main/core/
|
||||
├── App.ts # 🎯 主应用程序协调器
|
||||
├── IoCContainer.ts # 🔌 依赖注入容器
|
||||
├── window/ # 🪟 窗口管理模块
|
||||
│ ├── WindowThemeManager.ts # 🎨 主题同步
|
||||
│ ├── WindowPositionManager.ts # 📐 位置持久化
|
||||
│ ├── WindowErrorHandler.ts # ⚠️ 错误边界
|
||||
│ └── WindowConfigBuilder.ts # ⚙️ 配置构建器
|
||||
├── browser/ # 🌐 浏览器管理模块
|
||||
│ ├── Browser.ts # 🪟 单个窗口实例
|
||||
│ └── BrowserManager.ts # 👥 多窗口协调器
|
||||
├── ui/ # 🎨 UI 系统模块
|
||||
│ ├── Tray.ts # 📍 系统托盘集成
|
||||
│ ├── TrayManager.ts # 🔧 托盘管理
|
||||
│ ├── MenuManager.ts # 📋 原生菜单系统
|
||||
│ └── ShortcutManager.ts # ⌨️ 全局快捷键
|
||||
└── infrastructure/ # 🔧 基础设施服务
|
||||
├── StoreManager.ts # 💾 配置存储
|
||||
├── I18nManager.ts # 🌍 国际化
|
||||
├── UpdaterManager.ts # 📦 自动更新系统
|
||||
└── StaticFileServerManager.ts # 🗂️ 本地文件服务
|
||||
```
|
||||
|
||||
### 🔄 应用程序生命周期
|
||||
|
||||
`App.ts` 类通过几个关键阶段协调整个应用程序的生命周期:
|
||||
|
||||
#### 1. 🚀 初始化阶段
|
||||
|
||||
- **系统信息记录** - 捕获操作系统、CPU、内存和区域设置详细信息
|
||||
- **存储管理器设置** - 初始化持久配置存储
|
||||
- **动态模块加载** - 通过 glob 导入自动发现控制器和服务
|
||||
- **IPC 事件注册** - 设置进程间通信通道
|
||||
|
||||
#### 2. 🏃 引导阶段
|
||||
|
||||
- **单实例检查** - 确保只运行一个应用程序实例
|
||||
- **IPC 服务器启动** - 启动通信服务器
|
||||
- **核心管理器初始化** - 按顺序初始化所有管理器:
|
||||
- 🌍 国际化管理器
|
||||
- 📋 原生菜单系统
|
||||
- 🗂️ 本地资源服务器
|
||||
- ⌨️ 全局快捷键注册
|
||||
- 🪟 浏览器窗口管理
|
||||
- 📍 系统托盘(仅 Windows)
|
||||
- 📦 自动更新系统
|
||||
|
||||
### 🔧 核心组件深度解析
|
||||
|
||||
#### 🌐 浏览器管理系统
|
||||
|
||||
- **多窗口架构** - 支持聊天、设置和开发工具窗口
|
||||
- **窗口状态管理** - 处理定位、主题和生命周期
|
||||
- **WebContents 映射** - WebContents 和标识符之间的双向映射
|
||||
- **事件广播** - 向所有或特定窗口的集中事件分发
|
||||
|
||||
#### 🔌 依赖注入和事件系统
|
||||
|
||||
- **IoC 容器** - 基于 WeakMap 的装饰控制器方法容器
|
||||
- **装饰器注册** - `@ipcClientEvent` 和 `@ipcServerEvent` 装饰器
|
||||
- **自动事件映射** - 控制器加载期间注册的事件
|
||||
- **服务定位器** - 类型安全的服务和控制器检索
|
||||
|
||||
#### 🪟 窗口管理
|
||||
|
||||
- **主题感知窗口** - 自动适应系统深色 / 浅色模式
|
||||
- **平台特定样式** - Windows 标题栏和覆盖自定义
|
||||
- **位置持久化** - 跨会话保存和恢复窗口位置
|
||||
- **错误边界** - 窗口操作的集中错误处理
|
||||
|
||||
#### 🔧 基础设施服务
|
||||
|
||||
##### 🌍 国际化管理器
|
||||
|
||||
- **18+ 语言支持** 懒加载和命名空间组织
|
||||
- **系统集成** 与 Electron 的区域检测集成
|
||||
- **动态 UI 刷新** 语言更改时的 UI 更新
|
||||
- **资源管理** 高效的加载策略
|
||||
|
||||
##### 📦 更新管理器
|
||||
|
||||
- **多渠道支持** (稳定版、测试版、每日构建)可配置间隔
|
||||
- **后台下载** 进度跟踪和用户通知
|
||||
- **回滚保护** 错误处理和恢复机制
|
||||
- **渠道管理** 自动渠道切换
|
||||
|
||||
##### 💾 存储管理器
|
||||
|
||||
- **类型安全存储** 使用带有 TypeScript 接口的 electron-store
|
||||
- **加密机密** 通过 Electron 的安全存储 API
|
||||
- **配置验证** 默认值管理
|
||||
- **文件系统集成** 自动目录创建
|
||||
|
||||
##### 🗂️ 静态文件服务器
|
||||
|
||||
- **本地 HTTP 服务器** 用于提供应用程序资源和用户文件
|
||||
- **安全控制** 请求过滤和访问验证
|
||||
- **文件管理** 上传、下载和删除功能
|
||||
- **路径解析** 存储位置之间的智能路由
|
||||
|
||||
#### 🎨 UI 系统集成
|
||||
|
||||
- **全局快捷键** - 平台感知的键盘快捷键注册与冲突检测
|
||||
- **系统托盘** - 带有上下文菜单和通知的原生集成
|
||||
- **原生菜单** - 带有 i18n 的平台特定应用程序和上下文菜单
|
||||
- **主题同步** - 所有 UI 组件的自动主题更新
|
||||
|
||||
### 🏛 控制器和服务架构
|
||||
|
||||
#### 🎮 控制器模式
|
||||
|
||||
- **IPC 事件处理** - 通过基于装饰器的注册处理来自渲染器的事件
|
||||
- **生命周期钩子** - 初始化阶段的 `beforeAppReady` 和 `afterAppReady`
|
||||
- **类型安全通信** - 所有 IPC 事件和响应的强类型
|
||||
- **错误边界** - 具有适当传播的全面错误处理
|
||||
|
||||
#### 🔧 服务模式
|
||||
|
||||
- **业务逻辑封装** - 关注点的清晰分离
|
||||
- **依赖管理** - 通过 IoC 容器管理
|
||||
- **跨控制器共享** - 通过服务定位器模式访问的服务
|
||||
- **资源管理** - 适当的初始化和清理
|
||||
|
||||
### 🔗 进程间通信
|
||||
|
||||
#### 📡 IPC 系统功能
|
||||
|
||||
- **双向通信** - Main↔Renderer 和 Main↔Next.js 服务器
|
||||
- **类型安全事件** - 所有事件参数的 TypeScript 接口
|
||||
- **上下文感知** - 事件包含用于窗口特定操作的发送者上下文
|
||||
- **错误传播** - 具有适当状态码的集中错误处理
|
||||
|
||||
#### 🛡️ 安全功能
|
||||
|
||||
- **OAuth 2.0 + PKCE** - 具有状态参数验证的安全认证
|
||||
- **加密令牌存储** - 在可用时使用 Electron 的安全存储 API
|
||||
- **自定义协议处理器** - OAuth 流程的安全回调处理
|
||||
- **请求过滤** - 网络请求和外部链接的安全控制
|
||||
|
||||
## 🧪 测试
|
||||
|
||||
### 测试结构
|
||||
|
||||
```bash
|
||||
apps/desktop/src/main/controllers/__tests__/ # 控制器单元测试
|
||||
tests/ # 集成测试
|
||||
```
|
||||
|
||||
### 运行测试
|
||||
|
||||
```bash
|
||||
pnpm test # 运行所有测试
|
||||
pnpm test:watch # 监视模式
|
||||
pnpm typecheck # 类型验证
|
||||
```
|
||||
|
||||
### 测试覆盖
|
||||
|
||||
- **控制器测试** - IPC 事件处理验证
|
||||
- **服务测试** - 业务逻辑验证
|
||||
- **集成测试** - 端到端工作流测试
|
||||
- **类型测试** - TypeScript 接口验证
|
||||
|
||||
## 🔒 安全功能
|
||||
|
||||
### 认证和授权
|
||||
|
||||
- **OAuth 2.0 流程** 使用 PKCE 进行安全令牌交换
|
||||
- **状态参数验证** 防止 CSRF 攻击
|
||||
- **加密令牌存储** 使用平台原生安全存储
|
||||
- **自动令牌刷新** 在失败时回退到重新认证
|
||||
|
||||
### 应用程序安全
|
||||
|
||||
- **代码签名** - macOS 公证认证以增强安全性
|
||||
- **沙盒** - 对系统资源的受控访问
|
||||
- **CSP 控制** - 内容安全策略管理
|
||||
- **请求过滤** - 外部请求的安全控制
|
||||
|
||||
### 数据保护
|
||||
|
||||
- **加密配置** - 敏感数据静态加密
|
||||
- **安全 IPC** - 类型安全的通信通道
|
||||
- **路径验证** - 安全的文件系统访问控制
|
||||
- **网络安全** - HTTPS 强制和代理支持
|
||||
|
||||
## 🤝 参与贡献
|
||||
|
||||
桌面应用程序开发涉及复杂的跨平台考虑和原生集成。我们欢迎社区贡献来改进功能、性能和用户体验。您可以通过以下方式参与改进:
|
||||
|
||||
### 如何贡献
|
||||
|
||||
1. **平台支持**:增强跨平台兼容性和原生集成
|
||||
2. **性能优化**:改进应用程序启动时间、内存使用和响应性
|
||||
3. **功能开发**:添加新的桌面特定功能和能力
|
||||
4. **错误修复**:修复平台特定问题和边缘情况
|
||||
5. **安全改进**:增强安全措施和认证流程
|
||||
6. **UI/UX 增强**:改进桌面用户界面和体验
|
||||
|
||||
### 贡献流程
|
||||
|
||||
1. Fork [LobeChat 仓库](https://github.com/lobehub/lobe-chat)
|
||||
2. 按照我们的设置指南建立桌面开发环境
|
||||
3. 对桌面应用程序进行修改
|
||||
4. 提交 Pull Request 并描述:
|
||||
|
||||
- 平台兼容性测试结果
|
||||
- 性能影响分析
|
||||
- 安全考虑
|
||||
- 用户体验改进
|
||||
- 破坏性更改(如有)
|
||||
|
||||
### 开发领域
|
||||
|
||||
- **核心架构**:依赖注入、事件系统和生命周期管理
|
||||
- **窗口管理**:多窗口支持、主题同步和状态持久化
|
||||
- **IPC 通信**:主进程和渲染进程之间的类型安全进程间通信
|
||||
- **平台集成**:原生菜单、快捷键、通知和系统托盘
|
||||
- **安全功能**:OAuth 流程、令牌加密和安全存储
|
||||
- **自动更新系统**:多渠道更新和回滚机制
|
||||
|
||||
## 📚 其他资源
|
||||
|
||||
- **开发指南**:[`Development.md`](./Development.md) - 全面的开发文档
|
||||
- **架构文档**:[`/docs`](../../docs/) - 详细的技术规范
|
||||
- **贡献指南**:[`CONTRIBUTING.md`](../../CONTRIBUTING.md) - 贡献指导
|
||||
- **问题和支持**:[GitHub Issues](https://github.com/lobehub/lobe-chat/issues)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 171 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 756 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 156 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 161 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 171 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 210 KiB |
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user