This commit is contained in:
dap
2024-09-20 08:06:53 +08:00
69 changed files with 2200 additions and 1218 deletions

View File

@@ -24,6 +24,6 @@
"@vben/stores": "workspace:*",
"@vben/types": "workspace:*",
"@vben/utils": "workspace:*",
"vue": "^3.5.6"
"vue": "catalog:"
}
}

View File

@@ -35,15 +35,15 @@
"@vben/locales": "workspace:*",
"@vben/preferences": "workspace:*",
"@vben/types": "workspace:*",
"@vueuse/integrations": "^11.1.0",
"@vueuse/integrations": "catalog:",
"codemirror": "^6.0.1",
"qrcode": "^1.5.4",
"vue": "^3.5.6",
"qrcode": "catalog:",
"vue": "catalog:",
"vue-codemirror6": "^1.3.4",
"vue-json-pretty": "^2.4.0",
"vue-router": "^4.4.5"
"vue-router": "catalog:"
},
"devDependencies": {
"@types/qrcode": "^1.5.5"
"@types/qrcode": "catalog:"
}
}

View File

@@ -5,7 +5,7 @@ import { RotateCw } from '@vben/icons';
import { $t } from '@vben/locales';
import { VbenButton, VbenIconButton } from '@vben-core/shadcn-ui';
import { CaptchaCard } from '.';
import CaptchaCard from './captcha-card.vue';
import { useCaptchaPoints } from './hooks/useCaptchaPoints';
const props = withDefaults(defineProps<PointSelectionCaptchaProps>(), {

View File

@@ -25,8 +25,8 @@
"@vben/stores": "workspace:*",
"@vben/types": "workspace:*",
"@vben/utils": "workspace:*",
"vue": "^3.5.6",
"vue-router": "^4.4.5",
"watermark-js-plus": "^1.5.6"
"vue": "catalog:",
"vue-router": "catalog:",
"watermark-js-plus": "catalog:"
}
}

View File

@@ -185,6 +185,7 @@ export function useElementPlusDesignTokens() {
'--el-bg-color-page': getCssVariableValue('--background-deep'),
'--el-border-color': border,
'--el-border-color-dark': border,
'--el-border-color-extra-light': border,
'--el-border-color-hover': accent,
'--el-border-color-light': border,
'--el-border-color-lighter': border,
@@ -195,26 +196,36 @@ export function useElementPlusDesignTokens() {
'--el-color-danger-light-3': getCssVariableValue('--destructive-400'),
'--el-color-danger-light-5': getCssVariableValue('--destructive-300'),
'--el-color-danger-light-7': getCssVariableValue('--destructive-200'),
'--el-color-danger-light-8': getCssVariableValue('--destructive-100'),
'--el-color-danger-light-8': isDark.value
? border
: getCssVariableValue('--destructive-100'),
'--el-color-danger-light-9': isDark.value
? accent
: getCssVariableValue('--destructive-50'),
'--el-color-danger-light-9': getCssVariableValue('--destructive-50'),
'--el-color-error': getCssVariableValue('--destructive-500'),
'--el-color-error-dark-2': getCssVariableValue('--destructive'),
'--el-color-error-light-3': getCssVariableValue('--destructive-400'),
'--el-color-error-light-5': getCssVariableValue('--destructive-300'),
'--el-color-error-light-7': getCssVariableValue('--destructive-200'),
'--el-color-error-light-8': getCssVariableValue('--destructive-100'),
'--el-color-error-light-8': isDark.value
? border
: getCssVariableValue('--destructive-100'),
'--el-color-error-light-9': isDark.value
? accent
: getCssVariableValue('--destructive-50'),
'--el-color-error-light-9': getCssVariableValue('--destructive-50'),
'--el-color-info-light-8': border,
'--el-color-info-light-9': background,
'--el-color-primary': getCssVariableValue('--primary-500'),
'--el-color-primary-dark-2': getCssVariableValue('--primary'),
'--el-color-primary-light-3': getCssVariableValue('--primary-400'),
'--el-color-primary-light-5': getCssVariableValue('--primary-300'),
'--el-color-primary-light-7': getCssVariableValue('--primary-200'),
'--el-color-primary-light-8': getCssVariableValue('--primary-100'),
'--el-color-primary-light-8': isDark.value
? border
: getCssVariableValue('--primary-100'),
'--el-color-primary-light-9': isDark.value
? accent
: getCssVariableValue('--primary-50'),
@@ -224,17 +235,26 @@ export function useElementPlusDesignTokens() {
'--el-color-success-light-3': getCssVariableValue('--success-400'),
'--el-color-success-light-5': getCssVariableValue('--success-300'),
'--el-color-success-light-7': getCssVariableValue('--success-200'),
'--el-color-success-light-8': getCssVariableValue('--success-100'),
'--el-color-success-light-8': isDark.value
? border
: getCssVariableValue('--success-100'),
'--el-color-success-light-9': isDark.value
? accent
: getCssVariableValue('--success-50'),
'--el-color-success-light-9': getCssVariableValue('--success-50'),
'--el-color-warning': getCssVariableValue('--warning-500'),
'--el-color-warning-dark-2': getCssVariableValue('--warning'),
'--el-color-warning-light-3': getCssVariableValue('--warning-400'),
'--el-color-warning-light-5': getCssVariableValue('--warning-300'),
'--el-color-warning-light-7': getCssVariableValue('--warning-200'),
'--el-color-warning-light-8': getCssVariableValue('--warning-100'),
'--el-color-warning-light-8': isDark.value
? border
: getCssVariableValue('--warning-100'),
'--el-color-warning-light-9': isDark.value
? accent
: getCssVariableValue('--warning-50'),
'--el-color-warning-light-9': getCssVariableValue('--warning-50'),
'--el-fill-color': getCssVariableValue('--accent'),
'--el-fill-color-blank': background,
'--el-fill-color-light': getCssVariableValue('--accent'),
'--el-text-color-primary': getCssVariableValue('--foreground'),

View File

@@ -35,8 +35,8 @@
"@vben/stores": "workspace:*",
"@vben/types": "workspace:*",
"@vben/utils": "workspace:*",
"@vueuse/core": "^11.1.0",
"vue": "^3.5.6",
"vue-router": "^4.4.5"
"@vueuse/core": "catalog:",
"vue": "catalog:",
"vue-router": "catalog:"
}
}

View File

@@ -21,8 +21,8 @@
},
"dependencies": {
"@vben/preferences": "workspace:*",
"@vueuse/core": "^11.1.0",
"echarts": "^5.5.1",
"vue": "^3.5.6"
"@vueuse/core": "catalog:",
"echarts": "catalog:",
"vue": "catalog:"
}
}

