forked from visiky/resume
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复 window undefined 的情况,导致部署不成功
- Loading branch information
Showing
2 changed files
with
6 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { windowIsDefined } from '@/helpers/detect-device'; | ||
import { getSearchObj } from '@/helpers/location'; | ||
|
||
/** | ||
* 获取语言 | ||
*/ | ||
export function getLanguage(): string { | ||
const query = getSearchObj(); | ||
const lang = (query.lang as string) || navigator.language || 'zh-CN'; | ||
const lang = | ||
(query.lang as string) || | ||
(windowIsDefined() ? navigator?.language : 'zh-CN') || | ||
'zh-CN'; | ||
typeof document !== 'undefined' && document.body.setAttribute('lang', lang); | ||
return lang; | ||
} |