diff --git a/assets/css/base.css b/assets/css/base.css index 9798f47..a6b7f12 100644 --- a/assets/css/base.css +++ b/assets/css/base.css @@ -1,8 +1,4 @@ /* 默认字体大小(桌面端) */ -body { - font-size: 16px; - color: var(--color-text); -} h1 { font-size: 24px; @@ -13,11 +9,11 @@ h2 { } h3 { - font-size: 18px; + font-size: 16px; } h4 { - font-size: 16px; + font-size: 14px; } /* * 手机端-手机端-手机端-手机端-手机端-手机端-手机端-手机端-手机端 * */ @@ -59,6 +55,9 @@ h4 { } } + +/* * 平板端-平板端-平板端-平板端-平板端-平板端-平板端-平板端-平板端 * */ + /* 平板端 */ @media (min-width: 768px) and (max-width: 1024px) { body { @@ -82,8 +81,6 @@ h4 { } } -/* * 平板端-平板端-平板端-平板端-平板端-平板端-平板端-平板端-平板端 * */ - /* 平板端(竖屏) */ @media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) { .container { diff --git a/assets/css/iconfont.css b/assets/css/iconfont.css index c27f4c5..7fbf71a 100644 --- a/assets/css/iconfont.css +++ b/assets/css/iconfont.css @@ -1,3 +1,4 @@ @import "../icon/cocoIconFont/iconfont.css"; @import "../icon/sxIconFont/iconfont.css"; @import "../icon/starIconFont/iconfont.css"; +@import "../icon/star-blogIconFont/iconfont.css"; diff --git a/assets/css/style.css b/assets/css/style.css index 307e802..ac28e5c 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -5,4 +5,49 @@ html, body { margin: 0; padding: 0; overflow: hidden; + font-size: 16px; +} +a { + /*去除默认下划线*/ + text-decoration: none; + /*设置初始颜色*/ + color: #333; + /*统一内边距和外边距*/ + margin: 0; + padding: 0; + /*去除默认的点击高亮*/ + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + /*处理不同状态的样式*/ + :link { + color: #333; + } + + :visited { + color: #333; + } + + :hover { + color: #333; + } + + :active { + color: #333; + } +} + +/*单行唱出隐藏显示省略号*/ +.oneLineOverMore{ + white-space: nowrap; /* 确保文本在一行内显示 */ + overflow: hidden; /* 隐藏超出部分 */ + text-overflow: ellipsis; /* 显示省略号 */ +} +/*宽高比*/ +.a11{ + aspect-ratio: 1; +} +/*全居中*/ +.allCenter{ + display: flex; + justify-content: center; + align-items: center; } diff --git a/assets/css/transitions.css b/assets/css/transitions.css index f4328f7..f5a599d 100644 --- a/assets/css/transitions.css +++ b/assets/css/transitions.css @@ -11,12 +11,12 @@ .slide-enter-active, .slide-leave-active { - transition: all 0.5s ease; + transition: all 0.3s ease; } .slide-enter-from, .slide-leave-to { opacity: 0; - transform: translate(100%, 0); + /*transform: translate(100%, 0);*/ } .slide-left-enter-active, @@ -27,17 +27,17 @@ } .slide-left-enter-from { opacity: 0; - transform: translate(50px, 0); + /*transform: translate(50px, 0);*/ } .slide-left-leave-to { opacity: 0; - transform: translate(-50px, 0); + /*transform: translate(-50px, 0);*/ } .slide-right-enter-from { opacity: 0; - transform: translate(-50px, 0); + /*transform: translate(-50px, 0);*/ } .slide-right-leave-to { opacity: 0; - transform: translate(50px, 0); -} \ No newline at end of file + /*transform: translate(50px, 0);*/ +} diff --git a/assets/css/value.css b/assets/css/value.css index 5d90763..1879818 100644 --- a/assets/css/value.css +++ b/assets/css/value.css @@ -24,7 +24,7 @@ /*字体颜色*/ --color-text: #333; --bg-opacity: 0.5; - --header-bg-color: #dddddd99; + --header-bg-color: rgb(254, 255, 252); /*#fefffc*/ /*主要着重颜色*/ --main-strong-color: #333; @@ -32,4 +32,16 @@ --nav-length: 5rem; /*圆角*/ --border-radius: 0.5rem; + /*blog菜单背景色*/ + --blog-menu-background-color: var(--header-bg-color); + /*blog菜单默认宽度*/ + --blog-menu-default-width: calc((100% - var(--main-width-auto)) / 2); + + /*字体颜色*/ + --font-color-top3-h1: #37352f; /*#37352f*/ + --font-color-top3-h2: #5f5e5b; /*1b1b1b*/ + --font-color-top3-h3: #91918e; /*1b1b1b*/ + --font-color-top3-active: rgb(232, 232, 231); /*#e8e8e7*/ + --font-color-top3-hover: rgb(239, 239, 237); /*#EFEFED*/ + } diff --git a/assets/icon/star-blogIconFont/demo.css b/assets/icon/star-blogIconFont/demo.css new file mode 100644 index 0000000..a67054a --- /dev/null +++ b/assets/icon/star-blogIconFont/demo.css @@ -0,0 +1,539 @@ +/* Logo 字体 */ +@font-face { + font-family: "iconfont logo"; + src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834'); + src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix') format('embedded-opentype'), + url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'), + url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'), + url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont') format('svg'); +} + +.logo { + font-family: "iconfont logo"; + font-size: 160px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* tabs */ +.nav-tabs { + position: relative; +} + +.nav-tabs .nav-more { + position: absolute; + right: 0; + bottom: 0; + height: 42px; + line-height: 42px; + color: #666; +} + +#tabs { + border-bottom: 1px solid #eee; +} + +#tabs li { + cursor: pointer; + width: 100px; + height: 40px; + line-height: 40px; + text-align: center; + font-size: 16px; + border-bottom: 2px solid transparent; + position: relative; + z-index: 1; + margin-bottom: -1px; + color: #666; +} + + +#tabs .active { + border-bottom-color: #f00; + color: #222; +} + +.tab-container .content { + display: none; +} + +/* 页面布局 */ +.main { + padding: 30px 100px; + width: 960px; + margin: 0 auto; +} + +.main .logo { + color: #333; + text-align: left; + margin-bottom: 30px; + line-height: 1; + height: 110px; + margin-top: -50px; + overflow: hidden; + *zoom: 1; +} + +.main .logo a { + font-size: 160px; + color: #333; +} + +.helps { + margin-top: 40px; +} + +.helps pre { + padding: 20px; + margin: 10px 0; + border: solid 1px #e7e1cd; + background-color: #fffdef; + overflow: auto; +} + +.icon_lists { + width: 100% !important; + overflow: hidden; + *zoom: 1; +} + +.icon_lists li { + width: 100px; + margin-bottom: 10px; + margin-right: 20px; + text-align: center; + list-style: none !important; + cursor: default; +} + +.icon_lists li .code-name { + line-height: 1.2; +} + +.icon_lists .icon { + display: block; + height: 100px; + line-height: 100px; + font-size: 42px; + margin: 10px auto; + color: #333; + -webkit-transition: font-size 0.25s linear, width 0.25s linear; + -moz-transition: font-size 0.25s linear, width 0.25s linear; + transition: font-size 0.25s linear, width 0.25s linear; +} + +.icon_lists .icon:hover { + font-size: 100px; +} + +.icon_lists .svg-icon { + /* 通过设置 font-size 来改变图标大小 */ + width: 1em; + /* 图标和文字相邻时,垂直对齐 */ + vertical-align: -0.15em; + /* 通过设置 color 来改变 SVG 的颜色/fill */ + fill: currentColor; + /* path 和 stroke 溢出 viewBox 部分在 IE 下会显示 + normalize.css 中也包含这行 */ + overflow: hidden; +} + +.icon_lists li .name, +.icon_lists li .code-name { + color: #666; +} + +/* markdown 样式 */ +.markdown { + color: #666; + font-size: 14px; + line-height: 1.8; +} + +.highlight { + line-height: 1.5; +} + +.markdown img { + vertical-align: middle; + max-width: 100%; +} + +.markdown h1 { + color: #404040; + font-weight: 500; + line-height: 40px; + margin-bottom: 24px; +} + +.markdown h2, +.markdown h3, +.markdown h4, +.markdown h5, +.markdown h6 { + color: #404040; + margin: 1.6em 0 0.6em 0; + font-weight: 500; + clear: both; +} + +.markdown h1 { + font-size: 28px; +} + +.markdown h2 { + font-size: 22px; +} + +.markdown h3 { + font-size: 16px; +} + +.markdown h4 { + font-size: 14px; +} + +.markdown h5 { + font-size: 12px; +} + +.markdown h6 { + font-size: 12px; +} + +.markdown hr { + height: 1px; + border: 0; + background: #e9e9e9; + margin: 16px 0; + clear: both; +} + +.markdown p { + margin: 1em 0; +} + +.markdown>p, +.markdown>blockquote, +.markdown>.highlight, +.markdown>ol, +.markdown>ul { + width: 80%; +} + +.markdown ul>li { + list-style: circle; +} + +.markdown>ul li, +.markdown blockquote ul>li { + margin-left: 20px; + padding-left: 4px; +} + +.markdown>ul li p, +.markdown>ol li p { + margin: 0.6em 0; +} + +.markdown ol>li { + list-style: decimal; +} + +.markdown>ol li, +.markdown blockquote ol>li { + margin-left: 20px; + padding-left: 4px; +} + +.markdown code { + margin: 0 3px; + padding: 0 5px; + background: #eee; + border-radius: 3px; +} + +.markdown strong, +.markdown b { + font-weight: 600; +} + +.markdown>table { + border-collapse: collapse; + border-spacing: 0px; + empty-cells: show; + border: 1px solid #e9e9e9; + width: 95%; + margin-bottom: 24px; +} + +.markdown>table th { + white-space: nowrap; + color: #333; + font-weight: 600; +} + +.markdown>table th, +.markdown>table td { + border: 1px solid #e9e9e9; + padding: 8px 16px; + text-align: left; +} + +.markdown>table th { + background: #F7F7F7; +} + +.markdown blockquote { + font-size: 90%; + color: #999; + border-left: 4px solid #e9e9e9; + padding-left: 0.8em; + margin: 1em 0; +} + +.markdown blockquote p { + margin: 0; +} + +.markdown .anchor { + opacity: 0; + transition: opacity 0.3s ease; + margin-left: 8px; +} + +.markdown .waiting { + color: #ccc; +} + +.markdown h1:hover .anchor, +.markdown h2:hover .anchor, +.markdown h3:hover .anchor, +.markdown h4:hover .anchor, +.markdown h5:hover .anchor, +.markdown h6:hover .anchor { + opacity: 1; + display: inline-block; +} + +.markdown>br, +.markdown>p>br { + clear: both; +} + + +.hljs { + display: block; + background: white; + padding: 0.5em; + color: #333333; + overflow-x: auto; +} + +.hljs-comment, +.hljs-meta { + color: #969896; +} + +.hljs-string, +.hljs-variable, +.hljs-template-variable, +.hljs-strong, +.hljs-emphasis, +.hljs-quote { + color: #df5000; +} + +.hljs-keyword, +.hljs-selector-tag, +.hljs-type { + color: #a71d5d; +} + +.hljs-literal, +.hljs-symbol, +.hljs-bullet, +.hljs-attribute { + color: #0086b3; +} + +.hljs-section, +.hljs-name { + color: #63a35c; +} + +.hljs-tag { + color: #333333; +} + +.hljs-title, +.hljs-attr, +.hljs-selector-id, +.hljs-selector-class, +.hljs-selector-attr, +.hljs-selector-pseudo { + color: #795da3; +} + +.hljs-addition { + color: #55a532; + background-color: #eaffea; +} + +.hljs-deletion { + color: #bd2c00; + background-color: #ffecec; +} + +.hljs-link { + text-decoration: underline; +} + +/* 代码高亮 */ +/* PrismJS 1.15.0 +https://prismjs.com/download.html#themes=prism&languages=markup+css+clike+javascript */ +/** + * prism.js default theme for JavaScript, CSS and HTML + * Based on dabblet (http://dabblet.com) + * @author Lea Verou + */ +code[class*="language-"], +pre[class*="language-"] { + color: black; + background: none; + text-shadow: 0 1px white; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + word-wrap: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +pre[class*="language-"]::-moz-selection, +pre[class*="language-"] ::-moz-selection, +code[class*="language-"]::-moz-selection, +code[class*="language-"] ::-moz-selection { + text-shadow: none; + background: #b3d4fc; +} + +pre[class*="language-"]::selection, +pre[class*="language-"] ::selection, +code[class*="language-"]::selection, +code[class*="language-"] ::selection { + text-shadow: none; + background: #b3d4fc; +} + +@media print { + + code[class*="language-"], + pre[class*="language-"] { + text-shadow: none; + } +} + +/* Code blocks */ +pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; +} + +:not(pre)>code[class*="language-"], +pre[class*="language-"] { + background: #f5f2f0; +} + +/* Inline code */ +:not(pre)>code[class*="language-"] { + padding: .1em; + border-radius: .3em; + white-space: normal; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: slategray; +} + +.token.punctuation { + color: #999; +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.boolean, +.token.number, +.token.constant, +.token.symbol, +.token.deleted { + color: #905; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.inserted { + color: #690; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + color: #9a6e3a; + background: hsla(0, 0%, 100%, .5); +} + +.token.atrule, +.token.attr-value, +.token.keyword { + color: #07a; +} + +.token.function, +.token.class-name { + color: #DD4A68; +} + +.token.regex, +.token.important, +.token.variable { + color: #e90; +} + +.token.important, +.token.bold { + font-weight: bold; +} + +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} diff --git a/assets/icon/star-blogIconFont/demo_index.html b/assets/icon/star-blogIconFont/demo_index.html new file mode 100644 index 0000000..f1f807f --- /dev/null +++ b/assets/icon/star-blogIconFont/demo_index.html @@ -0,0 +1,832 @@ + + + + + iconfont Demo + + + + + + + + + + + + + +
+

+ + +

+ +
+
+
    + +
  • + +
    通知
    +
    
    +
  • + +
  • + +
    首页
    +
    
    +
  • + +
  • + +
    定位
    +
    
    +
  • + +
  • + +
    日历
    +
    
    +
  • + +
  • + +
    邮件
    +
    
    +
  • + +
  • + +
    标签
    +
    
    +
  • + +
  • + +
    统计
    +
    
    +
  • + +
  • + +
    收藏
    +
    
    +
  • + +
  • + +
    文件
    +
    
    +
  • + +
  • + +
    设置
    +
    
    +
  • + +
  • + +
    喜爱
    +
    
    +
  • + +
  • + +
    指针
    +
    
    +
  • + +
  • + +
    分类
    +
    
    +
  • + +
  • + +
    购物包
    +
    
    +
  • + +
  • + +
    文档
    +
    
    +
  • + +
  • + +
    搜索
    +
    
    +
  • + +
  • + +
    游戏
    +
    
    +
  • + +
  • + +
    统计分析
    +
    
    +
  • + +
  • + +
    我的
    +
    
    +
  • + +
  • + +
    钱包
    +
    
    +
  • + +
  • + +
    消息
    +
    
    +
  • + +
  • + +
    数据动态
    +
    
    +
  • + +
  • + +
    二维码
    +
    
    +
  • + +
  • + +
    更多
    +
    
    +
  • + +
  • + +
    添加
    +
    
    +
  • + +
  • + +
    添加
    +
    
    +
  • + +
  • + +
    更多
    +
    
    +
  • + +
  • + +
    折叠-收起
    +
    
    +
  • + +
+
+

Unicode 引用

+
+ +

Unicode 是字体在网页端最原始的应用方式,特点是:

+
    +
  • 支持按字体的方式去动态调整图标大小,颜色等等。
  • +
  • 默认情况下不支持多色,直接添加多色图标会自动去色。
  • +
+
+

注意:新版 iconfont 支持两种方式引用多色图标:SVG symbol 引用方式和彩色字体图标模式。(使用彩色字体图标需要在「编辑项目」中开启「彩色」选项后并重新生成。)

+
+

Unicode 使用步骤如下:

+

第一步:拷贝项目下面生成的 @font-face

+
@font-face {
+  font-family: 'star-blog';
+  src: url('iconfont.woff2?t=1745569316996') format('woff2'),
+       url('iconfont.woff?t=1745569316996') format('woff'),
+       url('iconfont.ttf?t=1745569316996') format('truetype');
+}
+
+

第二步:定义使用 iconfont 的样式

+
.star-blog {
+  font-family: "star-blog" !important;
+  font-size: 16px;
+  font-style: normal;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+}
+
+

第三步:挑选相应图标并获取字体编码,应用于页面

+
+<span class="star-blog">&#x33;</span>
+
+
+

"star-blog" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

+
+
+
+
+
    + +
  • + +
    + 通知 +
    +
    .star-blog-tongzhi +
    +
  • + +
  • + +
    + 首页 +
    +
    .star-blog-shouye +
    +
  • + +
  • + +
    + 定位 +
    +
    .star-blog-dingwei +
    +
  • + +
  • + +
    + 日历 +
    +
    .star-blog-rili +
    +
  • + +
  • + +
    + 邮件 +
    +
    .star-blog-youjian +
    +
  • + +
  • + +
    + 标签 +
    +
    .star-blog-biaoqian +
    +
  • + +
  • + +
    + 统计 +
    +
    .star-blog-tongji +
    +
  • + +
  • + +
    + 收藏 +
    +
    .star-blog-shoucang +
    +
  • + +
  • + +
    + 文件 +
    +
    .star-blog-wenjian +
    +
  • + +
  • + +
    + 设置 +
    +
    .star-blog-shezhi +
    +
  • + +
  • + +
    + 喜爱 +
    +
    .star-blog-xiai +
    +
  • + +
  • + +
    + 指针 +
    +
    .star-blog-zhizhen +
    +
  • + +
  • + +
    + 分类 +
    +
    .star-blog-fenlei +
    +
  • + +
  • + +
    + 购物包 +
    +
    .star-blog-gouwubao +
    +
  • + +
  • + +
    + 文档 +
    +
    .star-blog-wendang +
    +
  • + +
  • + +
    + 搜索 +
    +
    .star-blog-sousuo +
    +
  • + +
  • + +
    + 游戏 +
    +
    .star-blog-youxi +
    +
  • + +
  • + +
    + 统计分析 +
    +
    .star-blog-tongjifenxi +
    +
  • + +
  • + +
    + 我的 +
    +
    .star-blog-wode +
    +
  • + +
  • + +
    + 钱包 +
    +
    .star-blog-qianbao +
    +
  • + +
  • + +
    + 消息 +
    +
    .star-blog-xiaoxi +
    +
  • + +
  • + +
    + 数据动态 +
    +
    .star-blog-shujudongtai +
    +
  • + +
  • + +
    + 二维码 +
    +
    .star-blog-erweima +
    +
  • + +
  • + +
    + 更多 +
    +
    .star-blog-gengduo +
    +
  • + +
  • + +
    + 添加 +
    +
    .star-blog-tianjia +
    +
  • + +
  • + +
    + 添加 +
    +
    .star-blog-tianjia1 +
    +
  • + +
  • + +
    + 更多 +
    +
    .star-blog-gengduo1 +
    +
  • + +
  • + +
    + 折叠-收起 +
    +
    .star-blog-zhedie-shouqi +
    +
  • + +
+
+

font-class 引用

+
+ +

font-class 是 Unicode 使用方式的一种变种,主要是解决 Unicode 书写不直观,语意不明确的问题。

+

与 Unicode 使用方式相比,具有如下特点:

+
    +
  • 相比于 Unicode 语意明确,书写更直观。可以很容易分辨这个 icon 是什么。
  • +
  • 因为使用 class 来定义图标,所以当要替换图标时,只需要修改 class 里面的 Unicode 引用。
  • +
+

使用步骤如下:

+

第一步:引入项目下面生成的 fontclass 代码:

+
<link rel="stylesheet" href="./iconfont.css">
+
+

第二步:挑选相应图标并获取类名,应用于页面:

+
<span class="star-blog star-blog-xxx"></span>
+
+
+

" + star-blog" 是你项目下的 font-family。可以通过编辑项目查看,默认是 "iconfont"。

+
+
+
+
+
    + +
  • + +
    通知
    +
    #star-blog-tongzhi
    +
  • + +
  • + +
    首页
    +
    #star-blog-shouye
    +
  • + +
  • + +
    定位
    +
    #star-blog-dingwei
    +
  • + +
  • + +
    日历
    +
    #star-blog-rili
    +
  • + +
  • + +
    邮件
    +
    #star-blog-youjian
    +
  • + +
  • + +
    标签
    +
    #star-blog-biaoqian
    +
  • + +
  • + +
    统计
    +
    #star-blog-tongji
    +
  • + +
  • + +
    收藏
    +
    #star-blog-shoucang
    +
  • + +
  • + +
    文件
    +
    #star-blog-wenjian
    +
  • + +
  • + +
    设置
    +
    #star-blog-shezhi
    +
  • + +
  • + +
    喜爱
    +
    #star-blog-xiai
    +
  • + +
  • + +
    指针
    +
    #star-blog-zhizhen
    +
  • + +
  • + +
    分类
    +
    #star-blog-fenlei
    +
  • + +
  • + +
    购物包
    +
    #star-blog-gouwubao
    +
  • + +
  • + +
    文档
    +
    #star-blog-wendang
    +
  • + +
  • + +
    搜索
    +
    #star-blog-sousuo
    +
  • + +
  • + +
    游戏
    +
    #star-blog-youxi
    +
  • + +
  • + +
    统计分析
    +
    #star-blog-tongjifenxi
    +
  • + +
  • + +
    我的
    +
    #star-blog-wode
    +
  • + +
  • + +
    钱包
    +
    #star-blog-qianbao
    +
  • + +
  • + +
    消息
    +
    #star-blog-xiaoxi
    +
  • + +
  • + +
    数据动态
    +
    #star-blog-shujudongtai
    +
  • + +
  • + +
    二维码
    +
    #star-blog-erweima
    +
  • + +
  • + +
    更多
    +
    #star-blog-gengduo
    +
  • + +
  • + +
    添加
    +
    #star-blog-tianjia
    +
  • + +
  • + +
    添加
    +
    #star-blog-tianjia1
    +
  • + +
  • + +
    更多
    +
    #star-blog-gengduo1
    +
  • + +
  • + +
    折叠-收起
    +
    #star-blog-zhedie-shouqi
    +
  • + +
+
+

Symbol 引用

+
+ +

这是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法。相关介绍可以参考这篇文章 + 这种用法其实是做了一个 SVG 的集合,与另外两种相比具有如下特点:

+
    +
  • 支持多色图标了,不再受单色限制。
  • +
  • 通过一些技巧,支持像字体那样,通过 font-size, color 来调整样式。
  • +
  • 兼容性较差,支持 IE9+,及现代浏览器。
  • +
  • 浏览器渲染 SVG 的性能一般,还不如 png。
  • +
+

使用步骤如下:

+

第一步:引入项目下面生成的 symbol 代码:

+
<script src="./iconfont.js"></script>
+
+

第二步:加入通用 CSS 代码(引入一次就行):

+
<style>
+.icon {
+  width: 1em;
+  height: 1em;
+  vertical-align: -0.15em;
+  fill: currentColor;
+  overflow: hidden;
+}
+</style>
+
+

第三步:挑选相应图标并获取类名,应用于页面:

+
<svg class="icon" aria-hidden="true">
+  <use xlink:href="#icon-xxx"></use>
+</svg>
+
+
+
+ +
+
+ + + diff --git a/assets/icon/star-blogIconFont/iconfont.css b/assets/icon/star-blogIconFont/iconfont.css new file mode 100644 index 0000000..8b49758 --- /dev/null +++ b/assets/icon/star-blogIconFont/iconfont.css @@ -0,0 +1,127 @@ +@font-face { + font-family: "star-blog"; /* Project id 4905744 */ + src: url('iconfont.woff2?t=1745569316996') format('woff2'), + url('iconfont.woff?t=1745569316996') format('woff'), + url('iconfont.ttf?t=1745569316996') format('truetype'); +} + +.star-blogIconFont { + font-family: "star-blog" !important; + font-size: 16px; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.star-blog-tongzhi:before { + content: "\e669"; +} + +.star-blog-shouye:before { + content: "\e66a"; +} + +.star-blog-dingwei:before { + content: "\e66c"; +} + +.star-blog-rili:before { + content: "\e66d"; +} + +.star-blog-youjian:before { + content: "\e66e"; +} + +.star-blog-biaoqian:before { + content: "\e66f"; +} + +.star-blog-tongji:before { + content: "\e670"; +} + +.star-blog-shoucang:before { + content: "\e671"; +} + +.star-blog-wenjian:before { + content: "\e672"; +} + +.star-blog-shezhi:before { + content: "\e673"; +} + +.star-blog-xiai:before { + content: "\e674"; +} + +.star-blog-zhizhen:before { + content: "\e675"; +} + +.star-blog-fenlei:before { + content: "\e676"; +} + +.star-blog-gouwubao:before { + content: "\e677"; +} + +.star-blog-wendang:before { + content: "\e678"; +} + +.star-blog-sousuo:before { + content: "\e679"; +} + +.star-blog-youxi:before { + content: "\e67a"; +} + +.star-blog-tongjifenxi:before { + content: "\e67b"; +} + +.star-blog-wode:before { + content: "\e67c"; +} + +.star-blog-qianbao:before { + content: "\e67d"; +} + +.star-blog-xiaoxi:before { + content: "\e67e"; +} + +.star-blog-shujudongtai:before { + content: "\e680"; +} + +.star-blog-erweima:before { + content: "\e681"; +} + +.star-blog-gengduo:before { + content: "\e73a"; +} + +.star-blog-tianjia:before { + content: "\e608"; +} + +.star-blog-tianjia1:before { + content: "\e668"; +} + +.star-blog-gengduo1:before { + content: "\e606"; +} + +.star-blog-zhedie-shouqi:before { + content: "\e67f"; +} + diff --git a/assets/icon/star-blogIconFont/iconfont.js b/assets/icon/star-blogIconFont/iconfont.js new file mode 100644 index 0000000..fa415f1 --- /dev/null +++ b/assets/icon/star-blogIconFont/iconfont.js @@ -0,0 +1 @@ +window._iconfont_svg_string_4905744='',(l=>{var a=(t=(t=document.getElementsByTagName("script"))[t.length-1]).getAttribute("data-injectcss"),t=t.getAttribute("data-disable-injectsvg");if(!t){var i,h,o,c,s,e=function(a,t){t.parentNode.insertBefore(a,t)};if(a&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(a){console&&console.log(a)}}i=function(){var a,t=document.createElement("div");t.innerHTML=l._iconfont_svg_string_4905744,(t=t.getElementsByTagName("svg")[0])&&(t.setAttribute("aria-hidden","true"),t.style.position="absolute",t.style.width=0,t.style.height=0,t.style.overflow="hidden",t=t,(a=document.body).firstChild?e(t,a.firstChild):a.appendChild(t))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(i,0):(h=function(){document.removeEventListener("DOMContentLoaded",h,!1),i()},document.addEventListener("DOMContentLoaded",h,!1)):document.attachEvent&&(o=i,c=l.document,s=!1,d(),c.onreadystatechange=function(){"complete"==c.readyState&&(c.onreadystatechange=null,p())})}function p(){s||(s=!0,o())}function d(){try{c.documentElement.doScroll("left")}catch(a){return void setTimeout(d,50)}p()}})(window); \ No newline at end of file diff --git a/assets/icon/star-blogIconFont/iconfont.json b/assets/icon/star-blogIconFont/iconfont.json new file mode 100644 index 0000000..6629e61 --- /dev/null +++ b/assets/icon/star-blogIconFont/iconfont.json @@ -0,0 +1,205 @@ +{ + "id": "4905744", + "name": "star-blog", + "font_family": "star-blog", + "css_prefix_text": "star-blog-", + "description": "", + "glyphs": [ + { + "icon_id": "23027728", + "name": "通知", + "font_class": "tongzhi", + "unicode": "e669", + "unicode_decimal": 58985 + }, + { + "icon_id": "23027729", + "name": "首页", + "font_class": "shouye", + "unicode": "e66a", + "unicode_decimal": 58986 + }, + { + "icon_id": "23027731", + "name": "定位", + "font_class": "dingwei", + "unicode": "e66c", + "unicode_decimal": 58988 + }, + { + "icon_id": "23027732", + "name": "日历", + "font_class": "rili", + "unicode": "e66d", + "unicode_decimal": 58989 + }, + { + "icon_id": "23027733", + "name": "邮件", + "font_class": "youjian", + "unicode": "e66e", + "unicode_decimal": 58990 + }, + { + "icon_id": "23027734", + "name": "标签", + "font_class": "biaoqian", + "unicode": "e66f", + "unicode_decimal": 58991 + }, + { + "icon_id": "23027735", + "name": "统计", + "font_class": "tongji", + "unicode": "e670", + "unicode_decimal": 58992 + }, + { + "icon_id": "23027736", + "name": "收藏", + "font_class": "shoucang", + "unicode": "e671", + "unicode_decimal": 58993 + }, + { + "icon_id": "23027737", + "name": "文件", + "font_class": "wenjian", + "unicode": "e672", + "unicode_decimal": 58994 + }, + { + "icon_id": "23027738", + "name": "设置", + "font_class": "shezhi", + "unicode": "e673", + "unicode_decimal": 58995 + }, + { + "icon_id": "23027739", + "name": "喜爱", + "font_class": "xiai", + "unicode": "e674", + "unicode_decimal": 58996 + }, + { + "icon_id": "23027740", + "name": "指针", + "font_class": "zhizhen", + "unicode": "e675", + "unicode_decimal": 58997 + }, + { + "icon_id": "23027741", + "name": "分类", + "font_class": "fenlei", + "unicode": "e676", + "unicode_decimal": 58998 + }, + { + "icon_id": "23027742", + "name": "购物包", + "font_class": "gouwubao", + "unicode": "e677", + "unicode_decimal": 58999 + }, + { + "icon_id": "23027743", + "name": "文档", + "font_class": "wendang", + "unicode": "e678", + "unicode_decimal": 59000 + }, + { + "icon_id": "23027744", + "name": "搜索", + "font_class": "sousuo", + "unicode": "e679", + "unicode_decimal": 59001 + }, + { + "icon_id": "23027745", + "name": "游戏", + "font_class": "youxi", + "unicode": "e67a", + "unicode_decimal": 59002 + }, + { + "icon_id": "23027746", + "name": "统计分析", + "font_class": "tongjifenxi", + "unicode": "e67b", + "unicode_decimal": 59003 + }, + { + "icon_id": "23027747", + "name": "我的", + "font_class": "wode", + "unicode": "e67c", + "unicode_decimal": 59004 + }, + { + "icon_id": "23027748", + "name": "钱包", + "font_class": "qianbao", + "unicode": "e67d", + "unicode_decimal": 59005 + }, + { + "icon_id": "23027749", + "name": "消息", + "font_class": "xiaoxi", + "unicode": "e67e", + "unicode_decimal": 59006 + }, + { + "icon_id": "23027750", + "name": "数据动态", + "font_class": "shujudongtai", + "unicode": "e680", + "unicode_decimal": 59008 + }, + { + "icon_id": "23027751", + "name": "二维码", + "font_class": "erweima", + "unicode": "e681", + "unicode_decimal": 59009 + }, + { + "icon_id": "577338", + "name": "更多", + "font_class": "gengduo", + "unicode": "e73a", + "unicode_decimal": 59194 + }, + { + "icon_id": "18799718", + "name": "添加", + "font_class": "tianjia", + "unicode": "e608", + "unicode_decimal": 58888 + }, + { + "icon_id": "23027730", + "name": "添加", + "font_class": "tianjia1", + "unicode": "e668", + "unicode_decimal": 58984 + }, + { + "icon_id": "24990207", + "name": "更多", + "font_class": "gengduo1", + "unicode": "e606", + "unicode_decimal": 58886 + }, + { + "icon_id": "36594927", + "name": "折叠-收起", + "font_class": "zhedie-shouqi", + "unicode": "e67f", + "unicode_decimal": 59007 + } + ] +} diff --git a/assets/icon/star-blogIconFont/iconfont.ttf b/assets/icon/star-blogIconFont/iconfont.ttf new file mode 100644 index 0000000..205a0c2 Binary files /dev/null and b/assets/icon/star-blogIconFont/iconfont.ttf differ diff --git a/assets/icon/star-blogIconFont/iconfont.woff b/assets/icon/star-blogIconFont/iconfont.woff new file mode 100644 index 0000000..1a253d7 Binary files /dev/null and b/assets/icon/star-blogIconFont/iconfont.woff differ diff --git a/assets/icon/star-blogIconFont/iconfont.woff2 b/assets/icon/star-blogIconFont/iconfont.woff2 new file mode 100644 index 0000000..4d50b11 Binary files /dev/null and b/assets/icon/star-blogIconFont/iconfont.woff2 differ diff --git a/assets/icon/starIconFont/iconfont.css b/assets/icon/starIconFont/iconfont.css index 1aba66b..b26ecc3 100644 --- a/assets/icon/starIconFont/iconfont.css +++ b/assets/icon/starIconFont/iconfont.css @@ -1,7 +1,7 @@ @font-face { font-family: "starIconFont"; /* Project id 4902296 */ /* Color fonts */ - src: + src: url('iconfont.woff2?t=1745398567721') format('woff2'), url('iconfont.woff?t=1745398567721') format('woff'), url('iconfont.ttf?t=1745398567721') format('truetype'); diff --git a/components/Home/Header.vue b/components/Home/Header.vue index 0c8249e..2073ed0 100644 --- a/components/Home/Header.vue +++ b/components/Home/Header.vue @@ -1,6 +1,5 @@ + + + + diff --git a/components/ResizeContent.vue b/components/ResizeContent.vue new file mode 100644 index 0000000..36f768c --- /dev/null +++ b/components/ResizeContent.vue @@ -0,0 +1,142 @@ + + + + + + diff --git a/docs/07-vue3高性能宽度拖拽调整.md b/docs/07-vue3高性能宽度拖拽调整.md new file mode 100644 index 0000000..4c2925a --- /dev/null +++ b/docs/07-vue3高性能宽度拖拽调整.md @@ -0,0 +1,221 @@ +> deepseek +> +> 以下是在 Vue3 中实现高性能拖拽调整宽度的 **完整代码**,包含详细注释和优化策略: + +```vue + + + + + +``` + +### 关键优化注释说明: + +1. **性能优化策略**: + ```javascript + // 使用 CSS 变量直接操作样式 + resizableElement.value.style.setProperty('--width', ...) + + // 通过 RAF 节流高频事件 + cancelAnimationFrame(rafId) + rafId = requestAnimationFrame(...) + + // passive 事件监听提升滚动性能 + { passive: true } + ``` + +2. **跨平台支持**: + ```javascript + // 统一处理鼠标/触摸事件 + const clientX = e.clientX ?? e.touches[0].clientX + ``` + +3. **内存管理**: + ```javascript + onBeforeUnmount(() => { + cancelAnimationFrame(rafId) // 避免内存泄漏 + }) + ``` + +4. **渲染优化**: + ```css + will-change: width; /* 提前告知浏览器变化属性 */ + transform: translateZ(0); /* 强制开启 GPU 加速 */ + ``` + +### 扩展建议用法: + +1. **添加约束条件**: + ```javascript + // 在 handleDrag 中扩展 + const maxWidth = 800 // 或通过 props 传入 + const clampedWidth = Math.max(100, Math.min(maxWidth, newWidth)) + ``` + +2. **持久化存储**: + ```javascript + // 在 stopDrag 中添加 + localStorage.setItem('savedWidth', width.value) + // 初始化时读取 + width.value = Number(localStorage.getItem('savedWidth')) || 300 + ``` + +3. **性能监控(开发环境)**: + ```javascript + import { usePerf } from '@vueuse/core' + const { fps } = usePerf() + // 在拖拽时观察 fps 值 + ``` + +该方案经过测试在以下场景表现良好: +- 2000px 快速拖拽(平均 58fps) +- 低端移动设备(Redmi 9A,45fps) +- 复杂页面环境(多图表+动画场景,52fps) + +建议根据实际需求调整过渡动画时间和手柄样式,可在不影响性能的前提下提升视觉体验。 diff --git a/layouts/home.vue b/layouts/home.vue index e2f090d..34d5101 100644 --- a/layouts/home.vue +++ b/layouts/home.vue @@ -6,7 +6,7 @@
- +
@@ -25,30 +25,16 @@ flex-shrink: 0; } - .homeMain { + div.homeMain { + position: relative; + overflow-y: hidden; flex: 1; width: 100%; - overflow: hidden; - display: flex; - - & > * { - position: relative; - overflow-y: auto; - } - - & > .homeMainLeft { - flex: 1; - } - & > main.homeMainContent { - flex-shrink: 0; - width: var(--main-width-auto); - background-color: var(--bg-color-be); - } - - & > .homeMainRight { - flex: 1; - + position: relative; + width: 100%; + height: 100%; + overflow: auto; } } } diff --git a/layouts/start.vue b/layouts/start.vue index 45c67d1..de2078c 100644 --- a/layouts/start.vue +++ b/layouts/start.vue @@ -8,5 +8,10 @@ diff --git a/nuxt.config.ts b/nuxt.config.ts index 60aa9e8..705ca03 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -8,7 +8,7 @@ import type {AddressInfo} from "node:net"; export default defineNuxtConfig({ compatibilityDate: '2024-11-01', devtools: { enabled: true }, - modules: ['@nuxt/eslint', '@nuxtjs/tailwindcss'], + modules: ['@nuxt/eslint', /*'@nuxtjs/tailwindcss'*/], devServer: { host: '0.0.0.0', port: 3000, diff --git a/pages/home/blog/index.vue b/pages/home/blog/index.vue index c8f8f41..0ae12e8 100644 --- a/pages/home/blog/index.vue +++ b/pages/home/blog/index.vue @@ -6,12 +6,209 @@ definePageMeta({ mode: 'out-in', }, }) -const {data} = useFetch('/api/blog/blogMenu') +const menuList = ref([]); + +const getMenuListFetch = async () => { + const { data, pending, error } = await useFetch('/api/blog/blogMenu'); + if (error.value) { + consola.error('数据获取失败:', error.value); + } + menuList.value = data.value?.filter(i => i.pid === '0') +} + + +// SSR运行 +await getMenuListFetch() +onMounted(() => { + consola.log(menuList.value) + +}) - \ No newline at end of file + diff --git a/pages/home/index.vue b/pages/home/index.vue index 172a6e3..528cc45 100644 --- a/pages/home/index.vue +++ b/pages/home/index.vue @@ -7,7 +7,6 @@ definePageMeta({ }, }) const {data} = await useFetch('/api/hello') -consola.info(toValue(data))