@fmdevui/fm-dev
Version:
Page level components developed based on Element Plus.
425 lines (420 loc) • 16.5 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var pinia = require('pinia');
var vueRouter = require('vue-router');
var vueI18n = require('vue-i18n');
require('../../stores/index.js');
var smCryptoV2 = require('sm-crypto-v2');
var sysInfo = require('../../utils/comm/sysInfo.js');
require('../../utils/index.js');
require('../../api/index.js');
var themeConfig = require('../../stores/themeConfig.js');
var userInfo = require('../../stores/userInfo.js');
var formatTime = require('../../utils/comm/formatTime.js');
var index = require('../../utils/storage/index.js');
var index$1 = require('../../api/sys/index.js');
const _hoisted_1 = { class: "layout-lock-screen" };
const _hoisted_2 = { class: "layout-lock-screen-date-box" };
const _hoisted_3 = { class: "layout-lock-screen-date-box-time" };
const _hoisted_4 = { class: "layout-lock-screen-date-box-minutes" };
const _hoisted_5 = { class: "layout-lock-screen-date-box-info" };
const _hoisted_6 = { class: "layout-lock-screen-date-top" };
const _hoisted_7 = { class: "layout-lock-screen-date-top-text" };
const _hoisted_8 = { class: "layout-lock-screen-login" };
const _hoisted_9 = { class: "layout-lock-screen-login-box" };
const _hoisted_10 = { class: "layout-lock-screen-login-box-img" };
const _hoisted_11 = ["src"];
const _hoisted_12 = { class: "layout-lock-screen-login-box-name" };
const _hoisted_13 = {
key: 0,
class: "layout-lock-screen-login-box-message"
};
const _hoisted_14 = {
key: 1,
class: "layout-lock-screen-login-box-value"
};
const _hoisted_15 = { class: "layout-lock-screen-login-icon" };
var _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "index",
setup(__props) {
const { t } = vueI18n.useI18n();
const needPassword = vue.ref("");
needPassword.value = t("message.layout.needPassword");
const layoutLockScreenDateRef = vue.ref();
const layoutLockScreenInputRef = vue.ref();
const storesThemeConfig = themeConfig.useThemeConfig();
const { themeConfig: themeConfig$1 } = pinia.storeToRefs(storesThemeConfig);
const storesUserInfo = userInfo.useUserInfo();
const { userInfos } = pinia.storeToRefs(storesUserInfo);
const state = vue.reactive({
transparency: 1,
downClientY: 0,
moveDifference: 0,
isShowLoockLogin: false,
isFlags: false,
querySelectorEl: "",
time: {
hm: "",
s: "",
mdq: ""
},
setIntervalTime: 0,
isShowLockScreen: false,
isShowLockScreenIntervalTime: 0,
lockScreenPassword: "",
message: "",
showMessage: false,
isShowPassword: false
});
const route = vueRouter.useRoute();
const onDownPc = (down) => {
state.isFlags = true;
state.downClientY = down.clientY;
};
const onDownApp = (down) => {
state.isFlags = true;
state.downClientY = down.touches[0].clientY;
};
const onMovePc = (move) => {
state.moveDifference = move.clientY - state.downClientY;
onMove();
};
const onMoveApp = (move) => {
state.moveDifference = move.touches[0].clientY - state.downClientY;
onMove();
};
const onMove = () => {
if (state.isFlags) {
const el = state.querySelectorEl;
const opacitys = state.transparency -= 1 / 200;
if (state.moveDifference >= 0) return false;
el.setAttribute("style", `top:${state.moveDifference}px;cursor:pointer;opacity:${opacitys};`);
if (state.moveDifference < -400) {
el.setAttribute("style", `top:${-el.clientHeight}px;cursor:pointer;transition:all 0.3s ease;`);
state.moveDifference = -el.clientHeight;
setTimeout(() => {
el && el.parentNode?.removeChild(el);
}, 300);
}
if (state.moveDifference === -el.clientHeight) {
state.isShowLoockLogin = true;
layoutLockScreenInputRef.value.focus();
}
}
};
const onEnd = () => {
state.isFlags = false;
state.transparency = 1;
if (state.moveDifference >= -400) {
state.querySelectorEl.setAttribute("style", `top:0px;opacity:1;transition:all 0.3s ease;`);
}
};
const initGetElement = () => {
vue.nextTick(() => {
state.querySelectorEl = layoutLockScreenDateRef.value;
});
};
const initTime = () => {
state.time.hm = formatTime.formatDate(/* @__PURE__ */ new Date(), "HH:MM");
state.time.s = formatTime.formatDate(/* @__PURE__ */ new Date(), "SS");
state.time.mdq = formatTime.formatDate(/* @__PURE__ */ new Date(), "mm-dd\uFF0CWWW");
};
const initSetTime = () => {
initTime();
state.setIntervalTime = window.setInterval(() => {
initTime();
}, 1e3);
};
const initLockScreen = () => {
if (themeConfig$1.value.isLockScreen) {
state.isShowLockScreenIntervalTime = window.setInterval(() => {
if (themeConfig$1.value.lockScreenTime == null) {
themeConfig$1.value.lockScreenTime = 300;
setLocalThemeConfig();
return false;
}
if (themeConfig$1.value.lockScreenTime <= 1) {
state.isShowLockScreen = true;
setLocalThemeConfig();
return false;
}
themeConfig$1.value.lockScreenTime--;
}, 1e3);
} else {
clearInterval(state.isShowLockScreenIntervalTime);
}
};
const setLocalThemeConfig = () => {
themeConfig$1.value.isDrawer = false;
index.Local.set("themeConfig", themeConfig$1.value);
};
const onLockScreenSubmit = async () => {
if (state.lockScreenPassword) {
try {
if (userInfos.value.account === void 0) {
themeConfig$1.value.isLockScreen = false;
themeConfig$1.value.lockScreenTime = 300;
setLocalThemeConfig();
return;
}
var publicKey = window.__env__.VITE_SM_PUBLIC_KEY;
if (publicKey == "") {
var res1 = await index$1.useSysApi().getSmPublicKey();
publicKey = window.__env__.VITE_SM_PUBLIC_KEY = res1.data.result ?? "";
}
const password = smCryptoV2.sm2.doEncrypt(state.lockScreenPassword, publicKey, 1);
const [err, res] = await index$1.feature(index$1.useSysApi().unLockScreen(password));
if (err) {
state.message = err.message;
state.showMessage = true;
state.lockScreenPassword = "";
return;
}
if (res.data.result) {
themeConfig$1.value.isLockScreen = false;
themeConfig$1.value.lockScreenTime = 300;
setLocalThemeConfig();
}
} catch (ex) {
state.message = `\u51FA\u9519\u4E86:${ex}`;
state.showMessage = true;
}
}
};
const hideMessage = () => {
state.showMessage = false;
vue.nextTick(() => {
layoutLockScreenInputRef.value.focus();
});
};
vue.onMounted(async () => {
initGetElement();
initSetTime();
initLockScreen();
var tenantid = Number(route.query.tid);
if (isNaN(tenantid)) {
tenantid = 0;
} else if (tenantid > 99999) {
index.Local.set("tid", tenantid);
}
await sysInfo.loadSysInfo(tenantid);
document.onkeydown = (e) => {
if (e.key === "Enter") {
if (state.isShowLoockLogin == false) {
const moveInterval = setInterval(() => {
state.isFlags = true;
state.moveDifference = state.moveDifference - 10;
onMove();
if (state.moveDifference < -410 && moveInterval) clearInterval(moveInterval);
}, 5);
}
if (state.showMessage == true) hideMessage();
}
};
});
vue.onUnmounted(() => {
window.clearInterval(state.setIntervalTime);
window.clearInterval(state.isShowLockScreenIntervalTime);
});
return (_ctx, _cache) => {
const _component_SvgIcon = vue.resolveComponent("SvgIcon");
const _component_el_button = vue.resolveComponent("el-button");
const _component_ele_Right = vue.resolveComponent("ele-Right");
const _component_el_icon = vue.resolveComponent("el-icon");
const _component_el_input = vue.resolveComponent("el-input");
return vue.withDirectives((vue.openBlock(), vue.createElementBlock(
"div",
null,
[
_cache[3] || (_cache[3] = vue.createElementVNode(
"div",
{ class: "layout-lock-screen-mask" },
null,
-1
/* CACHED */
)),
vue.createElementVNode(
"div",
{
class: vue.normalizeClass(["layout-lock-screen-img", { "layout-lock-screen-filter": state.isShowLoockLogin }])
},
null,
2
/* CLASS */
),
vue.createElementVNode("div", _hoisted_1, [
vue.createElementVNode(
"div",
{
class: "layout-lock-screen-date",
ref_key: "layoutLockScreenDateRef",
ref: layoutLockScreenDateRef,
onMousedown: onDownPc,
onMousemove: onMovePc,
onMouseup: onEnd,
onTouchstart: vue.withModifiers(onDownApp, ["stop"]),
onTouchmove: vue.withModifiers(onMoveApp, ["stop"]),
onTouchend: vue.withModifiers(onEnd, ["stop"])
},
[
vue.createElementVNode("div", _hoisted_2, [
vue.createElementVNode("div", _hoisted_3, [
vue.createTextVNode(
vue.toDisplayString(state.time.hm),
1
/* TEXT */
),
vue.createElementVNode(
"span",
_hoisted_4,
vue.toDisplayString(state.time.s),
1
/* TEXT */
)
]),
vue.createElementVNode(
"div",
_hoisted_5,
vue.toDisplayString(state.time.mdq),
1
/* TEXT */
)
]),
vue.createElementVNode("div", _hoisted_6, [
vue.createVNode(_component_SvgIcon, { name: "ele-Top" }),
vue.createElementVNode(
"div",
_hoisted_7,
vue.toDisplayString(_ctx.$t("message.layout.unlock")),
1
/* TEXT */
)
])
],
544
/* NEED_HYDRATION, NEED_PATCH */
),
vue.createVNode(vue.Transition, {
name: "el-zoom-in-center",
persisted: ""
}, {
default: vue.withCtx(() => [
vue.withDirectives(vue.createElementVNode(
"div",
_hoisted_8,
[
vue.createElementVNode("div", _hoisted_9, [
vue.createElementVNode("div", _hoisted_10, [
vue.createElementVNode("img", {
src: vue.unref(userInfos).avatar || "https://img2.baidu.com/it/u=1978192862,2048448374&fm=253&fmt=auto&app=138&f=JPEG?w=504&h=500"
}, null, 8, _hoisted_11)
]),
vue.createElementVNode(
"div",
_hoisted_12,
vue.toDisplayString(vue.unref(userInfos).account),
1
/* TEXT */
),
state.showMessage ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [
vue.createElementVNode(
"span",
null,
vue.toDisplayString(state.message),
1
/* TEXT */
),
vue.createVNode(_component_el_button, {
style: { "max-width": "80px", "margin-top": "20px" },
size: "default",
onClick: hideMessage
}, {
default: vue.withCtx(() => [
vue.createTextVNode(
vue.toDisplayString(_ctx.$t("message.layout.confirm")),
1
/* TEXT */
)
]),
_: 1
/* STABLE */
})
])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_14, [
vue.createVNode(_component_el_input, {
placeholder: needPassword.value,
type: state.isShowPassword ? "text" : "password",
ref_key: "layoutLockScreenInputRef",
ref: layoutLockScreenInputRef,
size: "default",
modelValue: state.lockScreenPassword,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => state.lockScreenPassword = $event),
onKeyup: _cache[2] || (_cache[2] = vue.withKeys(vue.withModifiers(($event) => onLockScreenSubmit(), ["stop"]), ["enter", "native"]))
}, {
append: vue.withCtx(() => [
vue.createVNode(_component_el_button, { onClick: onLockScreenSubmit }, {
default: vue.withCtx(() => [
vue.createVNode(_component_el_icon, { class: "el-input__icon" }, {
default: vue.withCtx(() => [
vue.createVNode(_component_ele_Right)
]),
_: 1
/* STABLE */
})
]),
_: 1
/* STABLE */
})
]),
suffix: vue.withCtx(() => [
vue.createElementVNode(
"i",
{
class: vue.normalizeClass(["iconfont el-input__icon login-content-password", state.isShowPassword ? "icon-yincangmima" : "icon-xianshimima"]),
onClick: _cache[0] || (_cache[0] = ($event) => state.isShowPassword = !state.isShowPassword)
},
null,
2
/* CLASS */
)
]),
_: 1
/* STABLE */
}, 8, ["placeholder", "type", "modelValue"])
]))
]),
vue.createElementVNode("div", _hoisted_15, [
vue.createVNode(_component_SvgIcon, {
name: "ele-Microphone",
size: 20
}),
vue.createVNode(_component_SvgIcon, {
name: "ele-AlarmClock",
size: 20
}),
vue.createVNode(_component_SvgIcon, {
name: "ele-SwitchButton",
size: 20
})
])
],
512
/* NEED_PATCH */
), [
[vue.vShow, state.isShowLoockLogin]
])
]),
_: 1
/* STABLE */
})
])
],
512
/* NEED_PATCH */
)), [
[vue.vShow, state.isShowLockScreen]
]);
};
}
});
exports.default = _sfc_main;