Skip to content

Commit 63fd1ca

Browse files
authored
release: 1.0.2 (#6)
* build: 使用 min-1px 库的1像素gif图(base64) * fix: 打开评论管理页面是会被其他元素覆盖在最顶层的bug * fix: 消息弹窗被zIndex拦截的bug * refactor: 移除 message 提示框,改用 msg-alert 库 * build: 1.0.2
1 parent 2bb9334 commit 63fd1ca

File tree

8 files changed

+11425
-108
lines changed

8 files changed

+11425
-108
lines changed

package-lock.json

Lines changed: 11372 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "discuss",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "一款简单,安全,免费的评论系统 | A simple, safe, free comment system",
55
"main": "index.js",
66
"unpkg": "dist/Discuss.js",
@@ -46,6 +46,8 @@
4646
"html-minifier": "^4.0.0",
4747
"jsonwebtoken": "^8.5.1",
4848
"md5": "^2.3.0",
49+
"min-1px": "^1.0.0",
50+
"msg-alert": "^1.0.0-beta.2",
4951
"nodemailer": "^6.7.0",
5052
"output-line": "^1.0.1",
5153
"simple-unique": "^1.2.0",

src/client/lib/stores.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { writable } from 'svelte/store'
2-
import massage from './massage'
2+
import msgAlert from 'msg-alert'
33
import lazyload from './lazyload'
44

5+
function massage(options) {
6+
const all = [...document.body.querySelectorAll('*')].map((el) => +window.getComputedStyle(el).zIndex || 0)
7+
options.zIndex = Math.max(...all) + 1
8+
msgAlert(options)
9+
}
10+
511
export const options = writable({})
612
export const openMenu = writable(false)
713
export const showSetting = writable(true)

src/client/lib/zIndex.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const str = 'D-zIndex'
2+
3+
/**
4+
* 让 admin 显示在最顶层
5+
* @param {String} flag open or close
6+
*/
7+
export default function (flag) {
8+
const all = [...document.body.querySelectorAll('*:not(._msg)')]
9+
all.forEach((el) => {
10+
const zIndex = window.getComputedStyle(el).zIndex
11+
if (flag === 'close') {
12+
el.classList.remove(str)
13+
el.style.removeProperty('z-index')
14+
return
15+
}
16+
if (flag === 'open' && zIndex > 0) {
17+
el.style.zIndex = -1
18+
el.classList.add(str)
19+
}
20+
})
21+
22+
let body,
23+
el = document.querySelector('#Discuss')
24+
25+
while (body !== 'BODY') {
26+
el = el.parentElement
27+
body = el.nodeName
28+
if (el.classList.contains(str)) {
29+
el.style.removeProperty('z-index')
30+
}
31+
}
32+
}

src/client/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gif1px from 'min-1px'
12
import Main from './view/main.svelte'
23
import { options } from './lib/stores'
34
import { translate, setLanguage } from './i18n'
@@ -16,7 +17,7 @@ function init(opt) {
1617
ph: translate('content'),
1718
path: location.pathname,
1819
visitStat: true,
19-
imgLoading: 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw'
20+
imgLoading: gif1px.GIF
2021
}
2122

2223
options.set(Object.assign(defaultOptions, opt))

src/client/view/admin.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { onMount } from 'svelte'
33
import { openMenu, showSetting } from '../lib/stores'
44
import { translate } from '../i18n'
5+
import zIndex from '../lib/zIndex'
56
import global from './global.svelte'
67
import Login from './adminLogin.svelte'
78
import Comment from './adminComment.svelte'
@@ -56,7 +57,8 @@
5657
// 为什么这样写?
5758
// 因为打包后评论区无法确定识别该方法(方法名会被缩小为一个字母,导致评论区无法调用)
5859
const onOpenAndClose = {}
59-
onOpenAndClose.onOpenAdmin = function () {
60+
onOpenAndClose.onOpenAdmin = function (flag) {
61+
zIndex(flag)
6062
$showSetting = !$showSetting
6163
}
6264
</script>
@@ -80,7 +82,7 @@
8082
{#if show}
8183
<!-- 是否显示关闭以及退出登录,主要区分页面评论区评论管理与以及评论管理独立初始化 -->
8284
<span class="D-exit" on:click={onExit}><IconExit /></span>
83-
<span class="D-close" on:click={onOpenAndClose.onOpenAdmin}><IconClose /></span>
85+
<span class="D-close" on:click={onOpenAndClose.onOpenAdmin('close')}><IconClose /></span>
8486
{/if}
8587
</nav>
8688
</header>

src/client/view/global.svelte

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -99,51 +99,7 @@
9999
height: auto;
100100
vertical-align: middle;
101101
}
102-
/* 消息提示框容器样式 */
103-
.D-msg {
104-
left: 50%;
105-
color: #909399;
106-
font-size: 14px;
107-
width: 300px;
108-
padding: 16px 17px;
109-
position: fixed;
110-
line-height: 1;
111-
letter-spacing: 1px;
112-
word-wrap: break-word;
113-
word-break: break-all;
114-
z-index: 9999999999;
115-
border-radius: 6px;
116-
border: 1px solid #edf2fc;
117-
background-color: #edf2fc;
118-
transform: translateX(-50%);
119-
transition: opacity 0.3s, transform 0.5s, top 0.5s;
120-
}
121-
122-
.D-msg-opacity {
123-
opacity: 0;
124-
transform: translate(-50%, -100%);
125-
}
126-
127-
/* 成功提示框样式 */
128-
.D-msg-success {
129-
background-color: #e1f3d8;
130-
border-color: #e1f3d8;
131-
color: #67c23a;
132-
}
133-
134-
/* 警告提示框样式 */
135-
.D-msg-warn {
136-
background-color: #fdfce6;
137-
border-color: #fdfce6;
138-
color: #e6a23c;
139-
}
140-
/* 错误提示框样式 */
141-
.D-msg-error {
142-
background-color: #fef0f0;
143-
border-color: #fef0f0;
144-
color: #f56c6c;
145-
}
146-
102+
147103
.D-zoom {
148104
animation: D-zoom-animation 0.3s forwards;
149105
}

src/client/view/main.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Comments from './comments.svelte'
77
import Footer from './footer.svelte'
88
import IconLoading from '../../../assets/svg/Loading.svg'
9-
9+
import zIndex from '../lib/zIndex'
1010
import loadScript from '../lib/import'
1111
1212
let isLoading = true
@@ -15,6 +15,7 @@
1515
let app
1616
1717
function initAdmin() {
18+
zIndex('open')
1819
app = window.DiscussAdmin.init({ ...$options, el: '.D-admin-wrap', show: true })
1920
}
2021
@@ -29,7 +30,7 @@
2930
if (app) {
3031
for (const fun of app.$$.ctx) {
3132
if (Object.prototype.toString.call(fun) === '[object Object]' && typeof fun.onOpenAdmin === 'function') {
32-
fun.onOpenAdmin()
33+
fun.onOpenAdmin('open')
3334
}
3435
}
3536
}
@@ -60,7 +61,7 @@
6061
<div class="D-admin-wrap" />
6162
<Submit on:onRefresh={onRefresh} on:onSetting={onSetting} on:submitComment={submitComment} />
6263
{#if isLoading}
63-
<Comments on:onComments={onComments} comment={comment}/>
64+
<Comments on:onComments={onComments} {comment} />
6465
{/if}
6566
<div class="D-loading-comments" style={isRefreshComments ? '' : 'display:none'}>
6667
<IconLoading />

0 commit comments

Comments
 (0)