chore: update deploy logic (#22189)

chore: update deploy
This commit is contained in:
0song
2025-09-16 20:25:46 +08:00
committed by GitHub
parent eef0aed8bc
commit bcb395da5e
4 changed files with 20 additions and 49 deletions

View File

@@ -69,7 +69,7 @@ jobs:
git-config-email: element-plus@outlook.com
commit-message: website deploy
- name: Deploy to vercel
- name: Deploy to Vercel
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
token: ${{ secrets.EP_BOT_TOKEN }}
@@ -79,7 +79,12 @@ jobs:
git-config-name: ElementPlusBot
git-config-email: element-plus@outlook.com
- name: Sync
env:
TRIGGERSYNCURL: ${{ secrets.TRIGGERSYNCURL }}
run: curl -k "$TRIGGERSYNCURL"
- name: Deploy to Vercel Main
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
token: ${{ secrets.EP_BOT_TOKEN }}
branch: main
folder: docs/.vitepress/dist
repository-name: element-plus/vercel-publish-main
git-config-name: ElementPlusBot
git-config-email: element-plus@outlook.com

View File

@@ -76,7 +76,7 @@ jobs:
git-config-email: element-plus@outlook.com
commit-message: website deploy
- name: Deploy to vercel
- name: Deploy to Vercel
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
token: ${{ secrets.EP_BOT_TOKEN }}
@@ -86,7 +86,12 @@ jobs:
git-config-name: ElementPlusBot
git-config-email: element-plus@outlook.com
- name: Sync
env:
TRIGGERSYNCURL: ${{ secrets.TRIGGERSYNCURL }}
run: curl -k "$TRIGGERSYNCURL"
- name: Deploy to Vercel Main
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
token: ${{ secrets.EP_BOT_TOKEN }}
branch: main
folder: docs/.vitepress/dist
repository-name: element-plus/vercel-publish-main
git-config-name: ElementPlusBot
git-config-email: element-plus@outlook.com

View File

@@ -1,8 +1,3 @@
import fs from 'fs'
import path from 'path'
import { vpRoot } from '@element-plus/build-utils'
import { languages } from '../utils/lang'
import type { HeadConfig } from 'vitepress'
export const head: HeadConfig[] = [
@@ -49,15 +44,6 @@ export const head: HeadConfig[] = [
content: 'codeva-q5gBxYcfOs',
},
],
[
'script',
{},
`;(() => {
window.supportedLangs = ${JSON.stringify(languages)}
})()`,
],
['script', {}, fs.readFileSync(path.resolve(vpRoot, 'lang.js'), 'utf-8')],
[
'script',
{

View File

@@ -1,25 +0,0 @@
;(() => {
const supportedLangs = window.supportedLangs
const cacheKey = 'preferred_lang'
const defaultLang = 'en-US'
const handleNavigatorLang = (navLang) => {
const { language, region } = new Intl.Locale(navLang).maximize()
return `${language}-${region}`
}
let userPreferredLang =
localStorage.getItem(cacheKey) || handleNavigatorLang(navigator.language)
const language = supportedLangs.includes(userPreferredLang)
? userPreferredLang
: defaultLang
localStorage.setItem(cacheKey, language)
userPreferredLang = language
if (!location.pathname.startsWith(`/${userPreferredLang}`)) {
const toPath = [`/${userPreferredLang}`]
.concat(location.pathname.split('/').slice(2))
.join('/')
location.pathname =
toPath.endsWith('.html') || toPath.endsWith('/')
? toPath
: toPath.concat('/')
}
})()