You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dianshang-qianduan/src/App.vue

76 lines
2.7 KiB
Vue

<!--
* @Author: qinzhenpen qzp1807@126.com
* @Date: 2024-08-28 14:21:24
* @LastEditors: qinzhenpen qzp1807@126.com
* @LastEditTime: 2024-08-29 08:57:36
* @FilePath: \digital-marketing\src\App.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<router-view />
</template>
<script setup>
import useSettingsStore from "@/store/modules/settings";
import { handleThemeStyle } from "@/utils/theme";
import cache from "@/plugins/cache";
import { removeUserInfo, removeToken } from "@/utils/auth.js";
const stepNameSelector = ".step-tab .step-copy > strong, .step-tab .step-copy > b, .step-tab .step-copy > .step-name";
const stepActionSelector = [
".student-training-shell .step-actions > button",
".student-training-shell .step-navigation > button",
".student-training-shell .footer-actions > button",
".student-training-shell .training-actions > button",
".student-training-shell .task-actions > button",
".student-training-shell .taskfooter > button",
].join(",");
let stepNameObserver;
let stepTitleRefreshQueued = false;
function addStepNameTitles() {
document.querySelectorAll(stepNameSelector).forEach((element) => {
const label = String(element.textContent || "").replace(/\s+/g, " ").trim();
if (label && !element.getAttribute("title")) element.setAttribute("title", label);
});
}
function normalizeStepActionStyles() {
document.querySelectorAll(stepActionSelector).forEach((button) => {
const label = String(button.textContent || "").replace(/\s+/g, " ").trim();
const isPrevious = label.includes("上一步");
const isPrimary = label.includes("保存当前进度") || label.includes("下一步");
if (!isPrevious && !isPrimary) return;
button.classList.add("student-step-action");
button.classList.toggle("student-step-action--primary", isPrimary);
button.classList.toggle("student-step-action--secondary", isPrevious);
});
}
function queueStepNameTitleRefresh() {
if (stepTitleRefreshQueued) return;
stepTitleRefreshQueued = true;
requestAnimationFrame(() => {
addStepNameTitles();
normalizeStepActionStyles();
stepTitleRefreshQueued = false;
});
}
onMounted(() => {
nextTick(() => {
// 初始化主题样式
handleThemeStyle(useSettingsStore().theme);
});
if (cache.session.getJSON("sessionObj") === undefined) {
removeToken();
removeUserInfo();
}
queueStepNameTitleRefresh();
stepNameObserver = new MutationObserver(queueStepNameTitleRefresh);
stepNameObserver.observe(document.body, { childList: true, subtree: true });
});
onBeforeUnmount(() => stepNameObserver?.disconnect());
</script>