From 3bffeabc2399cd3dda5816c13b1b56be25d7f95f Mon Sep 17 00:00:00 2001 From: MHuiG <616001163@qq.com> Date: Sun, 17 Apr 2022 16:39:31 +0800 Subject: [PATCH] fix: error friendly --- layout/_partial/scripts/index.ejs | 6 ++--- layout/_plugins/_page_plugins/index.ejs | 34 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/layout/_partial/scripts/index.ejs b/layout/_partial/scripts/index.ejs index baccae160..29b8a5043 100644 --- a/layout/_partial/scripts/index.ejs +++ b/layout/_partial/scripts/index.ejs @@ -66,9 +66,9 @@ <% if (theme.comments.service && theme.comments.service.length > 0) { - try { - partial('../../_plugins/comments/' + theme.comments.service + '/script') - } catch (e) { + try { %> + <%- partial('../../_plugins/comments/' + theme.comments.service + '/script') %> + <% } catch (e) { // error friendly console.log(` =============================================================================== diff --git a/layout/_plugins/_page_plugins/index.ejs b/layout/_plugins/_page_plugins/index.ejs index 4700bacf1..d852895c7 100644 --- a/layout/_plugins/_page_plugins/index.ejs +++ b/layout/_plugins/_page_plugins/index.ejs @@ -1,7 +1,27 @@ -<%_(page.plugins||[]).forEach(function(item){ _%> - <%_if (typeof item == "string") { _%> - <%- partial( item + "/index") %> - <%_}else if(typeof item == "object"){ _%> - <%- partial( Object.keys(item)[0] + "/index", { pagePlugin:item }) %> - <%_} _%> -<%_ }) _%> +<%_ +(page.plugins||[]).forEach(function(item){ + try { + if (typeof item == "string") { _%> + <%- partial( item + "/index") %> +<%_ }else if(typeof item == "object"){ _%> + <%- partial( Object.keys(item)[0] + "/index", { pagePlugin:item }) %> +<%_ } + } catch (error) { + // error friendly + console.log(` +=============================================================================== + 没有找到页面插件:${item} + 请检查是否存在该插件,或者检查插件名称是否正确:${item} + 出问题的页面:${page.path} + see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins +================================================================================ + There is no page plugin: ${item} + Please check if the plugin exists, or check the plugin name is correct: ${item} + The page that has problem: ${page.path} + see: https://volantis.js.org/v5/page-settings/#页面插件-page-plugins +=================================================================================`); + } + +}) + +_%>