Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

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

Alex Yangbbb1387469ed
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index 74184d5200..ccec807151 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -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,
diff --git a/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx b/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx
index 83730f1645..bfe667588d 100644
--- a/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx
+++ b/apps/web/src/components/affine/setting-modal/general-setting/about/index.tsx
@@ -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']()}
diff --git a/packages/env/src/global.ts b/packages/env/src/global.ts
index 1b3d09ce4a..c96df851be 100644
--- a/packages/env/src/global.ts
+++ b/packages/env/src/global.ts
@@ -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,
diff --git a/scripts/vitest/next-config-mock.ts b/scripts/vitest/next-config-mock.ts
index 3f41511ca1..ce3c55c84d 100644
--- a/scripts/vitest/next-config-mock.ts
+++ b/scripts/vitest/next-config-mock.ts
@@ -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,