|
@@ -72,11 +72,17 @@
|
|
<div class="item-title">Join Discord</div>
|
|
<div class="item-title">Join Discord</div>
|
|
</div>
|
|
</div>
|
|
<img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
|
|
<img :src="require('@/assets/gif/red-right.gif')" alt class="red-right"
|
|
- v-show="!state.done.join_discord && state.done.join_discord_red" />
|
|
|
|
- <img v-if="state.done.join_discord" :src="require('@/assets/svg/icon-true.svg')" alt />
|
|
|
|
- <div v-else class="btn" @click="joinDiscord">
|
|
|
|
- Join
|
|
|
|
- </div>
|
|
|
|
|
|
+ v-show="!data.done.join_discord && data.done.join_discord_red" />
|
|
|
|
+ <img v-if="data.done.join_discord" :src="require('@/assets/svg/icon-true.svg')" alt />
|
|
|
|
+ <template v-else>
|
|
|
|
+ <div v-if="joinDiscordIng" class="loading-wrapper">
|
|
|
|
+ <img class="icon-loading"
|
|
|
|
+ :src="require('@/assets/svg/icon-loading-gray.svg')"/>
|
|
|
|
+ </div>
|
|
|
|
+ <div v-else class="btn" @click="joinDiscord">
|
|
|
|
+ Join
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
</template>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -288,7 +294,7 @@ export default {
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<script setup>
|
|
<script setup>
|
|
-import { onMounted, reactive } from "vue";
|
|
|
|
|
|
+import { onMounted, reactive, ref } from "vue";
|
|
import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList } from '@/http/redPacket.js'
|
|
import { getPostDetail, getRedPacket, finishRedPacket, oneKeyLike, oneKeyReTweet, oneKeyFollow, getTaskDetail, getReceivedList } from '@/http/redPacket.js'
|
|
import { getQueryString, guid } from '@/uilts/help.js'
|
|
import { getQueryString, guid } from '@/uilts/help.js'
|
|
import { message } from 'ant-design-vue';
|
|
import { message } from 'ant-design-vue';
|
|
@@ -304,6 +310,7 @@ var moment = require('moment');
|
|
|
|
|
|
let discordAuthorizeRequired = false;
|
|
let discordAuthorizeRequired = false;
|
|
let joinDiscordActionState = 'default'; //authAndJoinIng joinIng reAuth
|
|
let joinDiscordActionState = 'default'; //authAndJoinIng joinIng reAuth
|
|
|
|
+let joinDiscordIng = ref(false);
|
|
|
|
|
|
let state = reactive({
|
|
let state = reactive({
|
|
status: '',
|
|
status: '',
|
|
@@ -732,6 +739,7 @@ function initTaskDetail() {
|
|
state.done.retweet = res.data[i].finished
|
|
state.done.retweet = res.data[i].finished
|
|
break
|
|
break
|
|
case 7:
|
|
case 7:
|
|
|
|
+ data.done.join_discord = res.data[i].finished
|
|
discordAuthorizeRequired = res.data[i].discordAuthorizeRequired
|
|
discordAuthorizeRequired = res.data[i].discordAuthorizeRequired
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -1093,13 +1101,11 @@ function checkJoinDiscord() {
|
|
if (joinDiscordActionState == 'joinIng') {
|
|
if (joinDiscordActionState == 'joinIng') {
|
|
joinDiscordActionState = 'default';
|
|
joinDiscordActionState = 'default';
|
|
let url = getInviteUrl();
|
|
let url = getInviteUrl();
|
|
- if (url) {
|
|
|
|
- checkGuildJoined({
|
|
|
|
- params: {
|
|
|
|
- inviteUrl: url
|
|
|
|
- }
|
|
|
|
- }).then(res => {
|
|
|
|
- if (res.code == 0) {
|
|
|
|
|
|
+ if(url) {
|
|
|
|
+ joinDiscordIng.value = true;
|
|
|
|
+ checkGuildJoinedStatus({url}, (res = {}) => {
|
|
|
|
+ joinDiscordIng.value = false;
|
|
|
|
+ if(res.code == 0) {
|
|
let { joined } = res.data || {};
|
|
let { joined } = res.data || {};
|
|
if (joined) {
|
|
if (joined) {
|
|
state.done.join_discord = true;
|
|
state.done.join_discord = true;
|
|
@@ -1112,15 +1118,56 @@ function checkJoinDiscord() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+const checkGuildJoinedStatus = ({url}, cb) => {
|
|
|
|
+ checkGuildJoined({
|
|
|
|
+ params: {
|
|
|
|
+ inviteUrl: url
|
|
|
|
+ }
|
|
|
|
+ }).then(res => {
|
|
|
|
+ cb && cb(res);
|
|
|
|
+ }).catch(err => {
|
|
|
|
+ cb && cb({catch:true})
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 加入discord 事件
|
|
* 加入discord 事件
|
|
*/
|
|
*/
|
|
-function joinDiscord() {
|
|
|
|
- //判断是否需要授权
|
|
|
|
- if (discordAuthorizeRequired) {
|
|
|
|
- discordAuth('authAndJoinIng');
|
|
|
|
- } else {
|
|
|
|
- openInviteUrl();
|
|
|
|
|
|
+async function joinDiscord() {
|
|
|
|
+ let _userInfo = await checkIsLogin();
|
|
|
|
+ if (!_userInfo) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if(joinDiscordIng.value) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ joinDiscordIng.value = true;
|
|
|
|
+ let url = getInviteUrl();
|
|
|
|
+ if(url) {
|
|
|
|
+ checkGuildJoinedStatus({url}, (res) => {
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ joinDiscordIng.value = false;
|
|
|
|
+ }, 1500);
|
|
|
|
+ if(res.code == 0) {
|
|
|
|
+ let { joined } = res.data || {};
|
|
|
|
+ if(joined) {
|
|
|
|
+ data.done.join_discord = true;
|
|
|
|
+ } else {
|
|
|
|
+ openInviteUrl();
|
|
|
|
+ }
|
|
|
|
+ } else if(res.code == 1010){
|
|
|
|
+ discordAuth('authAndJoinIng');
|
|
|
|
+ }
|
|
|
|
+ if(res.catch) {
|
|
|
|
+ //判断是否需要授权
|
|
|
|
+ if(discordAuthorizeRequired) {
|
|
|
|
+ discordAuth('authAndJoinIng');
|
|
|
|
+ } else {
|
|
|
|
+ openInviteUrl();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1128,35 +1175,31 @@ function joinDiscord() {
|
|
* discord授权
|
|
* discord授权
|
|
*/
|
|
*/
|
|
function discordAuth(actionState = 'default') {
|
|
function discordAuth(actionState = 'default') {
|
|
- let state = guid();
|
|
|
|
- discordAuthUrl({
|
|
|
|
- params: {
|
|
|
|
- redirectUrl: discordAuthRedirectUri,
|
|
|
|
- state
|
|
|
|
- }
|
|
|
|
- }).then(res => {
|
|
|
|
- if (res.code == 0) {
|
|
|
|
- let { authorizeUrl = '' } = res.data || {};
|
|
|
|
- if (authorizeUrl) {
|
|
|
|
- joinDiscordActionState = actionState;
|
|
|
|
- const width = 500, height = 800;
|
|
|
|
- chrome.windows.create({
|
|
|
|
- width,
|
|
|
|
- height,
|
|
|
|
- left: 0,
|
|
|
|
- top: 0,
|
|
|
|
- type: 'popup',
|
|
|
|
- url: authorizeUrl
|
|
|
|
- }, function (window) {
|
|
|
|
- let windowId = window.id;
|
|
|
|
- callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
|
|
|
|
- windowId: windowId
|
|
|
|
- }, function (response) {
|
|
|
|
- });
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ let state = guid();
|
|
|
|
+ discordAuthUrl({
|
|
|
|
+ params : {
|
|
|
|
+ redirectUrl: discordAuthRedirectUri,
|
|
|
|
+ state
|
|
|
|
+ }
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if(res.code == 0) {
|
|
|
|
+ let {authorizeUrl = ''} = res.data || {};
|
|
|
|
+ if(authorizeUrl) {
|
|
|
|
+ joinDiscordActionState = actionState;
|
|
|
|
+ const width = 500;
|
|
|
|
+ chrome.windows.create({
|
|
|
|
+ width,
|
|
|
|
+ type:'normal',
|
|
|
|
+ url: authorizeUrl}, function(window) {
|
|
|
|
+ let windowId = window.id;
|
|
|
|
+ callEventPageMethod("RED_PACKET_SAVE_DISCORD_AUTH_WINDOW_ID", {
|
|
|
|
+ windowId: windowId
|
|
|
|
+ }, function (response) {
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1732,6 +1775,14 @@ body {
|
|
color: #1D9BF0;
|
|
color: #1D9BF0;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .loading-wrapper {
|
|
|
|
+ width: 90px;
|
|
|
|
+ text-align:center;
|
|
|
|
+ .icon-loading {
|
|
|
|
+ animation:loading 1s infinite linear;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1952,6 +2003,14 @@ body {
|
|
z-index: 3;
|
|
z-index: 3;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ @keyframes loading{
|
|
|
|
+ from{
|
|
|
|
+ transform: rotate(0deg);
|
|
|
|
+ }
|
|
|
|
+ to{
|
|
|
|
+ transform: rotate(360deg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
.none {
|
|
.none {
|
|
display: flex;
|
|
display: flex;
|