This commit is contained in:
王创世 2025-07-04 13:15:56 +08:00
parent e0abba1a94
commit 6d292944da
11 changed files with 209 additions and 203 deletions

View File

@ -5,7 +5,7 @@
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="aboutid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350x;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -28,7 +28,7 @@
</div>
<div :class="['lef_boxitem2', { 'active': cateid == item.id }]" v-for="(item, index) in newsListtyp"
:key="index" @click="getMesList(item.id, 1)">
<div class="lef_boxitem2_title">{{ item.name }}</div>
<div class="lef_boxitem2_title">{{ item.tabtitle }}</div>
</div>
</div>
<div class="rig_box">
@ -38,17 +38,16 @@
<img :src="`/img/key.png`" style="width: 22px;height: 22px;">
</div>
<div style="font-size: 18px;color: #323232;margin-left: 10px;">当前位置首页 > 关于我们 > <span
style="color: #3B90DF;">{{newsListtyp.find(item => item.id == cateid)?.name
style="color: #3B90DF;">{{newsListtyp.find(item => item.id == cateid)?.tabtitle
}}</span></div>
</div>
<div style="background-color: #ffffff;width: 100%;padding: 18px;">
<div
style="font-weight: bold;font-size: 32px;color: #393939;text-align: center;padding: 25px 0px 25px 0;">
团市委的主要职责</div>
style="font-weight: bold;font-size: 32px;color: #393939;text-align: center;padding: 25px 0px 25px 0;">{{ info.title }}</div>
<div style="width: 100%;height: 3px;border-top: 1px dashed #BBBBBB;"></div>
<div
style="color: #999999;font-weight: 400;font-size: 16px;line-height: 25px;white-space: pre-line;">
<div v-html="ldbz"></div>
<div v-html="info.content"></div>
</div>
</div>
</div>
@ -79,136 +78,49 @@ import $api from '@/service/webRequest'
import emitter from '@/plugins/emitter'
const inputSearch = ref('');
const MesList = ref([]);
const newsListtyp = ref([{ id: 1, name: '领导班子' }, { id: 2, name: '​机构职能' }, { id: 3, name: '​部门设置' }, { id: 4, name: '直属单位' }, { id: 5, name: '​下属部门' }]);
const newsListtyp = ref([]);
const page = ref(1);
const total = ref(0);
const cateid = ref(1);
const cateid = ref(0);
const detailId = ref(null);
const ldbz = ref(`思想引领:筑牢青年理想信念根基​
政治引领
组织青年学习党的理论方针政策特别是习近平新时代中国特色社会主义思想开展主题教育活动青年大学习青马工程引导青年坚定四个自信增强两个维护的自觉性
价值观培育
弘扬社会主义核心价值观通过榜样宣传红色教育网络思政等方式引导青年树立正确的人生观价值观例如开展青年五四奖章优秀共青团员评选宣传青年典型事迹
意识形态阵地建设
加强青年网络舆论引导管理团属新媒体平台如微信公众号微博短视频账号传播正能量抵制错误思潮维护网络空间清朗
组织建设夯实团的基层基础
团组织覆盖与规范化
推动团的基层组织向新兴领域延伸如非公企业社会组织互联网行业等完善智慧团建系统加强团员档案管理和组织关系转接
团员发展与教育
严格团员发展程序优化团员结构开展团员意识教育落实三会两制一课制度增强团组织凝聚力和战斗力
团干部队伍建设
选拔培养优秀团干部组织专题培训挂职锻炼提升团干部的政治素养和业务能力打造忠诚干净担当的骨干队伍
服务青年解决青年急难愁盼问题
就业创业支持
联合人社部门企业开展千校万岗招聘会职业技能培训搭建青年创业孵化基地提供政策咨询资金扶持青创贷
婚恋与家庭服务
举办青年联谊活动搭建婚恋交友平台关注青年育儿需求推动普惠性托育服务
心理健康与法律援助
开通12355青少年服务热线提供心理咨询法律咨询和权益维护服务帮助青年缓解压力应对困境
维护青年权益当好青年利益代言人
政策倡导与落实
推动中长期青年发展规划在地方落地参与制定青年发展相关政策保障青年在教育就业住房等领域的合法权益
权益保护机制
建立青少年权益代表制度介入校园欺凌劳动纠纷等案件联合公检法司部门开展法治进校园模拟法庭等活动提升青年法律意识
特殊群体关爱
重点帮扶困境青少年如留守儿童残疾青年失业青年实施希望工程阳光助学等项目提供物质帮扶和精神关怀
志愿服务与社会动员
品牌志愿服务项目
组织青年参与大型赛会服务如马拉松博览会社区治理生态环保河小青护河行动助老助残等志愿活动
应急响应与公益行动
在自然灾害公共卫生事件中组建青年突击队开展物资调配心理疏导等应急服务发起公益募捐支援弱势群体
志愿服务体系建设
完善志愿者注册培训激励机制推广志愿汇平台推动志愿服务常态化专业化
创新创业与人才培养
青年创新创业扶持
举办创青春创业大赛青创论坛对接风险投资和创业导师推动高校与企业共建产学研合作平台
技能提升与职业发展
开展青年岗位能手评选职业技能竞赛组织青年参与工匠精神培育计划助力青年职业成长
青年人才引进与留用
配合地方人才政策吸引高校毕业生返乡就业为高层次青年人才提供政策咨询生活保障等配套服务
对外交流与协同合作
青年交流项目
组织与国内外青年团体的互访活动国际青年领袖对话促进文化交流与经验共享
区域协同与资源整合
联动工会妇联科协等群团组织整合社会资源服务青年与高校企业共建实践基地
港澳台青年工作
开展港澳台青年夏令营实习计划增进国家认同推动融合发展
桥梁纽带作用传达青年声音
青年诉求调研与反馈
定期开展青年发展状况调查形成报告提交党委政府推动青年关切问题纳入政策议程
参政议政渠道建设
推荐优秀青年担任人大代表政协委员组织共青团与人大代表政协委员面对面活动畅通青年政治参与渠道
  巴黎奥运赛场上我国体育健儿奋勇争先取得境外参赛最好成绩彰显了青年一代的昂扬向上自信阳光海军空军喜庆75岁生日人民子弟兵展现新风貌面对洪涝台风等自然灾害广大党员干部冲锋在前大家众志成城守望相助无数劳动者建设者创业者都在为梦想拼搏我为国家勋章和国家荣誉称号获得者颁奖光荣属于他们也属于每一个挺膺担当的奋斗者
  当今世界变乱交织中国作为负责任大国积极推动全球治理变革深化全球南方团结合作我们推进高质量共建一带一路走深走实成功举办中非合作论坛北京峰会在上合金砖亚太经合组织二十国集团等双边多边场合鲜明提出中国主张为维护世界和平稳定注入更多正能量
  我们隆重庆祝新中国成立75周年深情回望共和国的沧桑巨变从五千多年中华文明的传承中一路走来中国二字镌刻在何尊底部更铭刻在每个华夏儿女心中党的二十届三中全会胜利召开吹响进一步全面深化改革的号角我们乘着改革开放的时代大潮阔步前行中国式现代化必将在改革开放中开辟更加广阔的前景
  2025我们将全面完成十四五规划要实施更加积极有为的政策聚精会神抓好高质量发展推动高水平科技自立自强保持经济社会发展良好势头当前经济运行面临一些新情况有外部环境不确定性的挑战有新旧动能转换的压力但这些经过努力是可以克服的我们从来都是在风雨洗礼中成长在历经考验中壮大大家要充满信心
  家事国事天下事让人民过上幸福生活是头等大事家家户户都盼着孩子能有好的教育老人能有好的养老服务年轻人能有更多发展机会这些朴实的愿望就是对美好生活的向往我们要一起努力不断提升社会建设和治理水平持续营造和谐包容的氛围把老百姓身边的大事小情解决好让大家笑容更多心里更暖
  在澳门回归祖国25周年之际我再到濠江之畔新发展新变化令人欣喜我们将坚定不移贯彻一国两制方针保持香港澳门长期繁荣稳定两岸同胞一家亲谁也无法割断我们的血脉亲情谁也不能阻挡祖国统一的历史大势
  世界百年变局加速演进需要以宽广胸襟超越隔阂冲突以博大情怀关照人类命运中国愿同各国一道做友好合作的践行者文明互鉴的推动者构建人类命运共同体的参与者共同开创世界的美好未来
  梦虽遥追则能达愿虽艰持则可圆中国式现代化的新征程上每一个人都是主角每一份付出都弥足珍贵每一束光芒都熠熠生辉
  河山添锦绣星光映万家让我们满怀希望迎接新的一年祝祖国时和岁丰繁荣昌盛祝大家所愿皆所成多喜乐长安宁`)
const ldbz = ref('')
//
onMounted(() => {
//getMesList();
//getNewstypeList();
getNewstypeList(1);
})
const hmScroll = () => {
let home = document.getElementById('aboutid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe', 3);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 1);
}, 500);
}
}
const emit = defineEmits(['toSwpe'])
//
const openUrl = (id: number) => {
window.open(`/info/${id}?type=1`)
}
//
// const gotoDetail = (id: number) => {
// detailId.value = {
// id: id,
// type: '1'
// };
// localStorage.setItem('detailId', JSON.stringify(detailId.value));
// emit('toSwpe',6)
// emitter.emit('detailId', detailId.value);
// }
//
const toSearch = () => {
// emit('toSwpe',9);
// emitter.emit('inputSea', {
// keywords:inputSearch.value,
// type: 1,
// });
window.open(`/search_info?type=1&keywords=${inputSearch.value}`)
}
const getPageList = async () => {
page.value = page.value;
getMesList();
}
const getMesList = async (id: number, pagecru: number) => {
cateid.value = id ? id : cateid.value;
page.value = pagecru ? pagecru : page.value;
const res = await $api.post('/api/home.news/index',
{
cate_id: cateid.value,
limit: 7,
page: page.value,
isnews: 1
}
)
total.value = res.data.data.count;
MesList.value = res.data.data.list;
const info=ref({});
const getMesList=async(id:number)=>{
cateid.value=id;
info.value=newsListtyp.value.find(item=>item.id==id);
}
const getNewstypeList = async () => {
const res = await $api.get('/api/home.news/cate?isnews=1')
const res = await $api.get(`/api/index/about_us`)
newsListtyp.value = res.data.data.list;
cateid.value=res.data.data.list[0].id;
info.value=res.data.data.list[0];
}
</script>
@ -348,6 +260,7 @@ const getNewstypeList = async () => {
}
.rig_box {
width: 100%;
.re_box {
width: 100%;
height: 100%;

View File

@ -5,7 +5,7 @@
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="contid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350px;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -93,7 +93,7 @@
</template>
<script lang="ts" setup>
import { nextTick, ref } from 'vue'
import { defineEmits } from 'vue'
import $api from '@/service/webRequest'
const inputSearch = ref('');
//
@ -122,6 +122,16 @@ const getLiuyanList = async () => {
onMounted(() => {
getLiuyanList();
})
const emit = defineEmits(['toSwpe'])
const hmScroll = () => {
let home = document.getElementById('contid');
console.log(home.scrollTop);
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 6);
}, 500);
}
}
//
const submitForm = () => {
console.log(formData);

View File

@ -9,38 +9,7 @@
<div class="b1" style="padding: 0;">
<select @change="getSelect" style="width: 100%;height: 41px;padding-left:15px;">
<option value="0">省级共青团网站</option>
<option value="http://www.bjyouth.gov.cn/">北京</option>
<option value="http://www.youthtj.org.cn/">天津</option>
<option value="http://www.54heb.org.cn/">河北</option>
<option value="http://www.sxccyl.gov.cn/">山西</option>
<option value="http://www.nmyouth.org.cn/">内蒙古</option>
<option value="http://www.liaoninggqt.org.cn/">辽宁</option>
<option value="http://www.jl54.org/">吉林</option>
<option value="http://www.hljgqt.gov.cn/">黑龙江</option>
<option value="https://www.shyouth.net/html/1/index.html">上海</option>
<option value="http://www.jiangsugqt.org/">江苏</option>
<option value="https://www.zjgqt.org/">浙江</option>
<option value="http://www.ahyouth.org.cn/base/">安徽</option>
<option value="http://www.fjcyl.com/">福建</option>
<option value="http://www.jxyouth.org.cn/">江西</option>
<option value="http://www.sdyl.gov.cn/">山东</option>
<option value="http://www.hnyouth.org.cn/">河南</option>
<option value="http://www.hbgqt.org.cn/">湖北</option>
<option value="https://www.hngqt.org.cn/">湖南</option>
<option value="https://www.gdcyl.org/Index.html">广东</option>
<option value="http://www.gxgqt.org.cn/">广西</option>
<option value="http://www.hngqt.cn/">海南</option>
<option value="http://www.cqyl.org.cn/">重庆</option>
<option value="http://scgqt.gov.cn/home/">四川</option>
<option value="http://www.gzyouth.cn/">贵州</option>
<option value="http://www.yngqt.org.cn/">云南</option>
<option value="https://youth.xzdw.gov.cn/">西藏</option>
<option value="https://www.sxgqt.org.cn/">陕西</option>
<option value="https://www.gsgqt.gov.cn/">甘肃</option>
<option value="https://www.qhgqt.org.cn/index.html">青海</option>
<option value="https://www.nxgqt.org/">宁夏</option>
<option value="https://www.ts.cn/zxpd/zt3511/tw/index.html">新疆</option>
<option value="http://tw.xjbt.gov.cn/">新疆生产建设兵团</option>
<option v-for="item in s_list" :value="item.url">{{ item.title }}</option>
</select>
</div>
<div>
@ -49,11 +18,9 @@
</div>
<div style="display: flex;">
<div class="b1" style="padding: 0;">
<select style="width: 100%;height: 41px;padding-left:15px;">
<option value="1">各地共青团网站</option>
<option value="2">各地共青团网站</option>
<option value="3">各地共青团网站</option>
<option value="4">各地共青团网站</option>
<select @change="getSelect" style="width: 100%;height: 41px;padding-left:15px;">
<option value="0">各地共青团网站</option>
<option v-for="item in d_list" :value="item.url">{{ item.title }}</option>
</select>
</div>
<div>
@ -62,11 +29,9 @@
</div>
<div style="display: flex;">
<div class="b1" style="padding: 0;">
<select style="width: 100%;height: 41px;padding-left:15px;">
<option value="1">其他</option>
<option value="2">其他</option>
<option value="3">其他</option>
<option value="4">其他</option>
<select @change="getSelect" style="width: 100%;height: 41px;padding-left:15px;">
<option value="0">其他</option>
<option v-for="item in q_list" :value="item.url">{{ item.title }}</option>
</select>
</div>
<div>
@ -75,11 +40,9 @@
</div>
<div style="display: flex;">
<div class="b1" style="padding: 0;">
<select style="width: 100%;height: 41px;padding-left:15px;">
<option value="1">办公入口</option>
<option value="2">办公入口</option>
<option value="3">办公入口</option>
<option value="4">办公入口</option>
<select @change="getSelect" style="width: 100%;height: 41px;padding-left:15px;">
<option value="0">办公入口</option>
<option v-for="item in b_list" :value="item.url">{{ item.title }}</option>
</select>
</div>
<div>
@ -172,16 +135,32 @@
</template>
<script lang="ts" setup>
const selectValue = ref(false);
import { useStore } from '~/store'
const store = useStore();
const getSelect = (event: Event) => {
var url = event.target.value;
if (url == 0) {
const target = event.target as HTMLSelectElement;
var url = target.value;
if (url == '0') {
return;
}else{
} else {
window.open(url);
}
}
const openT = ()=>{
// 使store
const s_list = computed(() => store.s_list);
const d_list = computed(() => store.d_list);
const q_list = computed(() => store.q_list);
const b_list = computed(() => store.b_list);
onMounted(() => {
// store
store.getFriendshipLinks();
})
const openT = () => {
window.open('https://www.gov.cn/');
}
</script>

View File

@ -310,17 +310,17 @@ const swiperOptionsimgs = {
},
}
const hmScroll = () => {
// let home = document.getElementById('homeid');
// if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
// setTimeout(function () {
// emit('toSwpe', 2);
// }, 500);
// }
// if (home.scrollTop == 0) {
// setTimeout(function () {
// emit('toSwpe', 0);
// }, 500);
// }
let home = document.getElementById('homeid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe', 2);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 0);
}, 500);
}
}
const toSearch = () => {
// emit('toSwpe',9);

View File

@ -5,7 +5,7 @@
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="luoyangid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350px;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -108,6 +108,19 @@ onMounted(() => {
//getMesList();
getNewstypeList();
})
const hmScroll = () => {
let home = document.getElementById('luoyangid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe', 5);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 3);
}, 500);
}
}
const emit = defineEmits(['toSwpe'])
//

