提交 944889a6 编写于 作者: 雨爱无痕

Fix issue

上级 5ef2e013
......@@ -4,9 +4,11 @@ import { ResponseData } from '@/utils/request';
import { listProxy } from '@/views/proxy/service';
import {getCurrProxyId, setCurrProxyId} from "@/utils/cache";
import { get as getWorkspace } from "@/views/workspace/service";
import {listInterpreter} from "@/views/interpreter/service";
export interface ProxyData {
proxies: any[];
interpreters: any[];
proxyMap: Record<number, string>;
currProxy: any;
}
......@@ -15,11 +17,13 @@ export interface ModuleType extends StoreModuleType<ProxyData> {
state: ProxyData;
mutations: {
saveProxies: Mutation<any>;
saveInterpreters: Mutation<any>;
saveProxyMap: Mutation<any>;
saveCurrProxy: Mutation<any>;
};
actions: {
fetchProxies: Action<ProxyData, ProxyData>;
fetchInterpreters: Action<ProxyData, ProxyData>;
selectProxy: Action<ProxyData, ProxyData>;
fetchProxyByWorkspace: Action<ProxyData, ProxyData>;
};
......@@ -27,6 +31,7 @@ export interface ModuleType extends StoreModuleType<ProxyData> {
const initState: ProxyData = {
proxies: [],
interpreters: [],
proxyMap: {},
currProxy:{},
};
......@@ -42,6 +47,10 @@ const StoreModel: ModuleType = {
console.log('payload', payload);
state.proxies = payload;
},
saveInterpreters(state, payload) {
console.log('payload', payload);
state.interpreters = payload;
},
saveProxyMap(state, payload) {
console.log('payload', payload);
const map = {};
......@@ -84,6 +93,16 @@ const StoreModel: ModuleType = {
return false;
}
},
async fetchInterpreters({ commit, state }, params) {
try {
const response: ResponseData = await listInterpreter(state.currProxy.path);
const { data } = response;
commit('saveInterpreters', data);
return true;
} catch (error) {
return false;
}
},
async selectProxy({ commit }, payload) {
await setCurrProxyId(payload.currProxyId);
commit('saveCurrProxy', []);
......
......@@ -68,13 +68,10 @@ import {
withDefaults,
} from "vue";
import { useStore } from "vuex";
import { StateType } from "@/views/site/store";
import { momentUtcDef } from "@/utils/datetime";
import Table from "@/components/Table.vue";
import notification from "@/utils/notification";
import Modal from "@/utils/modal";
import Button from "@/components/Button.vue";
import LanguageSettings from "./LanguageSettings.vue";
import {listInterpreter, saveInterpreter, removeInterpreter} from "@/views/interpreter/service";
import FormInterpreter from "@/views/interpreter/FormInterpreter.vue";
import { getLangSettings } from "@/views/interpreter/service";
......@@ -108,6 +105,7 @@ onMounted(() => {
const store = useStore<{ global: GlobalData }>();
const serverUrl = computed<any>(() => store.state.global.serverUrl);
watch(serverUrl, () => {
console.log('watch serverUrl', serverUrl.value)
list()
......@@ -154,7 +152,7 @@ const setColumns = () => {
setColumns();
const showCreateInterpreterModal = ref(false);
let languageMap = ref<any>({});
const getInterpretersA = async () => {
const data = await getLangSettings(props.proxyInfo.path);
......@@ -219,6 +217,7 @@ const createInterpreter = (formData) => {
formInterpreter.value.clearFormData();
showCreateInterpreterModal.value = false;
list();
store.dispatch('proxy/fetchInterpreters', {})
}
}, (json) => { console.log(json) })
});
......@@ -230,6 +229,7 @@ const createInterpreter = (formData) => {
formInterpreter.value.clearFormData();
showCreateInterpreterModal.value = false;
list();
store.dispatch('proxy/fetchInterpreters', {})
}
}, (json) => { console.log(json) })
}
......
......@@ -10,7 +10,7 @@
class="padding-0-bottom"
:items="proxies"
keyName="id"
:checkedKey="currProxy.id"
:checkedKey="currProxy.id == undefined ? 0 : currProxy.id"
@click="selectProxy"
:replaceFields="replaceFields"
>
......
......@@ -90,7 +90,7 @@
<Button v-if="!record.value.is_default" @click="() => handleSetDefault(record)" class="tab-setting-btn" size="sm"
>{{ t("set_default") }}</Button>
<Button @click="() => createProxy(record)" class="tab-setting-btn" size="sm">{{
t("create_interpreter")
t("create_remote_proxy")
}}
</Button>
</template>
......@@ -170,7 +170,6 @@ const emit = defineEmits<{
const { t, locale } = useI18n();
const momentUtc = momentUtcDef;
const interpreters = ref<any>([]);
const remoteServers = ref<any>([]);
const editInfo = ref({});
......@@ -183,7 +182,9 @@ onMounted(() => {
const store = useStore<{ global: GlobalData, proxy: ProxyData }>();
store.dispatch("proxy/fetchProxies");
store.dispatch('proxy/fetchInterpreters')
const interpreters = computed<any>(() => store.state.proxy.interpreters);
const serverUrl = computed<any>(() => store.state.global.serverUrl);
watch(serverUrl, () => {
console.log('watch serverUrl', serverUrl.value)
......@@ -272,6 +273,7 @@ const showCreateInterpreterModal = ref(false);
const showCreateProxyModal = ref(false);
const showCreateServerModal = ref(false);
const showInterpreterModal = ref(false);
const defaultProxy = computed<any>(() => store.state.proxy.currProxy);
let languageMap = ref<any>({});
const getInterpretersA = async () => {
......@@ -282,17 +284,15 @@ getInterpretersA();
onMounted(() => {
console.log("onMounted");
list();
});
const list = () => {
const defaultProxy = computed<any>(() => store.state.proxy.currProxy);
listInterpreter(defaultProxy.value.path).then((json) => {
console.log("---", json);
watch(defaultProxy, () => {
console.log("watch default proxy")
list()
})
if (json.code === 0) {
interpreters.value = json.data;
}
});
const list = () => {
listServer().then((json) => {
if (json.code === 0) {
let defaultServerId = 0;
......@@ -312,7 +312,7 @@ const list = () => {
}
});
};
list();
const create = () => {
editInfo.value = {};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册