fix: footer date in edgeone without cloudflare env
This commit is contained in:
@@ -22,13 +22,6 @@ onBeforeMount(() => {
|
|||||||
<span m="l-1" class="inline-flex" style="margin-top: 1px;">B 站</span>
|
<span m="l-1" class="inline-flex" style="margin-top: 1px;">B 站</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div mt-2>
|
|
||||||
本站点由
|
|
||||||
<a color="#F6821F" href="https://www.cloudflare-cn.com/" target="_blank" title="Cloudflare" border="b-1 dashed">
|
|
||||||
<span>Cloudflare</span>
|
|
||||||
</a>
|
|
||||||
提供 CDN 支持
|
|
||||||
</div>
|
|
||||||
<div m="t-2" opacity="80" class="flex items-center justify-center">
|
<div m="t-2" opacity="80" class="flex items-center justify-center">
|
||||||
©️ <a href="https://github.com/YunYouJun/cook" target="_blank">Cook</a>
|
©️ <a href="https://github.com/YunYouJun/cook" target="_blank">Cook</a>
|
||||||
<div text="xs" m="x-1" i-ri-cloud-line />
|
<div text="xs" m="x-1" i-ri-cloud-line />
|
||||||
|
|||||||
13
app/components/footer/CdnSupport.vue
Normal file
13
app/components/footer/CdnSupport.vue
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
// migrate to 腾讯云 EdgeOne
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div mt-2>
|
||||||
|
本站点由
|
||||||
|
<a color="#F6821F" href="https://www.cloudflare-cn.com/" target="_blank" title="Cloudflare" border="b-1 dashed">
|
||||||
|
<span>Cloudflare</span>
|
||||||
|
</a>
|
||||||
|
提供 CDN 支持
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
import pkg from '~/../package.json'
|
import pkg from '~/../package.json'
|
||||||
|
|
||||||
const commitSha = (import.meta.env.VITE_COMMIT_REF || '').slice(0, 7)
|
const commitSha = (import.meta.env.VITE_COMMIT_REF || '').slice(0, 7)
|
||||||
const now = import.meta.env.VITE_APP_BUILD_TIME
|
const date = import.meta.env.VITE_APP_BUILD_DATE
|
||||||
const buildDate = (new Date(Number.parseInt(now))).toLocaleDateString()
|
const buildDate = (new Date(date)).toLocaleDateString()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -2,14 +2,22 @@ import process from 'node:process'
|
|||||||
import { pwa } from './app/config/pwa'
|
import { pwa } from './app/config/pwa'
|
||||||
import { appDescription } from './app/constants/index'
|
import { appDescription } from './app/constants/index'
|
||||||
|
|
||||||
Object.assign(process.env, {
|
// for cloudflare
|
||||||
VITE_COMMIT_REF: process.env.CF_PAGES_COMMIT_SHA || '',
|
// Object.assign(process.env, {
|
||||||
})
|
// VITE_COMMIT_REF: process.env.CF_PAGES_COMMIT_SHA || '',
|
||||||
|
// })
|
||||||
|
|
||||||
|
import { getLatestCommit } from './scripts/git'
|
||||||
|
|
||||||
|
const latestCommit = await getLatestCommit()
|
||||||
|
/**
|
||||||
|
* CF_PAGES_COMMIT_SHA is Cloudflare Pages env
|
||||||
|
*/
|
||||||
|
import.meta.env.VITE_COMMIT_REF = process.env.CF_PAGES_COMMIT_SHA || latestCommit?.hash || ''
|
||||||
|
// add build date string to env
|
||||||
|
import.meta.env.VITE_APP_BUILD_DATE = latestCommit?.date || new Date().toString()
|
||||||
|
|
||||||
// add build time to env
|
|
||||||
import.meta.env.VITE_APP_BUILD_TIME = new Date().getTime().toString()
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
'@vueuse/nuxt',
|
'@vueuse/nuxt',
|
||||||
'@unocss/nuxt',
|
'@unocss/nuxt',
|
||||||
|
|||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -146,7 +146,11 @@ importers:
|
|||||||
specifier: ^3.0.5
|
specifier: ^3.0.5
|
||||||
version: 3.0.5(typescript@5.9.2)
|
version: 3.0.5(typescript@5.9.2)
|
||||||
|
|
||||||
scripts: {}
|
scripts:
|
||||||
|
devDependencies:
|
||||||
|
simple-git:
|
||||||
|
specifier: ^3.28.0
|
||||||
|
version: 3.28.0
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -8484,7 +8488,7 @@ snapshots:
|
|||||||
|
|
||||||
'@kwsites/file-exists@1.1.1':
|
'@kwsites/file-exists@1.1.1':
|
||||||
dependencies:
|
dependencies:
|
||||||
debug: 4.4.0
|
debug: 4.4.1
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -14375,7 +14379,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@kwsites/file-exists': 1.1.1
|
'@kwsites/file-exists': 1.1.1
|
||||||
'@kwsites/promise-deferred': 1.1.1
|
'@kwsites/promise-deferred': 1.1.1
|
||||||
debug: 4.4.0
|
debug: 4.4.1
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
|||||||
17
scripts/git.ts
Normal file
17
scripts/git.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { simpleGit } from 'simple-git'
|
||||||
|
|
||||||
|
const git = simpleGit()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get git repo latest commit
|
||||||
|
*/
|
||||||
|
export async function getLatestCommit() {
|
||||||
|
try {
|
||||||
|
const log = await git.log({ maxCount: 1 })
|
||||||
|
return log.latest
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error('Error fetching latest commit:', error)
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,5 +3,8 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"convert": "tsx convert.ts"
|
"convert": "tsx convert.ts"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"simple-git": "^3.28.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user