added logs
This commit is contained in:
15
src/App.jsx
15
src/App.jsx
@@ -8,18 +8,17 @@ import Button from "@mui/material/Button";
|
||||
import Switch from "@mui/material/Switch";
|
||||
import Picker from "./components/Picker";
|
||||
import Info from "./components/Info";
|
||||
import getConfiguration from "./utils/config";
|
||||
import log from "./utils/log";
|
||||
|
||||
const { ClipboardItem } = window;
|
||||
|
||||
function App() {
|
||||
// unregister service worker because skill issue
|
||||
useEffect(() => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.getRegistrations().then(function (registrations) {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
try {
|
||||
getConfiguration();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -125,6 +124,7 @@ function App() {
|
||||
link.download = `${characters[character].name}_st.ayaka.one.png`;
|
||||
link.href = canvas.toDataURL();
|
||||
link.click();
|
||||
log(characters[character].id, characters[character].name, "download");
|
||||
};
|
||||
|
||||
function b64toBlob(b64Data, contentType = null, sliceSize = null) {
|
||||
@@ -151,6 +151,7 @@ function App() {
|
||||
"image/png": b64toBlob(canvas.toDataURL().split(",")[1]),
|
||||
}),
|
||||
]);
|
||||
log(characters[character].id, characters[character].name, "copy");
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
3
src/config.json
Normal file
3
src/config.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"apiUrl": "https://st-api-o2v8.onrender.com"
|
||||
}
|
||||
18
src/utils/config.js
Normal file
18
src/utils/config.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import axios from "axios";
|
||||
import config from "../config.json";
|
||||
|
||||
async function getConfiguration() {
|
||||
const key = localStorage.getItem("x-key");
|
||||
const responce = await axios.get(`${config.apiUrl}/config`, {
|
||||
headers: {
|
||||
"x-key": key,
|
||||
},
|
||||
});
|
||||
if (responce.data.key) {
|
||||
localStorage.setItem("x-key", responce.data.key);
|
||||
}
|
||||
console.log(responce.data);
|
||||
return responce.data;
|
||||
}
|
||||
|
||||
export default getConfiguration;
|
||||
30
src/utils/log.js
Normal file
30
src/utils/log.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import axios from "axios";
|
||||
import config from "../config";
|
||||
|
||||
async function log(id, name, type) {
|
||||
const key = localStorage.getItem("x-key");
|
||||
try {
|
||||
const responce = await axios.post(
|
||||
`${config.apiUrl}/log`,
|
||||
{
|
||||
id: id,
|
||||
name: name,
|
||||
type: type,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"x-key": key,
|
||||
},
|
||||
}
|
||||
);
|
||||
if (responce.data.key) {
|
||||
localStorage.setItem("x-key", responce.data.key);
|
||||
}
|
||||
console.log(responce.data);
|
||||
return responce.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
export default log;
|
||||
Reference in New Issue
Block a user