修改copy代码在http协议下不生效

main
JayChou 5 days ago
parent 0399812594
commit be92f66f9c
  1. 29
      src/views/compiler/index.vue
  2. 2
      src/views/largeDataScreen/home.vue

@ -29,11 +29,11 @@ const useSettingStore = settingStore();
const isShowStrring = Boolean(localStorage.getItem("falg")) || false;
const saveCode = () => {
if(!validateJavaCode(answer, code.value.innerText)){
ElMessage({
if (!validateJavaCode(answer, code.value.innerText)) {
return ElMessage({
message: "代码编写错误",
type: "warning",
})
});
}
useSettingStore.setValue(true, "isRunCode");
localStorage.setItem("isRunCode", "true");
@ -72,9 +72,26 @@ public String convert() throws IOException {
}
`;
const copyCode = () => {
navigator.clipboard.writeText(answer).then(() => {
ElMessage.success("复制成功");
});
const textarea = document.createElement("textarea");
textarea.value = answer;
textarea.style.position = "fixed"; //
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
try {
const success = document.execCommand("copy");
if (success) {
ElMessage.success("复制成功");
} else {
ElMessage.error("复制失败");
}
} catch (err) {
ElMessage.error("复制失败");
console.error("复制异常", err);
}
document.body.removeChild(textarea);
};
</script>

@ -836,7 +836,7 @@ const isShowStrring = Boolean(localStorage.getItem("falg")) || false;
// labView
const goToLabView = async () => {
console.log(isShowStrring);
console.log(isShowStrring,localStorage.getItem("falg"));
if (isShowStrring) {
await setStepEvent(1, formatDate(new Date()));

Loading…
Cancel
Save