pref: message component
This commit is contained in:
parent
5cee4cd046
commit
b4dddd7c11
|
@ -45,8 +45,8 @@ watch(
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="kungalgame-message-container">
|
||||||
<div class="message" :class="messageClass(type)">
|
<div class="kungalgame-message" :class="messageClass(type)">
|
||||||
<span class="icon" v-if="type === 'warn'"
|
<span class="icon" v-if="type === 'warn'"
|
||||||
><Icon icon="line-md:alert"
|
><Icon icon="line-md:alert"
|
||||||
/></span>
|
/></span>
|
||||||
|
@ -65,7 +65,7 @@ watch(
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.container {
|
.kungalgame-message-container {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 100px;
|
top: 100px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
@ -75,7 +75,7 @@ watch(
|
||||||
display: flex;
|
display: flex;
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
.message {
|
.kungalgame-message {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
font-size: large;
|
font-size: large;
|
||||||
color: var(--kungalgame-font-color-2);
|
color: var(--kungalgame-font-color-2);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { render, h } from 'vue'
|
import { render, h, ref } from 'vue'
|
||||||
import Message from './KUNGalgameMessage.vue'
|
import Message from './KUNGalgameMessage.vue'
|
||||||
|
|
||||||
type MessageType = `warn` | `success` | `error` | `info`
|
type MessageType = `warn` | `success` | `error` | `info`
|
||||||
|
@ -10,13 +10,18 @@ type MessageType = `warn` | `success` | `error` | `info`
|
||||||
* @param {number} duration - 消息的展示时间,可选,默认 3s
|
* @param {number} duration - 消息的展示时间,可选,默认 3s
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// 消息的计数,在有新消息展示的时候销毁消息会产生错误后果
|
||||||
|
const messageCount = ref(0)
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
messageEN: string,
|
messageEN: string,
|
||||||
messageCN: string,
|
messageCN: string,
|
||||||
type: MessageType,
|
type: MessageType,
|
||||||
duration?: number
|
duration?: number
|
||||||
) => {
|
) => {
|
||||||
// 初始化的时候先将上一次创建的内容销毁
|
// 增加消息计数
|
||||||
|
messageCount.value++
|
||||||
|
// 先移除上一个组件
|
||||||
render(null, document.body)
|
render(null, document.body)
|
||||||
|
|
||||||
const messageNode = h(Message, {
|
const messageNode = h(Message, {
|
||||||
|
@ -28,13 +33,16 @@ export default (
|
||||||
|
|
||||||
const time = duration ? duration : 3000
|
const time = duration ? duration : 3000
|
||||||
|
|
||||||
const handleDestroy = () => {
|
// 指定时间后删除消息
|
||||||
|
setTimeout(() => {
|
||||||
|
// 递减消息计数
|
||||||
|
messageCount.value--
|
||||||
|
|
||||||
|
// 消息计数为零时再移除组件
|
||||||
|
if (!messageCount.value) {
|
||||||
// 从 body 上移除组件
|
// 从 body 上移除组件
|
||||||
render(null, document.body)
|
render(null, document.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
handleDestroy()
|
|
||||||
}, time)
|
}, time)
|
||||||
|
|
||||||
render(messageNode, document.body)
|
render(messageNode, document.body)
|
||||||
|
|
|
@ -188,7 +188,7 @@ const handelCloseSettingsPanel = () => {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--kungalgame-red-3);
|
background-color: var(--kungalgame-red-4);
|
||||||
color: var(--kungalgame-white);
|
color: var(--kungalgame-white);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,13 @@ export default {
|
||||||
all: 'All Topics',
|
all: 'All Topics',
|
||||||
history: 'Search History',
|
history: 'Search History',
|
||||||
clear: 'Clear all history',
|
clear: 'Clear all history',
|
||||||
updated: 'Restore default',
|
updated: 'Default',
|
||||||
time: 'Sort by time',
|
time: 'Time',
|
||||||
popularity: 'Sort by popularity',
|
popularity: 'Popularity',
|
||||||
views: 'Sort by views',
|
views: 'Views',
|
||||||
likes: 'Sort by likes',
|
likes: 'Likes',
|
||||||
replies: 'Sort by replies',
|
replies: 'Replies',
|
||||||
comments: 'Sort by comments',
|
comments: 'Comments',
|
||||||
},
|
},
|
||||||
asideActive: {
|
asideActive: {
|
||||||
fold: 'Fold Aside',
|
fold: 'Fold Aside',
|
||||||
|
|
|
@ -61,10 +61,8 @@ html {
|
||||||
|
|
||||||
--shadow: 0 1px 2px hsla(0, 0%, 0%, 0.05), 0 1px 4px hsla(0, 0%, 0%, 0.05),
|
--shadow: 0 1px 2px hsla(0, 0%, 0%, 0.05), 0 1px 4px hsla(0, 0%, 0%, 0.05),
|
||||||
0 2px 8px hsla(0, 0%, 0%, 0.05);
|
0 2px 8px hsla(0, 0%, 0%, 0.05);
|
||||||
--kungalgame-shadow-0: 5px 5px 10px var(--kungalgame-trans-blue-1),
|
--kungalgame-shadow-0: 0px 0px 17px 5px var(--kungalgame-blue-1);
|
||||||
-5px -5px 10px var(--kungalgame-trans-blue-1);
|
--kungalgame-shadow-1: 0px 0px 7px 2px var(--kungalgame-blue-1);
|
||||||
--kungalgame-shadow-1: 2px 2px 4px var(--kungalgame-blue-1),
|
|
||||||
-2px -2px 4px var(--kungalgame-blue-1);
|
|
||||||
--kungalgame-shadow-2: inset 1px 1px 2px var(--kungalgame-blue-1),
|
--kungalgame-shadow-2: inset 1px 1px 2px var(--kungalgame-blue-1),
|
||||||
inset -1px -1px 2px var(--kungalgame-blue-1);
|
inset -1px -1px 2px var(--kungalgame-blue-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ const props = defineProps<{
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--kungalgame-white);
|
background-color: var(--kungalgame-white);
|
||||||
|
box-shadow: var(--kungalgame-shadow-1);
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
}
|
}
|
||||||
&:last-child {
|
&:last-child {
|
||||||
|
|
|
@ -114,6 +114,7 @@ const getRepliesCount = computed(() => {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
color: var(--kungalgame-blue-5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 话题点赞数等信息 */
|
/* 话题点赞数等信息 */
|
||||||
|
|
|
@ -64,7 +64,6 @@ defineProps<{
|
||||||
|
|
||||||
/* 发帖人昵称位置设置 */
|
/* 发帖人昵称位置设置 */
|
||||||
.name {
|
.name {
|
||||||
border-top: 1px solid var(--kungalgame-blue-1);
|
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ const orderDescending = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const iconMap: Record<string, string> = {
|
const iconMap: Record<string, string> = {
|
||||||
updated: 'bi:sort-down',
|
updated: 'line-md:arrows-vertical',
|
||||||
time: 'eos-icons:hourglass',
|
time: 'eos-icons:hourglass',
|
||||||
popularity: 'bi:fire',
|
popularity: 'bi:fire',
|
||||||
views: 'ic:outline-remove-red-eye',
|
views: 'ic:outline-remove-red-eye',
|
||||||
|
@ -56,13 +56,13 @@ const isSortField = () => {
|
||||||
<div class="sort-container">
|
<div class="sort-container">
|
||||||
<div class="sort-submenu">
|
<div class="sort-submenu">
|
||||||
<div
|
<div
|
||||||
|
class="sort-item"
|
||||||
v-for="kun in navSortItem"
|
v-for="kun in navSortItem"
|
||||||
:key="kun.index"
|
:key="kun.index"
|
||||||
@click="handleSortByField(kun.sortField)"
|
@click="handleSortByField(kun.sortField)"
|
||||||
>
|
>
|
||||||
<Icon class="icon-item" :icon="kun.icon" />{{
|
<span><Icon class="icon-item" :icon="kun.icon" /></span>
|
||||||
$tm(`mainPage.header.${kun.name}`)
|
<span>{{ $tm(`mainPage.header.${kun.name}`) }}</span>
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="sort-order">
|
<div class="sort-order">
|
||||||
<span @click="orderAscending">
|
<span @click="orderAscending">
|
||||||
|
@ -123,22 +123,23 @@ const isSortField = () => {
|
||||||
.container:hover .sort-submenu {
|
.container:hover .sort-submenu {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
.sort-submenu > div {
|
.sort-item {
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
background-color: var(--kungalgame-trans-white-2);
|
background-color: var(--kungalgame-trans-white-2);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: var(--kungalgame-font-color-3);
|
color: var(--kungalgame-font-color-3);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: flex;
|
display: grid;
|
||||||
align-items: center;
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
justify-content: center;
|
grid-template-rows: repeat(1, minmax(0, 1fr));
|
||||||
|
place-items: center;
|
||||||
}
|
}
|
||||||
/* 单个二级菜单 hover */
|
/* 单个二级菜单 hover */
|
||||||
.sort-submenu > div:hover {
|
.sort-item:hover {
|
||||||
background-color: var(--kungalgame-trans-blue-1);
|
background-color: var(--kungalgame-trans-blue-1);
|
||||||
backdrop-filter: blur(5px);
|
backdrop-filter: blur(5px);
|
||||||
}
|
}
|
||||||
.sort-submenu > div:active {
|
.sort-item:active {
|
||||||
background-color: var(--kungalgame-trans-blue-2);
|
background-color: var(--kungalgame-trans-blue-2);
|
||||||
}
|
}
|
||||||
.icon-item {
|
.icon-item {
|
||||||
|
@ -150,8 +151,10 @@ const isSortField = () => {
|
||||||
/* 按照升序还是降序排列 */
|
/* 按照升序还是降序排列 */
|
||||||
.sort-order {
|
.sort-order {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding: 10px 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
background-color: var(--kungalgame-trans-white-2);
|
||||||
span {
|
span {
|
||||||
color: var(--kungalgame-blue-4);
|
color: var(--kungalgame-blue-4);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -8,7 +8,7 @@ interface Sort {
|
||||||
export const navSortItem: Sort[] = [
|
export const navSortItem: Sort[] = [
|
||||||
{
|
{
|
||||||
index: 1,
|
index: 1,
|
||||||
icon: 'bi:sort-down',
|
icon: 'line-md:arrows-vertical',
|
||||||
name: 'updated',
|
name: 'updated',
|
||||||
sortField: 'updated',
|
sortField: 'updated',
|
||||||
},
|
},
|
||||||
|
|
|
@ -148,8 +148,6 @@ const handleClickUpvote = async () => {
|
||||||
props.master.uid
|
props.master.uid
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(res.code)
|
|
||||||
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
// 更新推数
|
// 更新推数
|
||||||
actions.upvotes.length++
|
actions.upvotes.length++
|
||||||
|
|
Loading…
Reference in a new issue