mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
now user can login
This commit is contained in:
parent
e7960a6bf8
commit
e19001ca82
25 changed files with 493 additions and 32844 deletions
33
src/utils/api.js
Normal file
33
src/utils/api.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import axios from 'axios/index';
|
||||
|
||||
import { API } from '$constants/api';
|
||||
|
||||
const report = console.warn;
|
||||
|
||||
export const checkUserToken = ({
|
||||
callback, fallback, id, token
|
||||
}) => (
|
||||
axios.get(API.GET_GUEST, {
|
||||
params: { action: 'check_token', id, token }
|
||||
})
|
||||
.then(result => (result && result.data))
|
||||
.then(data => ({ ...data, id, token }))
|
||||
.then(callback)
|
||||
.catch(fallback)
|
||||
);
|
||||
export const getGuestToken = ({ callback }) => (
|
||||
axios.get(API.GET_GUEST, {
|
||||
params: { action: 'gen_guest_token' }
|
||||
})
|
||||
.then(result => (result && result.data))
|
||||
.then(callback)
|
||||
.catch(report)
|
||||
);
|
||||
|
||||
export const getMergedImage = ({ placement, callback }) => (
|
||||
axios.get(API.COMPOSE, {
|
||||
params: { placement }
|
||||
})
|
||||
.then(callback)
|
||||
.catch(report)
|
||||
);
|
25
src/utils/storage.js
Normal file
25
src/utils/storage.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
const canStore = typeof window.localStorage !== 'undefined'
|
||||
|
||||
export const storeData = (key, data) => {
|
||||
if (!canStore) return;
|
||||
|
||||
const value = JSON.stringify(data);
|
||||
|
||||
localStorage.setItem(key, value);
|
||||
};
|
||||
|
||||
export const getData = key => {
|
||||
if (!canStore) return;
|
||||
|
||||
let result = null;
|
||||
|
||||
try {
|
||||
result = JSON.parse(localStorage.getItem(key));
|
||||
} catch(e) {
|
||||
result = null;
|
||||
}
|
||||
|
||||
if (!result) return;
|
||||
|
||||
return result;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue