index.js 641 B

1234567891011121314151617181920212223242526
  1. import React from 'react';
  2. import { useTokenKeys } from '../../components/fetchTokenKeys';
  3. const chat2page = () => {
  4. const { keys, chatLink, serverAddress, isLoading } = useTokenKeys();
  5. const comLink = (key) => {
  6. if (!chatLink || !serverAddress || !key) return '';
  7. return `${chatLink}/#/?settings={"key":"sk-${key}","url":"${encodeURIComponent(serverAddress)}"}`;
  8. };
  9. if (keys.length > 0) {
  10. const redirectLink = comLink(keys[0]);
  11. if (redirectLink) {
  12. window.location.href = redirectLink;
  13. }
  14. }
  15. return (
  16. <div>
  17. <h3>正在加载,请稍候...</h3>
  18. </div>
  19. );
  20. };
  21. export default chat2page;