Unverified Commit 3a42ebbf authored by Xiaomeng Zhao's avatar Xiaomeng Zhao Committed by GitHub
Browse files

Merge pull request #838 from opendatalab/release-0.9.0

Release 0.9.0
parents 765c6d77 14024793
<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Frame 1312318468">
<g id="Group 1312318394">
<path id="Rectangle 1921711210" d="M13.2347 12.3647L26.0552 18.9175L16.6535 25.4702L3.83301 18.9175L13.2347 12.3647Z" fill="url(#paint0_linear_3389_2351)" fill-opacity="0.3"/>
<g id="Rectangle 1921711209" filter="url(#filter0_b_3389_2351)">
<path d="M13.2347 4.66675L26.0552 11.2195L16.6535 17.7722L3.83301 11.2195L13.2347 4.66675Z" fill="url(#paint1_linear_3389_2351)" fill-opacity="0.5"/>
</g>
<g id="Group 1312318397">
<g id="Group 1312318397_2">
<g id="Ellipse 2410" filter="url(#filter1_b_3389_2351)">
<circle cx="26.0549" cy="21.01" r="5.01" fill="url(#paint2_linear_3389_2351)" fill-opacity="0.8"/>
</g>
<path id="&#239;&#188;&#129;" d="M25.4747 17.8989H26.636L26.4209 22.3347H25.6897L25.4747 17.8989ZM26.051 22.8052C26.2403 22.8052 26.4037 22.8662 26.5328 22.9883C26.6532 23.1103 26.722 23.2671 26.722 23.4588C26.722 23.6506 26.6532 23.8161 26.5328 23.9381C26.3951 24.0601 26.2403 24.1211 26.051 24.1211C25.8618 24.1211 25.707 24.0514 25.5865 23.9294C25.4489 23.8074 25.3887 23.6506 25.3887 23.4588C25.3887 23.2671 25.4489 23.1103 25.5865 22.9883C25.707 22.8662 25.8618 22.8052 26.051 22.8052Z" fill="white"/>
</g>
</g>
</g>
</g>
<defs>
<filter id="filter0_b_3389_2351" x="-0.166992" y="0.666748" width="30.2227" height="21.1055" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImageFix" stdDeviation="2"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_3389_2351"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur_3389_2351" result="shape"/>
</filter>
<filter id="filter1_b_3389_2351" x="-28.9551" y="-34" width="110.02" height="110.02" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImageFix" stdDeviation="25"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_3389_2351"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur_3389_2351" result="shape"/>
</filter>
<linearGradient id="paint0_linear_3389_2351" x1="-8.6191" y1="15.9068" x2="20.9846" y2="34.5261" gradientUnits="userSpaceOnUse">
<stop stop-color="#0D53DE"/>
<stop offset="1" stop-color="#5246FF"/>
</linearGradient>
<linearGradient id="paint1_linear_3389_2351" x1="1.95006" y1="6.11183" x2="16.196" y2="21.7253" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
<linearGradient id="paint2_linear_3389_2351" x1="26.0549" y1="12.8531" x2="26.0024" y2="29.6744" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
</defs>
</svg>
<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Frame 1312318469">
<g id="Group 1312318395">
<g id="Polygon 11" filter="url(#filter0_b_3389_2363)">
<path d="M15.4853 18.3465L25.1366 7.6665H5.83398L15.4853 18.3465Z" fill="url(#paint0_linear_3389_2363)" fill-opacity="0.5"/>
</g>
<path id="Polygon 12" d="M15.4847 19.5808L10.4492 25.0319H20.5202L15.4847 19.5808Z" fill="url(#paint1_linear_3389_2363)" fill-opacity="0.3"/>
<g id="Group 1312318396">
<g id="Ellipse 2410" filter="url(#filter1_b_3389_2363)">
<circle cx="22.1881" cy="15.5684" r="5.01228" fill="url(#paint2_linear_3389_2363)" fill-opacity="0.8"/>
</g>
<path id="Union" fill-rule="evenodd" clip-rule="evenodd" d="M22.7153 15.0406V12.9302H21.6601V15.0406H19.5498V16.0958H21.6601V18.2063H22.7153V16.0958H24.8259V15.0406H22.7153Z" fill="white"/>
</g>
</g>
</g>
<defs>
<filter id="filter0_b_3389_2363" x="1.83398" y="3.6665" width="27.3027" height="18.6799" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImageFix" stdDeviation="2"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_3389_2363"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur_3389_2363" result="shape"/>
</filter>
<filter id="filter1_b_3389_2363" x="-32.8242" y="-39.4438" width="110.024" height="110.025" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feGaussianBlur in="BackgroundImageFix" stdDeviation="25"/>
<feComposite in2="SourceAlpha" operator="in" result="effect1_backgroundBlur_3389_2363"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_backgroundBlur_3389_2363" result="shape"/>
</filter>
<linearGradient id="paint0_linear_3389_2363" x1="4.19842" y1="8.84415" x2="15.7172" y2="22.3004" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
<linearGradient id="paint1_linear_3389_2363" x1="4.80602" y1="21.0541" x2="17.5463" y2="29.7848" gradientUnits="userSpaceOnUse">
<stop stop-color="#0D53DE"/>
<stop offset="1" stop-color="#5246FF"/>
</linearGradient>
<linearGradient id="paint2_linear_3389_2363" x1="22.1881" y1="7.40786" x2="22.1355" y2="24.2367" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
</defs>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
\ No newline at end of file
<svg width="84" height="84" viewBox="0 0 84 84" fill="none" xmlns="http://www.w3.org/2000/svg">
<g id="Frame 1312317176">
<g id="Group 1312316503">
<path id="Vector 2" d="M4.19922 45.0843L19.2327 27.332H62.2174L74.9123 45.0843H4.19922Z" fill="#D6DAE1"/>
<path id="Vector 3" d="M4.19922 55.7337L19.2327 38.2773H62.2174L74.9123 55.7337H4.19922Z" fill="#EFF2F4"/>
<path id="Rectangle 4" d="M4.19922 45.082H74.9123V71.4011H4.19922V45.082Z" fill="#D6DAE1"/>
<path id="Vector" d="M27.3008 42.1886C27.3008 42.1886 31.6288 21.2106 47.9877 22.1117C58.6237 22.6672 52.933 31.5185 47.5387 27.6078C40.2531 22.353 46.8737 12.158 58.3672 12.6165" stroke="white" stroke-width="1.4" stroke-miterlimit="10"/>
</g>
<path id="Polygon 1" d="M72.4199 13.1319L57.3994 19.1593L61.2849 12.8308L57.747 6.30166L72.4199 13.1319Z" fill="#005DFF"/>
<g id="Group 1312317183">
<line id="Line 1" x1="12.0223" y1="19.4777" x2="16.4771" y2="23.9325" stroke="white" stroke-width="1.4"/>
<line id="Line 2" x1="8.24367" y1="24.8864" x2="14.329" y2="26.5169" stroke="white" stroke-width="1.4"/>
<line id="Line 3" x1="18.816" y1="22.0288" x2="17.1855" y2="15.9435" stroke="white" stroke-width="1.4"/>
</g>
</g>
</svg>
<svg width="117" height="33" viewBox="0 0 117 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.4" d="M1.62333 12.0672C1.59143 11.9352 1.61643 11.7959 1.69224 11.6832L7.00309 3.7881C7.07068 3.68762 7.17347 3.6161 7.29119 3.58765L21.6677 0.113558C21.9277 0.050728 22.1894 0.210569 22.2522 0.470572L25.9139 15.6234C27.3912 21.7368 23.6329 27.8902 17.5196 29.3675C11.4062 30.8448 5.25278 27.0866 3.77548 20.9732L1.62333 12.0672Z" fill="url(#paint0_linear_4102_1070)"/>
<path d="M5.82617 8.67262C5.82617 8.53679 5.88321 8.4072 5.98337 8.31546L13.0001 1.88877C13.0894 1.80697 13.2061 1.7616 13.3272 1.7616H28.1175C28.385 1.7616 28.6018 1.97844 28.6018 2.24593V17.8349C28.6018 24.1243 23.5033 29.2228 17.214 29.2228C10.9247 29.2228 5.82617 24.1243 5.82617 17.8349V8.67262Z" fill="url(#paint1_linear_4102_1070)"/>
<path d="M12.3314 8.75272L5.94842 8.35474L13.0703 1.83537L13.3688 7.72672C13.3987 8.30987 12.9142 8.78905 12.3314 8.75272Z" fill="#5D76FF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.4163 15.0221V16.7333C20.4163 18.0609 19.34 19.1372 18.0124 19.1372C16.6848 19.1372 15.6085 18.0609 15.6085 16.7333V12.4552H12.7972V17.1407C12.7972 20.021 15.1321 22.3559 18.0124 22.3559C20.8927 22.3559 23.2276 20.021 23.2276 17.1407V12.4552L23.2276 15.0221H20.4163Z" fill="#0028FD"/>
<path d="M23.2276 13.8812H24.3684V15.0221L23.2276 15.0221L23.2276 13.8812Z" fill="#0028FD"/>
<path d="M20.4163 13.1886H22.2497V15.0221L20.4163 15.0221L20.4163 13.1886Z" fill="#0028FD"/>
<path d="M22.2497 12.2107H23.2276V13.1886L22.2497 13.1886L22.2497 12.2107Z" fill="#0028FD"/>
<path d="M23.798 10.581H24.4091V11.1922H23.798V10.581Z" fill="#0028FD"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M20.0864 14.9121V16.6233C20.0864 17.9509 19.0102 19.0272 17.6825 19.0272C16.3549 19.0272 15.2787 17.951 15.2787 16.6233V12.3453H12.4674V17.0308C12.4674 19.911 14.8023 22.2459 17.6825 22.2459C20.5628 22.2459 22.8977 19.911 22.8977 17.0308V12.3453L22.8977 14.9121H20.0864Z" fill="white"/>
<path d="M22.8977 13.7713H24.0385V14.9121L22.8977 14.9121L22.8977 13.7713Z" fill="white"/>
<path d="M20.0864 13.0786H21.9199V14.9121L20.0864 14.9121L20.0864 13.0786Z" fill="white"/>
<path d="M21.9199 12.1008H22.8977V13.0786L21.9199 13.0786L21.9199 12.1008Z" fill="white"/>
<path d="M23.4681 10.4711H24.0793V11.0822H23.4681V10.4711Z" fill="white"/>
<path d="M38.498 7.70654H43.5757L46.833 17.5265H46.9767L50.3299 7.70654H55.2638V24.3286H52.1741V10.7723H52.0304L48.4617 20.9754H45.2522L41.7075 10.7723H41.5638V24.3286H38.498V7.70654Z" fill="#2951F2"/>
<path d="M102.908 8.5108H106.093V18.2239C106.093 19.1975 106.355 19.9625 106.878 20.5189C107.498 21.2298 108.364 21.5852 109.475 21.5852C110.585 21.5852 111.451 21.2298 112.072 20.5189C112.595 19.9625 112.856 19.1975 112.856 18.2239V8.5108H116.041V17.9689C116.041 19.7307 115.633 21.1062 114.816 22.0952C114.244 22.8061 113.477 23.3548 112.513 23.7411C111.566 24.1275 110.553 24.3207 109.475 24.3207C108.397 24.3207 107.376 24.1275 106.412 23.7411C105.465 23.3548 104.705 22.8061 104.133 22.0952C103.317 21.1062 102.908 19.7307 102.908 17.9689V8.5108Z" fill="#2951F2"/>
<path d="M90.4883 24.3163V13.6627H93.49V15.2619C93.8509 14.573 94.2937 14.0809 94.8186 13.7857C95.3107 13.474 95.9012 13.3182 96.5901 13.3182C96.9838 13.3182 97.4103 13.4002 97.8696 13.5642L97.4759 16.3691C97.0986 16.1067 96.6311 15.9755 96.0734 15.9755C95.2041 15.9755 94.5398 16.2625 94.0805 16.8366C93.6868 17.3287 93.49 18.116 93.49 19.1986V24.3163H90.4883Z" fill="#2951F2"/>
<path d="M85.3342 20.5716L88.0899 21.0145C87.9751 21.3098 87.8193 21.605 87.6224 21.9003C87.442 22.1791 87.1549 22.5318 86.7613 22.9583C86.3676 23.3683 85.8345 23.7046 85.162 23.967C84.4895 24.2131 83.7185 24.3361 82.8492 24.3361C81.1761 24.3361 79.8147 23.8358 78.7649 22.8352C77.6495 21.7854 77.0918 20.3994 77.0918 18.6771C77.0918 16.9712 77.6331 15.577 78.7157 14.4944C79.7327 13.4938 81.0695 12.9935 82.7262 12.9935C84.5305 12.9935 85.9165 13.5758 86.8843 14.7404C87.7372 15.7574 88.1637 17.1516 88.1637 18.9232V19.1692H80.1919C80.1919 19.8909 80.3642 20.4896 80.7086 20.9653C81.2007 21.6378 81.9142 21.9741 82.8492 21.9741C83.9646 21.9741 84.7929 21.5066 85.3342 20.5716ZM80.2903 17.2501H85.3342C85.2194 16.5611 84.9159 16.0363 84.4239 15.6754C83.9482 15.2981 83.4069 15.1095 82.8 15.1095C82.2095 15.1095 81.6682 15.2981 81.1761 15.6754C80.7004 16.0527 80.4052 16.5775 80.2903 17.2501Z" fill="#2951F2"/>
<path d="M64.4902 24.3163V13.6627H67.492V15.0405C68.3121 13.8923 69.4111 13.3182 70.7889 13.3182C72.1832 13.3182 73.2329 13.7529 73.9383 14.6222C74.496 15.3112 74.7748 16.3117 74.7748 17.624V24.3163H71.7731V18.5097C71.7731 17.5091 71.5845 16.812 71.2072 16.4183C70.8627 16.0575 70.3953 15.877 69.8048 15.877C68.9846 15.877 68.3695 16.1887 67.9594 16.812C67.6478 17.3041 67.492 17.993 67.492 18.8788V24.3163H64.4902Z" fill="#2951F2"/>
<path d="M58.627 13.6622H61.6287V24.3159H58.627V13.6622Z" fill="#2951F2"/>
<path d="M58.6387 11.0709C58.6387 11.4795 58.7817 11.8335 59.0677 12.1331C59.3673 12.4191 59.7213 12.5621 60.1299 12.5621C60.5385 12.5621 60.8857 12.4191 61.1717 12.1331C61.4713 11.8335 61.6211 11.4795 61.6211 11.0709C61.6211 10.6624 61.4713 10.3151 61.1717 10.0291C60.8857 9.72948 60.5385 9.57968 60.1299 9.57968C59.7213 9.57968 59.3673 9.72948 59.0677 10.0291C58.7817 10.3151 58.6387 10.6624 58.6387 11.0709Z" fill="#2951F2"/>
<defs>
<linearGradient id="paint0_linear_4102_1070" x1="-1.1646" y1="8.74619" x2="26.2454" y2="15.8908" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
<linearGradient id="paint1_linear_4102_1070" x1="3.89633" y1="4.78963" x2="28.8613" y2="18.1727" gradientUnits="userSpaceOnUse">
<stop stop-color="#1543FE"/>
<stop offset="1" stop-color="#8C46FF"/>
</linearGradient>
</defs>
</svg>
import React, {
useState,
useEffect,
useImperativeHandle,
forwardRef,
} from "react";
import cls from "classnames";
interface SaveStatusProps {
className?: string;
}
export interface SaveStatusRef {
triggerSave: () => void;
reset: () => void; // 新增的重置方法
}
const SaveStatus = forwardRef<SaveStatusRef, SaveStatusProps>(
({ className }, ref) => {
const [lastSaveTime, setLastSaveTime] = useState<Date | null>(null);
const [showSaved, setShowSaved] = useState(false);
const [timeSinceLastSave, setTimeSinceLastSave] = useState(0);
useImperativeHandle(ref, () => ({
triggerSave: () => {
setLastSaveTime(new Date());
setShowSaved(true);
},
reset: () => {
// 新增的重置方法
setLastSaveTime(null);
setShowSaved(false);
setTimeSinceLastSave(0);
},
}));
useEffect(() => {
if (showSaved) {
const timer = setTimeout(() => {
setShowSaved(false);
}, 10000);
return () => clearTimeout(timer);
}
}, [showSaved]);
useEffect(() => {
const updateTimeSinceLastSave = () => {
if (lastSaveTime) {
const now = new Date();
const diffInMinutes = Math.floor(
(now.getTime() - lastSaveTime.getTime()) / 60000
);
if (diffInMinutes > 0) {
setTimeSinceLastSave(diffInMinutes);
}
}
};
const timer = setInterval(updateTimeSinceLastSave, 60000);
updateTimeSinceLastSave(); // 立即更新一次
return () => clearInterval(timer);
}, [lastSaveTime]);
return (
<div className={cls("flex items-center", className)}>
{showSaved && (
<span className="text-[#121316]/[0.6] text-[13px] leading-[24px]">
已保存
</span>
)}
{timeSinceLastSave > 0 && !showSaved && lastSaveTime && (
<span className="text-[#121316]/[0.6] text-[13px] leading-[24px]">
最近修改:{timeSinceLastSave} 分钟前
</span>
)}
{(showSaved ||
(timeSinceLastSave > 0 && !showSaved && lastSaveTime)) && (
<span className="w-[1px] h-[0.75rem] bg-[#D7D8DD] ml-[1rem] block"></span>
)}
</div>
);
}
);
export default SaveStatus;
.code-mirror {
:global {
.ͼ1 .cm-scroller {
overflow-x: visible !important;
border: none !important;
}
.cm-editor.cm-focused {
outline: none !important;
}
}
}
\ No newline at end of file
import React, { PropsWithChildren } from "react";
import ReactCodeMirror, { EditorView, Extension } from "@uiw/react-codemirror";
import { loadLanguage } from "@uiw/codemirror-extensions-langs";
import cls from "classnames";
import style from "./index.module.scss";
// import { scrollPastEnd } from "@codemirror/view";
interface IProps {
className?: string;
editable?: boolean;
language?: "json" | "markdown" | "yaml";
value: string;
onChange?: (value: string) => void;
lineWrapping?: boolean;
onBeforeChange?: (editor: any, data: any, value: any) => void;
}
const CodeMirror: React.FC<PropsWithChildren<IProps>> = ({
language = "markdown",
value,
className,
onChange,
lineWrapping,
onBeforeChange,
editable,
}) => {
// const noScrollPastEnd = scrollPastEnd();
const extensions = [
{
ext: EditorView.lineWrapping,
on: lineWrapping,
},
{
ext: loadLanguage(language),
on: true,
},
]
.map((i) => (i.on ? i.ext : null))
.filter(Boolean) as Extension[];
return (
<ReactCodeMirror
className={cls("odl-code-mirror", className, style.codeMirror)}
value={value}
theme="light"
basicSetup={{
lineNumbers: false,
highlightActiveLineGutter: false,
foldGutter: false,
highlightActiveLine: false,
// syntaxHighlighting: true,
}}
editable={editable}
extensions={extensions}
onChange={(v) => {
onChange?.(v);
}}
/>
);
};
export default React.memo(CodeMirror);
import { Component, ErrorInfo, ReactNode } from "react";
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
}
class ErrorBoundary extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(_: Error): State {
return { hasError: true };
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
console.error("ErrorBoundary caught an error:", error, errorInfo);
}
render() {
if (this.state.hasError) {
return (
this.props.children || (
<h1 className="text-red-500 flex items-center justify-center">
Error
</h1>
)
);
}
return this.props.children;
}
}
export default ErrorBoundary;
import { createFromIconfontCN } from "@ant-design/icons";
const IconFont = createFromIconfontCN({
scriptUrl: `/iconfont.js`,
});
export default IconFont;
import styles from './loadingAnimation.module.scss';
interface ILoadingAnimationProps {
className?: string;
}
const LoadingAnimation = (props: ILoadingAnimationProps) => {
const { className } = props;
return <div className={`${styles.loader} ${className}`}></div>;
};
export default LoadingAnimation;
.loader {
width: 14px;
height: 14px;
border-radius: 50%;
display: inline-block;
position: relative;
/* stylelint-disable-next-line alpha-value-notation */
background: linear-gradient(0deg, rgba(13,83,222,1) 0%, rgba(43,105,226,1) 30%, rgba(13, 20, 222, 0) 100%);
box-sizing: border-box;
animation: rotation 1.5s linear infinite;
}
.loader::after {
content: '';
box-sizing: border-box;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 10px;
height: 10px;
border-radius: 50%;
background: #fff;
}
@keyframes rotation {
0% { transform: rotate(0deg) }
100% { transform: rotate(360deg)}
}
.textTooltip {
:global {
.ant-tooltip-arrow {
// display: none !important;
}
.ant-tooltip-inner, .ant-tooltip-content, .ant-tooltip-inner-content {
padding: 0px !important;
border-radius: 4px !important;
overflow: hidden;
}
}
}
import { Popover, Tooltip } from 'antd';
import React, { useRef, useState } from 'react';
import styles from './index.module.scss';
import { RefObject } from 'react';
import { useIsomorphicLayoutEffect, useMemoizedFn } from 'ahooks';
export function useResizeEffect<T extends HTMLElement>(effect: (target: T) => void, targetRef: RefObject<T>) {
const fn = useMemoizedFn(effect);
useIsomorphicLayoutEffect(() => {
const target = targetRef.current;
if (!target) return;
if (window.ResizeObserver) {
let animationFrame: number;
const observer = new ResizeObserver(() => {
animationFrame = window.requestAnimationFrame(() => fn(target));
});
observer.observe(target);
return () => {
window.cancelAnimationFrame(animationFrame);
observer.disconnect();
};
} else {
fn(target);
}
}, [targetRef]);
}
interface ITextTooltip {
style?: React.CSSProperties;
str: string;
suffix?: React.ReactNode | string;
trigger?: 'hover' | 'click';
handleClick?: () => void;
}
export const TextTooltip = (props: ITextTooltip) => {
const { style = {}, str, trigger = 'click', suffix, handleClick } = props;
const rootRef = useRef<HTMLDivElement>(null);
const tooltipRef = useRef<HTMLDivElement>(null);
const [clickable, setClickable] = useState(false);
function calcEllipsised() {
// 没有被截断
if (tooltipRef!?.current!?.scrollWidth > tooltipRef!?.current!?.clientWidth) {
setClickable(true);
} else {
setClickable(false);
}
}
useResizeEffect(calcEllipsised, rootRef);
return (
<Tooltip
title={<div className="bg-black/[0.85] text-white p-[6px]">{str}</div>}
trigger={clickable ? trigger : ('' as 'click')}
overlayClassName={styles.textTooltip}
style={{ width: '100%' }}
zIndex={999999}
placement="right"
align={{
offset: [72, 0]
}}
>
<div style={{ width: '100%', ...style }} className="flex" ref={rootRef}>
<div className="text-ellipsis overflow-hidden whitespace-nowrap" ref={tooltipRef}>
<span onClick={() => handleClick?.()}>{str}</span>
</div>
{suffix}
</div>
</Tooltip>
);
};
// cl 2022/4/21 18:22
import { customUploadToOss } from "@/api/oss";
import { Upload as AntdUpload } from "antd";
import { DraggerProps, UploadProps } from "antd/es/upload";
import React from "react";
interface IProps extends UploadProps, DraggerProps {
isDragger?: boolean;
openRead?: boolean;
taskType?: string;
changeOption?: (option: any) => any;
}
const Upload: React.FC<IProps> = (props) => {
const { isDragger, openRead, taskType, changeOption, ...rest } = props;
const Component = isDragger ? AntdUpload.Dragger : AntdUpload;
return (
<Component
{...rest}
customRequest={(options: any) =>
customUploadToOss(changeOption ? changeOption?.(options) : options, {
openRead: openRead || false,
fileType: taskType || "pdf",
uploadType: "local",
})
}
>
{props.children}
</Component>
);
};
export default Upload;
export const PDF_DRIVE_MD = "pdf-drive-md";
export const MD_DRIVE_PDF = "pdf-drive-md";
export const ADD_TASK_LIST = "add-task-list";
export const UPDATE_TASK_LIST = "update-task-list";
export enum Language {
ZH_CN = "zh-CN",
EN_US = "en-US",
}
export const PDF_COLOR_PICKER = {
title: {
line: 'rgba(121, 124, 255, 1)',
fill: 'rgba(121, 124, 255, 0.4)'
},
text: {
line: 'rgba(230, 122, 171, 1)',
fill: 'rgba(230, 122, 171, 0.4)'
},
interline_equation: {
line: 'rgba(240, 240, 124, 1)',
fill: 'rgba(240, 240, 124, 0.4)'
},
discarded: {
line: 'rgba(164,164,164,1)',
fill: 'rgba(164,164,164,0.4)'
},
image: {
line: 'rgba(149, 226, 115, 1)',
fill: 'rgba(149, 226, 115, 0.4)'
},
table: {
line: 'rgba(230, 113, 230, 1)',
fill: 'rgba(230, 113, 230, 0.4)'
},
inline_equation: {
line: 'rgba(150, 232, 172, 1)',
fill: 'rgba(150, 232, 172, 0.4)'
}
};
export const DEFAULT_COLOR_SECTION = {
line: 'rgba(166, 113, 230, 1)',
fill: 'rgba(166, 113, 230, 0.4)'
};
export const PDF_TEMPLATE_URL_KEY = 't';
\ No newline at end of file
export enum Path {
Home = "/",
Settings = "/settings",
}
export enum SlotID {
AppBody = "app-body",
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment