-
-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support multiple instance translate service (#828)
* provides the ability to multiple instances of translate service from buildin * support openai translate service multiple instances * multiple instance in translate window * config translate service * add instance config name * display instanceName in translate window
- Loading branch information
Showing
17 changed files
with
285 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
export enum ServiceSourceType { | ||
BUILDIN = 'buildin', | ||
PLUGIN = 'plugin', | ||
} | ||
|
||
export function getServiceSouceType(serviceInstanceKey: string): ServiceSourceType { | ||
if (serviceInstanceKey.startsWith('[plugin]')) { | ||
return ServiceSourceType.PLUGIN | ||
} else { | ||
return ServiceSourceType.BUILDIN | ||
} | ||
} | ||
|
||
export function whetherPluginService(serviceInstanceKey: string): boolean { | ||
return getServiceSouceType(serviceInstanceKey) === ServiceSourceType.PLUGIN | ||
} | ||
|
||
|
||
// The serviceInstanceKey consists of the service name and it's id, separated by @ | ||
// In earlier versions, the @ separator and id were optional, so they all have only one instance. | ||
export function createServiceInstanceKey(serviceName: string): string { | ||
const randomId = Math.random().toString(36).substring(2) | ||
return `${serviceName}@${randomId}` | ||
} | ||
|
||
|
||
// if the serviceInstanceKey is from a plugin, serviceName is it's pluginId | ||
export function getServiceName(serviceInstanceKey: string): string { | ||
return serviceInstanceKey.split('@')[0] | ||
} | ||
|
||
export const INSTANCE_NAME_CONFIG_KEY = 'instanceName' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.