mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 优化客户端
This commit is contained in:
parent
07254c9f27
commit
94af3822d8
25
electron/electron.js
vendored
25
electron/electron.js
vendored
@ -578,8 +578,6 @@ function createWebTabWindow(args) {
|
|||||||
|
|
||||||
// 创建父级窗口
|
// 创建父级窗口
|
||||||
if (!webTabWindow) {
|
if (!webTabWindow) {
|
||||||
let config = Object.assign(args.config || {}, userConf.get('webTabWindow', {}));
|
|
||||||
let webPreferences = args.webPreferences || {};
|
|
||||||
const titleBarOverlay = {
|
const titleBarOverlay = {
|
||||||
height: webTabHeight
|
height: webTabHeight
|
||||||
}
|
}
|
||||||
@ -600,14 +598,14 @@ function createWebTabWindow(args) {
|
|||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
titleBarOverlay,
|
titleBarOverlay,
|
||||||
backgroundColor: nativeTheme.shouldUseDarkColors ? '#3B3B3D' : '#EFF0F4',
|
backgroundColor: nativeTheme.shouldUseDarkColors ? '#3B3B3D' : '#EFF0F4',
|
||||||
webPreferences: Object.assign({
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
webSecurity: true,
|
webSecurity: true,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
nativeWindowOpen: true
|
nativeWindowOpen: true
|
||||||
}, webPreferences),
|
},
|
||||||
}, config))
|
}, userConf.get('webTabWindow', {})))
|
||||||
|
|
||||||
webTabWindow.on('resize', () => {
|
webTabWindow.on('resize', () => {
|
||||||
resizeWebTab(0)
|
resizeWebTab(0)
|
||||||
@ -672,15 +670,20 @@ function createWebTabWindow(args) {
|
|||||||
webTabWindow.show();
|
webTabWindow.show();
|
||||||
|
|
||||||
// 创建 tab 子窗口
|
// 创建 tab 子窗口
|
||||||
const browserView = new BrowserView({
|
const viewOptions = Object.assign({
|
||||||
useHTMLTitleAndIcon: true,
|
useHTMLTitleAndIcon: true,
|
||||||
useLoadingView: true,
|
useLoadingView: true,
|
||||||
useErrorView: true,
|
useErrorView: true,
|
||||||
webPreferences: {
|
}, args.config || {})
|
||||||
preload: path.join(__dirname, 'electron-preload.js'),
|
viewOptions.webPreferences = Object.assign({
|
||||||
}
|
preload: path.join(__dirname, 'electron-preload.js'),
|
||||||
})
|
nodeIntegration: true,
|
||||||
if (nativeTheme.shouldUseDarkColors) {
|
contextIsolation: true
|
||||||
|
}, args.webPreferences || {})
|
||||||
|
const browserView = new BrowserView(viewOptions)
|
||||||
|
if (args.backgroundColor) {
|
||||||
|
browserView.setBackgroundColor(args.backgroundColor)
|
||||||
|
} else if (nativeTheme.shouldUseDarkColors) {
|
||||||
browserView.setBackgroundColor('#575757')
|
browserView.setBackgroundColor('#575757')
|
||||||
} else {
|
} else {
|
||||||
browserView.setBackgroundColor('#FFFFFF')
|
browserView.setBackgroundColor('#FFFFFF')
|
||||||
|
|||||||
@ -180,6 +180,23 @@ export default {
|
|||||||
return type;
|
return type;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getUserData() {
|
||||||
|
if (!this.userInfo.userid && this.userId && this.userToken) {
|
||||||
|
this.$store.dispatch("showSpinner", 300).then(_ => {})
|
||||||
|
try {
|
||||||
|
await this.$store.dispatch("getUserInfo");
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e);
|
||||||
|
} finally {
|
||||||
|
this.$store.dispatch("hiddenSpinner").then(_ => {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"id": String(this.userInfo.userid),
|
||||||
|
"name": this.userInfo.nickname
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
loadFile(keyAppend = '') {
|
loadFile(keyAppend = '') {
|
||||||
if (this.docEditor !== null) {
|
if (this.docEditor !== null) {
|
||||||
this.docEditor.destroyEditor();
|
this.docEditor.destroyEditor();
|
||||||
@ -199,35 +216,32 @@ export default {
|
|||||||
if (this.historyId > 0) {
|
if (this.historyId > 0) {
|
||||||
fileKey += `-${this.historyId}`
|
fileKey += `-${this.historyId}`
|
||||||
}
|
}
|
||||||
const config = {
|
|
||||||
"document": {
|
|
||||||
"fileType": this.fileType,
|
|
||||||
"title": fileName,
|
|
||||||
"key": fileKey,
|
|
||||||
"url": `http://nginx/api/${this.fileUrl}`,
|
|
||||||
},
|
|
||||||
"editorConfig": {
|
|
||||||
"mode": "edit",
|
|
||||||
"lang": lang,
|
|
||||||
"user": {
|
|
||||||
"id": String(this.userInfo.userid),
|
|
||||||
"name": this.userInfo.nickname
|
|
||||||
},
|
|
||||||
"customization": {
|
|
||||||
"uiTheme": this.themeName === 'dark' ? "theme-dark" : "theme-classic-light",
|
|
||||||
"forcesave": true,
|
|
||||||
"help": false,
|
|
||||||
},
|
|
||||||
"callbackUrl": `http://nginx/api/file/content/office?id=${codeId}&dootask-token=${this.userToken}`,
|
|
||||||
},
|
|
||||||
"events": {
|
|
||||||
"onDocumentReady": this.onDocumentReady,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
|
|
||||||
config.document.title = " ";
|
|
||||||
}
|
|
||||||
(async _ => {
|
(async _ => {
|
||||||
|
const config = {
|
||||||
|
"document": {
|
||||||
|
"fileType": this.fileType,
|
||||||
|
"title": fileName,
|
||||||
|
"key": fileKey,
|
||||||
|
"url": `http://nginx/api/${this.fileUrl}`,
|
||||||
|
},
|
||||||
|
"editorConfig": {
|
||||||
|
"mode": "edit",
|
||||||
|
"lang": lang,
|
||||||
|
"user": await this.getUserData(),
|
||||||
|
"customization": {
|
||||||
|
"uiTheme": this.themeName === 'dark' ? "theme-dark" : "theme-classic-light",
|
||||||
|
"forcesave": true,
|
||||||
|
"help": false,
|
||||||
|
},
|
||||||
|
"callbackUrl": `http://nginx/api/file/content/office?id=${codeId}&dootask-token=${this.userToken}`,
|
||||||
|
},
|
||||||
|
"events": {
|
||||||
|
"onDocumentReady": this.onDocumentReady,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
if (/\/hideenOfficeTitle\//.test(window.navigator.userAgent)) {
|
||||||
|
config.document.title = " ";
|
||||||
|
}
|
||||||
if (this.readOnly || this.historyId > 0) {
|
if (this.readOnly || this.historyId > 0) {
|
||||||
config.editorConfig.mode = "view";
|
config.editorConfig.mode = "view";
|
||||||
config.editorConfig.callbackUrl = null;
|
config.editorConfig.callbackUrl = null;
|
||||||
|
|||||||
11
resources/assets/js/store/actions.js
vendored
11
resources/assets/js/store/actions.js
vendored
@ -1107,8 +1107,8 @@ export default {
|
|||||||
* @param params
|
* @param params
|
||||||
*/
|
*/
|
||||||
async openChildWindow({dispatch}, params) {
|
async openChildWindow({dispatch}, params) {
|
||||||
const path = await dispatch("userUrl", params.path)
|
params.path = await dispatch("userUrl", params.path)
|
||||||
$A.Electron.sendMessage('openChildWindow', Object.assign(params, {path}))
|
$A.Electron.sendMessage('openChildWindow', params)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1117,10 +1117,13 @@ export default {
|
|||||||
* @param url
|
* @param url
|
||||||
*/
|
*/
|
||||||
async openWebTabWindow({dispatch}, url) {
|
async openWebTabWindow({dispatch}, url) {
|
||||||
|
const params = {url}
|
||||||
if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) {
|
if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) {
|
||||||
url = await dispatch("userUrl", url)
|
params.url = await dispatch("userUrl", url)
|
||||||
|
} else {
|
||||||
|
params.webPreferences = {contextIsolation: false}
|
||||||
}
|
}
|
||||||
$A.Electron.sendMessage('openWebTabWindow', {url})
|
$A.Electron.sendMessage('openWebTabWindow', params)
|
||||||
},
|
},
|
||||||
|
|
||||||
/** *****************************************************************************************/
|
/** *****************************************************************************************/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user