159 行
5.3 KiB
PHP
159 行
5.3 KiB
PHP
<template>
|
||
<b-navbar toggleable="md" sticky type="dark" variant="dark">
|
||
<b-navbar-toggle target="nav_collapse"></b-navbar-toggle>
|
||
<b-navbar-brand @click="$router.replace('/home')">076</b-navbar-brand>
|
||
<b-collapse is-nav id="nav_collapse">
|
||
<b-navbar-nav v-for="(m, i) in menuItem" :key="`menu-${i}`">
|
||
<b-nav-item v-if="m.int" @click="$router.replace('/' + m.slug)">{{ m.title }}</b-nav-item>
|
||
<b-nav-item v-else :href="m.slug">{{ m.title }}</b-nav-item>
|
||
</b-navbar-nav>
|
||
</b-collapse>
|
||
<b-navbar-nav class="ml-auto" v-if="whoami === 0">
|
||
<b-nav-item href="https://user.076.ne.jp/#/login">サインイン</b-nav-item>
|
||
<b-nav-item href="https://user.076.ne.jp/#/register">新規登録</b-nav-item>
|
||
</b-navbar-nav>
|
||
<b-navbar-nav class="ml-auto" v-else>
|
||
<new-page v-if="canAddPage === 1" />
|
||
<b-nav-item-dropdown right>
|
||
<template slot="button-content">
|
||
<span v-if="notification.length === 0">通知</span>
|
||
<span v-else><b-badge variant="light">通知 {{ notification.length }}</b-badge></span>
|
||
</template>
|
||
<span v-if="notification.length !== 0">
|
||
<b-dropdown-item v-for="(n, j) in notification" :key="`tsuchi-${j}`" :href="n.url" @click="delNotify(n.id)">{{ n.text }}</b-dropdown-item>
|
||
</span>
|
||
<span v-else>
|
||
<b-dropdown-item>通知がありません</b-dropdown-item>
|
||
</span>
|
||
</b-nav-item-dropdown>
|
||
<b-nav-item-dropdown right>
|
||
<template slot="button-content">
|
||
<img :src="'https://srv.076.ne.jp/' + userAvatar" height="25px" /> <span :style="userColour">{{ userName }}</span>
|
||
</template>
|
||
<b-dropdown-item :href="'https://user.076.ne.jp/#/member'">ユーザーリスト</b-dropdown-item>
|
||
<b-dropdown-item :href="'https://user.076.ne.jp/#/profile/' + whoami">プロファイル</b-dropdown-item>
|
||
<b-dropdown-item @click="logout">サインアウト</b-dropdown-item>
|
||
</b-nav-item-dropdown>
|
||
</b-navbar-nav>
|
||
</b-navbar>
|
||
</template>
|
||
|
||
<script>
|
||
import Vue from 'vue';
|
||
import Cookie from 'js-cookie';
|
||
import { Navbar } from 'bootstrap-vue/es/components';
|
||
import auth from '../auth';
|
||
import NewPage from './newpage';
|
||
|
||
Vue.use(Navbar);
|
||
|
||
export default {
|
||
components: { NewPage },
|
||
data: function () {
|
||
return {
|
||
whoami: 0,
|
||
groupCol: [],
|
||
showName: '',
|
||
showCol: '',
|
||
userName: '',
|
||
userColour: '',
|
||
userAvatar: '',
|
||
menuItem: [],
|
||
notification: [],
|
||
canAddPage: 0
|
||
}
|
||
},
|
||
created: function () {
|
||
const tok = Cookie.get('kero_token');
|
||
|
||
if (tok) {
|
||
axios.post('/api/auth/getpermissions', {
|
||
kero_token: tok
|
||
}).then(res => {
|
||
res.data.forEach(cb => {
|
||
this.canAddPage = cb.blg_addpage;
|
||
});
|
||
});
|
||
|
||
axios.post('/api/auth/checkauth', {
|
||
kero_token: tok
|
||
}).then(res => {
|
||
this.whoami = res.data.id;
|
||
axios.get('/api/rpc/user/user/getgroupcolours').then(res => {
|
||
res.data.forEach(cb => {
|
||
this.groupCol.push({
|
||
'id': cb.id,
|
||
'name': cb.name,
|
||
'male': cb.colour_m,
|
||
'female': cb.colour_f,
|
||
'unknown': cb.colour_u
|
||
});
|
||
});
|
||
}).then(() => {
|
||
axios.get('/api/rpc/user/user/getuser/' + res.data.id, { params: { kero_token: tok } }).then(des => {
|
||
des.data.forEach(cb => {
|
||
if (cb.display_name !== '') this.showName = cb.display_name;
|
||
else this.showName = cb.username;
|
||
|
||
if (cb.name_style !== '') this.showCol = cb.name_style;
|
||
else {
|
||
this.groupCol.forEach(re => {
|
||
if (re.id === cb.perm_id) {
|
||
if (cb.gender === 1) this.showCol = re.male;
|
||
else if (cb.gender === 2) this.showCol = re.female;
|
||
else this.showCol = re.unknown;
|
||
}
|
||
});
|
||
}
|
||
this.userName = this.showName;
|
||
this.userAvatar = (cb.avatar !== '' ? cb.avatar : 'assets/avatars/haznoavaz.png');
|
||
this.userColour = this.showCol;
|
||
});
|
||
});
|
||
});
|
||
});
|
||
}
|
||
axios.get('/api/rpc/site/page/get/menu', {
|
||
params: {
|
||
kero_token: Cookie.get('kero_token')
|
||
}
|
||
}).then(des => {
|
||
des.data.forEach(cb => {
|
||
this.menuItem.push({
|
||
title: cb.title,
|
||
slug: cb.slug,
|
||
int: true
|
||
});
|
||
});
|
||
}).then(() => {
|
||
this.menuItem.push({
|
||
title: 'サポート掲示板',
|
||
slug: 'https://board.076.ne.jp',
|
||
int: false
|
||
});
|
||
});
|
||
axios.get('/api/rpc/user/notification/get', {
|
||
params: {
|
||
kero_token: Cookie.get('kero_token')
|
||
}
|
||
}).then(nes => {
|
||
nes.data.forEach(cb => {
|
||
this.notification.push(cb);
|
||
});
|
||
});
|
||
},
|
||
methods: {
|
||
delNotify: function (id) {
|
||
axios.post('/api/rpc/user/notification/del', {
|
||
kero_token: Cookie.get('kero_token'),
|
||
id: id
|
||
});
|
||
},
|
||
logout: function () {
|
||
auth.logout();
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|