165 lines
6.1 KiB
Vue
165 lines
6.1 KiB
Vue
<script>
|
|
/** 根据站点 oauth 配置显示第三方登录入口;启动跳转及错误处理复用 useOAuth。 */
|
|
import "~/assets/styles/GenericOAuthProviders.Bv8oNwXP.css";
|
|
import { toDisplayString } from "vue";
|
|
import { renderList } from "vue";
|
|
import { onMounted } from "vue";
|
|
import { createBlock } from "vue";
|
|
import { ref } from "vue";
|
|
import { withCtx } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { computed } from "vue";
|
|
import { createElementBlock } from "vue";
|
|
import { Fragment } from "vue";
|
|
import { createTextVNode } from "vue";
|
|
import { unref } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { openBlock } from "vue";
|
|
import { NuxtLink } from "#components";
|
|
import { t as useSiteConfig_t } from "~/lib/useSiteConfig.js";
|
|
import button from "primevue/button";
|
|
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
|
import message from "primevue/message";
|
|
import { t as oauth_t } from "~/lib/oauth.js";
|
|
import { t as useOAuth_t } from "~/lib/useOAuth.js";
|
|
var x = {
|
|
key: 0,
|
|
class: `oauth-providers`,
|
|
},
|
|
S = {
|
|
key: 0,
|
|
class: `oauth-buttons`,
|
|
},
|
|
C = [`src`],
|
|
w = Object.assign(
|
|
_plugin_vue_export_helper_t(
|
|
defineComponent({
|
|
__name: `GenericOAuthProviders`,
|
|
setup(f) {
|
|
let _ = useSiteConfig_t(),
|
|
w = computed(() => oauth_t(_.config.value?.oauth)),
|
|
{ busy: T, error: E, start: D } = useOAuth_t(),
|
|
O = ref(!1);
|
|
return (
|
|
onMounted(() => {
|
|
_.load();
|
|
try {
|
|
// 只读取浏览器会话中的待完成提示,不将该标志当作登录身份或授权凭证。
|
|
O.value =
|
|
sessionStorage.getItem(`console-oauth-pending`) === `1`;
|
|
} catch {}
|
|
}),
|
|
(n, i) => {
|
|
let s = button,
|
|
f = message,
|
|
h = NuxtLink;
|
|
return unref(w).length || unref(O)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, x, [
|
|
unref(w).length
|
|
? (openBlock(),
|
|
createElementBlock(`div`, S, [
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
unref(w),
|
|
(t) => (
|
|
openBlock(),
|
|
createBlock(
|
|
s,
|
|
{
|
|
key: t.name,
|
|
severity: `secondary`,
|
|
outlined: ``,
|
|
disabled: unref(T),
|
|
onClick: (e) => unref(D)(t.name),
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
t.image
|
|
? (openBlock(),
|
|
createElementBlock(
|
|
`img`,
|
|
{
|
|
key: 0,
|
|
src: t.image,
|
|
alt: ``,
|
|
referrerpolicy: `no-referrer`,
|
|
},
|
|
null,
|
|
8,
|
|
C,
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
createTextVNode(
|
|
toDisplayString(t.title) + `登录`,
|
|
1,
|
|
),
|
|
]),
|
|
_: 2,
|
|
},
|
|
1032,
|
|
[`disabled`, `onClick`],
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
]))
|
|
: createCommentVNode(``, !0),
|
|
unref(E)
|
|
? (openBlock(),
|
|
createBlock(
|
|
f,
|
|
{
|
|
key: 1,
|
|
severity: `error`,
|
|
closable: !1,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createTextVNode(toDisplayString(unref(E)), 1),
|
|
]),
|
|
_: 1,
|
|
},
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
unref(O)
|
|
? (openBlock(),
|
|
createBlock(
|
|
h,
|
|
{
|
|
key: 2,
|
|
to: `/oauth/callback`,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
...(i[0] ||= [
|
|
createTextVNode(
|
|
`已完成第三方授权?继续登录`,
|
|
-1,
|
|
),
|
|
]),
|
|
]),
|
|
_: 1,
|
|
},
|
|
))
|
|
: createCommentVNode(``, !0),
|
|
]))
|
|
: createCommentVNode(``, !0);
|
|
}
|
|
);
|
|
},
|
|
}),
|
|
[[`__scopeId`, `data-v-45e5a5aa`]],
|
|
),
|
|
{
|
|
__name: `GenericOAuthProviders`,
|
|
},
|
|
);
|
|
export {};
|
|
export default w;
|
|
</script>
|