mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-16 14:12:51 +00:00
perf: 优化客户端子窗口
This commit is contained in:
parent
91533c5cac
commit
1e83c7442a
8
electron/electron.js
vendored
8
electron/electron.js
vendored
@ -310,6 +310,7 @@ function createChildWindow(args) {
|
|||||||
const name = args.name || "auto_" + utils.randomString(6);
|
const name = args.name || "auto_" + utils.randomString(6);
|
||||||
const wind = childWindow.find(item => item.name == name);
|
const wind = childWindow.find(item => item.name == name);
|
||||||
let browser = wind ? wind.browser : null;
|
let browser = wind ? wind.browser : null;
|
||||||
|
let isPreload = false;
|
||||||
if (browser) {
|
if (browser) {
|
||||||
browser.focus();
|
browser.focus();
|
||||||
if (args.force === false) {
|
if (args.force === false) {
|
||||||
@ -340,6 +341,7 @@ function createChildWindow(args) {
|
|||||||
// 使用预加载窗口
|
// 使用预加载窗口
|
||||||
browser = preloadWindow;
|
browser = preloadWindow;
|
||||||
preloadWindow = null;
|
preloadWindow = null;
|
||||||
|
isPreload = true;
|
||||||
setTimeout(() => onShowWindow(browser), 300)
|
setTimeout(() => onShowWindow(browser), 300)
|
||||||
browser.once('resize', () => setTimeout(() => onShowWindow(browser), 10))
|
browser.once('resize', () => setTimeout(() => onShowWindow(browser), 10))
|
||||||
browser.setSize(options.width, options.height);
|
browser.setSize(options.width, options.height);
|
||||||
@ -419,6 +421,10 @@ function createChildWindow(args) {
|
|||||||
const hash = args.hash || args.path;
|
const hash = args.hash || args.path;
|
||||||
if (/^https?:/i.test(hash)) {
|
if (/^https?:/i.test(hash)) {
|
||||||
browser.loadURL(hash).then(_ => { }).catch(_ => { })
|
browser.loadURL(hash).then(_ => { }).catch(_ => { })
|
||||||
|
} else if (isPreload) {
|
||||||
|
browser.webContents.executeJavaScript(`if(typeof $A.goForward === 'function'){$A.goForward('${hash}')}else{throw new Error('no function')}`, true).catch(() => {
|
||||||
|
utils.loadUrlOrFile(browser, devloadUrl, hash)
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
utils.loadUrlOrFile(browser, devloadUrl, hash)
|
utils.loadUrlOrFile(browser, devloadUrl, hash)
|
||||||
}
|
}
|
||||||
@ -1221,7 +1227,7 @@ ipcMain.on('bindScreenshotKey', (event, args) => {
|
|||||||
screenshotKey = key
|
screenshotKey = key
|
||||||
globalShortcut.register(key, () => {
|
globalShortcut.register(key, () => {
|
||||||
screenshotObj.startCapture().then(_ => {
|
screenshotObj.startCapture().then(_ => {
|
||||||
screenshotObj.view.webContents.executeJavaScript('if(typeof window.__initializeShortcuts===\'undefined\'){window.__initializeShortcuts=true;document.addEventListener(\'keydown\',function(e){console.log(e);if(e.keyCode===27){window.screenshots.cancel()}})}', true).catch(() => {});
|
screenshotObj.view.webContents.executeJavaScript(`if(typeof window.__initializeShortcuts==='undefined'){window.__initializeShortcuts=true;document.addEventListener('keydown',function(e){console.log(e);if(e.keyCode===27){window.screenshots.cancel()}})}`, true).catch(() => {});
|
||||||
screenshotObj.view.webContents.focus()
|
screenshotObj.view.webContents.focus()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
4
electron/utils.js
vendored
4
electron/utils.js
vendored
@ -301,11 +301,11 @@ const utils = {
|
|||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const contents = app.webContents
|
const contents = app.webContents
|
||||||
if (contents != null) {
|
if (contents != null) {
|
||||||
contents.executeJavaScript('if(typeof window.__onBeforeUnload === \'function\'){window.__onBeforeUnload()}', true).then(options => {
|
contents.executeJavaScript(`if(typeof window.__onBeforeUnload === 'function'){window.__onBeforeUnload()}`, true).then(options => {
|
||||||
if (utils.isJson(options)) {
|
if (utils.isJson(options)) {
|
||||||
let choice = dialog.showMessageBoxSync(app, options)
|
let choice = dialog.showMessageBoxSync(app, options)
|
||||||
if (choice === 1) {
|
if (choice === 1) {
|
||||||
contents.executeJavaScript('if(typeof window.__removeBeforeUnload === \'function\'){window.__removeBeforeUnload()}', true).catch(() => {});
|
contents.executeJavaScript(`if(typeof window.__removeBeforeUnload === 'function'){window.__removeBeforeUnload()}`, true).catch(() => {});
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
} else if (options !== true) {
|
} else if (options !== true) {
|
||||||
|
|||||||
0
public/js/recorder/frequency.histogram.view.js
vendored
Normal file → Executable file
0
public/js/recorder/frequency.histogram.view.js
vendored
Normal file → Executable file
0
public/js/recorder/lib.fft.js
vendored
Normal file → Executable file
0
public/js/recorder/lib.fft.js
vendored
Normal file → Executable file
2
public/js/recorder/recorder.mp3.min.js
vendored
Normal file → Executable file
2
public/js/recorder/recorder.mp3.min.js
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
39
resources/assets/js/app.js
vendored
39
resources/assets/js/app.js
vendored
@ -127,25 +127,44 @@ if (!isSoftware) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 加载路由
|
// 加载路由
|
||||||
Vue.prototype.goForward = function(location, isReplace) {
|
Vue.prototype.goForward = function(route, isReplace) {
|
||||||
if (typeof location === 'string') {
|
// 处理路由格式
|
||||||
location = {name: location};
|
if (typeof route === 'string') {
|
||||||
|
if ($A.strExists(route, '/')) {
|
||||||
|
if (/^https?:\/\//.test(route)) {
|
||||||
|
if ($A.getDomain(route) === $A.getDomain($A.mainUrl())) {
|
||||||
|
route = route.replace(/^https?:\/\/[^\/]+/, '');
|
||||||
|
} else {
|
||||||
|
// 处理外部链接
|
||||||
|
if (isReplace) {
|
||||||
|
window.location.replace(route);
|
||||||
|
} else {
|
||||||
|
window.location.href = route;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
route = { path: route };
|
||||||
|
} else {
|
||||||
|
route = { name: route };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// 初始化路由历史
|
||||||
if (app.$store.state.routeHistorys.length === 0) {
|
if (app.$store.state.routeHistorys.length === 0) {
|
||||||
app.$store.state.routeHistorys.push(app.$route)
|
app.$store.state.routeHistorys.push(app.$route)
|
||||||
}
|
}
|
||||||
if (isReplace === true) {
|
// 执行路由跳转
|
||||||
app.$router.replace(location).then(to => {
|
const routerMethod = isReplace ? 'replace' : 'push';
|
||||||
|
app.$router[routerMethod](route).then(to => {
|
||||||
|
if (isReplace) {
|
||||||
app.$store.state.routeHistorys.pop();
|
app.$store.state.routeHistorys.pop();
|
||||||
app.$store.state.routeHistorys.push(to);
|
app.$store.state.routeHistorys.push(to);
|
||||||
}).catch(_ => {});
|
} else {
|
||||||
} else {
|
|
||||||
app.$router.push(location).then(to => {
|
|
||||||
const length = app.$store.state.routeHistorys.push(to)
|
const length = app.$store.state.routeHistorys.push(to)
|
||||||
length > 120 && app.$store.state.routeHistorys.splice(length - 100)
|
length > 120 && app.$store.state.routeHistorys.splice(length - 100)
|
||||||
app.$store.state.routeHistoryLast = length >= 2 ? app.$store.state.routeHistorys[length - 2] : {};
|
app.$store.state.routeHistoryLast = length >= 2 ? app.$store.state.routeHistorys[length - 2] : {};
|
||||||
}).catch(_ => {});
|
}
|
||||||
}
|
}).catch(err => console.warn('路由跳转失败:', err));
|
||||||
};
|
};
|
||||||
|
|
||||||
// 返回路由
|
// 返回路由
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user