diff --git a/src/hooks/useConfig.jsx b/src/hooks/useConfig.jsx
index 1f1f31125a..5559507ff2 100644
--- a/src/hooks/useConfig.jsx
+++ b/src/hooks/useConfig.jsx
@@ -13,7 +13,8 @@ export const useConfig = (key, defaultValue, options = {}) => {
debounce((v) => {
store.set(key, v);
store.save();
- emit(`${key}_changed`, v);
+ let eventKey = key.replaceAll('.', '_').replaceAll('@', ':');
+ emit(`${eventKey}_changed`, v);
}),
[]
);
@@ -44,8 +45,8 @@ export const useConfig = (key, defaultValue, options = {}) => {
// 初始化
useEffect(() => {
syncToState(null);
- if (key.includes('[')) return;
- const unlisten = listen(`${key}_changed`, (e) => {
+ const eventKey = key.replaceAll('.', '_').replaceAll('@', ':');
+ const unlisten = listen(`${eventKey}_changed`, (e) => {
syncToState(e.payload);
});
return () => {
diff --git a/src/services/translate/alibaba/Config.jsx b/src/services/translate/alibaba/Config.jsx
index 953103d7e1..a34f608b3e 100644
--- a/src/services/translate/alibaba/Config.jsx
+++ b/src/services/translate/alibaba/Config.jsx
@@ -1,3 +1,4 @@
+import { INSTANCE_NAME_CONFIG_KEY } from '../../../utils/service_instance';
import { Input, Button } from '@nextui-org/react';
import toast, { Toaster } from 'react-hot-toast';
import { useTranslation } from 'react-i18next';
@@ -10,10 +11,12 @@ import { translate } from './index';
import { Language } from './index';
export function Config(props) {
- const { updateServiceList, onClose } = props;
+ const { instanceKey, updateServiceList, onClose } = props;
+ const { t } = useTranslation();
const [config, setConfig] = useConfig(
- 'alibaba',
+ instanceKey,
{
+ [INSTANCE_NAME_CONFIG_KEY]: t('services.translate.alibaba.title'),
accesskey_id: '',
accesskey_secret: '',
},
@@ -21,7 +24,6 @@ export function Config(props) {
);
const [isLoading, setIsLoading] = useState(false);
- const { t } = useTranslation();
const toastStyle = useToastStyle();
return (
@@ -34,7 +36,7 @@ export function Config(props) {
() => {
setIsLoading(false);
setConfig(config, true);
- updateServiceList('alibaba');
+ updateServiceList(instanceKey);
onClose();
},
(e) => {
@@ -45,6 +47,25 @@ export function Config(props) {
}}
>