优化
This commit is contained in:
@@ -59,6 +59,9 @@ export default {
|
||||
countryRequired: 'Please enter country name',
|
||||
countrySetSuccess: 'Country Set Successfully',
|
||||
unknown: 'Unknown',
|
||||
editCountry: 'Edit Country',
|
||||
editCountryPrompt: 'Please enter country name (in Chinese)',
|
||||
editCountryTitle: 'Edit Country',
|
||||
},
|
||||
hostList: {
|
||||
placeCountry: 'Select country',
|
||||
@@ -176,6 +179,9 @@ export default {
|
||||
countryRequired: 'Please enter country name',
|
||||
countrySetSuccess: 'Country Set Successfully',
|
||||
unknown: 'Unknown',
|
||||
editCountry: 'Edit Country',
|
||||
editCountryPrompt: 'Please enter country name (in Chinese)',
|
||||
editCountryTitle: 'Edit Country',
|
||||
},
|
||||
countries: {
|
||||
// ... (truncated common countries for brevity, or include all if critical. I'll include a subset or all if possible. The file read showed all.)
|
||||
|
||||
@@ -59,6 +59,9 @@ export default {
|
||||
countryRequired: '请输入国家名称',
|
||||
countrySetSuccess: '国家设置成功',
|
||||
unknown: '未知',
|
||||
editCountry: '编辑国家',
|
||||
editCountryPrompt: '请输入国家名称(中文)',
|
||||
editCountryTitle: '编辑国家',
|
||||
},
|
||||
hostList: {
|
||||
placeCountry: '选择国家',
|
||||
@@ -176,6 +179,9 @@ export default {
|
||||
countryRequired: '请输入国家名称',
|
||||
countrySetSuccess: '国家设置成功',
|
||||
unknown: '未知',
|
||||
editCountry: '编辑国家',
|
||||
editCountryPrompt: '请输入国家名称(中文)',
|
||||
editCountryTitle: '编辑国家',
|
||||
},
|
||||
countries: {
|
||||
AD: "安道尔", AE: "阿拉伯联合酋长国", AF: "阿富汗", AG: "安提瓜和巴布达", AI: "安圭拉", AL: "阿尔巴尼亚", AM: "亚美尼亚", AO: "安哥拉", AQ: "南极洲", AR: "阿根廷", AS: "美属萨摩亚", AT: "奥地利", AU: "澳大利亚", AU1: "澳大利亚", AW: "阿鲁巴", AX: "奥兰群岛", AZ: "阿塞拜疆",
|
||||
|
||||
@@ -126,6 +126,55 @@ export const useCountryStore = defineStore('country', () => {
|
||||
await fetchCountryInfo(t, true)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动设置国家信息
|
||||
* @param {string} countryName - 国家名称(中文)
|
||||
* @param {Function} t - 国际化函数(可选)
|
||||
*/
|
||||
const setCountryManually = (countryName, t = null) => {
|
||||
if (!countryName || countryName.trim() === '') {
|
||||
return false
|
||||
}
|
||||
|
||||
countryData.value = countryName.trim()
|
||||
countryDataEN.value = countryName.trim()
|
||||
hasInitialized.value = true
|
||||
lastFetchTime.value = Date.now()
|
||||
|
||||
if (t) {
|
||||
ElMessage.success(t('workbenchesSetup.countrySetSuccess') || t('hostsList.countrySetSuccess') || '国家设置成功')
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示编辑国家的弹窗
|
||||
* @param {Function} t - 国际化函数
|
||||
*/
|
||||
const showEditCountryDialog = (t) => {
|
||||
ElMessageBox.prompt(
|
||||
t('workbenchesSetup.editCountryPrompt') || t('hostsList.editCountryPrompt') || '请输入国家名称(中文)',
|
||||
t('workbenchesSetup.editCountryTitle') || t('hostsList.editCountryTitle') || '编辑国家',
|
||||
{
|
||||
confirmButtonText: t('workbenchesSetup.confirm') || t('hostsList.confirm') || '确定',
|
||||
cancelButtonText: t('workbenchesSetup.cancel') || t('hostsList.cancel') || '取消',
|
||||
inputPlaceholder: t('workbenchesSetup.countryPlaceholder') || t('hostsList.countryPlaceholder') || '例如:美国、日本、英国',
|
||||
inputValue: countryData.value, // 预填充当前值
|
||||
inputValidator: (value) => {
|
||||
if (!value || value.trim() === '') {
|
||||
return t('workbenchesSetup.countryRequired') || t('hostsList.countryRequired') || '请输入国家名称'
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
).then(({ value }) => {
|
||||
setCountryManually(value, t)
|
||||
}).catch(() => {
|
||||
// 用户取消编辑
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
// 状态
|
||||
countryData,
|
||||
@@ -139,5 +188,7 @@ export const useCountryStore = defineStore('country', () => {
|
||||
refreshCountry,
|
||||
showCountryInputDialog,
|
||||
initCountryInfo,
|
||||
setCountryManually,
|
||||
showEditCountryDialog,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -36,7 +36,11 @@ export function usePythonBridge() {
|
||||
if (!inElectron) return;
|
||||
await window.electronAPI.tk.loginTikTok();
|
||||
};
|
||||
|
||||
// loginTikTok
|
||||
const loginBigTikTok = async () => {
|
||||
if (!inElectron) return;
|
||||
await window.electronAPI.tk.loginBigTikTok();
|
||||
};
|
||||
// loginBackStage
|
||||
const loginBackStage = async (data) => {
|
||||
if (!inElectron) return;
|
||||
@@ -228,6 +232,7 @@ export function usePythonBridge() {
|
||||
fetchDataCount,
|
||||
loginBackStage,
|
||||
loginTikTok,
|
||||
loginBigTikTok,
|
||||
givePyAnchorId,
|
||||
backStageloginStatus,
|
||||
backStageloginStatusCopy,
|
||||
|
||||
@@ -112,6 +112,11 @@
|
||||
<div class="bg-slate-50 px-4 py-2 rounded-xl border border-slate-100 text-sm flex items-center gap-2">
|
||||
<span class="text-slate-500">{{ $t('hostsList.currentNetwork') || '当前网络' }}:</span>
|
||||
<span class="font-bold text-primary">{{ countryData }}</span>
|
||||
<button @click="editCountry" :disabled="isRefreshingCountry"
|
||||
class="p-1 rounded-md hover:bg-slate-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:title="$t('hostsList.editCountry') || '编辑国家'">
|
||||
<span class="material-icons-round text-slate-500 text-base">edit</span>
|
||||
</button>
|
||||
<button @click="refreshCountry" :disabled="isRefreshingCountry"
|
||||
class="p-1 rounded-md hover:bg-slate-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:title="$t('hostsList.refreshCountry') || '刷新国家'">
|
||||
@@ -303,7 +308,7 @@ const sortNameOptions = ref([
|
||||
const {
|
||||
givePyAnchorId,
|
||||
exportToExcel,
|
||||
loginTikTok,
|
||||
loginBigTikTok,
|
||||
controlTask,
|
||||
getBrotherInfo,
|
||||
Specifystreaming,
|
||||
@@ -394,6 +399,7 @@ const getlist = () => {
|
||||
};
|
||||
|
||||
function getBigBrother() {
|
||||
queryFormData.value.isRunning = true;
|
||||
const settingData = { ...queryFormData.value, tenantId: userInfo.value.tenantId, region: countryData.value };
|
||||
|
||||
// Save settings
|
||||
@@ -401,7 +407,7 @@ function getBigBrother() {
|
||||
|
||||
controlTask(JSON.stringify(settingData)).then(() => {
|
||||
isRunnings.value = true;
|
||||
queryFormData.value.isRunning = true;
|
||||
|
||||
startTimerfun();
|
||||
|
||||
// Start polling stats
|
||||
@@ -555,9 +561,14 @@ function exportList() {
|
||||
}
|
||||
|
||||
function openTikTok() {
|
||||
loginTikTok();
|
||||
loginBigTikTok();
|
||||
}
|
||||
|
||||
// 编辑国家信息 - 使用共享 store
|
||||
const editCountry = () => {
|
||||
countryStore.showEditCountryDialog(t);
|
||||
};
|
||||
|
||||
// 刷新国家信息 - 使用共享 store
|
||||
const refreshCountry = async () => {
|
||||
await countryStore.refreshCountry(t);
|
||||
|
||||
@@ -118,8 +118,13 @@
|
||||
<div class="flex items-center gap-2 text-slate-500">
|
||||
<span>{{ $t('workbenchesSetup.network') }}:</span>
|
||||
<span class="text-blue-600 font-bold">{{ locale == 'zh' ? countryData : countryDataEN }}</span>
|
||||
<button @click="refreshCountry" :disabled="isRefreshingCountry"
|
||||
<button @click="editCountry" :disabled="isRefreshingCountry"
|
||||
class="ml-1 p-1 rounded-md hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:title="$t('workbenchesSetup.editCountry') || '编辑国家'">
|
||||
<span class="material-icons-round text-slate-500 text-base">edit</span>
|
||||
</button>
|
||||
<button @click="refreshCountry" :disabled="isRefreshingCountry"
|
||||
class="p-1 rounded-md hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:title="$t('workbenchesSetup.refreshCountry') || '刷新国家'">
|
||||
<span class="material-icons-round text-slate-500 text-base" :class="{ 'animate-spin': isRefreshingCountry }">refresh</span>
|
||||
</button>
|
||||
@@ -431,6 +436,11 @@ onMounted(async () => {
|
||||
}, 1000 * 20)
|
||||
})
|
||||
|
||||
// 编辑国家信息 - 使用共享 store
|
||||
const editCountry = () => {
|
||||
countryStore.showEditCountryDialog(t);
|
||||
};
|
||||
|
||||
// 刷新国家信息 - 使用共享 store
|
||||
const refreshCountry = async () => {
|
||||
await countryStore.refreshCountry(t);
|
||||
|
||||
Reference in New Issue
Block a user