Compare commits
No commits in common. "1f9788498ac0aab3f7075121e0e7b0f19fc00d3c" and "776be8eaac63c9caf60e654a1062cf117cab2141" have entirely different histories.
1f9788498a
...
776be8eaac
|
@ -5,7 +5,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, onMounted, defineEmits } from 'vue';
|
||||
import { ref, watch, defineProps, onMounted, defineEmits } from 'vue';
|
||||
const placeholder = ref('')
|
||||
|
||||
const props = defineProps({
|
||||
|
|
|
@ -19,7 +19,7 @@ export function shareStorePlugin({store}) {
|
|||
// 同步数据-发送给主线程
|
||||
function stateSync(store) {
|
||||
const storeName = store.$id
|
||||
const jsonStr = circularSafeStringify(store.$state)
|
||||
const jsonStr = JSON.stringify(store.$state)
|
||||
console.log('state-change', jsonStr, storeName)
|
||||
// 通知主线程更新
|
||||
ipcRenderer?.invoke('pinia-state-change', storeName, jsonStr)
|
||||
|
@ -30,7 +30,7 @@ function stateChange(store) {
|
|||
ipcRenderer?.on('pinia-state-set', (e, sName, jsonStr) => {
|
||||
if (sName == storeName) { // 更新对应数据
|
||||
// console.log('state-set', jsonStr, sName)
|
||||
const curJson = circularSafeStringify(store.$state) // 当前数据
|
||||
const curJson = JSON.stringify(store.$state) // 当前数据
|
||||
const isUp = curJson != jsonStr // 不同的时候才写入,不然会导致触发数据变化监听,导致死循环
|
||||
if (!isUp) return
|
||||
const stateJson = JSON.parse(jsonStr) // 新数据
|
||||
|
@ -41,18 +41,3 @@ function stateChange(store) {
|
|||
}
|
||||
})
|
||||
}
|
||||
//解决JSON.stringify嵌套循环产生的bug
|
||||
const circularSafeStringify = (obj) => {
|
||||
const cache = new Set();
|
||||
return JSON.stringify(obj, (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (cache.has(value)) {
|
||||
// 当前对象已经存在于缓存中,说明存在循环引用,返回占位符或其他处理方式
|
||||
return "[Circular Reference]";
|
||||
}
|
||||
cache.add(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
|
||||
<script setup>
|
||||
import {listClassmain, listClassuser, addClassgroup, listClassgroup, delClassgroup,getClassgroup,updateClassgroup} from '@/api/classManage/index'
|
||||
import {ref, onMounted, reactive, watch} from 'vue'
|
||||
import {ref, onMounted, reactive, defineProps, watch} from 'vue'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
import { getClassmain,listClassuser,leaveClass} from '@/api/classManage/index'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import {reactive,onMounted,nextTick,watch} from 'vue'
|
||||
import {reactive,onMounted,defineProps,nextTick,watch} from 'vue'
|
||||
import delClassDemo from '@/store/modules/delClass'
|
||||
const props = defineProps({
|
||||
classId: {
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
|
||||
<script setup>
|
||||
import {addStudentmain, listClassuser,updateStudentmain,getClassmain,getStudentmain,leaveClass,removeStudentDataAll,addStudentmainByNameArray} from '@/api/classManage/index'
|
||||
import {ref, onMounted, reactive, nextTick, watch} from 'vue'
|
||||
import {ref, onMounted, reactive, nextTick, defineProps, watch} from 'vue'
|
||||
import {ElMessage,ElMessageBox} from "element-plus";
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import * as XLSX from 'xlsx'
|
||||
|
|
Loading…
Reference in New Issue