forked from XPoet/picx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: you can log in with GitHub OAuth authorization (XPoet#60)
- Loading branch information
Showing
37 changed files
with
870 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# use pwa | ||
VITE_USE_PWA = false | ||
|
||
# PicX GitHub APP Client ID | ||
VITE_CLIENT_ID = Iv1.274fe6f96551b91f | ||
|
||
# PicX GitHub APP Redirect URI | ||
VITE_REDIRECT_URI = http://localhost:4000 | ||
|
||
# PicX GitHub APP Authorize URI | ||
VITE_AUTHORIZE_URI = https://github.com/login/oauth/authorize | ||
|
||
# PicX GitHub APP Installations URL | ||
VITE_INSTALL_URL = https://github.com/apps/picx-app/installations/select_target | ||
|
||
# PicX GitHub APP Installations Target User URL | ||
VITE_INSTALL_URL_USER = https://github.com/apps/picx-app/installations/new/permissions?target_id= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# use pwa | ||
VITE_USE_PWA = true | ||
|
||
# PicX GitHub APP Client ID | ||
VITE_CLIENT_ID = Iv1.274fe6f96551b91f | ||
|
||
# PicX GitHub APP Redirect URI | ||
VITE_REDIRECT_URI = https://picx.xpoet.cn | ||
|
||
# PicX GitHub APP Authorize URI | ||
VITE_AUTHORIZE_URI = https://github.com/login/oauth/authorize | ||
|
||
# PicX GitHub APP Installations URL | ||
VITE_INSTALL_URL = https://github.com/apps/picx-app/installations/select_target | ||
|
||
# PicX GitHub APP Installations Target User URL | ||
VITE_INSTALL_URL_USER = https://github.com/apps/picx-app/installations/new/permissions?target_id= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
export declare type Recordable<T = any> = Record<string, T> | ||
|
||
export declare interface ViteEnv { | ||
VITE_USE_PWA?: boolean | ||
VITE_USE_PWA?: boolean // 是否启用 PWA | ||
VITE_CLIENT_ID?: string // PicX GitHub APP Client ID | ||
VITE_REDIRECT_URI?: string // PicX GitHub APP Callback URL | ||
VITE_AUTHORIZE_URI?: string // GitHub Authorize URI | ||
VITE_INSTALL_URL?: string | ||
VITE_INSTALL_URL_USER?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/components/authorization-status-bar/authorization-status-bar.styl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.authorization-status-box { | ||
display flex | ||
align-items center | ||
justify-content space-between | ||
padding 2rem 0 2rem 12rem | ||
color var(--text-color-2) | ||
font-size 14rem | ||
border-color var(--text-color-4) | ||
border-style solid | ||
border-width 1rem | ||
border-radius 6rem | ||
|
||
|
||
&.success { | ||
color var(--el-color-success) | ||
background var(--el-color-success-light-9) | ||
border-color var(--el-color-success) | ||
} | ||
|
||
&.warning { | ||
color var(--el-color-warning) | ||
background var(--el-color-warning-light-9) | ||
border-color var(--el-color-warning) | ||
} | ||
|
||
&.error { | ||
color var(--el-color-danger) | ||
background var(--el-color-danger-light-9) | ||
border-color var(--el-color-danger) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/components/authorization-status-bar/authorization-status-bar.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<div | ||
class="authorization-status-box border-box" | ||
:class="{ | ||
error: isAutoAuthorize && token && isAuthorizeExpire(), | ||
warning: isAutoAuthorize && token && !installed, | ||
success: isAutoAuthorize && token && !isAuthorizeExpire() | ||
}" | ||
> | ||
<div> | ||
<span v-if="isAutoAuthorize"> | ||
<span v-if="isAuthorizeExpire()"> | ||
{{ $t('authorization.text_4') }} | ||
</span> | ||
<span v-else>{{ $t('authorization.text_3') }}</span> | ||
</span> | ||
<span v-else>{{ $t('authorization.text_5') }}</span> | ||
</div> | ||
|
||
<el-tooltip placement="top" :content="$t('authorization.text_6')"> | ||
<el-button type="primary" text :icon="icon.IEpSwitch" @click="onOK">{{ | ||
$t('authorization.text_7') | ||
}}</el-button> | ||
</el-tooltip> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { onMounted, shallowRef, computed } from 'vue' | ||
import router from '@/router' | ||
import { store } from '@/stores' | ||
import { isAuthorizeExpire } from '@/views/picx-login/picx-login.util' | ||
const icon = shallowRef({ IEpCheck, IEpClose, IEpSwitch }) | ||
const { token, isAutoAuthorize, installed } = computed( | ||
() => store.getters.getGitHubAuthorizationInfo | ||
).value | ||
const onOK = () => { | ||
router.push({ path: '/login', query: { jump: '0' } }) | ||
} | ||
onMounted(() => {}) | ||
</script> | ||
|
||
<style scoped lang="stylus"> | ||
@import "authorization-status-bar.styl" | ||
</style> |
Oops, something went wrong.