fix types
Gitea Actions Demo / build_and_push (push) Successful in 1m38s Details

This commit is contained in:
artem 2024-09-17 16:28:30 +03:00
parent 2038ca5322
commit 8b8f5fc3c1
4 changed files with 19 additions and 15 deletions

View File

@ -8,6 +8,7 @@ import router from "./router";
import vuesticGlobalConfig from "./services/vuestic-ui/global-config"; import vuesticGlobalConfig from "./services/vuestic-ui/global-config";
import App from "./App.vue"; import App from "./App.vue";
import axios from 'axios'; import axios from 'axios';
import { AxiosResponse } from "axios";
const HOST = "https://cycle-rider.ru"; const HOST = "https://cycle-rider.ru";
// const HOST = "http://localhost:8000"; // const HOST = "http://localhost:8000";
@ -31,7 +32,7 @@ axiosAuth.interceptors.request.use(
return Promise.reject(error) return Promise.reject(error)
} }
); );
function httpErrorHandler(error) { function httpErrorHandler(error: any) {
if (error === null) throw new Error('Unrecoverable error!! Error is null!') if (error === null) throw new Error('Unrecoverable error!! Error is null!')
if (axios.isAxiosError(error)) { if (axios.isAxiosError(error)) {
//here we have a type guard check, error inside this if will be treated as AxiosError //here we have a type guard check, error inside this if will be treated as AxiosError
@ -65,7 +66,7 @@ function responseHandler(response: AxiosResponse<any>) {
return response return response
} }
function responseErrorHandler(response) { function responseErrorHandler(response: any) {
const config = response?.config const config = response?.config
if (config.raw) { if (config.raw) {
return response return response

View File

@ -18,8 +18,9 @@ import { inject } from 'vue'
import { ref } from "vue"; import { ref } from "vue";
import { useForm, useToast } from "vuestic-ui"; import { useForm, useToast } from "vuestic-ui";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import { AxiosResponse, AxiosInstance } from "axios";
const axiosAuth = inject('axiosAuth'); const axiosAuth = inject('axiosAuth') as AxiosInstance;
const form = useForm("passwordForm"); const form = useForm("passwordForm");
const code = ref(""); const code = ref("");
const router = useRouter(); const router = useRouter();
@ -33,7 +34,7 @@ const submit = () => {
email: email.value, email: email.value,
code: code.value, code: code.value,
}) })
.then((response) => { .then((response: AxiosResponse) => {
localStorage.setItem('token', response.data.token); localStorage.setItem('token', response.data.token);
localStorage.setItem('profile', JSON.stringify(response.data.profile)); localStorage.setItem('profile', JSON.stringify(response.data.profile));
@ -41,7 +42,7 @@ const submit = () => {
localStorage.setItem('attachments', JSON.stringify(response.data.attachments)); localStorage.setItem('attachments', JSON.stringify(response.data.attachments));
router.push({ name: "dashboard" }).catch((error) => { }); router.push({ name: "dashboard" }).catch((error) => { });
}).catch((error) => { }).catch((error: any) => {
if (error.response.data.detail.code_string == "ObjectNotFound") { if (error.response.data.detail.code_string == "ObjectNotFound") {
init({ init({
message: "Неверный код", message: "Неверный код",

View File

@ -25,13 +25,14 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { AxiosResponse, AxiosInstance } from "axios";
import { inject } from 'vue' import { inject } from 'vue'
import { VaFileUpload } from "vuestic-ui"; import { VaFileUpload } from "vuestic-ui";
import { useUserStore } from "../../../stores/user-store"; import { useUserStore } from "../../../stores/user-store";
import { useToast } from "vuestic-ui/web-components"; import { useToast } from "vuestic-ui/web-components";
import { ref } from 'vue'; import { ref } from 'vue';
const axiosAuth = inject('axiosAuth'); const axiosAuth = inject('axiosAuth') as AxiosInstance;
const store = useUserStore(); const store = useUserStore();
const { init } = useToast(); const { init } = useToast();
const avatar = ref(store.avatar); const avatar = ref(store.avatar);
@ -51,7 +52,7 @@ let file: {
function onFileChanged() { function onFileChanged() {
var formData = new FormData(); var formData = new FormData();
formData.append("file", file); formData.append("file", file);
axiosAuth.post(`/api/v0/attachment/upload`, formData, ).then(function (response) { axiosAuth.post(`/api/v0/attachment/upload`, formData, ).then(function (response: AxiosResponse) {
let dataUser = JSON.parse(localStorage.getItem("user")!); let dataUser = JSON.parse(localStorage.getItem("user")!);
dataUser["attachment_id"] = response.data.id; dataUser["attachment_id"] = response.data.id;
store.changeAvatar(response.data.url); store.changeAvatar(response.data.url);
@ -60,10 +61,10 @@ function onFileChanged() {
.patch(`/api/v0/profiles/${store.profileID}`, { .patch(`/api/v0/profiles/${store.profileID}`, {
"user": dataUser, "user": dataUser,
}) })
.then((response) => { .then((response: any) => {
init({ message: "Фото успешно загружено!", color: "success" }); init({ message: "Фото успешно загружено!", color: "success" });
}) })
.catch((error) => { .catch((error: any) => {
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",
@ -71,7 +72,7 @@ function onFileChanged() {
}); });
}) })
.catch(function (error) { .catch(function (error: any) {
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",

View File

@ -10,11 +10,12 @@
/> />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { AxiosResponse, AxiosInstance } from "axios";
import { inject } from 'vue' import { inject } from 'vue'
import { VaFileUpload } from "vuestic-ui"; import { VaFileUpload } from "vuestic-ui";
import { useToast } from "vuestic-ui/web-components"; import { useToast } from "vuestic-ui/web-components";
const axiosAuth = inject('axiosAuth'); const axiosAuth= inject('axiosAuth') as AxiosInstance;
const { init } = useToast(); const { init } = useToast();
let file: { let file: {
@ -36,7 +37,7 @@ function onFileChanged() {
headers: { headers: {
'Authorization': `Bearer ${localStorage.getItem("token")}`, 'Authorization': `Bearer ${localStorage.getItem("token")}`,
} }
}).then(function (response) { }).then(function (response: AxiosResponse) {
axiosAuth axiosAuth
.post(`/api/v0/workouts`, { .post(`/api/v0/workouts`, {
"attachment_id": response.data.id, "attachment_id": response.data.id,
@ -44,10 +45,10 @@ function onFileChanged() {
}, { }, {
headers: { Authorization: `Bearer ${localStorage.getItem("token")}` } headers: { Authorization: `Bearer ${localStorage.getItem("token")}` }
}) })
.then((response) => { .then((response: AxiosResponse) => {
init({ message: "Тренировка успешно загружена!", color: "success" }); init({ message: "Тренировка успешно загружена!", color: "success" });
}) })
.catch((error) => { .catch((error: any) => {
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",
@ -55,7 +56,7 @@ function onFileChanged() {
}); });
}) })
.catch(function (error) { .catch(function (error: any) {
init({ init({
message: "Что-то пошло не так.", message: "Что-то пошло не так.",
color: "error", color: "error",