aboutsummaryrefslogtreecommitdiff
path: root/src/main.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.ts')
-rw-r--r--src/main.ts31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main.ts b/src/main.ts
index 2886300..c3b6952 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -26,35 +26,42 @@ axios.interceptors.request.use(
axios.interceptors.response.use(
(res) => {
- return res;
+ return res
},
async (err) => {
- const originalConfig = err.config;
+ const originalConfig = err.config
- if (originalConfig.url !== "/auth/signin" && err.response) {
+ if (originalConfig.url !== '/auth/signin' && err.response) {
if (err.response.status === 401 && !originalConfig._retry) {
- originalConfig._retry = true;
+ originalConfig._retry = true
try {
- const rs = await axios.post("/auth/refresh", {
- RefreshToken: localStorage.getItem("refToken")
- });
+ const rs = await axios.post('/auth/refresh', {
+ RefreshToken: localStorage.getItem('refToken')
+ })
- localStorage.setItem("authToken", rs.data.auth_token)
+ localStorage.setItem('authToken', rs.data.auth_token)
- return axios(originalConfig);
+ return axios(originalConfig)
} catch (_error) {
- return Promise.reject(_error);
+ return Promise.reject(_error)
}
}
}
- return Promise.reject(err);
+ return Promise.reject(err)
}
-);
+)
const app = createApp(App)
app.use(router)
app.mount('#app')
+
+// use dark theme if system is in dark mode
+// flaky
+document.documentElement.setAttribute(
+ 'data-bs-theme',
+ window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
+)