| import { RegionInfo } from "@/api/controllers/core.ts"; |
| import { BASE_URL_DREAMINA_US, BASE_URL_DREAMINA_HK, BASE_URL_IMAGEX_US, BASE_URL_IMAGEX_HK } from "@/api/consts/dreamina.ts"; |
|
|
| |
| |
| |
| |
| export class RegionUtils { |
| |
| |
| |
| static getServiceId(regionInfo: RegionInfo, providedServiceId?: string): string { |
| if (providedServiceId) { |
| return providedServiceId; |
| } |
|
|
| |
| if (regionInfo.isUS || regionInfo.isHK || regionInfo.isJP || regionInfo.isSG) { |
| return "wopfjsm1ax"; |
| } |
|
|
| |
| return "tb4s082cfz"; |
| } |
|
|
| |
| |
| |
| static getImageXUrl(regionInfo: RegionInfo): string { |
| if (regionInfo.isUS) { |
| return BASE_URL_IMAGEX_US; |
| } |
|
|
| if (regionInfo.isHK || regionInfo.isJP || regionInfo.isSG) { |
| return BASE_URL_IMAGEX_HK; |
| } |
|
|
| return 'https://imagex.bytedanceapi.com'; |
| } |
|
|
| |
| |
| |
| static getOrigin(regionInfo: RegionInfo): string { |
| if (regionInfo.isUS) { |
| return new URL(BASE_URL_DREAMINA_US).origin; |
| } |
|
|
| if (regionInfo.isHK || regionInfo.isJP || regionInfo.isSG) { |
| return new URL(BASE_URL_DREAMINA_HK).origin; |
| } |
|
|
| return 'https://jimeng.jianying.com'; |
| } |
|
|
| |
| |
| |
| static getAWSRegion(regionInfo: RegionInfo): string { |
| if (regionInfo.isUS) { |
| return 'us-east-1'; |
| } |
|
|
| if (regionInfo.isHK || regionInfo.isJP || regionInfo.isSG) { |
| return 'ap-southeast-1'; |
| } |
|
|
| return 'cn-north-1'; |
| } |
|
|
| |
| |
| |
| static getRefererPath(regionInfo: RegionInfo, path: string = '/ai-tool/generate'): string { |
| const origin = this.getOrigin(regionInfo); |
| return `${origin}${path}`; |
| } |
| } |
|
|