Skip to content

Commit

Permalink
♻️ 改了一些组件
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Sep 2, 2023
1 parent 4debd35 commit faba854
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
7 changes: 3 additions & 4 deletions src/assets/css/post-parser.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
* @file assets css post-parser.css
* @description 米游社解析 css
* @author BTMuli <[email protected]>
* @since Alpha v0.2.0
* @since Beta v0.3.0
*/

.mys-post-body {
width: 800px;
margin: 0 auto;
color: var(--post-default-text);
font-family: var(--font-text);
}

.mys-post-title {
color: var(--common-text-title);
font-family: var(--font-title);
font-size: 24px;
font-size: 20px;
}

.mys-post-subtitle {
color: var(--common-text-quote);
font-size: 16px;
opacity: 0.6;
}

.mys-post-content {
Expand Down
1 change: 0 additions & 1 deletion src/assets/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ html.dark {
--common-text-quote: var(--tgc-dark-7); /* quote */

--back-top-shadow: #000000;
--theme-switch-icon: #e1e1e1;
--post-default-text: #faf7e8;

--content-bg-2: #393b40;
Expand Down
1 change: 0 additions & 1 deletion src/assets/themes/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ html.default {
--common-text-quote: var(--common-color-blue-3); /* quote todo */

--back-top-shadow: #546d8b;
--theme-switch-icon: #393b40;
--post-default-text: #1e1e1e;

--content-bg-2: #faf7e8;
Expand Down
4 changes: 2 additions & 2 deletions src/components/app/t-switchTheme.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="switch-box">
<div class="switch-btn" @click="switchTheme()">
<v-icon style="color: var(--theme-switch-icon)">
<v-icon>
{{ themeGet === "default" ? "mdi-weather-night" : "mdi-weather-sunny" }}
</v-icon>
</div>
Expand Down Expand Up @@ -48,7 +48,7 @@ async function listenOnTheme(): Promise<void> {
position: absolute;
top: 20px;
left: 20px;
border: var(--theme-switch-icon) 2px solid;
border: 2px solid var(--common-shadow-8);
border-radius: 50%;
cursor: pointer;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/main/t-shareBtn.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="share-box">
<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>
</template>
Expand Down Expand Up @@ -31,7 +31,7 @@ async function shareContent(): Promise<void> {
position: absolute;
top: 20px;
right: 20px;
border: var(--theme-switch-icon) 2px solid;
border: 2px solid var(--common-shadow-8);
border-radius: 50%;
cursor: pointer;
}
Expand Down
18 changes: 7 additions & 11 deletions src/components/overlay/to-channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ async function toChannel(link: string): Promise<void> {
.toc-top {
padding: 10px;
border-radius: 5px;
background: rgb(255 255 255 / 30%);
background: var(--app-page-bg);
}
.toc-title {
color: var(--common-color-blue);
color: var(--common-text-title);
font-family: var(--font-title);
font-size: 20px;
}
Expand All @@ -134,18 +134,14 @@ async function toChannel(link: string): Promise<void> {
display: flex;
align-items: center;
justify-content: start;
border: 1px solid var(--common-shadow-2);
border-radius: 5px;
background: rgb(0 0 0 / 20%);
color: var(--common-color-black);
background: var(--box-bg-1);
color: var(--box-text-2);
cursor: pointer;
transition: all 0.5s linear;
}
.toc-list-item:hover {
background: rgb(0 0 0 / 50%);
color: var(--common-color-white);
}
.toc-list-item img {
width: 45px;
height: 45px;
Expand Down Expand Up @@ -175,8 +171,8 @@ async function toChannel(link: string): Promise<void> {
align-items: center;
justify-content: center;
border-radius: 50%;
background: rgb(255 255 255 / 30%);
color: #faf7e8;
background: var(--app-page-bg);
color: var(--app-page-content);
cursor: pointer;
}
</style>
9 changes: 5 additions & 4 deletions src/plugins/Mys/utils/parsePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function hexToRgb(hex: string): { r: number; g: number; b: number } {

/**
* @description 给定两个16进制颜色值,确认两者是否相近
* @since Alpha v0.1.3
* @since Beta v0.3.0
* @param {string} colorBg 背景颜色
* @param {string} colorFg 前景颜色
* @returns {boolean} 是否相近
Expand All @@ -44,7 +44,8 @@ function isColorSimilar(colorBg: string, colorFg: string): boolean {
const contrast =
(Math.max(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;
}

/**
Expand Down Expand Up @@ -206,8 +207,8 @@ function parseText(data: TGApp.Plugins.Mys.Post.StructuredContent): HTMLSpanElem
if (data.attributes.color) {
let colorGet = data.attributes.color;
// 如果 colorGet 在 darkColorList 中,就设置为对应的颜色
if (isColorSimilar("#ffffff", colorGet) || isColorSimilar("#000000", colorGet)) {
colorGet = "var(--post-default-text)";
if (isColorSimilar("#000000", colorGet)) {
colorGet = "var(--app-page-content)";
}
text.style.color = colorGet;
}
Expand Down

0 comments on commit faba854

Please sign in to comment.