feat: 🚀 站点切换

This commit is contained in:
2025-04-09 09:25:12 +08:00
parent af5894dd5a
commit f8d73b1ddb
12 changed files with 115 additions and 97 deletions

View File

@@ -5,6 +5,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// import { useUserStore } from "@/stores/modules/user";
// const userStore: any = useUserStore();
import { reactive, ref, computed } from "vue"; import { reactive, ref, computed } from "vue";
import { useTheme } from "@/hooks/useTheme"; import { useTheme } from "@/hooks/useTheme";
@@ -26,4 +28,11 @@ const assemblySize = computed(() => globalStore.assemblySize);
// element button config // element button config
const buttonConfig = reactive({ autoInsertSpace: false }); const buttonConfig = reactive({ autoInsertSpace: false });
// watch(
// () => userStore.languageType,
// (newVal: any) => {
// console.log(newVal, "=======newVal=======");
// window.location.reload();
// }
// );
</script> </script>

View File

@@ -14,8 +14,10 @@ const getDispositionName = (response: any) => {
//导出表格,从content-disposition获取表格的名称 只有导出服务端才会返回该字段 //导出表格,从content-disposition获取表格的名称 只有导出服务端才会返回该字段
const contentDisposition = response.headers["content-disposition"]; const contentDisposition = response.headers["content-disposition"];
if (contentDisposition) { if (contentDisposition) {
let contentDispositionClone = decodeURIComponent(contentDisposition);
console.log(contentDispositionClone);
// 解析 Content-Disposition 以提取文件名 // 解析 Content-Disposition 以提取文件名
const filenameMatch = contentDisposition.match(/filename=(.*)/i); const filenameMatch = contentDispositionClone.match(/filename=(.*)/i);
if (filenameMatch && filenameMatch[1]) { if (filenameMatch && filenameMatch[1]) {
let filename = filenameMatch[1].trim(); let filename = filenameMatch[1].trim();
localStorage.setItem("filename", filename); localStorage.setItem("filename", filename);

View File

@@ -83,7 +83,7 @@
<script setup lang="ts" name="ProTable"> <script setup lang="ts" name="ProTable">
// /watch // /watch
import { ref, provide, onMounted, watch } from "vue"; import { ref, provide, onMounted } from "vue";
import { ElTable } from "element-plus"; import { ElTable } from "element-plus";
import { useTable } from "@/hooks/useTable"; import { useTable } from "@/hooks/useTable";
import { useSelection } from "@/hooks/useSelection"; import { useSelection } from "@/hooks/useSelection";
@@ -93,6 +93,8 @@ import SearchForm from "@/components/SearchForm/index.vue";
import Pagination from "./components/Pagination.vue"; import Pagination from "./components/Pagination.vue";
import ColSetting from "./components/ColSetting.vue"; import ColSetting from "./components/ColSetting.vue";
import TableColumn from "./components/TableColumn.vue"; import TableColumn from "./components/TableColumn.vue";
// import { useUserStore } from "@/stores/modules/user";
// const userStore = useUserStore();
const $router = useRouter(); const $router = useRouter();
const routeName: any = ref($router.currentRoute.value.name); const routeName: any = ref($router.currentRoute.value.name);
export interface ProTableProps { export interface ProTableProps {
@@ -157,7 +159,7 @@ onMounted(() => props.requestAuto && getTableList());
// 监听页面 initParam 改化,重新获取表格数据 // 监听页面 initParam 改化,重新获取表格数据
// watch(() => props.initParam, getTableList, { deep: true }); // watch(() => props.initParam, getTableList, { deep: true });
// 监听页面 orgCode 改化,重新获取表格数据 // 监听页面 orgCode 改化,重新获取表格数据
watch(() => props.orgCode, getTableList, { deep: true }); // watch(() => userStore.languageType, getTableList, { deep: true });
// 接收 columns 并设置为响应式 // 接收 columns 并设置为响应式
const tableColumns = ref<ColumnProps[]>(props.columns); const tableColumns = ref<ColumnProps[]>(props.columns);
@@ -195,7 +197,12 @@ const colRef = ref();
const colSetting = tableColumns.value!.filter( const colSetting = tableColumns.value!.filter(
item => !["selection", "index", "expand"].includes(item.type!) && item.prop !== "operation" && item.isShow item => !["selection", "index", "expand"].includes(item.type!) && item.prop !== "operation" && item.isShow
); );
// watch(
// () => userStore.languageType,
// (newVal: any) => {
// console.log(newVal, "=newVal=");
// }
// );
// 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去) // 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
defineExpose({ defineExpose({
element: tableRef, element: tableRef,

View File

@@ -108,7 +108,17 @@
> >
</el-radio-group> </el-radio-group>
</template> </template>
<!-- <template v-if="item.type === 'radio1'">
<el-radio-group v-model="_ruleForm[`${item.prop}`]">
<el-radio
:value="option.value"
:label="option.value"
v-for="(option, optionIndex) in item.options"
:key="optionIndex"
>{{ option.label }}</el-radio
>
</el-radio-group>
</template> -->
<template v-if="item.type === 'upImg'"> <template v-if="item.type === 'upImg'">
<UploadImg v-model:image-url="_ruleForm[`${item.prop}`]"> <UploadImg v-model:image-url="_ruleForm[`${item.prop}`]">
<template #tip> <template #tip>

View File

@@ -42,26 +42,28 @@ import { ref } from "vue";
import { logoutApi } from "@/api/modules/login"; import { logoutApi } from "@/api/modules/login";
import { useMsg } from "@/hooks/useMsg"; import { useMsg } from "@/hooks/useMsg";
import { useUserStore } from "@/stores/modules/user"; import { useUserStore } from "@/stores/modules/user";
import { ElMessageBox } from "element-plus"; import { ElMessageBox } from "element-plus";
import { outLogin } from "@/utils/outLogin"; import { outLogin } from "@/utils/outLogin";
//getLanguageCutoverApi
import { getLanguageListApi, getLanguageCutoverApi } from "@/api/modules/global"; import { getLanguageListApi, getLanguageCutoverApi } from "@/api/modules/global";
const userStore: any = useUserStore();
const userStore = useUserStore();
document.cookie = `lang=zh_cn`; document.cookie = `lang=zh_cn`;
const langs = ref<any>([]); const langs = ref<any>([]);
const name = ref(""); const name = ref("");
// 站点列表 // 站点列表
const getLanguageList = async () => { const getLanguageList = async () => {
const result = await getLanguageListApi(); const result = await getLanguageListApi();
if (result?.code === 0) { if (result?.code === 0) {
const { data } = result; const { data } = result;
langs.value = data; langs.value = data;
getLanguageCutover(data[0]?.id); console.log(userStore?.languageType, "===== userStore?.languageType==========");
let id = userStore?.languageType ? userStore?.languageType : data[0]?.id;
getLanguageCutover(id);
} }
}; };
getLanguageList(); getLanguageList();
// 站点切换接口 // 站点切换接口
const getLanguageCutover = async (id: any) => { const getLanguageCutover = async (id: any) => {
const result = await getLanguageCutoverApi(id); const result = await getLanguageCutoverApi(id);
@@ -73,10 +75,12 @@ const getLanguageCutover = async (id: any) => {
name.value = names[0]?.country_name; name.value = names[0]?.country_name;
} }
}; };
// 站点切换事件 // 站点切换事件
const handleCommand = (val: string) => { const handleCommand = (val: string) => {
getLanguageCutover(val); getLanguageCutover(val);
}; };
// 退出登录 // 退出登录
const logout = () => { const logout = () => {
ElMessageBox.confirm("您是否确认重新登录?", "温馨提示", { ElMessageBox.confirm("您是否确认重新登录?", "温馨提示", {

View File

@@ -34,30 +34,36 @@ import { useTabsStore } from "@/stores/modules/tabs";
import { useGlobalStore } from "@/stores/modules/global"; import { useGlobalStore } from "@/stores/modules/global";
import { useKeepAliveStore } from "@/stores/modules/keepAlive"; import { useKeepAliveStore } from "@/stores/modules/keepAlive";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
// import { initCache } from "./init/init"; import { useUserStore } from "@/stores/modules/user";
const userStore = useUserStore();
// import { useMsg } from "@/hooks/useMsg";
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const tabStore = useTabsStore(); const tabStore = useTabsStore();
const globalStore = useGlobalStore(); const globalStore = useGlobalStore();
const keepAliveStore = useKeepAliveStore(); const keepAliveStore = useKeepAliveStore();
// // refresh current page // refresh current page
// const refreshCurrentPage: Function = inject("refresh") as Function; const refreshCurrentPage: Function = inject("refresh") as Function;
// const refresh = async () => {
// // initCache(data);
// setTimeout(() => {
// keepAliveStore.removeKeepAliveName(route.name as string);
// refreshCurrentPage(false);
// nextTick(() => {
// keepAliveStore.addKeepAliveName(route.name as string);
// refreshCurrentPage(true);
// });
// }, 300);
// };
const refresh = async () => {
// initCache(data);
setTimeout(() => {
keepAliveStore.removeKeepAliveName(route.name as string);
refreshCurrentPage(false);
nextTick(() => {
keepAliveStore.addKeepAliveName(route.name as string);
refreshCurrentPage(true);
});
}, 300);
};
watch(
() => userStore.languageType,
(newVal: any) => {
refresh();
console.log(newVal, "我是tab");
}
);
// maximize current page // maximize current page
const maximize = () => { const maximize = () => {
globalStore.setGlobalState("maximize", true); globalStore.setGlobalState("maximize", true);

View File

@@ -31,6 +31,7 @@ import { useTabsStore } from "@/stores/modules/tabs";
import { useAuthStore } from "@/stores/modules/auth"; import { useAuthStore } from "@/stores/modules/auth";
import { useKeepAliveStore } from "@/stores/modules/keepAlive"; import { useKeepAliveStore } from "@/stores/modules/keepAlive";
import { TabsPaneContext, TabPaneName } from "element-plus"; import { TabsPaneContext, TabPaneName } from "element-plus";
import MoreButton from "./components/MoreButton.vue"; import MoreButton from "./components/MoreButton.vue";
const route = useRoute(); const route = useRoute();
@@ -55,9 +56,6 @@ watch(
() => { () => {
if (route.meta.isFull) return; if (route.meta.isFull) return;
tabsMenuValue.value = route.fullPath; tabsMenuValue.value = route.fullPath;
// const TITLES_OBJ = {
// "/articleManagement/list/edit?type=add": "添加文章"
// };
let title: any = route.query.title ? route.query.title : route.meta.title; let title: any = route.query.title ? route.query.title : route.meta.title;
const tabsParams = { const tabsParams = {
icon: route.meta.icon as string, icon: route.meta.icon as string,

View File

@@ -61,7 +61,7 @@ export const EDIT_FORM_DATA: FormItem[] = [
}, },
{ {
label: "否", label: "否",
value: 0 value: -1
} }
] ]
}, },

View File

@@ -152,15 +152,24 @@ const buildTree = (data: any, outerLinkTo: any = "") => {
}; };
// let isFirstRequest = true; // let isFirstRequest = true;
const handleRadioGroupEmits = (value: any) => { const handleRadioGroupEmits = (value: any) => {
// if (value !== "video" || value !== "image") {
// return;
// }
if (value === "video") {
dataStore.editFormData = EDIT_FORM_DATA1;
dataStore.rules = RULES1;
getBannerClassEditList();
}
// getBannerClassList(); // getBannerClassList();
if (value === "image") { if (value === "image") {
dataStore.isFirstRequest = true; dataStore.isFirstRequest = true;
dataStore.editFormData = EDIT_FORM_DATA; dataStore.editFormData = EDIT_FORM_DATA;
dataStore.rules = RULES; dataStore.rules = RULES;
} else { getBannerClassEditList();
dataStore.editFormData = EDIT_FORM_DATA1;
dataStore.rules = RULES1;
} }
// console.log(value, "==========value==========");
// getBannerClassEditList();
}; };
const getSystemUrls = async (node: any, resolve: any) => { const getSystemUrls = async (node: any, resolve: any) => {
@@ -205,7 +214,6 @@ const getBannerRead = async (id: any) => {
if (result?.code === 0) { if (result?.code === 0) {
dataStore.editRuleForm = result?.data; dataStore.editRuleForm = result?.data;
setImgOrVideo(); setImgOrVideo();
if (dataStore.editRuleForm.link && dataStore.editRuleForm.link_to) { if (dataStore.editRuleForm.link && dataStore.editRuleForm.link_to) {
let { id, name, link } = dataStore.editRuleForm.link_echo_data; let { id, name, link } = dataStore.editRuleForm.link_echo_data;
let obj: any = { let obj: any = {
@@ -277,7 +285,7 @@ const getBannerClassEditList = async () => {
} }
}; };
// 新增 getBannerListSave // 新增
const getBannerListSave = async () => { const getBannerListSave = async () => {
const result = await getBannerListSaveApi(dataStore.editRuleForm); const result = await getBannerListSaveApi(dataStore.editRuleForm);
if (result?.code === 0) { if (result?.code === 0) {
@@ -370,21 +378,6 @@ const handleBlur = (row: any) => {
const handleInput = (row: any) => { const handleInput = (row: any) => {
row.sort = integerRexg(row.sort); row.sort = integerRexg(row.sort);
}; };
// watch(
// () => dataStore.editRuleForm.type,
// newVal => {
// console.log(dataStore.editRuleForm.type);
// if (newVal === "video") {
// dataStore.editFormData = EDIT_FORM_DATA1;
// } else {
// dataStore.editFormData = EDIT_FORM_DATA;
// }
// },
// {
// immediate: true,
// deep: true
// }
// );
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -14,10 +14,10 @@
<script setup lang="ts" name="feedbackProductIndex"> <script setup lang="ts" name="feedbackProductIndex">
import ProTable from "@/components/ProTable/index.vue"; import ProTable from "@/components/ProTable/index.vue";
// const $router = useRouter();
//列表接口 //列表接口
import { getProductListApi } from "@/api/modules/product"; import { getProductListApi } from "@/api/modules/product";
// import { getCountryListApi } from "@/api/modules/global";
// import { useUserStore } from "@/stores/modules/user"; // import { useUserStore } from "@/stores/modules/user";
// const userStore: any = useUserStore(); // const userStore: any = useUserStore();
//深拷贝方法 //深拷贝方法
@@ -32,36 +32,15 @@ const dataStore = reactive<any>({
initParam: cloneDeep(RULE_FORM), // 初始化搜索条件|重置搜索条件 initParam: cloneDeep(RULE_FORM), // 初始化搜索条件|重置搜索条件
ruleForm: cloneDeep(RULE_FORM), // 搜索參數 ruleForm: cloneDeep(RULE_FORM), // 搜索參數
formData: FORM_DATA //搜索配置项 formData: FORM_DATA //搜索配置项
// ZH: [],
// EN: []
}); });
// const getCountryList = async () => {
// const result = await getCountryListApi();
// if (result?.code === 0) {
// dataStore.ZH = [];
// dataStore.EN = [];
// result?.data.forEach((item: any) => {
// dataStore.ZH.push({
// label: item.name,
// value: item.id
// });
// dataStore.EN.push({
// label: item.name,
// value: item.id
// });
// });
// dataStore.formData[1].options = userStore.languageType === 1 ? dataStore.ZH : dataStore.EN;
// }
// };
// getCountryList();
// watch( // watch(
// () => userStore.languageType, // () => userStore.languageType,
// (newVal: any) => { // (newVal: any) => {
// dataStore.formData[1].options = newVal === 1 ? dataStore.ZH : dataStore.EN; // console.log(newVal, "=======newVal=======");
// }, // // window.location.reload();
// { deep: true, immediate: true } // $router.go(0);
// }
// ); // );
</script> </script>

View File

@@ -19,6 +19,8 @@
<script setup lang="ts" name="feedbackContactIndex"> <script setup lang="ts" name="feedbackContactIndex">
import ProTable from "@/components/ProTable/index.vue"; import ProTable from "@/components/ProTable/index.vue";
import { useExport } from "@/hooks/useExport"; import { useExport } from "@/hooks/useExport";
// import { useUserStore } from "@/stores/modules/user";
// const userStore: any = useUserStore();
//列表接口 //列表接口
import { getBPListExportApi, getBPListApi, getBPInterestedListApi } from "@/api/modules/purchase"; import { getBPListExportApi, getBPListApi, getBPInterestedListApi } from "@/api/modules/purchase";
//深拷贝方法 //深拷贝方法
@@ -58,10 +60,18 @@ const getBPInterestedList = async () => {
}); });
}); });
dataStore.formData[1].options = arr; dataStore.formData[1].options = arr;
console.log(result?.data, "=======data========");
} }
}; };
getBPInterestedList(); getBPInterestedList();
// watch(
// () => userStore.languageType,
// (newVal: any) => {
// console.log(newVal);
// getBPInterestedList();
// },
// { deep: true, immediate: true }
// );
</script> </script>
<style scoped></style> <style scoped></style>

View File

@@ -109,22 +109,22 @@ export const BASIC_INFO_FORM_DATA: FormItem[] = [
] ]
}, },
{ // {
prop: "is_show1", // prop: "is_show1",
placeholder: "", // placeholder: "",
type: "radio", // type: "radio",
label: "是否启用: ", // label: "是否启用: ",
options: [ // options: [
{ // {
label: "是", // label: "是",
value: 1 // value: 1
}, // },
{ // {
label: "否", // label: "否",
value: 0 // value: -1
} // }
] // ]
}, // },
{ {
prop: "seo_title", prop: "seo_title",