-
-
Notifications
You must be signed in to change notification settings - Fork 10k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: support detect new version and upgrade action (#282)
- Loading branch information
Showing
14 changed files
with
201 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Alert, Button } from 'antd'; | ||
import Link from 'next/link'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { MANUAL_UPGRADE_URL } from '@/const/version'; | ||
import { useGlobalStore } from '@/store/global'; | ||
|
||
const UpgradeAlert = memo(() => { | ||
const [hasNewVersion, latestVersion] = useGlobalStore((s) => [s.hasNewVersion, s.latestVersion]); | ||
const { t } = useTranslation('common'); | ||
|
||
return ( | ||
hasNewVersion && ( | ||
<Alert | ||
action={ | ||
<Link href={MANUAL_UPGRADE_URL} target={'_blank'}> | ||
<Button size={'small'} type={'primary'}> | ||
{t('upgradeVersion.action')} | ||
</Button> | ||
</Link> | ||
} | ||
banner | ||
closable | ||
message={t('upgradeVersion.newVersion', { version: latestVersion })} | ||
type={'info'} | ||
/> | ||
) | ||
); | ||
}); | ||
|
||
export default UpgradeAlert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pkg from '@/../package.json'; | ||
|
||
export const CURRENT_VERSION = pkg.version; | ||
|
||
export const MANUAL_UPGRADE_URL = | ||
'https://github.com/lobehub/lobe-chat/blob/main/docs/Upstream-Sync.md'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
fetch('https://registry.npmmirror.com/@lobehub/chat'); | ||
const VERSION_URL = 'https://registry.npmmirror.com/@lobehub/chat'; | ||
|
||
/** | ||
* get latest version from npm | ||
*/ | ||
export const featLatestVersion = async (): Promise<string> => { | ||
const res = await fetch(VERSION_URL); | ||
const data = await res.json(); | ||
|
||
return data['dist-tags']?.latest; | ||
}; |
Oops, something went wrong.