Implement color palette in Vue (#2047)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-25 21:41:48 -05:00
committed by GitHub
parent f1eee96ebc
commit db572a4085
29 changed files with 501 additions and 608 deletions

View File

@@ -1,9 +1,8 @@
import { t } from '@/i18n'
import { useToastStore } from '@/stores/toastStore'
import { useI18n } from 'vue-i18n'
export function useErrorHandling() {
const toast = useToastStore()
const { t } = useI18n()
const toastErrorHandler = (error: any) => {
toast.add({
@@ -15,12 +14,12 @@ export function useErrorHandling() {
}
const wrapWithErrorHandling =
(
action: (...args: any[]) => any,
<TArgs extends any[], TReturn>(
action: (...args: TArgs) => TReturn,
errorHandler?: (error: any) => void,
finallyHandler?: () => void
) =>
(...args: any[]) => {
(...args: TArgs): TReturn | undefined => {
try {
return action(...args)
} catch (e) {
@@ -31,12 +30,12 @@ export function useErrorHandling() {
}
const wrapWithErrorHandlingAsync =
(
action: ((...args: any[]) => Promise<any>) | ((...args: any[]) => any),
<TArgs extends any[], TReturn>(
action: (...args: TArgs) => Promise<TReturn> | TReturn,
errorHandler?: (error: any) => void,
finallyHandler?: () => void
) =>
async (...args: any[]) => {
async (...args: TArgs): Promise<TReturn | undefined> => {
try {
return await action(...args)
} catch (e) {