Switched to MPA powered by Razor Pages
After reconsidering where I want to take this project, I realized that a MPA is more fitting.
This commit is contained in:
2
Props/assets/js/main.js
Normal file
2
Props/assets/js/main.js
Normal file
@@ -0,0 +1,2 @@
|
||||
import "../../node_modules/bootstrap/js/dist/collapse";
|
||||
import "simplebar";
|
23
Props/assets/js/services/http.js
Normal file
23
Props/assets/js/services/http.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import axios from "axios";
|
||||
|
||||
let currentAuthorizationInterceptorID = null;
|
||||
|
||||
const apiHttp = axios.create({
|
||||
baseURL: window.location.origin + "/api",
|
||||
timeout: 3000,
|
||||
});
|
||||
|
||||
function addBearerTokenInterceptor(token) {
|
||||
currentAuthorizationInterceptorID = apiHttp.interceptors.request.use((config) => {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
return config;
|
||||
}, (err) => {
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
function removeBearerTokenInterceptor() {
|
||||
apiHttp.interceptors.request.eject(currentAuthorizationInterceptorID);
|
||||
}
|
||||
|
||||
export { apiHttp, addBearerTokenInterceptor, removeBearerTokenInterceptor };
|
31
Props/assets/js/services/persistence.js
Normal file
31
Props/assets/js/services/persistence.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const prefix = "Props";
|
||||
function put(key, value) {
|
||||
if (value == null) return false;
|
||||
try {
|
||||
localStorage.setItem(prefix + ":" + key, JSON.stringify(value));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function get(key) {
|
||||
if (!exists(key)) return null;
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(prefix + ":" + key));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function remove(key) {
|
||||
localStorage.removeItem(prefix + ":" + key);
|
||||
}
|
||||
|
||||
function exists(key) {
|
||||
return localStorage.getItem(prefix + ":" + key) != null;
|
||||
}
|
||||
|
||||
export { put, get, remove, exists };
|
1
Props/assets/js/specific/search.js
Normal file
1
Props/assets/js/specific/search.js
Normal file
@@ -0,0 +1 @@
|
||||
console.log("abc");
|
Reference in New Issue
Block a user