diff --git a/package.json b/package.json index 78b993553348052d4b5c98adb0dbb4b881d9f8d8..3cfc7dc7a1fd47a6a6c1d9a308b62c9a482c3463 100755 --- a/package.json +++ b/package.json @@ -12,8 +12,7 @@ "clipboard": "^2.0.6", "element-ui": "^2.3.4", "vue": "^2.5.16", - "vue-photo-preview": "^1.1.3", - "vue-router": "^3.3.2" + "vue-photo-preview": "^1.1.3" }, "engines": { "node": ">=6" diff --git a/src/App.vue b/src/App.vue index 0bbbf5c3ec1c66f7c771b12f6442c2c59bc36fd0..087a1199076f6dc7031b950cbcbbb48cf2112aa8 100755 --- a/src/App.vue +++ b/src/App.vue @@ -21,31 +21,31 @@
- +
点歌
- +
- +
已点
- +
- +
歌单
- +
- +
房间
- +
@@ -64,9 +64,9 @@
- - +
+ +
@@ -284,9 +284,22 @@ {{urldecode(songInfo.user.user_name)}}
+
+ + + + + + + + + + + + + +
- -
- \ No newline at end of file diff --git a/src/components/DingCallback.vue b/src/components/DingCallback.vue deleted file mode 100755 index 322cd98b4f5e079991aa9aa5019bb54f0eba5773..0000000000000000000000000000000000000000 --- a/src/components/DingCallback.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/GiteeCallback.vue b/src/components/GiteeCallback.vue deleted file mode 100755 index dc535661e0386cbd935cd2fd5d4141c01f68f457..0000000000000000000000000000000000000000 --- a/src/components/GiteeCallback.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/GithubCallback.vue b/src/components/GithubCallback.vue deleted file mode 100755 index 2f1df2b64984eec3441e93a424e67b27c4962fca..0000000000000000000000000000000000000000 --- a/src/components/GithubCallback.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/Login.vue b/src/components/Login.vue index 6d6cbd645897e32d22b6772918535bf64afb1a8c..dcc802b475a2c019b06dedc3694737381e1b34fb 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -38,9 +38,6 @@ href="https://oapi.dingtalk.com/connect/qrconnect?appid=dingoag8afgz20g2otw0jf&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=https://bbbug.com/ding"> 钉钉 - 立即登录 @@ -67,11 +64,7 @@ }, methods: { loginGuest() { - let that = this; - that.global.baseData.access_token = that.global.guestUserInfo.access_token; - that.global.userInfo = that.global.guestUserInfo; - that.$emit('App', 'getUserInfo'); - that.$router.push('/'); + this.$parent.loginGuest(); }, doLogin(formName) { let that = this; @@ -85,8 +78,8 @@ that.bbbug_loading = false; that.global.baseData.access_token = res.data.access_token; localStorage.setItem('access_token', res.data.access_token); - that.$emit('App', 'getUserInfo'); - that.$router.push('/'); + that.$parent.hideAll(); + that.$parent.getUserInfo(); }, error(res) { that.bbbug_loading = false; diff --git a/src/components/MySetting.vue b/src/components/MySetting.vue index 5634737e3a48c77ba57bb98e4d1334272740276b..91a99c9c29cd54cddc83aa2a68a0286a02e78870 100755 --- a/src/components/MySetting.vue +++ b/src/components/MySetting.vue @@ -5,7 +5,7 @@
我的个人中心
保存
- +
-
我点过的歌 - -
+
我点过的歌
@@ -46,10 +44,6 @@ } }, created() { - if (!this.global.userInfo || !this.global.roomInfo) { - this.$router.push('/'); - return; - } this.userInfo = this.global.userInfo; this.roomInfo = Object.assign({}, this.global.roomInfo); this.getList(); diff --git a/src/components/OSChinaCallback.vue b/src/components/OSChinaCallback.vue deleted file mode 100755 index c685d79c739228dc689fd3b354d474a58de91b62..0000000000000000000000000000000000000000 --- a/src/components/OSChinaCallback.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/OnlineList.vue b/src/components/OnlineList.vue index c06483aaf88540c0988d2ef3071da985edfe2b9e..59510c68c43d61d35e6010858507881a0c551cbc 100755 --- a/src/components/OnlineList.vue +++ b/src/components/OnlineList.vue @@ -47,7 +47,8 @@
-
+
@@ -92,7 +93,7 @@ this.roomInfo = this.global.roomInfo; this.getList(); } else { - this.$router.push('/'); + this.$parent.hideAll(); } }, methods: { @@ -134,8 +135,8 @@ user_id: cmd.row.user_id, user_name: cmd.row.user_name }; - that.$emit('App', 'atUser'); - that.$router.push('/'); + that.$parent.atUser(); + that.$parent.hideAll(); break; case 'touch': that.doTouch(cmd.row.user_id); @@ -182,12 +183,14 @@ case 'profile': that.global.profileUserId = cmd.row.user_id; that.$nextTick(function () { - that.$router.push('/profile'); + that.$parent.hideAll(); + that.$parent.dialog.Profile = true; }); break; case 'sendSong': that.global.atSongUserInfo = cmd.row; - that.$router.push('/search_songs'); + that.$parent.hideAll(); + that.$parent.dialog.SearchSongs = true; break; default: that.$message.error('即将上线,敬请期待'); diff --git a/src/components/PlayingSongList.vue b/src/components/PlayingSongList.vue index e91a97119bea0c5b25ae152479017ba1a4381487..74d7ce81e1efec1f4c0b75f6dac6c96a92a9d204 100755 --- a/src/components/PlayingSongList.vue +++ b/src/components/PlayingSongList.vue @@ -3,7 +3,7 @@
正在等待播放的歌 - 我要点歌 +
我要点歌
@@ -54,15 +54,15 @@ } }, created() { - if (!this.global.userInfo || !this.global.roomInfo) { - this.$router.push('/'); - return; - } this.userInfo = this.global.userInfo; this.roomInfo = Object.assign({}, this.global.roomInfo); this.getList(); }, methods: { + searchSong() { + this.$parent.hideAll(); + this.$parent.dialog.SearchSongs = true; + }, getList() { let that = this; if (that.bbbug_loading) { diff --git a/src/components/Profile.vue b/src/components/Profile.vue index f1e0deee3d5d76a43beafa0cf0781a836b1b53f4..d1e83e2bae34bf025b80a8990f665d876bf7d105 100755 --- a/src/components/Profile.vue +++ b/src/components/Profile.vue @@ -34,8 +34,8 @@
{{urldecode(userInfo.user_name)}}
@@ -66,10 +66,6 @@ } }, created() { - if (!this.global.roomInfo) { - this.$router.push('/'); - return; - } this.roomInfo = this.global.roomInfo; this.getUserProfile(); this.getSongList(); @@ -108,7 +104,8 @@ if (that.userInfo.myRoom) { let room_id = that.userInfo.myRoom.room_id; localStorage.setItem('room_change_id', room_id); - that.$emit('App', 'changeRoom'); + that.$parent.hideAll(); + that.$parent.changeRoom(); } else { that.$message.error("Ta当前没有创建自己的音乐房间"); } diff --git a/src/components/QQCallback.vue b/src/components/QQCallback.vue deleted file mode 100755 index bfc39a04f8d23bf4da3c49c067fc07483346d5ef..0000000000000000000000000000000000000000 --- a/src/components/QQCallback.vue +++ /dev/null @@ -1,48 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/RoomCreate.vue b/src/components/RoomCreate.vue index 77a8cbb997f2a3233f308b8bbffeab86bfc4aaea..503ef300e5a77214a71683134336712775f17b63 100755 --- a/src/components/RoomCreate.vue +++ b/src/components/RoomCreate.vue @@ -12,14 +12,6 @@ - - - - @@ -46,26 +38,13 @@ }, { value: 1, title: "点歌音乐房" - // }, { - // value: 2, - // title: "猜歌游戏房" }, { - // value: 3, - // title: "有声故事房" - // }, { value: 4, title: "房主电台房" - // }, { - // value: 5, - // title: "虎牙直播房" }], } }, created() { - if (!this.global.userInfo) { - this.$router.push('/'); - return; - } this.userInfo = this.global.userInfo; }, methods: { @@ -81,10 +60,10 @@ type: 'warning' }).then(function () { localStorage.setItem('room_change_id', res.data.room_id); - that.$emit('App', 'getUserInfo'); - that.$router.push('/'); + that.$parent.hideAll(); + that.$parent.getUserInfo(); }).catch(function () { - that.$router.push('/'); + that.$parent.hideAll(); }); } }); diff --git a/src/components/RoomList.vue b/src/components/RoomList.vue index 8d6c9f04cd7400d9e1671366c8a1da707a96bcd9..e6d5a9aa6ccc730bfe26d1f38c3c6ac861dd765e 100755 --- a/src/components/RoomList.vue +++ b/src/components/RoomList.vue @@ -3,8 +3,7 @@
热门房间列表 - 创建房间 - +
创建房间
我的房间
@@ -63,18 +62,22 @@ urldecode(str) { return decodeURIComponent(str); }, + createNewRoom() { + this.$parent.hideAll(); + this.$parent.dialog.RoomCreate = true; + }, joinRoom(room_id) { - let that = this; if (room_id) { localStorage.setItem('room_change_id', room_id); - that.$emit('App', 'changeRoom'); + this.$parent.hideAll(); + this.$parent.changeRoom(); } }, joinMyRoom() { - let that = this; - let room_id = that.userInfo.myRoom.room_id; + let room_id = this.userInfo.myRoom.room_id; localStorage.setItem('room_change_id', room_id); - that.$emit('App', 'changeRoom'); + this.$parent.hideAll(); + this.$parent.changeRoom(); }, getList() { let that = this; diff --git a/src/components/RoomPassword.vue b/src/components/RoomPassword.vue index 0723257e7a41f2ca3261b12c27c47c379cb75285..64079cf5b7e2d13fdd617d1daa830f0db7f7a99a 100755 --- a/src/components/RoomPassword.vue +++ b/src/components/RoomPassword.vue @@ -7,7 +7,8 @@
- + +
@@ -26,18 +27,18 @@ }, created() { if (!this.global.userInfo) { - this.$router.push('/'); localStorage.setItem('room_change_id', 888); + this.$parent.hideAll(); + this.$parent.getRoomInfo(); return; } this.userInfo = this.global.userInfo; }, methods: { enterRoom() { - let that = this; - that.global.room_password = that.room_password; - that.$emit('App', 'getRoomInfo'); - that.$router.push('/'); + this.global.room_password = this.room_password; + this.$parent.hideAll(); + this.$parent.getRoomInfo(); }, }, } diff --git a/src/components/RoomSetting.vue b/src/components/RoomSetting.vue index f0e15bcf76a24ffba3b252de384b67b238708baa..9ff34723c2ed5257a814d004533e7e9ffa22df92 100755 --- a/src/components/RoomSetting.vue +++ b/src/components/RoomSetting.vue @@ -12,14 +12,6 @@ - - - - @@ -168,26 +160,13 @@ }, { value: 1, title: "点歌音乐房" - // }, { - // value: 2, - // title: "猜歌游戏房" }, { - // value: 3, - // title: "有声故事房" - // }, { value: 4, title: "房主电台房" - // }, { - // value: 5, - // title: "虎牙直播房" }], } }, created() { - if (!this.global.userInfo || !this.global.roomInfo) { - this.$router.push('/'); - return; - } this.userInfo = this.global.userInfo; this.roomInfo = Object.assign({}, this.global.roomInfo); }, diff --git a/src/components/SearchSongs.vue b/src/components/SearchSongs.vue index 2cbbcd74a57d62627ccd5004f755a6c9691023bc..2c7c4e55b758fa3c9dda69bfbe31e9da15601875 100755 --- a/src/components/SearchSongs.vue +++ b/src/components/SearchSongs.vue @@ -4,7 +4,6 @@
歌曲搜索 - 搜索 @@ -56,10 +55,6 @@ }; }, created() { - if (!this.global.userInfo || !this.global.roomInfo) { - this.$router.push('/'); - return; - } this.userInfo = this.global.userInfo; this.roomInfo = Object.assign({}, this.global.roomInfo); this.atSongUserInfo = this.global.atSongUserInfo; diff --git a/src/components/SystemSetting.vue b/src/components/SystemSetting.vue index 4e6330ac0f09b48000190367d15c630d2a5c92af..81095495303180eaebc9ba7557b96d440159489a 100755 --- a/src/components/SystemSetting.vue +++ b/src/components/SystemSetting.vue @@ -28,19 +28,15 @@ roomInfo: {}, isEnableNoticePlayer: true, isEnableNotification: true, - isDarkModelTemp: true + isDarkModelTemp: false } }, created() { - if (!this.global.userInfo || !this.global.roomInfo) { - this.$router.push('/'); - return; - } this.userInfo = Object.assign({}, this.global.userInfo); this.roomInfo = Object.assign({}, this.global.roomInfo); this.isEnableNoticePlayer = localStorage.getItem('isEnableNoticePlayer') != 1 ? true : false; this.isEnableNotification = localStorage.getItem('isEnableNotification') != 1 ? true : false; - this.isDarkModelTemp = localStorage.getItem('isDarkModel') == 1 ? true : false; + this.isDarkModelTemp = this.$parent.isDarkModel; }, methods: { isEnableNoticePlayerChanged() { @@ -52,14 +48,7 @@ this.$emit('App', 'loadConfig'); }, isDarkModelChanged() { - let that = this; - console.log(this.isDarkModelTemp) - this.isDarkModel = this.isDarkModelTemp; - localStorage.setItem('isDarkModel', this.isDarkModel ? 1 : 0); - this.$emit('App', 'updateDarkModel'); - this.$nextTick(function(){ - that.$router.push('/'); - }); + this.$parent.updateDarkModel(this.isDarkModelTemp); } }, } diff --git a/src/main.js b/src/main.js index 314221f8976894e769490cd8736410f3d9e61423..7b40ede34654498faade41be39233391cab5ef8c 100755 --- a/src/main.js +++ b/src/main.js @@ -1,11 +1,12 @@ //main.js文件中引入 import Vue from 'vue'; -import VueRouter from 'vue-router'; //导入ElementUI import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; Vue.use(ElementUI); import axios from 'axios'; +import preview from 'vue-photo-preview' +import 'vue-photo-preview/dist/skin.css' import './assets/css/bbbug.css'; Vue.prototype.$axios = axios; import clipboard from 'clipboard'; @@ -14,7 +15,7 @@ Vue.prototype.clipboard = clipboard; Vue.prototype.Event = new Vue(); Vue.prototype.global = { - isDarkModel:true, + isDarkModel: true, room_id: 888, room_password: "", guestUserInfo: { @@ -39,19 +40,13 @@ Vue.prototype.global = { url: "https://api.bbbug.com/api/", static: "https://cdn.bbbug.com/",//这里修改为 https://api.bbbug.com/ 对应你的api 根路径 }, - songKeyword:"", + songKeyword: "", }; Vue.prototype.isDarkModel = false; -Vue.prototype.changeDarkModel=function(enabled){ +Vue.prototype.changeDarkModel = function (enabled) { this.isDarkModel = enabled; }; -Vue.prototype.doLogout = function () { - this.global.userInfo = this.global.guestUserInfo; - this.global.baseData.access_token = this.global.guestUserInfo.access_token; - localStorage.removeItem('access_token'); -}; - Vue.prototype.urldecode = function (str) { return decodeURIComponent(str); }; @@ -75,6 +70,9 @@ Vue.prototype.request = function (_data) { case 401: that.$emit('App', 'hideLoading'); that.$emit('App', 'hideAll'); + that.$parent.$emit('App', 'hideLoading'); + that.$parent.$emit('App', 'hideAll'); + console.log(that); if (_data.login) { that.$message.error(response.data.msg); _data.login(); @@ -86,11 +84,14 @@ Vue.prototype.request = function (_data) { closeOnPressEscape: false, type: 'warning' }).then(function () { - that.doLogout(); - that.$router.push('/login'); + that.$emit('App', 'loginGuest'); + that.$emit('App', 'showLoginForm'); + that.$parent.$emit('App', 'loginGuest'); + that.$parent.$emit('App', 'showLoginForm'); }).catch(function () { if (that.global.baseData.access_token != that.global.guestUserInfo.access_token) { - that.doLogout(); + that.$emit('App', 'loginGuest'); + that.$parent.$emit('App', 'loginGuest'); that.request(_data); } }); @@ -129,100 +130,11 @@ Vue.prototype.websocket = { }; //主体 import App from './App.vue'; -import preview from 'vue-photo-preview' -import 'vue-photo-preview/dist/skin.css' -import RoomList from './components/RoomList.vue'; -import MySongList from './components/MySongList.vue'; -import PlayingSongList from './components/PlayingSongList.vue'; -import SearchSongs from './components/SearchSongs.vue'; -import Login from './components/Login.vue'; -import GiteeCallback from './components/GiteeCallback.vue'; -import OSChinaCallback from './components/OSChinaCallback.vue'; -import DingCallback from './components/DingCallback.vue'; -import QQCallback from './components/QQCallback.vue'; -// import GithubCallback from './components/GithubCallback.vue'; -import OnlineList from './components/OnlineList.vue'; -import RoomSetting from './components/RoomSetting.vue'; -import RoomCreate from './components/RoomCreate.vue'; -import RoomPassword from './components/RoomPassword.vue'; -import MySetting from './components/MySetting.vue'; -import AutoLogin from './components/AutoLogin.vue'; -import Profile from './components/Profile.vue'; -import SystemSetting from './components/SystemSetting.vue'; Vue.use(vuePhotoPreview, {}); -//安装插件 -Vue.use(VueRouter); //挂载属性 -//创建路由对象并配置路由规则 -let router = new VueRouter({ - mode: 'history', - routes: [ - //一个个对象 - { - path: '/login', - component: Login - }, { - path: '/hot_rooms', - component: RoomList - }, { - path: '/my_songs', - component: MySongList - }, { - path: '/playing_songs', - component: PlayingSongList - }, { - path: '/search_songs', - component: SearchSongs - }, { - path: '/gitee', - component: GiteeCallback - }, { - path: '/oschina', - component: OSChinaCallback - }, { - path: '/qq', - component: QQCallback - }, { - path: '/ding', - component: DingCallback - }, { - path: '/online', - component: OnlineList - }, { - path: '/room_setting', - component: RoomSetting - }, { - path: '/room_password', - component: RoomPassword - }, { - path: '/create_room', - component: RoomCreate - }, { - path: '/my_setting', - component: MySetting - }, { - path: '/auto_login', - component: AutoLogin - }, { - path: '/*.html', - component: AutoLogin - }, { - path: '/profile', - component: Profile - }, { - path: '/system_setting', - component: SystemSetting - }, - // { - // path: '/github', - // component: GithubCallback - // } - ] -}); + //new Vue 启动 new Vue({ el: '#app', - //让vue知道我们的路由规则 - router: router, //可以简写router render: c => c(App), }); \ No newline at end of file