PlayEdu-h5/src/utils/index.ts
2023-06-25 11:25:39 +08:00

53 lines
1.3 KiB
TypeScript

import moment from "moment";
export function getToken(): string {
return window.localStorage.getItem("playedu-h5-token") || "";
}
export function setToken(token: string) {
window.localStorage.setItem("playedu-h5-token", token);
}
export function clearToken() {
window.localStorage.removeItem("playedu-h5-token");
}
export function dateFormat(dateStr: string) {
return moment(dateStr).format("YYYY-MM-DD HH:mm");
}
export function getHost() {
return window.location.protocol + "//" + window.location.host + "/";
}
export function getDepKey(): string {
return window.localStorage.getItem("playedu-h5-depatmentKey") || "";
}
export function setDepKey(token: string) {
window.localStorage.setItem("playedu-h5-depatmentKey", token);
}
export function clearDepKey() {
window.localStorage.removeItem("playedu-h5-depatmentKey");
}
export function getDepName(): string {
return window.localStorage.getItem("playedu-h5-depatmentName") || "";
}
export function setDepName(token: string) {
window.localStorage.setItem("playedu-h5-depatmentName", token);
}
export function clearDepName() {
window.localStorage.removeItem("playedu-frontend-depatmentName");
}
export function changeAppUrl(str: string) {
let key = str.slice(str.length - 1);
if (key === "/") {
return str;
} else {
return str + "/";
}
}