hexo-theme-solitude 1.2.6 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +41 -0
- package/README.md +8 -8
- package/README_EN.md +6 -6
- package/_config.yml +502 -297
- package/languages/en-US.yml +105 -8
- package/languages/zh-CN.yml +98 -1
- package/layout/archive.pug +4 -5
- package/layout/category.pug +4 -5
- package/layout/includes/body/mode.pug +40 -0
- package/layout/includes/console.pug +15 -16
- package/layout/includes/footer.pug +26 -28
- package/layout/includes/head/config.pug +27 -8
- package/layout/includes/head/fest.pug +22 -0
- package/layout/includes/head/opengraph.pug +11 -0
- package/layout/includes/head.pug +1 -3
- package/layout/includes/header.pug +1 -1
- package/layout/includes/inject/body.pug +36 -13
- package/layout/includes/inject/head.pug +30 -20
- package/layout/includes/layout.pug +12 -8
- package/layout/includes/loading.pug +1 -64
- package/layout/includes/mixins/articleSort.pug +4 -4
- package/layout/includes/mixins/pagination.pug +1 -1
- package/layout/includes/nav.pug +10 -10
- package/layout/includes/page/about.pug +1 -0
- package/layout/includes/page/categories.pug +3 -3
- package/layout/includes/page/default.pug +1 -1
- package/layout/includes/page/echarts.pug +3 -3
- package/layout/includes/page/equipment.pug +0 -1
- package/layout/includes/page/links.pug +5 -26
- package/layout/includes/page/moments.pug +0 -1
- package/layout/includes/page/music.pug +19 -0
- package/layout/includes/page/not_configured.pug +18 -0
- package/layout/includes/page/rss.pug +20 -22
- package/layout/includes/page/says.pug +1 -2
- package/layout/includes/page/tags.pug +3 -3
- package/layout/includes/page/tlink.pug +0 -1
- package/layout/includes/sidebar.pug +7 -7
- package/layout/includes/widgets/aside/aside.pug +13 -1
- package/layout/includes/widgets/aside/asideArchive.pug +5 -3
- package/layout/includes/widgets/aside/asideCustom.pug +6 -0
- package/layout/includes/widgets/aside/asideHistory.pug +3 -3
- package/layout/includes/widgets/aside/asideInfoCard.pug +4 -6
- package/layout/includes/widgets/aside/asideNewestPost.pug +1 -1
- package/layout/includes/widgets/aside/asideSwitch.pug +0 -11
- package/layout/includes/widgets/aside/asideTag.pug +2 -2
- package/layout/includes/widgets/aside/asideToc.pug +1 -1
- package/layout/includes/widgets/aside/asideWebInfo.pug +6 -6
- package/layout/includes/widgets/aside/asideWelcome.pug +1 -1
- package/layout/includes/widgets/home/banner.pug +2 -2
- package/layout/includes/widgets/home/bbTimeList.pug +3 -3
- package/layout/includes/widgets/home/categoryBar.pug +3 -3
- package/layout/includes/widgets/home/categoryGroup.pug +2 -2
- package/layout/includes/widgets/home/hometop.pug +7 -7
- package/layout/includes/widgets/home/postList.pug +12 -8
- package/layout/includes/widgets/home/topGroup.pug +17 -13
- package/layout/includes/widgets/nav/left.pug +6 -6
- package/layout/includes/widgets/nav/menu.pug +4 -4
- package/layout/includes/widgets/nav/right.pug +14 -14
- package/layout/includes/widgets/page/about/authorinfo.pug +1 -1
- package/layout/includes/widgets/page/about/award.pug +11 -9
- package/layout/includes/widgets/page/about/contentinfo.pug +7 -7
- package/layout/includes/widgets/page/about/hobbies.pug +1 -1
- package/layout/includes/widgets/page/about/motto.pug +2 -2
- package/layout/includes/widgets/page/about/other.pug +10 -9
- package/layout/includes/widgets/page/about/personalities.pug +2 -2
- package/layout/includes/widgets/page/about/skillsinfo.pug +10 -12
- package/layout/includes/widgets/page/about/tenyear.pug +48 -0
- package/layout/includes/widgets/page/banner.pug +2 -2
- package/layout/includes/widgets/page/links/banner.pug +12 -14
- package/layout/includes/widgets/page/links/linksItem.pug +0 -1
- package/layout/includes/widgets/page/moments/angle.pug +7 -12
- package/layout/includes/widgets/page/moments/index.pug +7 -2
- package/layout/includes/widgets/post/award.pug +12 -8
- package/layout/includes/widgets/post/copyright.pug +16 -14
- package/layout/includes/widgets/post/postMeta.pug +36 -25
- package/layout/includes/widgets/post/postNav.pug +15 -15
- package/layout/includes/widgets/randomlink.pug +10 -5
- package/layout/includes/widgets/rightside/index.pug +9 -8
- package/layout/includes/widgets/third-party/ai/index.pug +12 -0
- package/layout/includes/widgets/third-party/comments/comment.pug +6 -1
- package/layout/includes/widgets/third-party/comments/twikoo.pug +5 -4
- package/layout/includes/widgets/third-party/comments/waline.pug +4 -5
- package/layout/includes/widgets/third-party/music.pug +1 -1
- package/layout/includes/widgets/third-party/pjax.pug +6 -1
- package/layout/includes/widgets/third-party/search/algolia-search.pug +4 -3
- package/layout/includes/widgets/third-party/search/index.pug +2 -2
- package/layout/includes/widgets/third-party/search/local-search.pug +3 -3
- package/layout/index.pug +5 -6
- package/layout/page.pug +34 -29
- package/layout/post.pug +3 -23
- package/layout/tag.pug +3 -3
- package/package.json +2 -2
- package/scripts/filter/checkThemeConfig.js +0 -5
- package/scripts/helper/cdn.js +12 -0
- package/scripts/helper/page.js +13 -0
- package/scripts/helper/related_post.js +0 -1
- package/scripts/tags/button.js +21 -0
- package/scripts/tags/card.js +9 -0
- package/scripts/tags/checkbox.js +51 -0
- package/scripts/tags/fold.js +0 -5
- package/scripts/tags/image.js +75 -0
- package/scripts/tags/inline-image.js +12 -0
- package/scripts/tags/label.js +10 -0
- package/scripts/tags/link.js +2 -0
- package/scripts/tags/media.js +29 -0
- package/scripts/tags/span.js +17 -0
- package/scripts/tags/timeline.js +2 -15
- package/scripts/tags/u.js +7 -0
- package/source/css/_global/animation.css +57 -0
- package/source/css/_global/index.styl +5 -20
- package/source/css/_global/var.styl +16 -1
- package/source/css/_layout/{base.styl → basic.styl} +24 -116
- package/source/css/_layout/header.styl +204 -616
- package/source/css/_layout/index.styl +29 -271
- package/source/css/_mode/index.styl +102 -93
- package/source/css/_page/_home/category-bar.styl +74 -0
- package/source/css/_page/_home/home-top.styl +541 -0
- package/source/css/_page/_home/index.styl +15 -0
- package/source/css/_page/_home/pagination.styl +176 -0
- package/source/css/_page/_home/recent-post.styl +204 -0
- package/source/css/_page/about/index.styl +1 -0
- package/source/css/_page/about/tenyear.styl +56 -0
- package/source/css/_page/about.styl +555 -626
- package/source/css/_page/category.styl +95 -119
- package/source/css/_page/douban.styl +126 -0
- package/source/css/_page/equipment.styl +100 -99
- package/source/css/_page/error.styl +130 -146
- package/source/css/_page/home.styl +41 -50
- package/source/css/_page/index.styl +42 -10
- package/source/css/_page/links.styl +306 -0
- package/source/css/_page/moment.styl +51 -51
- package/source/css/_page/music.styl +506 -0
- package/source/css/_page/rss.styl +62 -67
- package/source/css/_page/says.styl +375 -344
- package/source/css/_page/tag.styl +15 -13
- package/source/css/_widgets/{aside → _aside}/flip.styl +7 -5
- package/source/css/_widgets/{aside → _aside}/history.styl +9 -2
- package/source/css/_widgets/_aside/index.styl +96 -0
- package/source/css/_widgets/{aside → _aside}/info.styl +86 -89
- package/source/css/_widgets/{aside → _aside}/newPost.styl +7 -1
- package/source/css/_widgets/{aside → _aside}/toc.styl +28 -5
- package/source/css/_widgets/{comment → _comment}/index.styl +4 -12
- package/source/css/_widgets/{comment → _comment}/twikoo.styl +5 -2
- package/source/css/_widgets/{comment → _comment}/waline.styl +21 -5
- package/source/css/{_extra → _widgets/_extra}/console.styl +33 -10
- package/source/css/_widgets/_extra/fullpage.styl +46 -0
- package/source/css/_widgets/_extra/music.styl +218 -0
- package/source/css/_widgets/_extra/pace.styl +39 -0
- package/source/css/_widgets/_extra/rightmenu.styl +78 -0
- package/source/css/_widgets/_mixins/article-sort.styl +93 -0
- package/source/css/_widgets/_mixins/footer.styl +273 -0
- package/source/css/_widgets/_mixins/other.styl +34 -0
- package/source/css/_widgets/_mixins/sidebar.styl +230 -0
- package/source/css/_widgets/_post/_highlight/diff.styl +75 -0
- package/source/css/_widgets/_post/_highlight/index.styl +144 -0
- package/source/css/_widgets/_post/_highlight/theme/default.styl +12 -0
- package/source/css/_widgets/_post/_highlight/theme/mac.styl +25 -0
- package/source/css/_widgets/_post/_highlight/theme.styl +68 -0
- package/source/css/_widgets/_post/commentBarrage.styl +144 -0
- package/source/css/_widgets/_post/content.styl +152 -0
- package/source/css/_widgets/_post/copyright.styl +98 -0
- package/source/css/_widgets/_post/index.styl +20 -0
- package/source/css/_widgets/_post/meta.styl +420 -0
- package/source/css/_widgets/_post/pagination.styl +177 -0
- package/source/css/_widgets/_post/postAI.styl +131 -0
- package/source/css/{_post → _widgets/_post}/relatedPost.styl +4 -1
- package/source/css/_widgets/_post/tools.styl +249 -0
- package/source/css/{_search → _widgets/_search}/algolia-search.styl +4 -0
- package/source/css/{_search → _widgets/_search}/local-search.styl +15 -5
- package/source/css/_widgets/_tags/button.styl +60 -0
- package/source/css/_widgets/_tags/bvideo.styl +8 -0
- package/source/css/_widgets/_tags/card.styl +52 -0
- package/source/css/_widgets/_tags/checkbox.styl +85 -0
- package/source/css/_widgets/_tags/fold.styl +79 -0
- package/source/css/_widgets/_tags/image.styl +10 -0
- package/source/css/_widgets/_tags/index.styl +61 -0
- package/source/css/_widgets/_tags/inline-image.styl +6 -0
- package/source/css/_widgets/_tags/label.styl +3 -0
- package/source/css/_widgets/_tags/link.styl +80 -0
- package/source/css/_widgets/_tags/note.styl +101 -0
- package/source/css/_widgets/_tags/span.styl +61 -0
- package/source/css/_widgets/_tags/tabs.styl +105 -0
- package/source/css/_widgets/_tags/timeline.styl +80 -0
- package/source/css/_widgets/index.styl +50 -1
- package/source/css/index.styl +0 -25
- package/source/js/{commentBarrage.js → extend/comment/twikoo/commentBarrage.js} +0 -4
- package/source/js/extend/comment/{twikoo.js → twikoo/twikoo.js} +12 -40
- package/source/js/extend/comment/waline/commentBarrage.js +155 -0
- package/source/js/extend/comment/{waline.js → waline/waline.js} +10 -11
- package/source/js/extend/search/algolia-search.js +1 -5
- package/source/js/extend/search/local-search.js +33 -13
- package/source/js/main.js +135 -171
- package/source/js/music.js +129 -0
- package/source/js/utils.js +4 -7
- package/source/lib/cover-color.min.js +7 -0
- package/source/lib/rightside.min.js +1 -0
- package/source/lib/sco-ai.min.js +8 -0
- package/source/lib/snackbar.min.css +1 -1
- package/source/lib/txmap.min.js +1 -0
- package/source/lib/universe.min.js +1 -0
- package/source/lib/view-image.min.js +1 -1
- package/layout/includes/widgets/aside/asidePower.pug +0 -19
- package/layout/includes/widgets/home/rencentPost.pug +0 -26
- package/source/css/_extra/rightmenu.styl +0 -83
- package/source/css/_layout/articleSort.styl +0 -199
- package/source/css/_layout/footer.styl +0 -359
- package/source/css/_layout/sidebar.styl +0 -226
- package/source/css/_page/homeTop.styl +0 -1035
- package/source/css/_page/link.styl +0 -433
- package/source/css/_post/commentBarrage.styl +0 -149
- package/source/css/_post/externalTags.styl +0 -694
- package/source/css/_post/highlight.styl +0 -96
- package/source/css/_post/index.styl +0 -935
- package/source/css/_post/pagination.styl +0 -467
- package/source/css/_post/postContent.styl +0 -957
- package/source/css/_post/reward.styl +0 -217
- package/source/css/_widgets/aside/index.styl +0 -156
- package/source/css/_widgets/aside/power.styl +0 -90
- package/source/img/logo-horizontal_version.png +0 -0
- package/source/img/pwa/16.png +0 -0
- package/source/img/pwa/180.png +0 -0
- package/source/img/pwa/192.png +0 -0
- package/source/img/pwa/32.png +0 -0
- package/source/img/pwa/512.png +0 -0
- package/source/img/pwa/logo.png +0 -0
- package/source/img/pwa/siteicon/splash-1125x2436.png +0 -0
- package/source/img/pwa/siteicon/splash-1136x640.png +0 -0
- package/source/img/pwa/siteicon/splash-1170x2532.png +0 -0
- package/source/img/pwa/siteicon/splash-1179x2556.png +0 -0
- package/source/img/pwa/siteicon/splash-1242x2208.png +0 -0
- package/source/img/pwa/siteicon/splash-1242x2688.png +0 -0
- package/source/img/pwa/siteicon/splash-1248x2778.png +0 -0
- package/source/img/pwa/siteicon/splash-1290x2796.png +0 -0
- package/source/img/pwa/siteicon/splash-1334x750.png +0 -0
- package/source/img/pwa/siteicon/splash-1536x2048.png +0 -0
- package/source/img/pwa/siteicon/splash-1620x2160.png +0 -0
- package/source/img/pwa/siteicon/splash-1668x2224.png +0 -0
- package/source/img/pwa/siteicon/splash-1668x2388.png +0 -0
- package/source/img/pwa/siteicon/splash-1792x828.png +0 -0
- package/source/img/pwa/siteicon/splash-2048x1536.png +0 -0
- package/source/img/pwa/siteicon/splash-2048x2732.png +0 -0
- package/source/img/pwa/siteicon/splash-2160x1620.png +0 -0
- package/source/img/pwa/siteicon/splash-2208x1242.png +0 -0
- package/source/img/pwa/siteicon/splash-2224x1668.png +0 -0
- package/source/img/pwa/siteicon/splash-2388x1668.png +0 -0
- package/source/img/pwa/siteicon/splash-2436x1125.png +0 -0
- package/source/img/pwa/siteicon/splash-2532x1170.png +0 -0
- package/source/img/pwa/siteicon/splash-2556x1179.png +0 -0
- package/source/img/pwa/siteicon/splash-2688x1242.png +0 -0
- package/source/img/pwa/siteicon/splash-2732x2048.png +0 -0
- package/source/img/pwa/siteicon/splash-2778x1248.png +0 -0
- package/source/img/pwa/siteicon/splash-2796x1290.png +0 -0
- package/source/img/pwa/siteicon/splash-640x1136.png +0 -0
- package/source/img/pwa/siteicon/splash-750x1334.png +0 -0
- package/source/img/pwa/siteicon/splash-828x1792.png +0 -0
- package/source/img/solitude-show.jpg +0 -0
- package/source/js/extend/covercolor/local.js +0 -160
- package/source/js/rightside.js +0 -402
- package/source/js/txmap.js +0 -236
- package/source/lib/chuckle-post-ai.js +0 -1
- /package/source/css/_widgets/{aside → _aside}/allinfo.styl +0 -0
- /package/source/css/_widgets/{aside → _aside}/welcome.styl +0 -0
- /package/source/img/{theme/avatar.png → avatar.png} +0 -0
@@ -1,160 +0,0 @@
|
|
1
|
-
function coverColor() {
|
2
|
-
var path = document.getElementById("post-cover")?.src;
|
3
|
-
if (path !== undefined) {
|
4
|
-
var img = new Image();
|
5
|
-
img.crossOrigin = "Anonymous";
|
6
|
-
img.src = path;
|
7
|
-
img.onload = function () {
|
8
|
-
var canvas = document.createElement("canvas");
|
9
|
-
canvas.width = this.width;
|
10
|
-
canvas.height = this.height;
|
11
|
-
var ctx = canvas.getContext("2d");
|
12
|
-
ctx.drawImage(this, 0, 0);
|
13
|
-
var data = ctx.getImageData(0, 0, this.width, this.height).data;
|
14
|
-
var colorCounts = {};
|
15
|
-
var dominantColor = '';
|
16
|
-
var maxCount = 0;
|
17
|
-
var step = 5;
|
18
|
-
for (var i = 0; i < data.length; i += 4 * step) {
|
19
|
-
var r = data[i];
|
20
|
-
var g = data[i + 1];
|
21
|
-
var b = data[i + 2];
|
22
|
-
var color = `${r},${g},${b}`;
|
23
|
-
|
24
|
-
colorCounts[color] = (colorCounts[color] || 0) + 1;
|
25
|
-
|
26
|
-
if (colorCounts[color] > maxCount) {
|
27
|
-
maxCount = colorCounts[color];
|
28
|
-
dominantColor = color;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
var rgb = dominantColor.split(',').map(c => parseInt(c, 10));
|
32
|
-
var value = "#" + rgb[0].toString(16) + rgb[1].toString(16) + rgb[2].toString(16);
|
33
|
-
if (getContrastYIQ(value) == "light") {
|
34
|
-
value = LightenDarkenColor(colorHex(value), -50)
|
35
|
-
}
|
36
|
-
|
37
|
-
document.documentElement.style.setProperty('--sco-main', value);
|
38
|
-
document.documentElement.style.setProperty('--sco-main-op', value + '23');
|
39
|
-
document.documentElement.style.setProperty('--sco-main-op-deep', value + 'dd');
|
40
|
-
document.documentElement.style.setProperty('--sco-main-none', value + '00');
|
41
|
-
initThemeColor()
|
42
|
-
document.getElementById("coverdiv").classList.add("loaded");
|
43
|
-
}
|
44
|
-
} else {
|
45
|
-
document.documentElement.style.setProperty('--sco-main', 'var(--sco-theme)');
|
46
|
-
document.documentElement.style.setProperty('--sco-main-op', 'var(--sco-theme-op)');
|
47
|
-
document.documentElement.style.setProperty('--sco-main-op-deep', 'var(--sco-theme-op-deep)');
|
48
|
-
document.documentElement.style.setProperty('--sco-main-none', 'var(--sco-theme-none)');
|
49
|
-
initThemeColor()
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
function colorHex(colorString) {
|
54
|
-
const hexRegex = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
|
55
|
-
let color = colorString;
|
56
|
-
|
57
|
-
if (/^(rgb|RGB)/.test(color)) {
|
58
|
-
const colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
|
59
|
-
const hexArr = colorArr.map(c => {
|
60
|
-
const hex = Number(c).toString(16);
|
61
|
-
return hex.length === 1 ? "0" + hex : hex;
|
62
|
-
});
|
63
|
-
return "#" + hexArr.join("");
|
64
|
-
} else if (hexRegex.test(color)) {
|
65
|
-
const hexDigits = color.replace(/#/, "").split("");
|
66
|
-
if (hexDigits.length === 6) {
|
67
|
-
return color;
|
68
|
-
} else if (hexDigits.length === 3) {
|
69
|
-
const hexArr = hexDigits.map(c => c + c);
|
70
|
-
return "#" + hexArr.join("");
|
71
|
-
}
|
72
|
-
}
|
73
|
-
return color;
|
74
|
-
}
|
75
|
-
|
76
|
-
|
77
|
-
function colorRgb(str) {
|
78
|
-
const HEX_SHORT_REGEX = /^#([0-9a-fA-f]{3})$/;
|
79
|
-
const HEX_LONG_REGEX = /^#([0-9a-fA-f]{6})$/;
|
80
|
-
const HEX_SHORT_LENGTH = 4;
|
81
|
-
|
82
|
-
if (!str || typeof str !== 'string') {
|
83
|
-
return str;
|
84
|
-
}
|
85
|
-
|
86
|
-
const sColor = str.toLowerCase();
|
87
|
-
let hexValue = "";
|
88
|
-
|
89
|
-
if (sColor && (HEX_SHORT_REGEX.test(sColor) || HEX_LONG_REGEX.test(sColor))) {
|
90
|
-
hexValue = sColor.length === HEX_SHORT_LENGTH ?
|
91
|
-
sColor.replace(/^#(.)/g, "#$1$1") :
|
92
|
-
sColor;
|
93
|
-
|
94
|
-
const rgbValue = hexValue.slice(1)
|
95
|
-
.match(/.{2}/g)
|
96
|
-
.map(val => parseInt(val, 16));
|
97
|
-
|
98
|
-
return `rgb(${rgbValue[0]}, ${rgbValue[1]}, ${rgbValue[2]})`;
|
99
|
-
} else {
|
100
|
-
return sColor;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
function LightenDarkenColor(col, amt) {
|
106
|
-
let usePound = false;
|
107
|
-
|
108
|
-
if (col[0] === "#") {
|
109
|
-
col = col.slice(1);
|
110
|
-
usePound = true;
|
111
|
-
}
|
112
|
-
|
113
|
-
const num = parseInt(col, 16);
|
114
|
-
const r = Math.min(255, Math.max(0, (num >> 16) + amt));
|
115
|
-
const b = Math.min(255, Math.max(0, ((num >> 8) & 0xff) + amt));
|
116
|
-
const g = Math.min(255, Math.max(0, (num & 0xff) + amt));
|
117
|
-
|
118
|
-
return `${usePound ? "#" : ""}${(g | (b << 8) | (r << 16)).toString(16).padStart(6, "0")}`;
|
119
|
-
}
|
120
|
-
|
121
|
-
|
122
|
-
function getContrastYIQ(hexcolor) {
|
123
|
-
var colorrgb = colorRgb(hexcolor);
|
124
|
-
var colors = colorrgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
125
|
-
if (!colors) {
|
126
|
-
return "light"; // or "dark", depending on your preference
|
127
|
-
}
|
128
|
-
var red = colors[1];
|
129
|
-
var green = colors[2];
|
130
|
-
var blue = colors[3];
|
131
|
-
var brightness;
|
132
|
-
brightness = (red * 299) + (green * 587) + (blue * 114);
|
133
|
-
brightness = brightness / 255000;
|
134
|
-
if (brightness >= 0.5) {
|
135
|
-
return "light";
|
136
|
-
} else {
|
137
|
-
return "dark";
|
138
|
-
}
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
function initThemeColor() {
|
143
|
-
const currentTop = window.scrollY || document.documentElement.scrollTop;
|
144
|
-
let themeColor;
|
145
|
-
if (currentTop > 0) {
|
146
|
-
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-card-bg');
|
147
|
-
} else if (PAGE_CONFIG.is_post) {
|
148
|
-
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-main');
|
149
|
-
} else {
|
150
|
-
themeColor = getComputedStyle(document.documentElement).getPropertyValue('--sco-background');
|
151
|
-
}
|
152
|
-
changeThemeColor(themeColor);
|
153
|
-
}
|
154
|
-
|
155
|
-
function changeThemeColor(color) {
|
156
|
-
const meta = document.querySelector('meta[name="theme-color"]');
|
157
|
-
if (meta) {
|
158
|
-
meta.setAttribute('content', color);
|
159
|
-
}
|
160
|
-
}
|
package/source/js/rightside.js
DELETED
@@ -1,402 +0,0 @@
|
|
1
|
-
let rm = {};
|
2
|
-
|
3
|
-
rm.stopdragimg = Array.from(document.getElementsByTagName('img'));
|
4
|
-
rm.stopdragimg.forEach(function (img) {
|
5
|
-
img.addEventListener('dragstart', function () {
|
6
|
-
return false;
|
7
|
-
});
|
8
|
-
});
|
9
|
-
|
10
|
-
rm.showRightMenu = function (e, n = 0, t = 0) {
|
11
|
-
let o = document.getElementById('rightMenu');
|
12
|
-
o.style.top = n + 'px';
|
13
|
-
o.style.left = t + 'px';
|
14
|
-
|
15
|
-
if (e) {
|
16
|
-
o.style.display = 'block';
|
17
|
-
stopMaskScroll();
|
18
|
-
} else {
|
19
|
-
o.style.display = 'none';
|
20
|
-
}
|
21
|
-
};
|
22
|
-
|
23
|
-
rm.hideRightMenu = function () {
|
24
|
-
rm.showRightMenu(false);
|
25
|
-
document.getElementById('rightmenu-mask').style.display = 'none';
|
26
|
-
};
|
27
|
-
|
28
|
-
document.querySelector("#rightMenu").style.display = "block"
|
29
|
-
rmWidth = document.querySelector("#rightMenu").offsetWidth;
|
30
|
-
rmHeight = document.querySelector("#rightMenu").offsetHeight;
|
31
|
-
document.querySelector("#rightMenu").style.display = 'none'
|
32
|
-
|
33
|
-
rm.reloadrmSize = function () {
|
34
|
-
document.querySelector("#rightMenu").style.display = "block"
|
35
|
-
rmWidth = document.querySelector("#rightMenu").offsetWidth;
|
36
|
-
rmHeight = document.querySelector("#rightMenu").offsetHeight;
|
37
|
-
document.querySelector("#rightMenu").style.display = 'none'
|
38
|
-
}
|
39
|
-
|
40
|
-
let domhref = "", domImgSrc = "", globalEvent = null;
|
41
|
-
|
42
|
-
function imageToBlob(e) {
|
43
|
-
const n = new Image
|
44
|
-
, t = document.createElement("canvas")
|
45
|
-
, o = t.getContext("2d");
|
46
|
-
return n.crossOrigin = "",
|
47
|
-
n.src = e,
|
48
|
-
new Promise((e => {
|
49
|
-
n.onload = function () {
|
50
|
-
t.width = this.naturalWidth,
|
51
|
-
t.height = this.naturalHeight,
|
52
|
-
o.drawImage(this, 0, 0),
|
53
|
-
t.toBlob((n => {
|
54
|
-
e(n)
|
55
|
-
}
|
56
|
-
), "image/png", .75)
|
57
|
-
}
|
58
|
-
}
|
59
|
-
))
|
60
|
-
}
|
61
|
-
|
62
|
-
async function copyImage(e) {
|
63
|
-
try {
|
64
|
-
const n = await imageToBlob(e);
|
65
|
-
const t = new ClipboardItem({
|
66
|
-
"image/png": n
|
67
|
-
});
|
68
|
-
await navigator.clipboard.write([t]);
|
69
|
-
} catch (error) {
|
70
|
-
console.error('Failed to copy image: ', error);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
function stopMaskScroll() {
|
75
|
-
if (document.getElementById("rightmenu-mask")) {
|
76
|
-
document.getElementById("rightmenu-mask").addEventListener("mousewheel", (function (e) {
|
77
|
-
rm.hideRightMenu()
|
78
|
-
}
|
79
|
-
), !1)
|
80
|
-
}
|
81
|
-
if (document.getElementById("rightMenu")) {
|
82
|
-
document.getElementById("rightMenu").addEventListener("mousewheel", (function (e) {
|
83
|
-
rm.hideRightMenu()
|
84
|
-
}
|
85
|
-
), !1)
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
window.oncontextmenu = function (e) {
|
90
|
-
if (document.body.clientWidth > 768) {
|
91
|
-
let n = e.clientX + 10;
|
92
|
-
let t = e.clientY;
|
93
|
-
let o = document.getElementsByClassName('rightMenuOther');
|
94
|
-
let i = document.getElementsByClassName('rightMenuPlugin');
|
95
|
-
let c = document.getElementById('menu-copytext');
|
96
|
-
let r = document.getElementById('menu-pastetext');
|
97
|
-
let m = document.getElementById('menu-commenttext');
|
98
|
-
let a = document.getElementById('menu-newwindow');
|
99
|
-
let u = document.getElementById('menu-copylink');
|
100
|
-
let l = document.getElementById('menu-copyimg');
|
101
|
-
let h = document.getElementById('menu-downloadimg');
|
102
|
-
let d = document.getElementById('menu-search');
|
103
|
-
let s = document.getElementById('menu-searchBaidu');
|
104
|
-
let g = document.getElementById('menu-music-toggle');
|
105
|
-
let w = document.getElementById('menu-music-back');
|
106
|
-
let f = document.getElementById('menu-music-forward');
|
107
|
-
let p = document.getElementById('menu-music-playlist');
|
108
|
-
let k = document.getElementById('menu-music-copyMusicName');
|
109
|
-
let y = e.target.href;
|
110
|
-
let M = e.target.currentSrc;
|
111
|
-
let b = false;
|
112
|
-
|
113
|
-
for (let j = 0; j < o.length; j++) {
|
114
|
-
o[j].style.display = 'block';
|
115
|
-
}
|
116
|
-
globalEvent = e;
|
117
|
-
|
118
|
-
if (selectTextNow && window.getSelection()) {
|
119
|
-
b = true;
|
120
|
-
c.style.display = 'block';
|
121
|
-
m.style.display = 'block';
|
122
|
-
d.style.display = 'block';
|
123
|
-
s.style.display = 'block';
|
124
|
-
} else {
|
125
|
-
c.style.display = 'none';
|
126
|
-
m.style.display = 'none';
|
127
|
-
s.style.display = 'none';
|
128
|
-
d.style.display = 'none';
|
129
|
-
}
|
130
|
-
|
131
|
-
if (y) {
|
132
|
-
b = true;
|
133
|
-
a.style.display = 'block';
|
134
|
-
u.style.display = 'block';
|
135
|
-
domhref = y;
|
136
|
-
} else {
|
137
|
-
a.style.display = 'none';
|
138
|
-
u.style.display = 'none';
|
139
|
-
}
|
140
|
-
|
141
|
-
if (M) {
|
142
|
-
b = true;
|
143
|
-
l.style.display = 'block';
|
144
|
-
h.style.display = 'block';
|
145
|
-
domImgSrc = M;
|
146
|
-
} else {
|
147
|
-
l.style.display = 'none';
|
148
|
-
h.style.display = 'none';
|
149
|
-
}
|
150
|
-
|
151
|
-
if (e.target.tagName.toLowerCase() === 'input' || e.target.tagName.toLowerCase() === 'textarea') {
|
152
|
-
b = true;
|
153
|
-
r.style.display = 'block';
|
154
|
-
} else {
|
155
|
-
r.style.display = 'none';
|
156
|
-
}
|
157
|
-
|
158
|
-
if (e.target.nodeName === 'METING-JS') {
|
159
|
-
b = true;
|
160
|
-
g.style.display = 'block';
|
161
|
-
w.style.display = 'block';
|
162
|
-
f.style.display = 'block';
|
163
|
-
p.style.display = 'block';
|
164
|
-
k.style.display = 'block';
|
165
|
-
} else {
|
166
|
-
g.style.display = 'none';
|
167
|
-
w.style.display = 'none';
|
168
|
-
f.style.display = 'none';
|
169
|
-
p.style.display = 'none';
|
170
|
-
k.style.display = 'none';
|
171
|
-
}
|
172
|
-
|
173
|
-
if (b) {
|
174
|
-
for (let j = 0; j < o.length; j++) {
|
175
|
-
o[j].style.display = 'none';
|
176
|
-
}
|
177
|
-
for (let j = 0; j < i.length; j++) {
|
178
|
-
i[j].style.display = 'block';
|
179
|
-
}
|
180
|
-
} else {
|
181
|
-
for (let j = 0; j < i.length; j++) {
|
182
|
-
i[j].style.display = 'none';
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
rm.reloadrmSize();
|
187
|
-
if (n + rmWidth > window.innerWidth) {
|
188
|
-
n -= rmWidth + 10;
|
189
|
-
}
|
190
|
-
|
191
|
-
if (t + rmHeight > window.innerHeight) {
|
192
|
-
t -= t + rmHeight - window.innerHeight;
|
193
|
-
}
|
194
|
-
rm.showRightMenu(true, t, n);
|
195
|
-
document.getElementById('rightmenu-mask').style.display = 'flex';
|
196
|
-
|
197
|
-
return false;
|
198
|
-
}
|
199
|
-
};
|
200
|
-
rm.downloadimging = !1
|
201
|
-
rm.writeClipImg = function (e) {
|
202
|
-
const n = "localhost" === window.location.hostname || "127.0.0.1" === window.location.hostname ? 0 : 1e4;
|
203
|
-
rm.hideRightMenu();
|
204
|
-
utils.snackbarShow("正在下载中,请稍后", !1, n);
|
205
|
-
if (0 == rm.downloadimging) {
|
206
|
-
rm.downloadimging = !0;
|
207
|
-
setTimeout(async function() {
|
208
|
-
await copyImage(e);
|
209
|
-
utils.snackbarShow("复制成功!图片已添加盲水印,请遵守版权协议");
|
210
|
-
rm.downloadimging = !1;
|
211
|
-
}, 1000);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
rm.switchDarkMode = function () {
|
216
|
-
sco.switchDarkMode()
|
217
|
-
rm.hideRightMenu()
|
218
|
-
}
|
219
|
-
|
220
|
-
rm.copyUrl = function (e) {
|
221
|
-
var n = e;
|
222
|
-
var t = document.createElement('input');
|
223
|
-
t.id = 'copyVal';
|
224
|
-
document.body.appendChild(t);
|
225
|
-
t.value = n;
|
226
|
-
t.select();
|
227
|
-
t.setSelectionRange(0, t.value.length);
|
228
|
-
document.execCommand('copy');
|
229
|
-
document.body.removeChild(t);
|
230
|
-
}
|
231
|
-
|
232
|
-
rm.rightmenuCopyText = function (e) {
|
233
|
-
navigator.clipboard && navigator.clipboard.writeText(e),
|
234
|
-
utils.snackbarShow("复制文本成功", !1, 2e3),
|
235
|
-
rm.hideRightMenu()
|
236
|
-
}
|
237
|
-
|
238
|
-
rm.copyPageUrl = function () {
|
239
|
-
var e = window.location.href;
|
240
|
-
rm.copyUrl(e),
|
241
|
-
utils.snackbarShow("复制本页链接地址成功", !1, 2e3),
|
242
|
-
rm.hideRightMenu()
|
243
|
-
}
|
244
|
-
|
245
|
-
rm.sharePage = function () {
|
246
|
-
window;
|
247
|
-
rm.copyUrl(url),
|
248
|
-
utils.snackbarShow("复制本页链接地址成功", !1, 2e3),
|
249
|
-
rm.hideRightMenu()
|
250
|
-
}
|
251
|
-
|
252
|
-
var selectTextNow = "";
|
253
|
-
|
254
|
-
function selceText() {
|
255
|
-
var e;
|
256
|
-
e = document.selection ? document.selection.createRange().text : window.getSelection() + "",
|
257
|
-
selectTextNow = e || ""
|
258
|
-
}
|
259
|
-
|
260
|
-
function replaceAll(e, n, t) {
|
261
|
-
return e.split(n).join(t)
|
262
|
-
}
|
263
|
-
|
264
|
-
function addRightMenuClickEvent() {
|
265
|
-
document.getElementById('menu-backward').addEventListener('click', function () {
|
266
|
-
window.history.back();
|
267
|
-
rm.hideRightMenu();
|
268
|
-
});
|
269
|
-
|
270
|
-
document.getElementById('menu-forward').addEventListener('click', function () {
|
271
|
-
window.history.forward();
|
272
|
-
rm.hideRightMenu();
|
273
|
-
});
|
274
|
-
|
275
|
-
document.getElementById('menu-refresh').addEventListener('click', function () {
|
276
|
-
window.location.reload();
|
277
|
-
});
|
278
|
-
|
279
|
-
document.getElementById('menu-top').addEventListener('click', function () {
|
280
|
-
utils.scrollToDest(0, 500);
|
281
|
-
rm.hideRightMenu();
|
282
|
-
});
|
283
|
-
|
284
|
-
Array.from(document.getElementsByClassName('menu-link')).forEach(function (element) {
|
285
|
-
element.addEventListener('click', rm.hideRightMenu);
|
286
|
-
});
|
287
|
-
|
288
|
-
var menuDarkmode = document.getElementById('menu-darkmode');
|
289
|
-
menuDarkmode.onclick = null;
|
290
|
-
menuDarkmode.addEventListener('click', rm.switchDarkMode);
|
291
|
-
|
292
|
-
document.getElementById('menu-randomPost').addEventListener('click', function () {
|
293
|
-
toRandomPost();
|
294
|
-
});
|
295
|
-
|
296
|
-
var menuCommentBarrage = document.getElementById('menu-commentBarrage');
|
297
|
-
menuCommentBarrage.onclick = null;
|
298
|
-
menuCommentBarrage.addEventListener('click', sco.switchCommentBarrage);
|
299
|
-
|
300
|
-
var rightmenuMask = document.getElementById('rightmenu-mask');
|
301
|
-
rightmenuMask.addEventListener('click', rm.hideRightMenu);
|
302
|
-
rightmenuMask.addEventListener('contextmenu', function () {
|
303
|
-
rm.hideRightMenu();
|
304
|
-
return false;
|
305
|
-
});
|
306
|
-
|
307
|
-
document.getElementById('menu-copy').addEventListener('click', rm.copyPageUrl);
|
308
|
-
document.getElementById('menu-pastetext').addEventListener('click', rm.pasteText);
|
309
|
-
|
310
|
-
document.getElementById('menu-copytext').addEventListener('click', function () {
|
311
|
-
rm.rightmenuCopyText(selectTextNow);
|
312
|
-
utils.snackbarShow("复制成功,复制和转载请标注本文地址");
|
313
|
-
});
|
314
|
-
|
315
|
-
document.getElementById('menu-commenttext').addEventListener('click', function () {
|
316
|
-
rm.rightMenuCommentText(selectTextNow);
|
317
|
-
});
|
318
|
-
|
319
|
-
document.getElementById('menu-newwindow').addEventListener('click', function () {
|
320
|
-
window.open(domhref);
|
321
|
-
rm.hideRightMenu();
|
322
|
-
});
|
323
|
-
|
324
|
-
document.getElementById('menu-copylink').addEventListener('click', rm.copyLink);
|
325
|
-
|
326
|
-
document.getElementById('menu-downloadimg').addEventListener('click', function () {
|
327
|
-
sco.downloadImage(domImgSrc, "sco");
|
328
|
-
});
|
329
|
-
|
330
|
-
document.getElementById('menu-copyimg').addEventListener('click', function () {
|
331
|
-
rm.writeClipImg(domImgSrc);
|
332
|
-
});
|
333
|
-
|
334
|
-
document.getElementById('menu-searchBaidu').addEventListener('click', rm.searchBaidu);
|
335
|
-
|
336
|
-
document.getElementById('menu-music-toggle').addEventListener('click', sco.musicToggle);
|
337
|
-
document.getElementById('menu-music-back').addEventListener('click', sco.musicSkipBack);
|
338
|
-
document.getElementById('menu-music-forward').addEventListener('click', sco.musicSkipForward);
|
339
|
-
|
340
|
-
document.getElementById('menu-music-copyMusicName').addEventListener('click', function () {
|
341
|
-
rm.rightmenuCopyText(sco.musicGetName());
|
342
|
-
utils.snackbarShow("复制歌曲名称成功", false, 3000);
|
343
|
-
});
|
344
|
-
}
|
345
|
-
|
346
|
-
document.onmouseup = document.ondbclick = selceText
|
347
|
-
rm.readClipboard = function () {
|
348
|
-
navigator.clipboard && navigator.clipboard.readText().then((e => rm.insertAtCaret(globalEvent.target, e)))
|
349
|
-
}
|
350
|
-
|
351
|
-
rm.insertAtCaret = function (e, n) {
|
352
|
-
const t = e.selectionStart
|
353
|
-
, o = e.selectionEnd;
|
354
|
-
if (document.selection)
|
355
|
-
e.focus(),
|
356
|
-
document.selection.createRange().text = n,
|
357
|
-
e.focus();
|
358
|
-
else if (t || "0" == t) {
|
359
|
-
var i = e.scrollTop;
|
360
|
-
e.value = e.value.substring(0, t) + n + e.value.substring(o, e.value.length),
|
361
|
-
e.focus(),
|
362
|
-
e.selectionStart = t + n.length,
|
363
|
-
e.selectionEnd = t + n.length,
|
364
|
-
e.scrollTop = i
|
365
|
-
} else
|
366
|
-
e.value += n,
|
367
|
-
e.focus()
|
368
|
-
}
|
369
|
-
|
370
|
-
rm.pasteText = function () {
|
371
|
-
rm.readClipboard();
|
372
|
-
rm.hideRightMenu()
|
373
|
-
}
|
374
|
-
|
375
|
-
rm.rightMenuCommentText = function (e) {
|
376
|
-
rm.hideRightMenu();
|
377
|
-
var n = document.getElementsByClassName("el-textarea__inner")[0];
|
378
|
-
let t = document.createEvent("HTMLEvents");
|
379
|
-
t.initEvent("input", !0, !0);
|
380
|
-
let o = replaceAll(e, "\n", "\n> ");
|
381
|
-
n.value = "> " + o + "\n\n",
|
382
|
-
n.dispatchEvent(t);
|
383
|
-
var i = document.querySelector("#post-comment").offsetTop;
|
384
|
-
window.scrollTo(0, i - 80),
|
385
|
-
n.focus(),
|
386
|
-
n.setSelectionRange(-1, -1),
|
387
|
-
document.getElementById("comment-tips") && document.getElementById("comment-tips").classList.add("show")
|
388
|
-
}
|
389
|
-
|
390
|
-
rm.searchBaidu = function () {
|
391
|
-
utils.snackbarShow("即将跳转到百度搜索", !1, 2e3),
|
392
|
-
setTimeout((function () {
|
393
|
-
window.open("https://www.baidu.com/s?wd=" + selectTextNow)
|
394
|
-
}
|
395
|
-
), "2000"),
|
396
|
-
rm.hideRightMenu()
|
397
|
-
}
|
398
|
-
|
399
|
-
rm.copyLink = function () {
|
400
|
-
rm.rightmenuCopyText(domhref),
|
401
|
-
utils.snackbarShow("已复制链接地址")
|
402
|
-
}
|