fix: 客户端偶尔出现无法打开文件的情况

This commit is contained in:
kuaifan 2022-02-09 21:04:03 +08:00
parent b28be29dc8
commit e89ff02b59
5 changed files with 34 additions and 12 deletions

2
electron/build.js vendored
View File

@ -33,7 +33,7 @@ function startBuild(data, publish) {
// index.html // index.html
let indexFile = path.resolve(electronDir, "index.html"); let indexFile = path.resolve(electronDir, "index.html");
let indexString = fs.readFileSync(indexFile, 'utf8'); let indexString = fs.readFileSync(indexFile, 'utf8');
indexString = indexString.replace(`<title></title>`, `<title>${data.name}</title>`); indexString = indexString.replace(/<title>(.*?)<\/title>/g, `<title>${data.name}</title>`);
fs.writeFileSync(indexFile, indexString, 'utf8'); fs.writeFileSync(indexFile, indexString, 'utf8');
// package.json Backup // package.json Backup
fse.copySync(packageFile, packageBakFile) fse.copySync(packageFile, packageBakFile)

View File

@ -601,7 +601,7 @@ export default {
const file = this.files.find(({id}) => id == row.id); const file = this.files.find(({id}) => id == row.id);
if (file) { if (file) {
setTimeout(() => { setTimeout(() => {
this.$set(file, '_edit', b); this.setEdit(file.id, b)
}, 100); }, 100);
} }
}, },
@ -849,7 +849,7 @@ export default {
case 'rename': case 'rename':
this.$set(item, 'newname', item.name); this.$set(item, 'newname', item.name);
this.$set(item, '_edit', true); this.setEdit(item.id, true)
this.autoBlur(item.id) this.autoBlur(item.id)
break; break;
@ -1032,18 +1032,18 @@ export default {
if (isCreate) { if (isCreate) {
this.$store.dispatch("forgetFile", item.id); this.$store.dispatch("forgetFile", item.id);
} else { } else {
this.$set(item, '_edit', false); this.setEdit(item.id, false)
} }
return; return;
} }
if (item.newname == item.name) { if (item.newname == item.name) {
this.$set(item, '_edit', false); this.setEdit(item.id, false)
return; return;
} }
if (item._load) { if (item._load) {
return; return;
} }
this.$set(item, '_load', true); this.setLoad(item.id, true)
this.$store.dispatch("call", { this.$store.dispatch("call", {
url: 'file/add', url: 'file/add',
data: { data: {
@ -1054,21 +1054,35 @@ export default {
}, },
}).then(({data, msg}) => { }).then(({data, msg}) => {
$A.messageSuccess(msg) $A.messageSuccess(msg)
this.$set(item, '_load', false); this.setLoad(item.id, false)
this.$set(item, '_edit', false); this.setEdit(item.id, false)
this.$store.dispatch("saveFile", data); this.$store.dispatch("saveFile", data);
if (isCreate) { if (isCreate) {
this.$store.dispatch("forgetFile", item.id); this.$store.dispatch("forgetFile", item.id);
} }
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg) $A.modalError(msg)
this.$set(item, '_load', false); this.setLoad(item.id, false)
if (isCreate) { if (isCreate) {
this.$store.dispatch("forgetFile", item.id); this.$store.dispatch("forgetFile", item.id);
} }
}) })
}, },
setEdit(fileId, is) {
let item = this.$store.state.files.find(({id}) => id == fileId)
if (item) {
this.$set(item, '_edit', is);
}
},
setLoad(fileId, is) {
let item = this.$store.state.files.find(({id}) => id == fileId)
if (item) {
this.$set(item, '_load', is);
}
},
onSearchFocus() { onSearchFocus() {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.searchInput.focus({ this.$refs.searchInput.focus({

View File

@ -427,11 +427,12 @@ export default {
dispatch("saveFile", file); dispatch("saveFile", file);
}); });
} else if ($A.isJson(data)) { } else if ($A.isJson(data)) {
let base = {_load: false, _edit: false};
let index = state.files.findIndex(({id}) => id == data.id); let index = state.files.findIndex(({id}) => id == data.id);
if (index > -1) { if (index > -1) {
state.files.splice(index, 1, Object.assign({}, state.files[index], data)); state.files.splice(index, 1, Object.assign(base, state.files[index], data));
} else { } else {
state.files.push(data) state.files.push(Object.assign(base, data))
} }
} }
}, },
@ -2100,8 +2101,9 @@ export default {
} }
let dialog = state.cacheDialogs.find(({id}) => id == data.dialog_id); let dialog = state.cacheDialogs.find(({id}) => id == data.dialog_id);
// 更新对话列表 // 更新对话列表
if (dialog) { if (dialog && state.cacheUnreads[data.id] === undefined) {
// 新增未读数 // 新增未读数
state.cacheUnreads[data.id] = true;
dialog.unread++; dialog.unread++;
} }
Store.set('dialogMsgPush', data); Store.set('dialogMsgPush', data);

View File

@ -19,6 +19,7 @@ const stateData = {
// Dialog // Dialog
cacheDialogs: $A.getStorageArray("cacheDialogs"), cacheDialogs: $A.getStorageArray("cacheDialogs"),
cacheUnreads: {},
// Project // Project
cacheProjects: $A.getStorageArray("cacheProjects"), cacheProjects: $A.getStorageArray("cacheProjects"),

View File

@ -35,6 +35,11 @@
align-items: center; align-items: center;
margin-top: 14px; margin-top: 14px;
overflow: auto; overflow: auto;
&::-webkit-scrollbar {
display: none;
}
> li { > li {
position: relative; position: relative;
list-style: none; list-style: none;