mirror of
https://github.com/rustfs/console.git
synced 2026-09-19 09:52:25 +08:00
feat: 新的登录页 & 修复剪贴板问题
This commit is contained in:
@@ -17,6 +17,11 @@ export default defineNuxtPlugin({
|
||||
} catch (error) {
|
||||
finalConfig = useRuntimeConfig().public
|
||||
}
|
||||
|
||||
if (!finalConfig.api.baseURL) {
|
||||
throw new Error('API URL is not defined in the configuration.')
|
||||
}
|
||||
|
||||
return {
|
||||
provide: {
|
||||
siteConfig: finalConfig
|
||||
|
||||
@@ -15,6 +15,7 @@ export default defineNuxtPlugin({
|
||||
const client = new S3Client({
|
||||
endpoint: siteConfig.s3.endpoint,
|
||||
region: siteConfig.s3.region || 'us-east-1',
|
||||
forcePathStyle: true,
|
||||
// https://github.com/aws/aws-sdk-js-v3/issues/6834#issuecomment-2611346849
|
||||
requestChecksumCalculation: "WHEN_REQUIRED",
|
||||
credentials: {
|
||||
@@ -24,6 +25,26 @@ export default defineNuxtPlugin({
|
||||
}
|
||||
});
|
||||
|
||||
// 添加中间件捕捉 401 错误
|
||||
client.middlewareStack.add(
|
||||
(next, context) => async (args) => {
|
||||
try {
|
||||
return await next(args);
|
||||
} catch (error: any) {
|
||||
if (error?.$metadata?.httpStatusCode === 401) {
|
||||
await useAuth().logoutAndRedirect();
|
||||
}
|
||||
// 其他错误处理
|
||||
console.error('S3Client error:', error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
{
|
||||
step: "finalizeRequest",
|
||||
name: "handleUnauthorizedMiddleware",
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
provide: {
|
||||
s3Client: client
|
||||
|
||||
Reference in New Issue
Block a user