feat: 初始化项目结构并添加基础配置
添加前后端基础项目结构,包括.gitignore、package.json等配置文件 实现前端基础功能模块,包括路由、状态管理、API请求封装等 添加前端UI组件库和样式体系 配置开发环境Mock系统和构建工具链
This commit is contained in:
39
front-end/src/utils/social.ts
Normal file
39
front-end/src/utils/social.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import qs from 'qs'
|
||||
import router from '@/router'
|
||||
|
||||
let _win: any
|
||||
let _winTime: any
|
||||
|
||||
export function login(url: any, options: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
_win = window.open(`${url}?${qs.stringify(options)}`)
|
||||
// 以小框的形式打开第三方登录页
|
||||
// _win = window.open(
|
||||
// `${url}?${qs.stringify(options)}`,
|
||||
// '_blank',
|
||||
// 'location=yes,height=600,width=500,scrollbars=yes,status=yes'
|
||||
// )
|
||||
_winTime = setInterval(() => {
|
||||
if (_win && _win.closed) {
|
||||
clearInterval(_winTime)
|
||||
const data = JSON.parse(
|
||||
localStorage.getItem('socialData') || '{}'
|
||||
)
|
||||
localStorage.removeItem('socialData')
|
||||
// 触发变更通知
|
||||
if (data) {
|
||||
resolve(data)
|
||||
} else {
|
||||
reject(data)
|
||||
}
|
||||
}
|
||||
}, 200)
|
||||
})
|
||||
}
|
||||
|
||||
export function callback() {
|
||||
let data: any = router.currentRoute.value.query
|
||||
if (JSON.stringify(data) === '{}')
|
||||
data = qs.parse(document.location.search.slice(1))
|
||||
localStorage.setItem('socialData', JSON.stringify(data))
|
||||
}
|
||||
Reference in New Issue
Block a user