?
This commit is contained in:
31
Atomx.Admin/Atomx.Admin.Client/wwwroot/js/common.js
Normal file
31
Atomx.Admin/Atomx.Admin.Client/wwwroot/js/common.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function getCookie(name) {
|
||||
console.log("Getting cookie:", name);
|
||||
const value = `; ${document.cookie}`;
|
||||
console.log("Document cookie string:", value);
|
||||
const parts = value.split(`; ${name}=`);
|
||||
console.log("Cookie parts:", parts);
|
||||
if (parts.length === 2) {
|
||||
var text = parts.pop().split(';').shift();
|
||||
console.log("Cookie value found:", text);
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
||||
document.cookie = `${name}=${value}; expires=${expires}; path=/; SameSite=Strict; Secure`;
|
||||
}
|
||||
|
||||
function deleteCookie(name) {
|
||||
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
||||
}
|
||||
|
||||
// 获取浏览器语言
|
||||
function getBrowserLanguage() {
|
||||
return navigator.language || navigator.userLanguage || 'zh-Hans';
|
||||
}
|
||||
|
||||
// 设置HTML lang属性
|
||||
function setHtmlLang(lang) {
|
||||
document.documentElement.lang = lang;
|
||||
}
|
||||
Reference in New Issue
Block a user