diff --git a/package-lock.json b/package-lock.json index 7605292..31aa458 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10697,9 +10697,7 @@ } }, "semantic-ui-css": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/semantic-ui-css/-/semantic-ui-css-2.3.3.tgz", - "integrity": "sha512-/UDs+a07LdxmYgVNqkbW9x5Gil1Dt4HnVq4LrHKKUAD/DUDh0fnwmCxbQFyKKD+YsVDQWFqftyVbYKlClBFLDw==", + "version": "github:otakukaze/Semantic-UI-CSS#36d40f3ae0fd555ee04a0a31e626ef1e043821b9", "requires": { "jquery": "3.3.1" } diff --git a/package.json b/package.json index 03b974f..a8ed49f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "axios": "^0.18.0", - "semantic-ui-css": "^2.3.3", + "semantic-ui-css": "github:otakukaze/Semantic-UI-CSS#master", "semantic-ui-vue": "^0.2.11", "vue": "^2.5.17", "vue-router": "^3.0.1", diff --git a/src/components/ControlPanel/channel/components/sidemenu.vue b/src/components/ControlPanel/channel/components/sidemenu.vue new file mode 100644 index 0000000..8f7a81e --- /dev/null +++ b/src/components/ControlPanel/channel/components/sidemenu.vue @@ -0,0 +1,21 @@ + + + Dashboard + Opay + + + + + + diff --git a/src/components/ControlPanel/channel/index.vue b/src/components/ControlPanel/channel/index.vue new file mode 100644 index 0000000..6d46862 --- /dev/null +++ b/src/components/ControlPanel/channel/index.vue @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + Channel: {{channel.name}} + + + {{channel.join ? 'leave chat' : 'join chat'}} + + + + + + + + + + + + diff --git a/src/components/ControlPanel/channelList/index.vue b/src/components/ControlPanel/channelList/index.vue index 8644b83..e1ff105 100644 --- a/src/components/ControlPanel/channelList/index.vue +++ b/src/components/ControlPanel/channelList/index.vue @@ -5,7 +5,7 @@ - {{item.name}} + {{item.name}} Channel Link @@ -30,7 +30,10 @@ export default { ...mapActions(['getChannelList']) }, computed: { - ...mapGetters(['channelList']) + ...mapGetters(['channelList']), + urlPath: function () { + return this.$route.path.replace(/\/$/, '') + } } } diff --git a/src/components/ControlPanel/topMenu.vue b/src/components/ControlPanel/topMenu.vue index 784fff0..e4134ce 100644 --- a/src/components/ControlPanel/topMenu.vue +++ b/src/components/ControlPanel/topMenu.vue @@ -1,6 +1,11 @@ + + + Channels + + User: {{userInfo.name}} @@ -16,7 +21,10 @@ export default { return {} }, computed: { - ...mapGetters(['userInfo']) + ...mapGetters(['userInfo']), + activeItem: function () { + return this.$route.meta.topMenu || '' + } } } diff --git a/src/router.js b/src/router.js index 6302872..bc5294b 100644 --- a/src/router.js +++ b/src/router.js @@ -4,6 +4,7 @@ import Router from 'vue-router' import Login from '@/components/Login' import ControlPanel from '@/components/ControlPanel' import ChannelList from '@/components/ControlPanel/channelList' +import Channel from '@/components/ControlPanel/channel' Vue.use(Router) @@ -25,7 +26,19 @@ export default new Router({ path: 'channels', alias: '', name: 'ChannelList', - component: ChannelList + component: ChannelList, + meta: { + topMenu: 'channel' + } + }, + { + path: 'channel/:chid', + alias: '', + name: 'Channel', + component: Channel, + meta: { + topMenu: 'channel' + } }, { path: '*', diff --git a/src/store/actions.js b/src/store/actions.js index 0d30277..6fb2fc0 100644 --- a/src/store/actions.js +++ b/src/store/actions.js @@ -1,8 +1,7 @@ import axios from 'axios' import { apiUrl, - chkObject, - toInt + chkObject } from '@/tools' const client = axios.create({ @@ -85,5 +84,60 @@ export default { errorCatch.apply(commit, [err]) } commit('toggleLoading', false) + }, + async getChannel ({commit}, {id}) { + if (typeof id !== 'string' || id.trim().length === 0) { + commit('addDialog', { + msg: 'channel id read fail' + }) + return + } + commit('toggleLoading', true) + try { + let result = await client({ + method: 'get', + url: `/api/twitch/channel/${id}` + }) + let channel = null + if ('data' in result && 'channel' in result.data && typeof result.data.channel === 'object') channel = result.data.channel + if (channel === null) { + commit('addDialog', { + msg: 'channel data read fail' + }) + } else { + commit('setChannel', channel) + } + } catch (err) { + errorCatch.apply(commit, [err]) + } + commit('toggleLoading', false) + }, + async changeBotJoin ({commit}, {id, join, cb}) { + if (typeof id !== 'string' || id.trim().length === 0) { + commit('addDialog', { + msg: 'channel id read fail' + }) + return + } + if (typeof join !== 'boolean') { + commit('addDialog', { + msg: 'join status read fail' + }) + return + } + commit('toggleLoading', true) + try { + await client({ + method: 'put', + url: `/api/twitch/channel/${id}/botjoin`, + data: { + join: join ? 1 : 0 + } + }) + if (typeof cb === 'function') cb() + } catch (err) { + errorCatch.apply(commit, [err]) + } + commit('toggleLoading', false) } } diff --git a/src/store/getters.js b/src/store/getters.js index 3d1521e..e768dea 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -2,3 +2,7 @@ export const getLoading = state => !!state.loading export const dialogMsg = state => state.dialog[0] || null export const userInfo = state => state.user export const channelList = state => state.twitch.channels +export const getChannel = state => id => { + let arr = state.twitch.channels.filter(t => t.id === id) + return arr.length > 0 ? arr[0] : null +} diff --git a/src/store/mutations.js b/src/store/mutations.js index 1f6e374..08a9c3e 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -23,5 +23,10 @@ export default { setChannels (state, list) { if (!Array.isArray(list)) return state.twitch.channels = [...list] + }, + setChannel (state, channel = null) { + if (channel === null || typeof channel !== 'object' || !('id' in channel)) return + let list = state.twitch.channels.filter(t => t.id !== channel.id) + state.twitch.channels = [...list, channel] } }