kana-bbs/layouts/default.vue

131 lines
3.0 KiB
Vue
Raw Normal View History

2022-01-30 13:34:10 +08:00
<template lang="pug">
.main
header.header
2022-01-31 14:21:50 +08:00
.circumscription
.logo Kana
nav.navbar
2022-02-24 16:45:45 +08:00
NuxtLink.navbar-item(:to="{ path: '/' }") 论坛
2022-01-31 14:21:50 +08:00
NuxtLink.navbar-item(to="/docs") 文档
NuxtLink.navbar-item(to="/chat") 聊天室
2022-02-08 03:43:55 +08:00
//NuxtLink.navbar-item(to="/admin") admin
2022-01-31 14:21:50 +08:00
.online
.navbar-user(v-if="account.online")
NuxtLink.userinfo(to="/account")
2024-04-16 20:06:06 +08:00
img.avatar(:src="account.avatar" onerror="this.src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'")
2022-01-31 14:21:50 +08:00
span.name {{ account.name }}
.navbar-sign(v-else)
NuxtLink.button(to="/account/signin") Signin
NuxtLink.button(to="/account/create") Login
.websocket(:class="{ on: websocket }")
2022-01-30 13:34:10 +08:00
Nuxt
</template>
<script>
2022-01-31 14:21:50 +08:00
import "@/assets/sass/main.sass";
import "@/assets/sass/default.sass";
import socket from "@/assets/js/socket.js";
2022-01-31 07:06:01 +08:00
2022-01-30 13:34:10 +08:00
export default {
2022-01-31 14:21:50 +08:00
data: () => ({
websocket: false,
}),
2022-01-30 13:34:10 +08:00
computed: {
account() {
return this.$store.state.account;
},
},
2022-01-31 14:21:50 +08:00
beforeMount() {
// 如果掉线调用变红, 如果上线调用变绿
socket.onclose = () => {
this.websocket = false;
};
socket.onopen = () => {
this.websocket = true;
};
let protocol = location.protocol === "https:" ? "wss:" : "ws:";
socket.init(`${protocol}//${location.host}/api/`);
},
2022-01-30 13:34:10 +08:00
mounted() {
console.log(
"%c こめいじ さとり %c satori.love ",
"color: white; background: #e9546b; padding:5px 0;",
"padding:4px;border:1px solid #e9546b;"
);
this.$store.dispatch("account/profile");
2022-02-08 03:37:22 +08:00
console.log(window.devicePixelRatio);
2022-01-30 13:34:10 +08:00
},
};
</script>
<style lang="sass">
2022-01-31 14:21:50 +08:00
.websocket
background: red
border-radius: 50%
width: 1rem
height: 1rem
margin: .25rem .5rem
.websocket.on
2022-02-02 06:15:27 +08:00
background: #00ee00
2022-01-30 13:34:10 +08:00
2022-01-31 14:21:50 +08:00
.main
2022-02-02 06:15:27 +08:00
>header.header
2022-02-05 05:08:17 +08:00
z-index: 100
2022-02-02 06:15:27 +08:00
position: fixed
top: 0
left: 0
width: 100%
padding: 1rem 0
>div
2022-01-30 18:12:48 +08:00
display: flex
2022-02-02 06:15:27 +08:00
align-items: flex-end
>.logo
font-size: 2rem
font-weight: 900
margin-right: 1.5rem
>nav.navbar
flex: 1
display: flex
align-items: center
//justify-content: center
.navbar-item
margin: 0 .25rem
padding: 0 .75rem
height: 2rem
line-height: 2rem
text-align: center
2022-01-31 14:21:50 +08:00
font-weight: 600
2022-02-06 12:08:19 +08:00
white-space: nowrap
2022-02-02 06:15:27 +08:00
>.online
.navbar-user
.userinfo
font-weight: 600
display: flex
align-items: center
.avatar
width: 24px
height: 24px
border-radius: 50%
margin-right: .5rem
2024-04-16 20:06:06 +08:00
background: rgba(0, 0, 0, .05)
2022-07-31 06:01:58 +08:00
.navbar-sign
a.button
margin-right: .5rem
2022-01-30 13:34:10 +08:00
footer.footer
text-align: center
2022-01-31 14:21:50 +08:00
padding: 4rem
.github
font-size: 2rem
2022-02-07 01:12:33 +08:00
2022-02-24 16:45:45 +08:00
//.admin
// position: relative
//.admin::before
// position: absolute
// top: 0
// right: 0
// content: '演示'
// width: 4rem
// height: 2rem
// background: #ff1414
2022-01-30 13:34:10 +08:00
</style>