Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Keywos committed Mar 18, 2024
1 parent 1878265 commit f5f61c6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.180",
"version": "2.14.181",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
8 changes: 4 additions & 4 deletions src/views/FileEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
type="text"
/> -->
<div style="margin-left: -10px; margin-right: -20px">
<cmView :isReadOnly="false" />
<cmView :isReadOnly="false" id="FileEditer"/>
</div>
</nut-form-item>
<!-- ua -->
Expand Down Expand Up @@ -255,7 +255,7 @@ provide("form", form);
const ignoreList = ["Quick Setting Operator"];
watch(
() => cmStore.CmCode,
() => cmStore.EditCode['FileEditer'],
(newCode) => {
form.content = newCode;
}
Expand All @@ -265,7 +265,7 @@ watchEffect(() => {
if (isInit.value) return;
if (configName === "UNTITLED") {
const fc = "// " + t(`filePage.content.placeholder`) + "\n"
cmStore.setCmCode(fc)
cmStore.setEditCode('FileEditer', fc)
// 标记 加载完成
isInit.value = true;
return;
Expand All @@ -284,7 +284,7 @@ watchEffect(() => {
form.ua = sourceData.ua;
form.mergeSources = sourceData.mergeSources;
form.content = sourceData.content;
cmStore.setCmCode(sourceData.content);
cmStore.setEditCode('FileEditer', sourceData.content);
form.ignoreFailedRemoteFile = sourceData.ignoreFailedRemoteFile;
const newProcess = JSON.parse(JSON.stringify(sourceData.process));
form.process = newProcess;
Expand Down
7 changes: 5 additions & 2 deletions src/views/FilePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<font-awesome-icon icon="fa-solid fa-circle-xmark" />
</button>
</header>
<cmView :isReadOnly="true" />
<cmView :isReadOnly="false" id="filePreview"/>
<!-- <div class="compare-page-body">
<div class="block-wrapper">
<div class="input-wrapper">
Expand Down Expand Up @@ -74,7 +74,10 @@ const displayName = computed(() => {
const originalData = previewData.original;
const processedData = previewData.processed;
cmStore.setCmCode(processedData)
// cmStore.setCmCode(processedData)
cmStore.setEditCode('filePreview',processedData)
const clickClose = () => {
emit("closePreview");
};
Expand Down
8 changes: 4 additions & 4 deletions src/views/SubEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
/> -->

<div style="margin-left: -10px; margin-right: -20px">
<cmView :isReadOnly="false"/>
<cmView :isReadOnly="false" id="SubEditer"/>
</div>
</nut-form-item>
<!-- ua -->
Expand Down Expand Up @@ -424,7 +424,7 @@ provide("form", form);
const ignoreList = ["Quick Setting Operator"];
watch(
() => cmStore.CmCode,
() => cmStore.EditCode['SubEditer'],
(newCode) => {
form.content = newCode;
}
Expand All @@ -443,7 +443,7 @@ watchEffect(() => {
form.url = "";
form.content = "";
form.ua = "";
cmStore.setCmCode("");
cmStore.setEditCode('SubEditer', "");
break;
}
// 标记 加载完成
Expand Down Expand Up @@ -474,7 +474,7 @@ watchEffect(() => {
form.source = sourceData.source;
form.url = sourceData.url;
form.content = sourceData.content;
cmStore.setCmCode(sourceData.content);
cmStore.setEditCode('SubEditer', sourceData.content);
form.ua = sourceData.ua;
break;
}
Expand Down
26 changes: 13 additions & 13 deletions src/views/editCode/cmView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ const { theme } = storeToRefs(settingsStore);
const isDarkModeEnabled = ref(true);
const Length = ref("");
const props = defineProps(["isReadOnly"]);
const props = defineProps(["isReadOnly", "id"]);
console.log(props.id);
const cmStore = useCodeStore();
const viewRef = ref(null);
Expand Down Expand Up @@ -116,7 +116,7 @@ const CreateView = () => {
const docContent = update.state.doc.toString();
docUpdate = true;
console.log("更新文档 - CodeValue");
cmStore.setCmCode(docContent);
cmStore.setEditCode([props.id], docContent);
Length.value = formatLength(docContent.length);
docUpdate = false;
}),
Expand All @@ -126,13 +126,13 @@ const CreateView = () => {
openText: "",
}),
],
doc: cmStore.CmCode,
doc: cmStore.EditCode[props.id],
}),
parent: viewRef.value,
});
watch(
() => cmStore.CmCode,
() => cmStore.EditCode[props.id],
(newValue) => {
if (!docUpdate && newValue !== view.state.doc.toString()) {
console.log("Code更新到文档");
Expand Down Expand Up @@ -171,13 +171,12 @@ function formatLength(length) {
}
}
const getjsjson = (res) => {
Length.value = formatLength(res.length);
Length.value = formatLength(res?.length);
try {
const jsRegex =
/(?:function|var|let|const|if|else|return|try|catch|finally|typeof|delete|async|await)\b/;
if (jsRegex.test(res.slice(0, 4000))) {
setHJ();
console.log("---setHJ");
return true;
} else {
Expand Down Expand Up @@ -227,7 +226,7 @@ watchEffect(() => {
onMounted(() => {
CreateView();
let lg = localStorage.getItem("highlightJS");
const x = getjsjson(cmStore.CmCode);
const x = getjsjson(cmStore.EditCode[props.id]);
if (!x) {
if (lg == 1 || lg == null) {
setHJ();
Expand Down Expand Up @@ -291,9 +290,10 @@ const redoCode = () => redo(view);
async function formatCode() {
try {
cmStore.setCmCode(
cmStore.setEditCode(
[props.id],
beautify
.js_beautify(cmStore.CmCode, {
.js_beautify(cmStore.EditCode[props.id], {
indent_size: 2,
})
.replace(/^\s*[\r\n]/gm, "\n")
Expand All @@ -304,7 +304,7 @@ async function formatCode() {
}
const copyText = async () => {
const x = await toClipboard(cmStore.CmCode);
const x = await toClipboard(cmStore.EditCode[props.id]);
if (x) {
showNotify({
type: "success",
Expand All @@ -314,7 +314,7 @@ const copyText = async () => {
};
const delAllCode = () => {
cmStore.setCmCode("");
cmStore.setEditCode([props.id], "");
showNotify({
type: "success",
title: "已清空",
Expand All @@ -325,7 +325,7 @@ const pasteNav = async () => {
try {
const clipboardText = await navigator.clipboard.readText();
if (clipboardText?.length > 0) {
cmStore.setCmCode(clipboardText);
cmStore.setEditCode([props.id], clipboardText);
showNotify({
type: "success",
title: "已粘贴字数: " + clipboardText.length,
Expand Down
2 changes: 1 addition & 1 deletion src/views/editCode/editScript.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<cmView :isReadOnly="false" />
<cmView :isReadOnly="false" :id="id" />
<div class="bottom-btn-wrapper">
<nut-button
@click="routerBack"
Expand Down
2 changes: 1 addition & 1 deletion src/views/editor/components/Script.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ watch(value, () => {
});
const pushEditCode = () => {
cmStore.setCmCode(value.code ? value.code : placeholders);
cmStore.setEditCode(id,value.code ? value.code : placeholders);
router.push(`/edit/Script/${id}`);
};
</script>
Expand Down

0 comments on commit f5f61c6

Please sign in to comment.