feat: show sdk version (#5)

This commit is contained in:
鲁树人
2023-05-15 00:09:54 +01:00
parent 3c0a9433dd
commit 0a7a095b9f
4 changed files with 46 additions and 4 deletions

20
src/SDKVersion.tsx Normal file
View File

@@ -0,0 +1,20 @@
import { InfoOutlineIcon } from '@chakra-ui/icons';
import { Tooltip } from '@chakra-ui/react';
import { workerClientBus } from './decrypt-worker/client';
import { DECRYPTION_WORKER_ACTION_NAME } from './decrypt-worker/constants';
import usePromise from 'react-promise-suspense';
const getSDKVersion = async () => {
const version = workerClientBus.request(DECRYPTION_WORKER_ACTION_NAME.VERSION, null);
return `SDK: ${version}`;
};
export function SDKVersion() {
const sdkVersion = usePromise(getSDKVersion, []);
return (
<Tooltip hasArrow placement="top" label={sdkVersion} bg="gray.300" color="black">
<InfoOutlineIcon />
</Tooltip>
);
}