added logs

This commit is contained in:
Ayaka
2022-10-17 21:16:45 +00:00
parent 26f17de24c
commit 7dafaebbde
6 changed files with 116 additions and 7 deletions

56
package-lock.json generated
View File

@@ -15,6 +15,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
@@ -5373,6 +5374,29 @@
"node": ">=4"
}
},
"node_modules/axios": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz",
"integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@@ -14159,6 +14183,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
@@ -21007,6 +21036,28 @@
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.3.tgz",
"integrity": "sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w=="
},
"axios": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.1.3.tgz",
"integrity": "sha512-00tXVRwKx/FZr/IDVFt4C+f9FYairX517WoGCL6dpOntqLkZofjhu43F/Xl44UOpqa+9sLFDrG/XAnFsUYgkDA==",
"requires": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
},
"dependencies": {
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@@ -27196,6 +27247,11 @@
}
}
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",

View File

@@ -10,6 +10,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",

View File

@@ -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
View File

@@ -0,0 +1,3 @@
{
"apiUrl": "https://st-api-o2v8.onrender.com"
}

18
src/utils/config.js Normal file
View 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
View 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;