修改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 isShowStrring = Boolean(localStorage.getItem("falg")) || false;
const saveCode = () => { const saveCode = () => {
if(!validateJavaCode(answer, code.value.innerText)){ if (!validateJavaCode(answer, code.value.innerText)) {
ElMessage({ return ElMessage({
message: "代码编写错误", message: "代码编写错误",
type: "warning", type: "warning",
}) });
} }
useSettingStore.setValue(true, "isRunCode"); useSettingStore.setValue(true, "isRunCode");
localStorage.setItem("isRunCode", "true"); localStorage.setItem("isRunCode", "true");
@ -72,9 +72,26 @@ public String convert() throws IOException {
} }
`; `;
const copyCode = () => { const copyCode = () => {
navigator.clipboard.writeText(answer).then(() => { const textarea = document.createElement("textarea");
ElMessage.success("复制成功"); 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> </script>

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

Loading…
Cancel
Save