Skip to content

Commit

Permalink
JS格式化按钮 加入判断
Browse files Browse the repository at this point in the history
  • Loading branch information
Keywos committed Mar 19, 2024
1 parent c7a15f3 commit 6681cb0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 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.195",
"version": "2.14.196",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
2 changes: 1 addition & 1 deletion 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="false" id="filePreview"/>
<cmView :isReadOnly="false" id="filePreview" />
<!-- <div class="compare-page-body">
<div class="block-wrapper">
<div class="input-wrapper">
Expand Down
10 changes: 7 additions & 3 deletions src/views/editCode/cmView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<button @click="hiCode"><img :src="jsimg" /></button>
<button @click="undoCode"><img :src="undoimg" /></button>
<button @click="redoCode"><img :src="redoimg" /></button>
<button @click="formatCode"><img :src="format" /></button>
<button v-if="isJS" @click="formatCode"><img :src="format" /></button>
<button @click="searchs"><img :src="searchimg" /></button>
<button @click="copyText"><img :src="copyimg" /></button>
<button @click="delAllCode"><img :src="del" /></button>
Expand Down Expand Up @@ -82,6 +82,7 @@ import { useCodeStore } from "@/store/codeStore";
import { storeToRefs } from "pinia";
import beautify from "js-beautify";
import { useAppNotifyStore } from "@/store/appNotify";
import { faL } from "@fortawesome/free-solid-svg-icons";
const { toClipboard } = useV3Clipboard();
const { showNotify } = useAppNotifyStore();
Expand All @@ -94,7 +95,7 @@ const Length = ref("");
const props = defineProps(["isReadOnly", "id"]);
console.log("cm-id: ", props.id);
const cmStore = useCodeStore();
const isJS = ref(false);
const viewRef = ref(null);
const editorTheme = new Compartment();
const langs = new Compartment();
Expand Down Expand Up @@ -183,6 +184,7 @@ function formatLength(length) {
}
const getjsjson = (res) => {
Length.value = formatLength(res?.length);
// if (props.isJS) return false;
try {
const jsRegex =
/(?:function|var|let|const|if|else|return|try|catch|finally|typeof|delete|async|await)\b/;
Expand Down Expand Up @@ -283,11 +285,13 @@ const searchs = () => {
};
const setHJ = () => {
isJS.value = true;
view.dispatch({
effects: langs.reconfigure(javascript()),
});
};
const noHJ = () => {
isJS.value = false;
view.dispatch({
effects: langs.reconfigure([]),
});
Expand Down Expand Up @@ -394,7 +398,7 @@ const pasteNav = async () => {
width: 33px;
transition: transform 0.2s;
}
.cimg-button {
.cimg-button {
// width: 33px;
height: 16px;
font-size: 12px;
Expand Down

0 comments on commit 6681cb0

Please sign in to comment.