添加国家独立设置

This commit is contained in:
2026-03-12 09:59:19 +08:00
parent b4efa96416
commit bfd8748554
3 changed files with 230 additions and 27 deletions

View File

@@ -228,7 +228,7 @@ import { getUser } from "@/utils/storage";
import { getCountryName } from "@/utils/countryUtil";
import { ElMessage, ElMessageBox, ElLoading } from "element-plus";
import { useI18n } from 'vue-i18n';
import { useCountryStore } from '@/stores/countryStore';
import { useCountryInfo } from '@/composables/useCountryInfo';
// Mock API calls if not present
// Ideally we should import these from api file, but for simplicity I will mock them or use empty callbacks
@@ -239,7 +239,14 @@ import { useCountryStore } from '@/stores/countryStore';
import { tkbigdata, getCountryinfo } from "@/api/account";
const { t, locale } = useI18n();
const countryStore = useCountryStore();
// 使用独立的国家信息管理(不与其他页面共享)
const {
countryData,
isLoading: isRefreshingCountry,
initCountryInfo,
refreshCountry: refreshCountryInfo,
showEditCountryDialog
} = useCountryInfo();
// Component State
const queryFormData = ref({
@@ -275,9 +282,8 @@ const streamdialogVisible = ref(false);
const streamdialogVisibletext = ref(false);
const filterdialogVisible = ref(false);
const textarea = ref("");
// 使用共享 store 的国家信息
const countryData = computed(() => countryStore.countryData);
const isRefreshingCountry = computed(() => countryStore.isLoading);
// 使用独立的国家信息
const countryDataRef = countryData;
const userInfo = ref({});
const options = ref([]);
@@ -326,8 +332,8 @@ const timerId = ref(null);
onMounted(async () => {
userInfo.value = getUser() || { tenantId: 0, id: 0 };
// 使用共享 store 初始化国家信息
await countryStore.initCountryInfo(t);
// 初始化独立的国家信息
await initCountryInfo(t);
getCountry();
getlist();
@@ -564,14 +570,14 @@ function openTikTok() {
loginBigTikTok();
}
// 编辑国家信息 - 使用共享 store
// 编辑国家信息
const editCountry = () => {
countryStore.showEditCountryDialog(t);
showEditCountryDialog(t);
};
// 刷新国家信息 - 使用共享 store
// 刷新国家信息
const refreshCountry = async () => {
await countryStore.refreshCountry(t);
await refreshCountryInfo(t);
};
function getCountry() {

View File

@@ -123,7 +123,7 @@
:title="$t('workbenchesSetup.editCountry') || '编辑国家'">
<span class="material-icons-round text-slate-500 text-base">edit</span>
</button>
<button @click="refreshCountry" :disabled="isRefreshingCountry"
<button @click="refreshCountryFn" :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>
@@ -312,18 +312,25 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import { getCountryName } from '@/utils/countryUtil'
import { tkaccountuseinfo, getExpiredTime } from '@/api/account'
import { useI18n } from 'vue-i18n'
import { useCountryStore } from '@/stores/countryStore'
import { useCountryInfo } from '@/composables/useCountryInfo'
const { t, locale } = useI18n()
const countryStore = useCountryStore()
// 使用独立的国家信息管理(不与其他页面共享)
const {
countryData,
countryDataEN,
isLoading: isRefreshingCountry,
initCountryInfo,
refreshCountry,
showEditCountryDialog
} = useCountryInfo()
//导入python交互方法
const { fetchDataConfig, fetchDataCount, loginBackStage, loginTikTok, backStageloginStatus, backStageloginStatusCopy, getTkLoginStatus } = usePythonBridge();
//ip国家 - 使用共享 store
const countryData = computed(() => countryStore.countryData);
const countryDataEN = computed(() => countryStore.countryDataEN);
const isRefreshingCountry = computed(() => countryStore.isLoading);
//ip国家 - 使用独立的国家信息
const countryDataRef = countryData;
const countryDataENRef = countryDataEN;
let country_info = ref('全部');
let country_Lst = ref();
//获取主播数量的定时器
@@ -417,8 +424,8 @@ onMounted(async () => {
tkaccountuse(tkData.value[0].account, 0)
tkaccountuse(tkData.value[1].account, 1)
// 使用共享 store 初始化国家信息
countryStore.initCountryInfo(t)
// 初始化独立的国家信息
initCountryInfo(t)
setTimeout(() => {
// Check if user exists before calling getExpiredTime
@@ -436,10 +443,10 @@ onMounted(async () => {
}, 1000 * 20)
})
// 编辑国家信息 - 使用共享 store
// 编辑国家信息
const editCountry = async () => {
try {
const newCountry = await countryStore.showEditCountryDialog(t);
const newCountry = await showEditCountryDialog(t);
// 确认后获取该国家的列表
if (newCountry) {
fetchCountryList(newCountry);
@@ -449,12 +456,12 @@ const editCountry = async () => {
}
};
// 刷新国家信息 - 使用共享 store
const refreshCountry = async () => {
await countryStore.refreshCountry(t);
// 刷新国家信息
const refreshCountryFn = async () => {
await refreshCountry(t);
// 刷新成功后获取国家列表
if (countryStore.countryData) {
fetchCountryList(countryStore.countryData);
if (countryData.value) {
fetchCountryList(countryData.value);
}
};