first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
@@ -0,0 +1,296 @@
|
||||
<script>
|
||||
import "~/assets/styles/WechatConnection.DI5ko1xy.css";
|
||||
import { toDisplayString } from "vue";
|
||||
import { onMounted } from "vue";
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import { watch } from "vue";
|
||||
import { createBlock } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { withCtx } from "vue";
|
||||
import { createCommentVNode } from "vue";
|
||||
import { createElementBlock } from "vue";
|
||||
import { Fragment } from "vue";
|
||||
import { createElementVNode } from "vue";
|
||||
import { createTextVNode } from "vue";
|
||||
import { unref } from "vue";
|
||||
import { defineComponent } from "vue";
|
||||
import { createVNode } from "vue";
|
||||
import { openBlock } from "vue";
|
||||
import { useApi } from "~/lib/auth.js";
|
||||
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 tag from "primevue/tag";
|
||||
import skeleton from "primevue/skeleton";
|
||||
import toggleswitch from "primevue/toggleswitch";
|
||||
var w = {
|
||||
key: 0,
|
||||
class: `wechat-connection`,
|
||||
"aria-label": `微信公众号`,
|
||||
},
|
||||
T = {
|
||||
key: 1,
|
||||
class: `connection-list wechat-loading`,
|
||||
role: `status`,
|
||||
"aria-label": `正在读取微信关联信息`,
|
||||
},
|
||||
E = {
|
||||
class: `connection-list`,
|
||||
},
|
||||
D = {
|
||||
class: `connection-provider`,
|
||||
},
|
||||
O = {
|
||||
class: `connection-provider-main`,
|
||||
},
|
||||
k = {
|
||||
key: 0,
|
||||
class: `connection-provider`,
|
||||
},
|
||||
A = {
|
||||
key: 0,
|
||||
class: `account-management-note wechat-binding-help`,
|
||||
},
|
||||
j = Object.assign(
|
||||
_plugin_vue_export_helper_t(
|
||||
defineComponent({
|
||||
__name: `WechatConnection`,
|
||||
setup(p) {
|
||||
let y = useApi(),
|
||||
j = useSiteConfig_t(),
|
||||
M = ref(null),
|
||||
N = ref(``),
|
||||
P = ref(!1),
|
||||
F = ref(!1),
|
||||
I = !0,
|
||||
L = 0;
|
||||
async function R() {
|
||||
if (!j.scanLoginEnabled.value || !I) return;
|
||||
let e = ++L;
|
||||
((F.value = !0), (N.value = ``));
|
||||
try {
|
||||
let t = await y.get(`/mp_weixin_notice/client`);
|
||||
if (!I || e !== L) return;
|
||||
if (
|
||||
![0, 1].includes(Number(t.is_subscribe)) ||
|
||||
![0, 1].includes(Number(t.accept_push))
|
||||
)
|
||||
throw Error(`微信关联状态无效,请重试`);
|
||||
M.value = {
|
||||
is_subscribe: Number(t.is_subscribe),
|
||||
accept_push: Number(t.accept_push),
|
||||
};
|
||||
} catch (t) {
|
||||
I &&
|
||||
e === L &&
|
||||
(N.value =
|
||||
t instanceof Error ? t.message : `微信关联信息加载失败`);
|
||||
} finally {
|
||||
I && e === L && (F.value = !1);
|
||||
}
|
||||
}
|
||||
async function z() {
|
||||
if (!(!I || P.value || F.value || M.value?.is_subscribe !== 1)) {
|
||||
((P.value = !0), (N.value = ``));
|
||||
try {
|
||||
(await y.put(`/mp_weixin_notice/accept_push`, {
|
||||
status: M.value.accept_push === 1 ? 0 : 1,
|
||||
}),
|
||||
I && (await R()));
|
||||
} catch (e) {
|
||||
I &&
|
||||
(N.value =
|
||||
e instanceof Error ? e.message : `推送设置保存失败`);
|
||||
} finally {
|
||||
I && (P.value = !1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
watch(j.scanLoginEnabled, () => {
|
||||
j.scanLoginEnabled.value ? R() : (L++, (M.value = null));
|
||||
}),
|
||||
onMounted(async () => {
|
||||
(await j.load(), await R());
|
||||
}),
|
||||
onBeforeUnmount(() => {
|
||||
((I = !1), L++);
|
||||
}),
|
||||
(t, n) => {
|
||||
let r = button,
|
||||
a = message,
|
||||
p = skeleton,
|
||||
g = tag,
|
||||
_ = toggleswitch;
|
||||
return unref(j).scanLoginEnabled.value
|
||||
? (openBlock(),
|
||||
createElementBlock(`section`, w, [
|
||||
(n[2] ||= createElementVNode(
|
||||
`h3`,
|
||||
{
|
||||
class: `connection-section-title`,
|
||||
},
|
||||
`微信公众号`,
|
||||
-1,
|
||||
)),
|
||||
unref(N)
|
||||
? (openBlock(),
|
||||
createBlock(
|
||||
a,
|
||||
{
|
||||
key: 0,
|
||||
severity: `error`,
|
||||
closable: !1,
|
||||
},
|
||||
{
|
||||
default: withCtx(() => [
|
||||
createTextVNode(
|
||||
toDisplayString(unref(N)) + ` `,
|
||||
1,
|
||||
),
|
||||
createVNode(
|
||||
r,
|
||||
{
|
||||
label: `重试`,
|
||||
size: `small`,
|
||||
text: ``,
|
||||
severity: `secondary`,
|
||||
disabled: unref(P),
|
||||
onClick: R,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`disabled`],
|
||||
),
|
||||
]),
|
||||
_: 1,
|
||||
},
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
unref(F)
|
||||
? (openBlock(),
|
||||
createElementBlock(`div`, T, [
|
||||
createVNode(p, {
|
||||
width: `40%`,
|
||||
height: `20px`,
|
||||
}),
|
||||
createVNode(p, {
|
||||
width: `65%`,
|
||||
height: `16px`,
|
||||
}),
|
||||
]))
|
||||
: unref(M)
|
||||
? (openBlock(),
|
||||
createElementBlock(
|
||||
Fragment,
|
||||
{
|
||||
key: 2,
|
||||
},
|
||||
[
|
||||
createElementVNode(`div`, E, [
|
||||
createElementVNode(`div`, D, [
|
||||
createElementVNode(`div`, O, [
|
||||
(n[0] ||= createElementVNode(
|
||||
`strong`,
|
||||
null,
|
||||
`关联状态`,
|
||||
-1,
|
||||
)),
|
||||
createElementVNode(
|
||||
`p`,
|
||||
null,
|
||||
toDisplayString(
|
||||
unref(M).is_subscribe === 1
|
||||
? `已关注并关联`
|
||||
: `尚未关注或关联`,
|
||||
),
|
||||
1,
|
||||
),
|
||||
]),
|
||||
createVNode(
|
||||
g,
|
||||
{
|
||||
value:
|
||||
unref(M).is_subscribe === 1
|
||||
? `已关联`
|
||||
: `未关联`,
|
||||
severity:
|
||||
unref(M).is_subscribe === 1
|
||||
? `success`
|
||||
: `secondary`,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`value`, `severity`],
|
||||
),
|
||||
]),
|
||||
unref(M).is_subscribe === 1
|
||||
? (openBlock(),
|
||||
createElementBlock(`div`, k, [
|
||||
(n[1] ||= createElementVNode(
|
||||
`div`,
|
||||
{
|
||||
class: `connection-provider-main`,
|
||||
},
|
||||
[
|
||||
createElementVNode(`strong`, null, [
|
||||
createElementVNode(
|
||||
`label`,
|
||||
{
|
||||
for: `wechat-notifications`,
|
||||
},
|
||||
`接收微信通知`,
|
||||
),
|
||||
]),
|
||||
createElementVNode(
|
||||
`p`,
|
||||
null,
|
||||
`通过公众号接收账户和服务通知`,
|
||||
),
|
||||
],
|
||||
-1,
|
||||
)),
|
||||
createVNode(
|
||||
_,
|
||||
{
|
||||
"input-id": `wechat-notifications`,
|
||||
"model-value":
|
||||
unref(M).accept_push === 1,
|
||||
disabled: unref(P) || unref(F),
|
||||
"onUpdate:modelValue": z,
|
||||
},
|
||||
null,
|
||||
8,
|
||||
[`model-value`, `disabled`],
|
||||
),
|
||||
]))
|
||||
: createCommentVNode(``, !0),
|
||||
]),
|
||||
unref(M).is_subscribe === 1
|
||||
? createCommentVNode(``, !0)
|
||||
: (openBlock(),
|
||||
createElementBlock(
|
||||
`p`,
|
||||
A,
|
||||
`使用微信扫码登录,并验证已注册的手机号或邮箱完成关联。`,
|
||||
)),
|
||||
],
|
||||
64,
|
||||
))
|
||||
: createCommentVNode(``, !0),
|
||||
]))
|
||||
: createCommentVNode(``, !0);
|
||||
}
|
||||
);
|
||||
},
|
||||
}),
|
||||
[[`__scopeId`, `data-v-4c933481`]],
|
||||
),
|
||||
{
|
||||
__name: `WechatConnection`,
|
||||
},
|
||||
);
|
||||
export {};
|
||||
export default j;
|
||||
</script>
|
||||
Reference in new issue
Block a user