mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-19 03:04:05 +00:00
Add HTTP client wrapper and upgrade Axios to v1 (#594)
* refactor: add HTTP client wrapper and upgrade axios to v1 Introduce a thin HTTP wrapper (resources/scripts/http) that centralizes axios configuration, interceptors, and auth header injection. All 43 files now import from the wrapper instead of axios directly, making future library swaps a single-file change. Upgrade axios from 0.30.0 to 1.14.0. * fix: restore window.Ls assignment removed during axios refactor company.js uses window.Ls.set() to persist selected company, which broke after the axios plugin (that set window.Ls) was deleted.
This commit is contained in:
committed by
GitHub
parent
a38f09cf7b
commit
691178857f
@@ -41,7 +41,7 @@
|
||||
</template>
|
||||
|
||||
<script type="text/babel" setup>
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { reactive, ref, computed } from 'vue'
|
||||
import { required, email, helpers } from '@vuelidate/validators'
|
||||
import { useVuelidate } from '@vuelidate/core'
|
||||
@@ -74,7 +74,7 @@ async function onSubmit(e) {
|
||||
if (!v$.value.$invalid) {
|
||||
try {
|
||||
isLoading.value = true
|
||||
let res = await axios.post('/api/v1/auth/password/email', formData)
|
||||
let res = await http.post('/api/v1/auth/password/email', formData)
|
||||
if (res.data) {
|
||||
notificationStore.showNotification({
|
||||
type: 'success',
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -96,8 +96,6 @@ const getInputType = computed(() => {
|
||||
})
|
||||
|
||||
async function onSubmit() {
|
||||
axios.defaults.withCredentials = true
|
||||
|
||||
v$.value.$touch()
|
||||
|
||||
if (v$.value.$invalid) {
|
||||
|
||||
@@ -58,7 +58,7 @@ import useVuelidate from '@vuelidate/core'
|
||||
import { required, email, minLength, sameAs } from '@vuelidate/validators'
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { handleError } from '@/scripts/helpers/error-handling'
|
||||
|
||||
@@ -141,7 +141,7 @@ async function onSubmit(e) {
|
||||
token: route.params.token,
|
||||
}
|
||||
isLoading.value = true
|
||||
let res = await axios.post('/api/v1/auth/reset/password', data)
|
||||
let res = await http.post('/api/v1/auth/reset/password', data)
|
||||
isLoading.value = false
|
||||
if (res.data) {
|
||||
notificationStore.showNotification({
|
||||
|
||||
@@ -673,7 +673,7 @@ import { useRoute } from 'vue-router'
|
||||
import { useDialogStore } from '@/scripts/stores/dialog'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import moment from 'moment'
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import ModulePlaceholder from './partials/ModulePlaceholder.vue'
|
||||
import RecentModuleCard from './partials/RecentModuleCard.vue'
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
@@ -853,7 +853,7 @@ async function installModule() {
|
||||
module: moduleData.value.module_name,
|
||||
}
|
||||
|
||||
let requestResponse = await axios.post(currentStep.stepUrl, updateParams)
|
||||
let requestResponse = await http.post(currentStep.stepUrl, updateParams)
|
||||
|
||||
currentStep.completed = true
|
||||
if (requestResponse.data) {
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
|
||||
<script setup>
|
||||
import { useNotificationStore } from '@/scripts/stores/notification'
|
||||
import axios from 'axios'
|
||||
import http from '@/scripts/http'
|
||||
import LoadingIcon from '@/scripts/components/icons/LoadingIcon.vue'
|
||||
import { reactive, ref, onMounted, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
@@ -301,7 +301,7 @@ window.addEventListener('beforeunload', (event) => {
|
||||
|
||||
// Created
|
||||
|
||||
axios.get('/api/v1/app/version').then((res) => {
|
||||
http.get('/api/v1/app/version').then((res) => {
|
||||
currentVersion.value = res.data.version
|
||||
insiderChannel.value = res.data.channel === 'insider'
|
||||
})
|
||||
@@ -344,7 +344,7 @@ function statusClass(step) {
|
||||
async function checkUpdate() {
|
||||
try {
|
||||
isCheckingforUpdate.value = true
|
||||
let response = await axios.get('/api/v1/check/update', {
|
||||
let response = await http.get('/api/v1/check/update', {
|
||||
params: {
|
||||
channel: insiderChannel ? 'insider' : ''
|
||||
}
|
||||
@@ -409,7 +409,7 @@ function onUpdateApp() {
|
||||
path: path || null,
|
||||
}
|
||||
|
||||
let requestResponse = await axios.post(
|
||||
let requestResponse = await http.post(
|
||||
currentStep.stepUrl,
|
||||
updateParams
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user