mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-30 20:50:52 +08:00
227 lines
7.0 KiB
TypeScript
227 lines
7.0 KiB
TypeScript
import { createI18n } from 'vue-i18n'
|
|
|
|
import en from '@/i18n/locales/en.json'
|
|
import zhCN from '@/i18n/locales/zh-CN.json'
|
|
import zhTW from '@/i18n/locales/zh-TW.json'
|
|
import type { IStringKeyMap } from '#/types/types'
|
|
|
|
import { AliyunAreaCodeName, QiniuAreaCodeName, TencentAreaCodeName } from './bucketConfigCons'
|
|
type MessageSchema = typeof en
|
|
|
|
const i18n = createI18n<MessageSchema, 'en' | 'zh-CN' | 'zh-TW'>({
|
|
legacy: false,
|
|
locale: localStorage.getItem('currentLanguage') || 'zh-CN',
|
|
fallbackLocale: 'zh-CN',
|
|
messages: {
|
|
en,
|
|
'zh-CN': zhCN,
|
|
'zh-TW': zhTW
|
|
}
|
|
})
|
|
const { t } = i18n.global
|
|
|
|
export const newBucketConfig: IStringKeyMap = {
|
|
tcyun: {
|
|
name: t('MANAGE_NEW_BUCKET_TCYUN_NAME'),
|
|
icon: 'tcyun',
|
|
configOptions: {
|
|
BucketName: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_TCYUN_BUCKETNAME_DESC'),
|
|
placeholder: t('MANAGE_NEW_BUCKET_TCYUN_BUCKETNAME_PLACEHOLDER'),
|
|
paraType: 'string',
|
|
component: 'input',
|
|
default: 'piclist',
|
|
rule: [
|
|
{
|
|
required: true,
|
|
message: t('MANAGE_NEW_BUCKET_TCYUN_BUCKETNAME_RULE_MSG_A'),
|
|
trigger: 'blur'
|
|
},
|
|
{
|
|
validator: (rule: any, value: any, callback: any) => {
|
|
const reg = /^[a-z0-9][a-z0-9-]{1,21}[a-z0-9]$/
|
|
if (value.length > 23) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_TCYUN_BUCKETNAME_RULE_MSG_B')))
|
|
} else if (!reg.test(value)) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_TCYUN_BUCKETNAME_RULE_MSG_C')))
|
|
} else {
|
|
callback()
|
|
}
|
|
},
|
|
trigger: 'change'
|
|
}
|
|
]
|
|
},
|
|
region: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_TCYUN_REGION'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'ap-nanjing',
|
|
options: TencentAreaCodeName
|
|
},
|
|
acl: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_TCYUN_ACL_DESC'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'private',
|
|
options: {
|
|
private: t('MANAGE_NEW_BUCKET_TCYUN_ACL_PRIVATE'),
|
|
'public-read': t('MANAGE_NEW_BUCKET_TCYUN_ACL_PUBLIC_R'),
|
|
'public-read-write': t('MANAGE_NEW_BUCKET_TCYUN_ACL_PUBLIC_RW')
|
|
}
|
|
}
|
|
},
|
|
options: ['BucketName', 'region', 'acl']
|
|
},
|
|
aliyun: {
|
|
name: t('MANAGE_NEW_BUCKET_ALIYUN_NAME'),
|
|
icon: 'aliyun',
|
|
configOptions: {
|
|
BucketName: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_ALIYUN_BUCKETNAME_DESC'),
|
|
placeholder: t('MANAGE_NEW_BUCKET_ALIYUN_BUCKETNAME_PLACEHOLDER'),
|
|
paraType: 'string',
|
|
component: 'input',
|
|
default: 'piclist',
|
|
rule: [
|
|
{
|
|
required: true,
|
|
message: t('MANAGE_NEW_BUCKET_ALIYUN_BUCKETNAME_RULE_MSG_A'),
|
|
trigger: 'blur'
|
|
},
|
|
{
|
|
validator: (rule: any, value: any, callback: any) => {
|
|
const reg = /^[a-z0-9][a-z0-9-]{0,61}[a-z0-9]$/
|
|
if (value.length > 63) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_ALIYUN_BUCKETNAME_RULE_MSG_B')))
|
|
} else if (!reg.test(value)) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_ALIYUN_BUCKETNAME_RULE_MSG_C')))
|
|
} else {
|
|
callback()
|
|
}
|
|
},
|
|
trigger: 'change'
|
|
}
|
|
]
|
|
},
|
|
region: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_ALIYUN_REGION'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'oss-cn-hangzhou',
|
|
options: AliyunAreaCodeName
|
|
},
|
|
acl: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_ALIYUN_ACL_DESC'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'private',
|
|
options: {
|
|
private: t('MANAGE_NEW_BUCKET_ALIYUN_ACL_PRIVATE'),
|
|
publicRead: t('MANAGE_NEW_BUCKET_ALIYUN_ACL_PUBLIC_R'),
|
|
publicReadWrite: t('MANAGE_NEW_BUCKET_ALIYUN_ACL_PUBLIC_RW')
|
|
}
|
|
}
|
|
},
|
|
options: ['BucketName', 'region', 'acl']
|
|
},
|
|
qiniu: {
|
|
name: t('MANAGE_NEW_BUCKET_QINIU_NAME'),
|
|
icon: 'qiniu',
|
|
configOptions: {
|
|
BucketName: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_QINIU_BUCKETNAME_DESC'),
|
|
placeholder: t('MANAGE_NEW_BUCKET_QINIU_BUCKETNAME_PLACEHOLDER'),
|
|
paraType: 'string',
|
|
component: 'input',
|
|
default: 'piclist',
|
|
rule: [
|
|
{
|
|
required: true,
|
|
message: t('MANAGE_NEW_BUCKET_QINIU_BUCKETNAME_RULE_MSG_A'),
|
|
trigger: 'blur'
|
|
},
|
|
{
|
|
validator: (rule: any, value: any, callback: any) => {
|
|
const reg = /^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/
|
|
if (value.length > 63) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_QINIU_BUCKETNAME_RULE_MSG_B')))
|
|
} else if (!reg.test(value)) {
|
|
callback(new Error(t('MANAGE_NEW_BUCKET_QINIU_BUCKETNAME_RULE_MSG_C')))
|
|
} else {
|
|
callback()
|
|
}
|
|
},
|
|
trigger: 'change'
|
|
}
|
|
]
|
|
},
|
|
region: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_QINIU_REGION'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'z0',
|
|
options: QiniuAreaCodeName
|
|
},
|
|
acl: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_QINIU_ACL_DESC'),
|
|
paraType: 'boolean',
|
|
component: 'switch',
|
|
default: false
|
|
}
|
|
},
|
|
options: ['BucketName', 'region', 'acl']
|
|
},
|
|
s3plist: {
|
|
name: t('MANAGE_NEW_BUCKET_S3PLIST_NAME'),
|
|
icon: 's3plist',
|
|
configOptions: {
|
|
BucketName: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_S3PLIST_BUCKETNAME_DESC'),
|
|
placeholder: t('MANAGE_NEW_BUCKET_S3PLIST_BUCKETNAME_PLACEHOLDER'),
|
|
paraType: 'string',
|
|
component: 'input',
|
|
default: 'piclist',
|
|
rule: [
|
|
{
|
|
required: true,
|
|
message: t('MANAGE_NEW_BUCKET_S3PLIST_BUCKETNAME_RULE_MSG_A'),
|
|
trigger: 'blur'
|
|
}
|
|
]
|
|
},
|
|
region: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_S3PLIST_REGION'),
|
|
paraType: 'string',
|
|
component: 'input',
|
|
default: 'us-east-1'
|
|
},
|
|
acl: {
|
|
required: true,
|
|
description: t('MANAGE_NEW_BUCKET_S3PLIST_ACL_DESC'),
|
|
paraType: 'string',
|
|
component: 'select',
|
|
default: 'private',
|
|
options: {
|
|
private: t('MANAGE_NEW_BUCKET_S3PLIST_ACL_PRIVATE'),
|
|
'public-read': t('MANAGE_NEW_BUCKET_S3PLIST_ACL_PUBLIC_R'),
|
|
'public-read-write': t('MANAGE_NEW_BUCKET_S3PLIST_ACL_PUBLIC_RW'),
|
|
'authenticated-read': t('MANAGE_NEW_BUCKET_S3PLIST_ACL_AUTHENTICATED_READ')
|
|
}
|
|
}
|
|
},
|
|
options: ['BucketName', 'region', 'acl']
|
|
}
|
|
}
|