Giter Site home page Giter Site logo

Comments (5)

logue avatar logue commented on May 24, 2024

It is a specification that it remains displayed when a script error occurs and becomes inoperable.
This loading screen is processed on the Pinia side.

/**
* Show loading Overlay
*
* @param display - visibility
*/
function setLoading(display: boolean): void {
loading.value = display;
if (!display) {
// Reset Progress value
progress.value = null;
}
}

For example, when a communication error occurs in axios, it is necessary to implement a process to manually turn off the loading screen as follows.

import axios, { type AxiosProgressEvent, type AxiosResponse } from 'axios';
import { useGlobal } from '@/store';

axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
axios.defaults.headers.common.Accept = 'application/json';
axios.defaults.withCredentials = true;
axios.defaults.onUploadProgress = (progressEvent: AxiosProgressEvent): void => {
  const globalStore = useGlobal();
  if (progressEvent.progress && progressEvent.total) {
    globalStore.setProgress(
      Math.round((progressEvent.loaded * 100) / progressEvent.total)
    );
  } else {
    globalStore.setProgress(null);
  }
  nextTick();
};
axios.defaults.onDownloadProgress = (
  progressEvent: AxiosProgressEvent
): void => {
  const globalStore = useGlobal();
  if (progressEvent.progress && progressEvent.total) {
    globalStore.setProgress(
      Math.round((progressEvent.loaded * 100) / progressEvent.total)
    );
  } else {
    globalStore.setProgress(null);
  }
  nextTick();
};
axios.interceptors.request.use(request => {
  const globalStore = useGlobal();
  globalStore.setLoading(true);
  return request;
});
axios.interceptors.response.use(
  (response: AxiosResponse<any, any>) => {
    const globalStore = useGlobal();
    globalStore.setLoading(false);
    return response;
  },
  async error => {
    const globalStore = useGlobal();
    
    globalStore.setMessage('An unknown error has occurred.');
    globalStore.setLoading(false);
    // location.reload();
    throw new Error(error);
    globalStore.setLoading(false);
    console.log(error.response.data);
    return await Promise.reject(error);
  }
);

from vite-vuetify-ts-starter.

vcpstudio avatar vcpstudio commented on May 24, 2024

Recorded a video for a visual example:

2023-05-22 13-20-52

(Google Chrome 113.0.5672.127 64bit)

from vite-vuetify-ts-starter.

logue avatar logue commented on May 24, 2024

Fixed.

from vite-vuetify-ts-starter.

vcpstudio avatar vcpstudio commented on May 24, 2024

I liked the page loader indicator idea, but your fix removed it

from vite-vuetify-ts-starter.

logue avatar logue commented on May 24, 2024

This is a provisional measure.

Due to various reasons (TypeScript5 compatibility, vitest issues, etc.), this is a last resort for the significant delay in release.

Since the idea used in Vuetify2 was diverted as it is, there were parts that did not work properly.

from vite-vuetify-ts-starter.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.