项目初始化

This commit is contained in:
禺狨
2023-06-25 11:25:39 +08:00
commit 87f82475aa
39 changed files with 893 additions and 0 deletions

52
src/utils/index.ts Normal file
View 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 + "/";
}
}