♻️ 改了一些组件

This commit is contained in:
BTMuli
2023-09-03 00:06:48 +08:00
parent 4debd354a7
commit faba854b74
7 changed files with 19 additions and 25 deletions

View File

@@ -2,25 +2,24 @@
* @file assets css post-parser.css * @file assets css post-parser.css
* @description 米游社解析 css * @description 米游社解析 css
* @author BTMuli <bt-muli@outlook.com> * @author BTMuli <bt-muli@outlook.com>
* @since Alpha v0.2.0 * @since Beta v0.3.0
*/ */
.mys-post-body { .mys-post-body {
width: 800px; width: 800px;
margin: 0 auto; margin: 0 auto;
color: var(--post-default-text);
font-family: var(--font-text); font-family: var(--font-text);
} }
.mys-post-title { .mys-post-title {
color: var(--common-text-title); color: var(--common-text-title);
font-family: var(--font-title); font-family: var(--font-title);
font-size: 24px; font-size: 20px;
} }
.mys-post-subtitle { .mys-post-subtitle {
color: var(--common-text-quote);
font-size: 16px; font-size: 16px;
opacity: 0.6;
} }
.mys-post-content { .mys-post-content {

View File

@@ -56,7 +56,6 @@ html.dark {
--common-text-quote: var(--tgc-dark-7); /* quote */ --common-text-quote: var(--tgc-dark-7); /* quote */
--back-top-shadow: #000000; --back-top-shadow: #000000;
--theme-switch-icon: #e1e1e1;
--post-default-text: #faf7e8; --post-default-text: #faf7e8;
--content-bg-2: #393b40; --content-bg-2: #393b40;

View File

@@ -52,7 +52,6 @@ html.default {
--common-text-quote: var(--common-color-blue-3); /* quote todo */ --common-text-quote: var(--common-color-blue-3); /* quote todo */
--back-top-shadow: #546d8b; --back-top-shadow: #546d8b;
--theme-switch-icon: #393b40;
--post-default-text: #1e1e1e; --post-default-text: #1e1e1e;
--content-bg-2: #faf7e8; --content-bg-2: #faf7e8;

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="switch-box"> <div class="switch-box">
<div class="switch-btn" @click="switchTheme()"> <div class="switch-btn" @click="switchTheme()">
<v-icon style="color: var(--theme-switch-icon)"> <v-icon>
{{ themeGet === "default" ? "mdi-weather-night" : "mdi-weather-sunny" }} {{ themeGet === "default" ? "mdi-weather-night" : "mdi-weather-sunny" }}
</v-icon> </v-icon>
</div> </div>
@@ -48,7 +48,7 @@ async function listenOnTheme(): Promise<void> {
position: absolute; position: absolute;
top: 20px; top: 20px;
left: 20px; left: 20px;
border: var(--theme-switch-icon) 2px solid; border: 2px solid var(--common-shadow-8);
border-radius: 50%; border-radius: 50%;
cursor: pointer; cursor: pointer;
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="share-box"> <div class="share-box">
<div class="share-btn" @click="shareContent()"> <div class="share-btn" @click="shareContent()">
<v-icon style="color: var(--theme-switch-icon)"> mdi-share-variant </v-icon> <v-icon> mdi-share-variant </v-icon>
</div> </div>
</div> </div>
</template> </template>
@@ -31,7 +31,7 @@ async function shareContent(): Promise<void> {
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 20px; right: 20px;
border: var(--theme-switch-icon) 2px solid; border: 2px solid var(--common-shadow-8);
border-radius: 50%; border-radius: 50%;
cursor: pointer; cursor: pointer;
} }

View File

@@ -114,11 +114,11 @@ async function toChannel(link: string): Promise<void> {
.toc-top { .toc-top {
padding: 10px; padding: 10px;
border-radius: 5px; border-radius: 5px;
background: rgb(255 255 255 / 30%); background: var(--app-page-bg);
} }
.toc-title { .toc-title {
color: var(--common-color-blue); color: var(--common-text-title);
font-family: var(--font-title); font-family: var(--font-title);
font-size: 20px; font-size: 20px;
} }
@@ -134,18 +134,14 @@ async function toChannel(link: string): Promise<void> {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: start; justify-content: start;
border: 1px solid var(--common-shadow-2);
border-radius: 5px; border-radius: 5px;
background: rgb(0 0 0 / 20%); background: var(--box-bg-1);
color: var(--common-color-black); color: var(--box-text-2);
cursor: pointer; cursor: pointer;
transition: all 0.5s linear; transition: all 0.5s linear;
} }
.toc-list-item:hover {
background: rgb(0 0 0 / 50%);
color: var(--common-color-white);
}
.toc-list-item img { .toc-list-item img {
width: 45px; width: 45px;
height: 45px; height: 45px;
@@ -175,8 +171,8 @@ async function toChannel(link: string): Promise<void> {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-radius: 50%; border-radius: 50%;
background: rgb(255 255 255 / 30%); background: var(--app-page-bg);
color: #faf7e8; color: var(--app-page-content);
cursor: pointer; cursor: pointer;
} }
</style> </style>

View File

@@ -25,7 +25,7 @@ function hexToRgb(hex: string): { r: number; g: number; b: number } {
/** /**
* @description 给定两个16进制颜色值确认两者是否相近 * @description 给定两个16进制颜色值确认两者是否相近
* @since Alpha v0.1.3 * @since Beta v0.3.0
* @param {string} colorBg 背景颜色 * @param {string} colorBg 背景颜色
* @param {string} colorFg 前景颜色 * @param {string} colorFg 前景颜色
* @returns {boolean} 是否相近 * @returns {boolean} 是否相近
@@ -44,7 +44,8 @@ function isColorSimilar(colorBg: string, colorFg: string): boolean {
const contrast = const contrast =
(Math.max(colorBgLumFinal, colorFgLumFinal) + 0.05) / (Math.max(colorBgLumFinal, colorFgLumFinal) + 0.05) /
(Math.min(colorBgLumFinal, colorFgLumFinal) + 0.05); (Math.min(colorBgLumFinal, colorFgLumFinal) + 0.05);
return contrast <= 2.5; // console.log(colorBg, colorFg, contrast);
return contrast > 1.5 && contrast < 4;
} }
/** /**
@@ -206,8 +207,8 @@ function parseText(data: TGApp.Plugins.Mys.Post.StructuredContent): HTMLSpanElem
if (data.attributes.color) { if (data.attributes.color) {
let colorGet = data.attributes.color; let colorGet = data.attributes.color;
// 如果 colorGet 在 darkColorList 中,就设置为对应的颜色 // 如果 colorGet 在 darkColorList 中,就设置为对应的颜色
if (isColorSimilar("#ffffff", colorGet) || isColorSimilar("#000000", colorGet)) { if (isColorSimilar("#000000", colorGet)) {
colorGet = "var(--post-default-text)"; colorGet = "var(--app-page-content)";
} }
text.style.color = colorGet; text.style.color = colorGet;
} }