Files
new-api/web/src/pages/Chat/index.js
2024-08-17 16:17:24 +00:00

35 lines
989 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react';
import { useTokenKeys } from '../../components/fetchTokenKeys';
import { Layout } from '@douyinfe/semi-ui';
const ChatPage = () => {
const { keys, chatLink, serverAddress, isLoading } = useTokenKeys();
const comLink = (key) => {
if (!chatLink || !serverAddress || !key) return '';
return `${chatLink}/#/?settings={"key":"sk-${key}","url":"${encodeURIComponent(serverAddress)}"}`;
};
const iframeSrc = keys.length > 0 ? comLink(keys[0]) : '';
return !isLoading && iframeSrc ? (
<iframe
src={iframeSrc}
style={{ width: '100%', height: '85vh', border: 'none' }}
title="Token Frame"
/>
) : (
<div>
<Layout>
<Layout.Header>
<h3 style={{ color: 'red'}}>
当前没有可用的已启用令牌请确认是否有令牌处于启用状态<br />
正在跳转......
</h3>
</Layout.Header>
</Layout>
</div>
);
};
export default ChatPage;