From 318020ead7724a3ad5acdd0151d4a56c76a955f7 Mon Sep 17 00:00:00 2001 From: alwayrun Date: Fri, 17 May 2024 11:48:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20render/App.vue?= =?UTF-8?q?,=20=E4=BD=BF=E7=94=A8=20Vue3=20=E7=BB=84=E5=90=88=E5=BC=8F=20A?= =?UTF-8?q?PI=20=E5=86=99=E6=B3=95=20(#117)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/render/App.vue | 166 +++++++++++++++++++++-------------------- web/src/render/main.js | 1 - 2 files changed, 85 insertions(+), 82 deletions(-) diff --git a/web/src/render/App.vue b/web/src/render/App.vue index 563cecb1..185c00c8 100644 --- a/web/src/render/App.vue +++ b/web/src/render/App.vue @@ -1,11 +1,21 @@ + +watch(skinConf, (value) => { + updateSkinConfig(value) +}) + +onMounted(async () => { + const surveyPath = location.pathname.split('/').pop() + + if (!surveyPath) { + store.commit('setRouter', 'EmptyPage') + return + } + + const alert = useCommandComponent(AlertDialog) + + try { + const res: any = await getPublishedSurveyInfo({ surveyPath }) + + if (res.code === 200) { + const data = res.data + const { bannerConf, baseConf, bottomConf, dataConf, skinConf, submitConf } = data.code + const questionData = { + bannerConf, + baseConf, + bottomConf, + dataConf, + skinConf, + submitConf + } + + document.title = data.title + + updateSkinConfig(skinConf) + + store.commit('setSurveyPath', surveyPath) + store.dispatch('init', questionData) + store.dispatch('getEncryptInfo') + } else { + throw new Error(res.errmsg) + } + } catch (error: any) { + console.log(error) + alert({ title: error.message || '获取问卷失败' }) + } +}) +