feat: display app version in setting panel (#3170)

This commit is contained in:
Alex Yang
2023-07-12 10:39:00 +08:00
committed by GitHub
parent 4f88774999
commit bbb1387469
4 changed files with 52 additions and 39 deletions
+5
View File
@@ -13,6 +13,9 @@ import { blockSuiteFeatureFlags, buildFlags } from './preset.config.mjs';
import { getCommitHash, getGitVersion } from './scripts/git-info.mjs';
const require = createRequire(import.meta.url);
const packageJson = require('./package.json');
const appVersion = packageJson.version;
const editorVersion = packageJson.dependencies['@blocksuite/editor'];
const { createVanillaExtractPlugin } = require('@vanilla-extract/next-plugin');
const withVanillaExtract = createVanillaExtractPlugin();
@@ -102,6 +105,8 @@ const nextConfig = {
publicRuntimeConfig: {
PROJECT_NAME: process.env.npm_package_name ?? 'AFFiNE',
BUILD_DATE: new Date().toISOString(),
appVersion,
editorVersion,
gitVersion: getGitVersion(),
hash: getCommitHash(),
serverAPI: profileTarget.local,
@@ -26,45 +26,49 @@ export const AboutAffine = () => {
subtitle={t['com.affine.settings.about.message']()}
data-testid="about-title"
/>
{runtimeConfig.enableNewSettingUnstableApi && environment.isDesktop ? (
<SettingWrapper title={t['Version']()}>
<SettingRow
name={t['Check for updates']()}
desc={t['New version is ready']()}
></SettingRow>
<SettingRow
name={t['Check for updates automatically']()}
desc={t['com.affine.settings.about.update.check.message']()}
>
<Switch
checked={appSettings.autoCheckUpdate}
onChange={checked => changeSwitch('autoCheckUpdate', checked)}
/>
</SettingRow>
<SettingRow
name={t['Download updates automatically']()}
desc={t['com.affine.settings.about.update.download.message']()}
>
<Switch
checked={appSettings.autoCheckUpdate}
onChange={checked => changeSwitch('autoCheckUpdate', checked)}
/>
</SettingRow>
<SettingRow
name={t[`Discover what's new`]()}
desc={t['View the AFFiNE Changelog.']()}
style={{ cursor: 'pointer' }}
onClick={() => {
window.open(
'https://affine.pro/blog/whats-new-affine-0630',
'_blank'
);
}}
>
<ArrowRightSmallIcon />
</SettingRow>
</SettingWrapper>
) : null}
<SettingWrapper title={t['Version']()}>
<SettingRow name="App Version" desc={runtimeConfig.appVersion} />
<SettingRow name="Editor Version" desc={runtimeConfig.editorVersion} />
{runtimeConfig.enableNewSettingUnstableApi && environment.isDesktop ? (
<>
<SettingRow
name={t['Check for updates']()}
desc={t['New version is ready']()}
></SettingRow>
<SettingRow
name={t['Check for updates automatically']()}
desc={t['com.affine.settings.about.update.check.message']()}
>
<Switch
checked={appSettings.autoCheckUpdate}
onChange={checked => changeSwitch('autoCheckUpdate', checked)}
/>
</SettingRow>
<SettingRow
name={t['Download updates automatically']()}
desc={t['com.affine.settings.about.update.download.message']()}
>
<Switch
checked={appSettings.autoCheckUpdate}
onChange={checked => changeSwitch('autoCheckUpdate', checked)}
/>
</SettingRow>
<SettingRow
name={t[`Discover what's new`]()}
desc={t['View the AFFiNE Changelog.']()}
style={{ cursor: 'pointer' }}
onClick={() => {
window.open(
'https://affine.pro/blog/whats-new-affine-0630',
'_blank'
);
}}
>
<ArrowRightSmallIcon />
</SettingRow>
</>
) : null}
</SettingWrapper>
<SettingWrapper title={t['Contact with us']()}>
<a className={link} href="https://affine.pro" target="_blank">
{t['Official Website']()}
+2
View File
@@ -93,6 +93,8 @@ export const publicRuntimeConfigSchema = buildFlagsSchema.extend({
PROJECT_NAME: z.string(),
BUILD_DATE: z.string(),
gitVersion: z.string(),
appVersion: z.string(),
editorVersion: z.string(),
hash: z.string(),
serverAPI: z.string(),
editorFlags: blockSuiteFeatureFlags,
+2
View File
@@ -11,6 +11,8 @@ export default function getConfig() {
BUILD_DATE: '2021-09-01T00:00:00.000Z',
gitVersion: 'UNKNOWN',
hash: 'UNKNOWN',
appVersion: '0.0.0',
editorVersion: '0.0.0',
serverAPI: 'http://127.0.0.1:3000/',
editorFlags: blockSuiteFeatureFlags,
...buildFlags,