mirror of
https://github.com/PlayEdu/h5.git
synced 2025-12-25 21:49:54 +08:00
项目初始化
This commit is contained in:
52
src/utils/index.ts
Normal file
52
src/utils/index.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
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 + "/";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user