48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import { ref } from "vue";
|
|
import { computed } from "vue";
|
|
import { useState } from "#app";
|
|
import { useApi } from "~/lib/auth.js";
|
|
var i = null;
|
|
function a() {
|
|
let a = useState(`site-config`, () => null),
|
|
o = ref(``);
|
|
async function s() {
|
|
if (((o.value = ``), a.value)) return a.value;
|
|
i ||= useApi()
|
|
.get(`/common`, void 0, !1, {
|
|
timeoutMs: 1e4,
|
|
})
|
|
.then((e) => ((a.value = e), e))
|
|
.catch((e) => {
|
|
throw ((i = null), e);
|
|
});
|
|
try {
|
|
return await i;
|
|
} catch (e) {
|
|
return (
|
|
(o.value = e instanceof Error ? e.message : `加载站点配置失败`),
|
|
null
|
|
);
|
|
}
|
|
}
|
|
let c = (e) => e === 1 || e === `1` || e === !0;
|
|
return {
|
|
config: a,
|
|
error: o,
|
|
load: s,
|
|
on: c,
|
|
maintenance: computed(() => c(a.value?.maintenance_mode)),
|
|
rechargeClosed: computed(
|
|
() => a.value != null && !c(a.value.recharge_open),
|
|
),
|
|
lockedFields: computed(
|
|
() => a.value?.prohibit_user_information_changes ?? [],
|
|
),
|
|
siteName: computed(() => a.value?.website_name || `破碎工坊云`),
|
|
scanLoginEnabled: computed(() =>
|
|
c(a.value?.plugin_configuration?.mp_weixin_notice?.scan_login),
|
|
),
|
|
};
|
|
}
|
|
export { a as t };
|