View File

@@ -22,9 +22,9 @@
"dependencies": {
"@vben/locales": "workspace:*",
"@vben/utils": "workspace:*",
"axios": "^1.7.7"
"axios": "catalog:"
},
"devDependencies": {
"axios-mock-adapter": "^2.0.0"
"axios-mock-adapter": "catalog:"
}
}

View File

@@ -34,7 +34,7 @@ describe('fileUploader', () => {
mockAxiosInstance.post as unknown as ReturnType<typeof vi.fn>
).mockResolvedValueOnce(mockResponse);
const result = await fileUploader.upload(url, file);
const result = await fileUploader.upload(url, { file });
expect(result).toEqual(mockResponse);
expect(mockAxiosInstance.post).toHaveBeenCalledWith(
url,
@@ -66,7 +66,7 @@ describe('fileUploader', () => {
headers: { 'Custom-Header': 'value' },
};
const result = await fileUploader.upload(url, file, customConfig);
const result = await fileUploader.upload(url, { file }, customConfig);
expect(result).toEqual(mockResponse);
expect(mockAxiosInstance.post).toHaveBeenCalledWith(
url,
@@ -87,7 +87,7 @@ describe('fileUploader', () => {
mockAxiosInstance.post as unknown as ReturnType<typeof vi.fn>
).mockRejectedValueOnce(new Error('Network Error'));
await expect(fileUploader.upload(url, file)).rejects.toThrow(
await expect(fileUploader.upload(url, { file })).rejects.toThrow(
'Network Error',
);
});
@@ -99,7 +99,7 @@ describe('fileUploader', () => {
mockAxiosInstance.post as unknown as ReturnType<typeof vi.fn>
).mockRejectedValueOnce(new Error('Request failed with status code 404'));
await expect(fileUploader.upload(url, file)).rejects.toThrow(
await expect(fileUploader.upload(url, { file })).rejects.toThrow(
'Request failed with status code 404',
);
});
@@ -111,7 +111,7 @@ describe('fileUploader', () => {
mockAxiosInstance.post as unknown as ReturnType<typeof vi.fn>
).mockRejectedValueOnce(new Error('Request failed with status code 404'));
await expect(fileUploader.upload(url, file)).rejects.toThrow(
await expect(fileUploader.upload(url, { file })).rejects.toThrow(
'Request failed with status code 404',
);
});

View File

@@ -11,11 +11,14 @@ class FileUploader {
public async upload(
url: string,
file: Blob | File,
data: { file: Blob | File } & Record<string, any>,
config?: AxiosRequestConfig,
): Promise<AxiosResponse> {
const formData = new FormData();
formData.append('file', file);
Object.entries(data).forEach(([key, value]) => {
formData.append(key, value);
});
const finalConfig: AxiosRequestConfig = {
...config,

View File

@@ -79,7 +79,9 @@ describe('requestClient', () => {
: [400, { error: 'Bad Request' }];
});
const response = await requestClient.upload('/test/upload', fileData);
const response = await requestClient.upload('/test/upload', {
file: fileData,
});
expect(response.data).toEqual({ data: 'file uploaded' });
});