Skip to content

Commit

Permalink
Fix RealName pay request
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Sep 7, 2024
1 parent 2f7daee commit 9d86e82
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 39 deletions.
18 changes: 9 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ import hljs from 'highlight.js/lib/core'
import ini from 'highlight.js/lib/languages/ini'
import nginx from 'highlight.js/lib/languages/nginx'
import api from '@/api'
import { sendWarningMessage, sendErrorMessage } from '@/utils/message'
import { sendWarningMessage } from '@/utils/message'
import { logout } from '@/utils/profile'
// import { init_ws, SetOnMessageFunction } from "@/utils/websocket.js";
import { sendInfoNotification } from '@/utils/notification'
// import { sendInfoNotification } from '@/utils/notification'
const osThemeRef = useOsTheme()
const theme = computed(() => (osThemeRef.value === 'dark' ? darkTheme : null))
Expand All @@ -49,13 +49,13 @@ let inited = false
hljs.registerLanguage('ini', ini)
hljs.registerLanguage('nginx', nginx)
function getMessage(e) {
const rs = JSON.parse(e.data)
// 通知
if (rs.type === 'notice') {
sendInfoNotification(rs.message)
}
}
// function getMessage(e) {
// const rs = JSON.parse(e.data)
// // 通知
// if (rs.type === 'notice') {
// sendInfoNotification(rs.message)
// }
// }
// 初始化websocket
if (inited === false) {
Expand Down
2 changes: 0 additions & 2 deletions src/api/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logger from '@/utils/logger'

const base = {
api_v1_url: 'https://api.locyanfrp.cn',
api_v2_url: 'https://api-v2.locyanfrp.cn/api/v2',
Expand Down
5 changes: 3 additions & 2 deletions src/api/v2/realperson/pay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import base from '@/api/base'
//@ts-ignore
import { get } from '@/utils/request'

const pay = async (username: string, notify_url: string) => {
const pay = async (username: string, notify_url: string, redirect_url: string) => {
const rs = get(`${base.api_v2_url}/realperson/pay`, {
username: username,
notify_url: notify_url
notify_url: notify_url,
redirect_url: redirect_url
})
return base.buildResponse(await rs)
}
Expand Down
36 changes: 13 additions & 23 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { changeMainSideBarShow } from '../components/MainNav.vue'
import { changeShowGuestSideBar } from '../components/GuestNav.vue'
import { setSideBarActiveKey } from '../components/MainSideBar.vue'
import { setGuestSideBarActiveKey } from '../components/GuestSideBar.vue'
import logger from '@/utils/logger'

const routes = [
{
Expand Down Expand Up @@ -155,32 +156,21 @@ const router = createRouter({
routes
})

// 检查本地存储是否存在token,若存在则直接使用
if (localStorage.getItem('token')) {
store.commit('set_token', localStorage.getItem('token'))
}
// // 检查本地存储是否存在token,若存在则直接使用
// if (localStorage.getItem('token')) {
// store.commit('set_token', localStorage.getItem('token'))
// }

// 检测到已登录之后自动跳转 /dashboard 的界面
const _autoRedirectLogined = ['Login', 'Register', 'ResetPassword']

router.beforeEach((to, from, next) => {
startLoadingBar()
if (to.name === 'Login') {
if (store.getters.get_token) {
next({ name: 'Dashboard' })
}
next()
return
}
if (to.name === 'Register') {
if (store.getters.get_token) {
next({ name: 'Dashboard' })
}
next()
return
}
if (to.name === 'ResetPassword') {
if (store.getters.get_token) {
next({ name: 'Dashboard' })
}
next()
if (_autoRedirectLogined.includes(to.name)) {
const hasToken = store.getters.get_token != ''
logger.info(`Has token: ${hasToken}${hasToken ? ` ${store.getters.get_token}` : ''}`)
if (hasToken) next({ name: 'Dashboard' })
else next()
return
}
if (to.name === 'MainPage') {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function clipboardError(msg) {
}

export default function handleClipboard(text, event, msg) {
logger.info('Writing clipboard: ' + text)
logger.info(`Writing clipboard [${event.target}]: ${text}`)
const clipboard = new Clipboard(event.target, {
text: () => text
})
Expand Down
2 changes: 1 addition & 1 deletion src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const model = ref([
// 检查是否存在redirect值
const redirect = getUrlKey('redirect')
if (redirect !== null) {
logger.info('登录后返回' + redirect)
logger.info('Redirect after login: ' + redirect)
}
// 检查是否存在第三方登录返回值
Expand Down
3 changes: 2 additions & 1 deletion src/views/RealName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ async function realPersonPay() {
try {
rs = await api.v2.realperson.pay(
store.getters.get_username,
'https://api-v2.locyanfrp.cn/api/v2/realperson/notify&redirect_url=https://dashboard.locyanfrp.cn/realname'
'https://api-v2.locyanfrp.cn/api/v2/realperson/notify',
'https://dashboard.locyanfrp.cn/realname'
)
} catch (e) {
sendErrorMessage('请求失败: ' + e)
Expand Down

0 comments on commit 9d86e82

Please sign in to comment.