Delay loading and toast 待æDone
This commit is contained in:
@@ -3,8 +3,13 @@ import loadingStore from './loading.js';
|
||||
import pinia from '@/stores/main.js'
|
||||
import axios from "axios";
|
||||
import moment from 'moment';
|
||||
import {useToast} from 'vue-toast-notification';
|
||||
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||
|
||||
const loading = loadingStore(pinia);
|
||||
const $toast = useToast();
|
||||
// Delay loading and toast 待模組化
|
||||
let delay = s => new Promise((resolve, reject) => setTimeout(resolve, s));
|
||||
|
||||
export default defineStore('filesStore', {
|
||||
state: () => ({
|
||||
@@ -67,8 +72,16 @@ export default defineStore('filesStore', {
|
||||
})
|
||||
if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} catch(error) {
|
||||
loading.isLoading = true;
|
||||
this.httpStatus = error.request.status;
|
||||
delay().then(() =>{
|
||||
loading.isLoading = true;
|
||||
return delay(1000);
|
||||
}).then(()=>{
|
||||
loading.isLoading = false;
|
||||
return delay(500);
|
||||
}).then(() => {
|
||||
$toast.default('Import Filter files error.');
|
||||
})
|
||||
};
|
||||
},
|
||||
/**
|
||||
@@ -88,8 +101,16 @@ export default defineStore('filesStore', {
|
||||
});
|
||||
if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} catch(error) {
|
||||
loading.isLoading = true;
|
||||
this.httpStatus = error.request.status;
|
||||
delay().then(() =>{
|
||||
loading.isLoading = true;
|
||||
return delay(1000);
|
||||
}).then(()=>{
|
||||
loading.isLoading = false;
|
||||
return delay(500);
|
||||
}).then(() => {
|
||||
$toast.default('Import Filter files error.');
|
||||
})
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { createPinia } from 'pinia';
|
||||
|
||||
const pinia = createPinia();
|
||||
|
||||
export default pinia;
|
||||
|
||||
Reference in New Issue
Block a user