feat: show commit id (#331)

zio/stable
三咲智子 Kevin Deng 2022-12-05 02:18:39 +08:00 committed by GitHub
parent 4d23fb1467
commit a96d564eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
const buildTime = import.meta.env.__BUILD_TIME__ as string const buildTime = import.meta.env.__BUILD_TIME__ as string
const buildCommit = import.meta.env.__BUILD_COMMIT__ as string
const buildTimeDate = new Date(buildTime) const buildTimeDate = new Date(buildTime)
const timeAgoOptions = useTimeAgoOptions() const timeAgoOptions = useTimeAgoOptions()
@ -46,7 +47,18 @@ const buildTimeAgo = useTimeAgo(buildTime, timeAgoOptions)
<div> <div>
<i18n-t keypath="nav_footer.built_at"> <i18n-t keypath="nav_footer.built_at">
<time :datetime="buildTime" :title="$d(buildTimeDate, 'long')">{{ buildTimeAgo }}</time> <time :datetime="buildTime" :title="$d(buildTimeDate, 'long')">{{ buildTimeAgo }}</time>
</i18n-t> · <a href="https://github.com/elk-zone/elk" target="_blank">GitHub</a> </i18n-t>
·
<NuxtLink
v-if="buildCommit"
external
:href="`https://github.com/elk-zone/elk/commit/${buildCommit}`"
target="_blank"
font-mono
>
{{ buildCommit.slice(0, 7) }}
</NuxtLink>
· <a href="https://github.com/elk-zone/elk" target="_blank">GitHub</a>
</div> </div>
</footer> </footer>
</template> </template>

View File

@ -31,6 +31,7 @@ export default defineNuxtConfig({
vite: { vite: {
define: { define: {
'import.meta.env.__BUILD_TIME__': JSON.stringify(new Date().toISOString()), 'import.meta.env.__BUILD_TIME__': JSON.stringify(new Date().toISOString()),
'import.meta.env.__BUILD_COMMIT__': JSON.stringify(process.env.COMMIT_REF || ''),
'process.env.VSCODE_TEXTMATE_DEBUG': 'false', 'process.env.VSCODE_TEXTMATE_DEBUG': 'false',
'process.mock': ((isDevelopment || (isCI && process.env.PULL_REQUEST === 'true')) && process.env.MOCK_USER) || 'false', 'process.mock': ((isDevelopment || (isCI && process.env.PULL_REQUEST === 'true')) && process.env.MOCK_USER) || 'false',
}, },