feat: frontend url setting

This commit is contained in:
Tristan Yang
2023-01-13 21:07:26 +08:00
parent cebe2f1414
commit 6ecffe557b
12 changed files with 135 additions and 94 deletions
@@ -1,17 +1,19 @@
import React, { PropsWithChildren } from 'react';
import { ReactElement } from 'react';
import { useGetServerVersionQuery } from '../../app/services/server';
import { compareVersion } from '../utils';
type Props = {
empty?: boolean,
version: string,
children: ReactElement
}
const ServerVersionChecker = ({ version, children }: PropsWithChildren<Props>) => {
const ServerVersionChecker = ({ empty = false, version, children }: Props) => {
const { data: currentVersion, isSuccess } = useGetServerVersionQuery();
if (!isSuccess) return null;
const res = compareVersion(currentVersion, version);
if (res < 0) return <div className='flex flex-col gap-2 items-start'>
<span className='text-gray-400 text-sm'>Server version:<strong className='font-bold'>{version}</strong> needed at least 🚨</span>
if (res < 0) return empty ? null : <div className='flex flex-col gap-2 items-start border border-solid border-orange-500 p-3 rounded-lg'>
<span className='text-gray-400 text-sm'>This function needs server version:<strong className='font-bold'>{version}</strong> at least 🚨</span>
<span className='text-gray-400 text-sm'>Your current version:<strong className='font-bold'>{currentVersion}</strong></span>
<span className='text-gray-400 text-sm'>Please upgrade the Server!</span>
<a className='text-blue-500 underline' href="https://doc.voce.chat/install/install-by-docker#update-vocechat-docker" target="_blank" rel="noopener noreferrer">How to Update VoceChat Server 📖 </a>