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 || '获取问卷失败' }) + } +}) +