View File

@ -5,7 +5,7 @@
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="msgid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350px;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -90,14 +90,27 @@ const MesList = ref([]);
const newsListtyp = ref([]);
const page = ref(1);
const total = ref(0);
const cateid = ref(null);
const cateid = ref(0);
const detailId = ref(null);
//
onMounted(() => {
// getMesList();
// getNewstypeList();
getNewstypeList();
})
const hmScroll = () => {
let home = document.getElementById('msgid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe', 7);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 5);
}, 500);
}
}
const emit = defineEmits(['toSwpe'])
//
@ -125,15 +138,14 @@ const toSearch = () => {
}
const getPageList = async () => {
page.value = page.value;
getMesList();
getMesList(cateid.value);
}
const getMesList = async (id: number, pagecru: number) => {
cateid.value = id ? id : cateid.value;
page.value = pagecru ? pagecru : page.value;
const res = await $api.post('/api/home.news/index',
const getMesList = async (id: number) => {
cateid.value = id;
const res = await $api.post('/api/home.information/index',
{
cate_id: cateid.value,
limit: 9,
limit: 7,
page: page.value,
isnews: 1
}
@ -142,8 +154,9 @@ const getMesList = async (id: number, pagecru: number) => {
MesList.value = res.data.data.list;
}
const getNewstypeList = async () => {
const res = await $api.get('/api/home.news/cate?isnews=1')
const res = await $api.get('/api/home.information/cate')
newsListtyp.value = res.data.data.list;
getMesList(res.data.data.list[0].id);
}
</script>

View File

@ -5,7 +5,7 @@
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="newsid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350px;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -101,7 +101,19 @@ onMounted(() => {
getNewstypeList();
})
const emit = defineEmits(['toSwpe'])
const hmScroll = () => {
let home = document.getElementById('newsid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe', 4);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 2);
}, 500);
}
}
//
const openUrl = (id: number) => {
window.open(`/info/${id}?type=1`)

View File

@ -3,7 +3,7 @@
<div class="flex justify-between w-full h-full">
<!-- 左边导航栏 -->
<!-- 右边内容栏 -->
<div class="rightcon">
<div class="rightcon" id="regid" @scroll="hmScroll">
<div class="flex top_search ">
<div style="width: 350px;">
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%;height: 100%;object-fit: cover;">
@ -146,6 +146,19 @@ onMounted(() => {
getYwList();
//getNewstypeList();
})
const hmScroll = () => {
let home = document.getElementById('regid');
if (home.scrollTop + home.clientHeight >= home.scrollHeight) {
setTimeout(function () {
emit('toSwpe',6);
}, 500);
}
if (home.scrollTop == 0) {
setTimeout(function () {
emit('toSwpe', 4);
}, 500);
}
}
const fwImg = ref([]);
//
const getFwImg = async () => {

View File

@ -53,8 +53,8 @@
<AppAboutdel></AppAboutdel>
</swiper-slide> -->
<!-- 留言板 -->
<swiper-slide @toSwpe="toswiper">
<AppContactUs></AppContactUs>
<swiper-slide >
<AppContactUs @toSwpe="toswiper"></AppContactUs>
</swiper-slide>
<!-- 搜索详情 -->
<!-- <swiper-slide :show="isSearch" id="searchid">
@ -158,9 +158,11 @@ const onSwiperNews = (swiper: any) => {
// isMeassage.value = false;
// console.log(newsSwiper);
swiper_exp.value = swiper.realIndex;
// newsSwiper.mousewheel.disable();
// newsSwiper.allowTouchMove = true;//
newsSwiper.mousewheel.disable();
newsSwiper.allowTouchMove = true;//
// if (swiper.realIndex == 1 || swiper.realIndex == 5 || swiper.realIndex == 2 || swiper.realIndex == 3 || swiper.realIndex == 4 || swiper.realIndex == 6) {
// if (swiper.realIndex == 1) {
// newsSwiper.mousewheel.disable();
// newsSwiper.allowTouchMove = true;//
// }

View File

@ -10,9 +10,9 @@
<img :src="`/img/index/dlogo.png`" alt="" style="width: 100%; height: 100%; object-fit: cover" />
</div>
<div class="inputform">
<input v-model="inputSearch" class="contactInput w-full md:w-[337px]" type="text"
<input v-model="keywords" class="contactInput w-full md:w-[337px]" type="text"
placeholder="请输入搜索关键字" />
<div class="search_rinput">
<div class="search_rinput" @click="getNewsdetail()">
<img src="/img/index/hmsearch.png" alt="" />
</div>
</div>
@ -115,6 +115,7 @@ const detailId = ref(null);
const datas = ref(null);
const keywords = ref(route.query.keywords)
const types = ref(route.query.type)
const inputSearch=ref('');
// emitter.on('inputSea', (data) => {
// console.log(data,111111)
// datas.value = data;
@ -179,6 +180,7 @@ const gotoDetails = (id: number) => {
// //
const getNewsdetail = async () => {
console.log(types.value);
//
if (types.value == 1) {
@ -186,9 +188,10 @@ const getNewsdetail = async () => {
{
keywords:keywords.value,
page:1,
limit:30
limit:10
}
)
console.log(res.data.data.list);
Newsdetailist.value = res.data.data.list;
}else if(types.value == 2){
//

View File

@ -7,10 +7,19 @@ export const useStore = defineStore({
tempApiData: {}, // 存储API返回的临时数据
serApiData: {}, // 存储API返回的临时数据
isEnglish: 'zh', // 判断是否是英文
// 友情链接相关状态
friendshipLinks: [], // 存储友情链接原始数据
isLinksLoaded: false, // 标识友情链接数据是否已加载
_friendshipLinksPromise: null as Promise<any> | null, // 私有Promise缓存
}),
getters: {
// 获取临时API数据的getter
getTempApiData: state => state.tempApiData,
// 友情链接分类数据的getter
s_list: state => state.friendshipLinks.filter((item: any) => item.status == 1),
d_list: state => state.friendshipLinks.filter((item: any) => item.status == 2),
q_list: state => state.friendshipLinks.filter((item: any) => item.status == 3),
b_list: state => state.friendshipLinks.filter((item: any) => item.status == 4),
},
actions: {
// 保存API返回的临时数据
@ -28,6 +37,45 @@ export const useStore = defineStore({
clearTempApiData() {
this.tempApiData = {}
},
// 获取友情链接数据
async getFriendshipLinks() {
// 如果数据已经加载过,直接返回
if (this.isLinksLoaded) {
return
}
// 如果已经有正在进行的请求直接返回该Promise
if (this._friendshipLinksPromise) {
return this._friendshipLinksPromise
}
// 创建新的Promise并缓存
this._friendshipLinksPromise = this._loadFriendshipLinks()
try {
await this._friendshipLinksPromise
} catch (error) {
// 如果请求失败清除缓存的Promise允许重新尝试
this._friendshipLinksPromise = null
throw error
}
},
// 私有方法实际执行API调用
async _loadFriendshipLinks() {
try {
// 动态导入API模块
const { default: $api } = await import('@/service/webRequest')
const res = await $api.get('/api/index/friendship_link')
this.friendshipLinks = res.data.data.list
this.isLinksLoaded = true
console.log('友情链接数据已加载:', res.data.data)
return res.data.data
} catch (error) {
console.error('获取友情链接数据失败:', error)
throw error
}
},
},
})