From b667036ae1a8a360f9d97b576ab3602ab2caa849 Mon Sep 17 00:00:00 2001 From: XPoet Date: Thu, 7 Mar 2024 15:50:55 +0800 Subject: [PATCH] perf: optimize page template render --- layout/_partial/first-screen.ejs | 11 +- .../templates => _template}/friends-link.ejs | 2 +- layout/_template/page-template.ejs | 59 +++++ .../templates => _template}/photo-album.ejs | 2 +- layout/_template/tools-nav.ejs | 3 + layout/page-template.ejs | 44 ---- layout/page.ejs | 14 +- scripts/events/config-handle.js | 13 +- source/css/common/css-variables.styl | 4 +- source/css/layout/_partial/header.styl | 5 + source/css/layout/_template/friends-link.styl | 183 +++++++++++++ .../css/layout/_template/page-template.styl | 43 +++ source/css/layout/_template/photo-album.styl | 19 ++ source/css/layout/page-template.styl | 244 ------------------ source/css/layout/page.styl | 5 + source/css/style.styl | 4 +- source/js/main.js | 11 + 17 files changed, 359 insertions(+), 307 deletions(-) rename layout/{_partial/templates => _template}/friends-link.ejs (95%) create mode 100644 layout/_template/page-template.ejs rename layout/{_partial/templates => _template}/photo-album.ejs (79%) create mode 100644 layout/_template/tools-nav.ejs delete mode 100644 layout/page-template.ejs create mode 100644 source/css/layout/_template/friends-link.styl create mode 100644 source/css/layout/_template/page-template.styl create mode 100644 source/css/layout/_template/photo-album.styl delete mode 100644 source/css/layout/page-template.styl diff --git a/layout/_partial/first-screen.ejs b/layout/_partial/first-screen.ejs index 7c8fbe8d..fc37534a 100644 --- a/layout/_partial/first-screen.ejs +++ b/layout/_partial/first-screen.ejs @@ -71,13 +71,14 @@ const { enable: sc_enable, links: sc_links } = theme?.social_contact || {} <% } %> - <% for (const icon in theme?.icons) { %> - <% if(theme.icons[icon]) { %> + <% const custom_icons = theme.source_data?.icons || {} %> + <% for (const icon in custom_icons) { %> + <% if(custom_icons[icon]) { %> <% - const custom_tmpl = theme.icons[icon].link.split('|').map(x => x.trim()) + const custom_tmpl = custom_icons[icon].link.split('|').map(x => x.trim()) let custom_is_img = false - let custom_link = theme.icons[icon].link - const custom_svg = theme.icons[icon].svg + let custom_link = custom_icons[icon].link + const custom_svg = custom_icons[icon].svg if (custom_tmpl.length > 1) { custom_link = custom_tmpl[1] custom_is_img = custom_tmpl[0] === 'img' diff --git a/layout/_partial/templates/friends-link.ejs b/layout/_template/friends-link.ejs similarity index 95% rename from layout/_partial/templates/friends-link.ejs rename to layout/_template/friends-link.ejs index 00da40e3..249f36dd 100644 --- a/layout/_partial/templates/friends-link.ejs +++ b/layout/_template/friends-link.ejs @@ -1,5 +1,5 @@