Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit a416d24

Browse files
committed
feat: add version & commit hash
for better debug experiences :)
1 parent 4049543 commit a416d24

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

src/components/Header.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
</router-link>
88
</div>
99
<div class="absolute bottom-8 text-slate-400 text-sm -translate-x-1/2 left-1/2">
10-
<a class="whitespace-nowrap" href="https://github.com/NaturalSelectionLabs" target="_blank"
11-
>@ Natural Selection Labs</a
12-
>
10+
<div>
11+
<el-tooltip placement="top" :content="`v${appVersion} #${commitHash}`"> CrossSync </el-tooltip>
12+
</div>
13+
<div>
14+
<a class="whitespace-nowrap" href="https://github.com/NaturalSelectionLabs" target="_blank">
15+
@ Natural Selection Labs
16+
</a>
17+
</div>
1318
</div>
1419
</template>
1520

1621
<script setup lang="ts">
1722
import logo from '../assets/logo.svg?raw';
23+
24+
const appVersion = __APP_VERSION__;
25+
const commitHash = __COMMIT_HASH__;
1826
</script>
1927
<style scoped></style>

src/types/env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ declare module '*.vue' {
66
const component: DefineComponent<{}, {}, any>;
77
export default component;
88
}
9+
10+
// Version related
11+
declare const __APP_VERSION__: string;
12+
declare const __COMMIT_HASH__: string;

vite.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ import { crx } from '@crxjs/vite-plugin';
99
import manifest from './manifest';
1010
import { viteCommonjs } from '@originjs/vite-plugin-commonjs';
1111

12+
import ChildProcess from 'child_process';
13+
1214
// const production = process.env.NODE_ENV === 'production';
1315

16+
const appVersion = JSON.stringify(process.env.npm_package_version);
17+
const commitHash = ChildProcess.execSync('git rev-parse --short HEAD').toString();
18+
1419
export default defineConfig({
1520
build: {
1621
rollupOptions: {
@@ -53,4 +58,8 @@ export default defineConfig({
5358
},
5459
}),
5560
],
61+
define: {
62+
__APP_VERSION__: appVersion,
63+
__COMMIT_HASH__: commitHash,
64+
},
5665
});

0 commit comments

Comments
 (0)