mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-11 18:42:54 +00:00
perf: 优化子窗口
This commit is contained in:
parent
c4430e1a6c
commit
c96bad3cdf
@ -406,23 +406,6 @@ class IndexController extends InvokeController
|
||||
abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存配置
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function storage__synch()
|
||||
{
|
||||
$key = Request::input('key');
|
||||
$value = Request::input('value');
|
||||
if ($key) {
|
||||
$value = [$key => $value];
|
||||
}
|
||||
if (!is_array($value)) {
|
||||
$value = Base::json2array($value);
|
||||
}
|
||||
return view('storage', ['value' => Base::array2json($value)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取所有中文
|
||||
* @return array|string
|
||||
|
||||
@ -15,9 +15,6 @@ class VerifyCsrfToken extends Middleware
|
||||
// 接口部分
|
||||
'api/*',
|
||||
|
||||
// 保存配置
|
||||
'storage/synch/',
|
||||
|
||||
// 发布桌面端
|
||||
'desktop/publish/',
|
||||
];
|
||||
|
||||
178
electron/electron.js
vendored
178
electron/electron.js
vendored
@ -26,8 +26,6 @@ let enablePlugins = false;
|
||||
|
||||
let mainWindow = null,
|
||||
mainTray = null,
|
||||
subWindow = [],
|
||||
storageBrowser = null,
|
||||
isReady = false,
|
||||
willQuitApp = false,
|
||||
devloadUrl = "",
|
||||
@ -36,7 +34,8 @@ let mainWindow = null,
|
||||
let screenshotObj = null,
|
||||
screenshotKey = null;
|
||||
|
||||
let webWindow = null,
|
||||
let childWindow = [],
|
||||
webTabWindow = null,
|
||||
webTabView = [],
|
||||
webTabHeight = 38;
|
||||
|
||||
@ -116,7 +115,7 @@ function createMainWindow() {
|
||||
* 创建子窗口
|
||||
* @param args {path, hash, title, titleFixed, force, userAgent, config, webPreferences}
|
||||
*/
|
||||
function createSubWindow(args) {
|
||||
function createChildWindow(args) {
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
@ -126,7 +125,7 @@ function createSubWindow(args) {
|
||||
}
|
||||
|
||||
let name = args.name || "auto_" + utils.randomString(6);
|
||||
let item = subWindow.find(item => item.name == name);
|
||||
let item = childWindow.find(item => item.name == name);
|
||||
let browser = item ? item.browser : null;
|
||||
if (browser) {
|
||||
browser.focus();
|
||||
@ -169,9 +168,9 @@ function createSubWindow(args) {
|
||||
})
|
||||
|
||||
browser.on('closed', () => {
|
||||
let index = subWindow.findIndex(item => item.name == name);
|
||||
let index = childWindow.findIndex(item => item.name == name);
|
||||
if (index > -1) {
|
||||
subWindow.splice(index, 1)
|
||||
childWindow.splice(index, 1)
|
||||
}
|
||||
})
|
||||
|
||||
@ -183,7 +182,7 @@ function createSubWindow(args) {
|
||||
onShowWindow(browser);
|
||||
})
|
||||
|
||||
subWindow.push({ name, browser })
|
||||
childWindow.push({ name, browser })
|
||||
}
|
||||
const originalUA = browser.webContents.session.getUserAgent() || browser.webContents.getUserAgent()
|
||||
browser.webContents.setUserAgent(originalUA + " SubTaskWindow/" + process.platform + "/" + os.arch() + "/1.0" + (args.userAgent ? (" " + args.userAgent) : ""));
|
||||
@ -219,7 +218,7 @@ function createSubWindow(args) {
|
||||
* @param browser
|
||||
* @param args
|
||||
*/
|
||||
function updateSubWindow(browser, args) {
|
||||
function updateChildWindow(browser, args) {
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
@ -239,7 +238,7 @@ function updateSubWindow(browser, args) {
|
||||
}
|
||||
}
|
||||
if (args.name) {
|
||||
const er = subWindow.find(item => item.browser == browser);
|
||||
const er = childWindow.find(item => item.browser == browser);
|
||||
if (er) {
|
||||
er.name = args.name;
|
||||
}
|
||||
@ -250,7 +249,7 @@ function updateSubWindow(browser, args) {
|
||||
* 创建内置浏览器
|
||||
* @param args {url, ?}
|
||||
*/
|
||||
function createWebWindow(args) {
|
||||
function createWebTabWindow(args) {
|
||||
if (!args) {
|
||||
return;
|
||||
}
|
||||
@ -264,8 +263,8 @@ function createWebWindow(args) {
|
||||
}
|
||||
|
||||
// 创建父级窗口
|
||||
if (!webWindow) {
|
||||
let config = Object.assign(args.config || {}, userConf.get('webWindow', {}));
|
||||
if (!webTabWindow) {
|
||||
let config = Object.assign(args.config || {}, userConf.get('webTabWindow', {}));
|
||||
let webPreferences = args.webPreferences || {};
|
||||
const titleBarOverlay = {
|
||||
height: webTabHeight
|
||||
@ -274,7 +273,7 @@ function createWebWindow(args) {
|
||||
titleBarOverlay.color = '#3B3B3D'
|
||||
titleBarOverlay.symbolColor = '#C5C5C5'
|
||||
}
|
||||
webWindow = new BrowserWindow(Object.assign({
|
||||
webTabWindow = new BrowserWindow(Object.assign({
|
||||
x: mainWindow.getBounds().x + webTabHeight,
|
||||
y: mainWindow.getBounds().y + webTabHeight,
|
||||
width: 1280,
|
||||
@ -295,55 +294,59 @@ function createWebWindow(args) {
|
||||
}, webPreferences),
|
||||
}, config))
|
||||
|
||||
webWindow.on('resize', () => {
|
||||
webTabWindow.on('resize', () => {
|
||||
resizeWebTab(0)
|
||||
})
|
||||
|
||||
webWindow.on('enter-full-screen', () => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
webTabWindow.on('enter-full-screen', () => {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'enter-full-screen',
|
||||
}).then(_ => { })
|
||||
})
|
||||
|
||||
webWindow.on('leave-full-screen', () => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
webTabWindow.on('leave-full-screen', () => {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'leave-full-screen',
|
||||
}).then(_ => { })
|
||||
})
|
||||
|
||||
webWindow.on('close', event => {
|
||||
webTabWindow.on('close', event => {
|
||||
if (!willQuitApp) {
|
||||
closeWebTab(0)
|
||||
event.preventDefault()
|
||||
} else {
|
||||
userConf.set('webWindow', webWindow.getBounds())
|
||||
userConf.set('webTabWindow', webTabWindow.getBounds())
|
||||
}
|
||||
})
|
||||
|
||||
webWindow.on('closed', () => {
|
||||
webWindow = null
|
||||
webTabWindow.on('closed', () => {
|
||||
webTabView.forEach(({view}) => {
|
||||
view.webContents.close()
|
||||
})
|
||||
webTabView = []
|
||||
webTabWindow = null
|
||||
})
|
||||
|
||||
webWindow.once('ready-to-show', () => {
|
||||
onShowWindow(webWindow);
|
||||
webTabWindow.once('ready-to-show', () => {
|
||||
onShowWindow(webTabWindow);
|
||||
})
|
||||
|
||||
webWindow.webContents.once('dom-ready', () => {
|
||||
onShowWindow(webWindow);
|
||||
webTabWindow.webContents.once('dom-ready', () => {
|
||||
onShowWindow(webTabWindow);
|
||||
})
|
||||
|
||||
webWindow.webContents.on('before-input-event', (event, input) => {
|
||||
webTabWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (utils.isMetaOrControl(input) && input.key.toLowerCase() === 'r') {
|
||||
reloadWebTab(0)
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
webWindow.loadFile('./render/tabs/index.html', {}).then(_ => {
|
||||
webTabWindow.loadFile('./render/tabs/index.html', {}).then(_ => {
|
||||
|
||||
})
|
||||
}
|
||||
webWindow.focus();
|
||||
webTabWindow.focus();
|
||||
|
||||
// 创建子窗口
|
||||
const browserView = new BrowserView({
|
||||
@ -364,18 +367,18 @@ function createWebWindow(args) {
|
||||
browserView.setBounds({
|
||||
x: 0,
|
||||
y: webTabHeight,
|
||||
width: webWindow.getContentBounds().width || 1280,
|
||||
height: (webWindow.getContentBounds().height || 800) - webTabHeight,
|
||||
width: webTabWindow.getContentBounds().width || 1280,
|
||||
height: (webTabWindow.getContentBounds().height || 800) - webTabHeight,
|
||||
})
|
||||
browserView.webContents.setWindowOpenHandler(({url}) => {
|
||||
if (allowedCalls.test(url)) {
|
||||
return {action: 'allow'}
|
||||
}
|
||||
createWebWindow({url})
|
||||
createWebTabWindow({url})
|
||||
return {action: 'deny'}
|
||||
})
|
||||
browserView.webContents.on('page-title-updated', (event, title) => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'title',
|
||||
id: browserView.webContents.id,
|
||||
title: title,
|
||||
@ -386,7 +389,7 @@ function createWebWindow(args) {
|
||||
if (!errorDescription) {
|
||||
return
|
||||
}
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'title',
|
||||
id: browserView.webContents.id,
|
||||
title: errorDescription,
|
||||
@ -394,20 +397,20 @@ function createWebWindow(args) {
|
||||
}).then(_ => { })
|
||||
})
|
||||
browserView.webContents.on('page-favicon-updated', (event, favicons) => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'favicon',
|
||||
id: browserView.webContents.id,
|
||||
favicons
|
||||
}).then(_ => { })
|
||||
})
|
||||
browserView.webContents.on('did-start-loading', _ => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'start-loading',
|
||||
id: browserView.webContents.id,
|
||||
}).then(_ => { })
|
||||
})
|
||||
browserView.webContents.on('did-stop-loading', _ => {
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'stop-loading',
|
||||
id: browserView.webContents.id,
|
||||
}).then(_ => { })
|
||||
@ -422,18 +425,18 @@ function createWebWindow(args) {
|
||||
})
|
||||
browserView.webContents.loadURL(args.url).then(_ => { }).catch(_ => { })
|
||||
|
||||
webWindow.addBrowserView(browserView)
|
||||
webTabWindow.addBrowserView(browserView)
|
||||
webTabView.push({
|
||||
id: browserView.webContents.id,
|
||||
view: browserView
|
||||
})
|
||||
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'create',
|
||||
id: browserView.webContents.id,
|
||||
url: args.url,
|
||||
}).then(_ => { })
|
||||
switchWebTab(browserView.webContents.id)
|
||||
activateWebTab(browserView.webContents.id)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,7 +444,7 @@ function createWebWindow(args) {
|
||||
* @returns {Electron.BrowserView|undefined}
|
||||
*/
|
||||
function currentWebTab() {
|
||||
const views = webWindow.getBrowserViews()
|
||||
const views = webTabWindow.getBrowserViews()
|
||||
const view = views.length ? views[views.length - 1] : undefined
|
||||
if (!view) {
|
||||
return undefined
|
||||
@ -473,8 +476,8 @@ function resizeWebTab(id) {
|
||||
item.view.setBounds({
|
||||
x: 0,
|
||||
y: webTabHeight,
|
||||
width: webWindow.getContentBounds().width || 1280,
|
||||
height: (webWindow.getContentBounds().height || 800) - webTabHeight,
|
||||
width: webTabWindow.getContentBounds().width || 1280,
|
||||
height: (webTabWindow.getContentBounds().height || 800) - webTabHeight,
|
||||
})
|
||||
}
|
||||
|
||||
@ -482,15 +485,15 @@ function resizeWebTab(id) {
|
||||
* 切换内置浏览器标签
|
||||
* @param id
|
||||
*/
|
||||
function switchWebTab(id) {
|
||||
function activateWebTab(id) {
|
||||
const item = id === 0 ? currentWebTab() : webTabView.find(item => item.id == id)
|
||||
if (!item) {
|
||||
return
|
||||
}
|
||||
resizeWebTab(item.id)
|
||||
webWindow.setTopBrowserView(item.view)
|
||||
webTabWindow.setTopBrowserView(item.view)
|
||||
item.view.webContents.focus()
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'switch',
|
||||
id: item.id,
|
||||
}).then(_ => { })
|
||||
@ -506,9 +509,9 @@ function closeWebTab(id) {
|
||||
return
|
||||
}
|
||||
if (webTabView.length === 1) {
|
||||
webWindow.hide()
|
||||
webTabWindow.hide()
|
||||
}
|
||||
webWindow.removeBrowserView(item.view)
|
||||
webTabWindow.removeBrowserView(item.view)
|
||||
item.view.webContents.close()
|
||||
|
||||
const index = webTabView.findIndex(({id}) => item.id == id)
|
||||
@ -516,16 +519,16 @@ function closeWebTab(id) {
|
||||
webTabView.splice(index, 1)
|
||||
}
|
||||
|
||||
utils.onDispatchEvent(webWindow.webContents, {
|
||||
utils.onDispatchEvent(webTabWindow.webContents, {
|
||||
event: 'close',
|
||||
id: item.id,
|
||||
}).then(_ => { })
|
||||
|
||||
if (webTabView.length === 0) {
|
||||
userConf.set('webWindow', webWindow.getBounds())
|
||||
webWindow.destroy()
|
||||
userConf.set('webTabWindow', webTabWindow.getBounds())
|
||||
webTabWindow.destroy()
|
||||
} else {
|
||||
switchWebTab(0)
|
||||
activateWebTab(0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,9 +615,6 @@ app.on('browser-window-focus', () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.send("browserWindowFocus", {})
|
||||
}
|
||||
if (storageBrowser) {
|
||||
storageBrowser.webContents.reload()
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
@ -649,8 +649,8 @@ ipcMain.on('windowQuit', (event) => {
|
||||
* 创建路由窗口
|
||||
* @param args {path, ?}
|
||||
*/
|
||||
ipcMain.on('windowRouter', (event, args) => {
|
||||
createSubWindow(args)
|
||||
ipcMain.on('openChildWindow', (event, args) => {
|
||||
createChildWindow(args)
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
@ -658,9 +658,9 @@ ipcMain.on('windowRouter', (event, args) => {
|
||||
* 更新路由窗口
|
||||
* @param args {?name, ?path} // name: 不是要更改的窗口名,是要把窗口名改成什么, path: 地址
|
||||
*/
|
||||
ipcMain.on('updateRouter', (event, args) => {
|
||||
ipcMain.on('updateChildWindow', (event, args) => {
|
||||
const browser = BrowserWindow.fromWebContents(event.sender);
|
||||
updateSubWindow(browser, args)
|
||||
updateChildWindow(browser, args)
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
@ -668,8 +668,8 @@ ipcMain.on('updateRouter', (event, args) => {
|
||||
* 内置浏览器 - 打开创建
|
||||
* @param args {url, ?}
|
||||
*/
|
||||
ipcMain.on('openWebWindow', (event, args) => {
|
||||
createWebWindow(args)
|
||||
ipcMain.on('openWebTabWindow', (event, args) => {
|
||||
createWebTabWindow(args)
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
@ -677,8 +677,8 @@ ipcMain.on('openWebWindow', (event, args) => {
|
||||
* 内置浏览器 - 激活标签
|
||||
* @param id
|
||||
*/
|
||||
ipcMain.on('webTabSwitch', (event, id) => {
|
||||
switchWebTab(id)
|
||||
ipcMain.on('webTabActivate', (event, id) => {
|
||||
activateWebTab(id)
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
@ -694,7 +694,7 @@ ipcMain.on('webTabClose', (event, id) => {
|
||||
/**
|
||||
* 内置浏览器 - 在外部浏览器打开
|
||||
*/
|
||||
ipcMain.on('webTabBrowser', (event) => {
|
||||
ipcMain.on('webTabExternal', (event) => {
|
||||
const item = currentWebTab()
|
||||
if (!item) {
|
||||
return
|
||||
@ -715,6 +715,16 @@ ipcMain.on('webTabOpenDevTools', (event) => {
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 内置浏览器 - 销毁所有标签及窗口
|
||||
*/
|
||||
ipcMain.on('webTabDestroyAll', (event) => {
|
||||
if (webTabWindow) {
|
||||
webTabWindow.destroy()
|
||||
}
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 隐藏窗口(mac、win隐藏,其他关闭)
|
||||
*/
|
||||
@ -748,8 +758,8 @@ ipcMain.on('windowDestroy', (event) => {
|
||||
/**
|
||||
* 关闭所有子窗口
|
||||
*/
|
||||
ipcMain.on('subWindowCloseAll', (event) => {
|
||||
subWindow.some(({browser}) => {
|
||||
ipcMain.on('childWindowCloseAll', (event) => {
|
||||
childWindow.some(({browser}) => {
|
||||
browser && browser.close()
|
||||
})
|
||||
event.returnValue = "ok"
|
||||
@ -758,8 +768,8 @@ ipcMain.on('subWindowCloseAll', (event) => {
|
||||
/**
|
||||
* 销毁所有子窗口
|
||||
*/
|
||||
ipcMain.on('subWindowDestroyAll', (event) => {
|
||||
subWindow.some(({browser}) => {
|
||||
ipcMain.on('childWindowDestroyAll', (event) => {
|
||||
childWindow.some(({browser}) => {
|
||||
browser && browser.destroy()
|
||||
})
|
||||
event.returnValue = "ok"
|
||||
@ -852,34 +862,6 @@ ipcMain.on('windowMax', (event) => {
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 创建子窗口存储浏览器
|
||||
* @param args {url}
|
||||
*/
|
||||
ipcMain.on('storageBrowser', (event, args) => {
|
||||
if (utils.isJson(args) && allowedUrls.test(args.url)) {
|
||||
if (storageBrowser === null) {
|
||||
storageBrowser = new BrowserWindow({
|
||||
show: false,
|
||||
frame: false,
|
||||
transparent: true,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'electron-preload.js'),
|
||||
webSecurity: true,
|
||||
nodeIntegration: true,
|
||||
contextIsolation: true,
|
||||
nativeWindowOpen: true
|
||||
},
|
||||
})
|
||||
storageBrowser.on('closed', () => {
|
||||
storageBrowser = null
|
||||
})
|
||||
}
|
||||
storageBrowser.loadURL(args.url).then(_ => { }).catch(_ => { })
|
||||
}
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 给主窗口发送信息
|
||||
* @param args {channel, data}
|
||||
@ -1087,7 +1069,7 @@ ipcMain.on('mainWindowActive', (event) => {
|
||||
ipcMain.on('updateQuitAndInstall', (event) => {
|
||||
event.returnValue = "ok"
|
||||
willQuitApp = true
|
||||
subWindow.some(({browser}) => {
|
||||
childWindow.some(({browser}) => {
|
||||
browser && browser.destroy()
|
||||
})
|
||||
setTimeout(_ => {
|
||||
|
||||
@ -120,7 +120,7 @@
|
||||
},
|
||||
methods: {
|
||||
onSwitch(item) {
|
||||
this.sendMessage('webTabSwitch', item.id)
|
||||
this.sendMessage('webTabActivate', item.id)
|
||||
},
|
||||
|
||||
onClose(item) {
|
||||
@ -128,7 +128,7 @@
|
||||
},
|
||||
|
||||
onBrowser() {
|
||||
this.sendMessage('webTabBrowser')
|
||||
this.sendMessage('webTabExternal')
|
||||
},
|
||||
|
||||
iconStyle(item) {
|
||||
|
||||
@ -41,7 +41,6 @@ import NetworkException from "./components/NetworkException";
|
||||
import GuidePage from "./components/GuidePage";
|
||||
import TaskOperation from "./pages/manage/components/TaskOperation";
|
||||
import {mapState} from "vuex";
|
||||
import {languageName} from "./language";
|
||||
|
||||
export default {
|
||||
components: {TaskOperation, NetworkException, PreviewImageState, RightBottom, FloatSpinner, GuidePage},
|
||||
@ -132,13 +131,6 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
//
|
||||
window.localStorage.setItem("__system:userId__", this.userId)
|
||||
window.localStorage.setItem("__system:userToken__", this.userToken)
|
||||
$A.storageByBrowser({
|
||||
userId: this.userId,
|
||||
userToken: this.userToken,
|
||||
})
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
@ -273,7 +265,7 @@ export default {
|
||||
}
|
||||
} catch (e) { }
|
||||
}
|
||||
this.$Electron.sendMessage('openWebWindow', {url});
|
||||
this.$store.dispatch("openWebTabWindow", url)
|
||||
return true;
|
||||
}
|
||||
this.$Electron.registerMsgListener('dispatch', args => {
|
||||
|
||||
21
resources/assets/js/app.js
vendored
21
resources/assets/js/app.js
vendored
@ -2,6 +2,27 @@ const isElectron = !!(window && window.process && window.process.type);
|
||||
const isEEUiApp = window && window.navigator && /eeui/i.test(window.navigator.userAgent);
|
||||
const isSoftware = isElectron || isEEUiApp;
|
||||
|
||||
const urlParams = $A.urlParameterAll()
|
||||
if (urlParams.language
|
||||
|| urlParams.theme
|
||||
|| urlParams.userid
|
||||
|| urlParams.token) {
|
||||
if (urlParams.language) {
|
||||
window.localStorage.setItem("__system:languageName__", urlParams.language)
|
||||
}
|
||||
if (urlParams.theme) {
|
||||
window.localStorage.setItem("__system:themeConf__", urlParams.language)
|
||||
}
|
||||
if (urlParams.userid) {
|
||||
window.localStorage.setItem("__system:userId__", urlParams.userid)
|
||||
}
|
||||
if (urlParams.token) {
|
||||
window.localStorage.setItem("__system:userToken__", urlParams.token)
|
||||
}
|
||||
const newUrl = $A.removeURLParameter(window.location.href, ['theme', 'language', 'userid', 'token'])
|
||||
window.history.replaceState(null, '', newUrl)
|
||||
}
|
||||
|
||||
import microappInit from "./microapp"
|
||||
import {switchLanguage as $L} from "./language";
|
||||
|
||||
|
||||
31
resources/assets/js/functions/web.js
vendored
31
resources/assets/js/functions/web.js
vendored
@ -915,37 +915,6 @@ import {MarkdownPreview} from "../store/markdown";
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* 通过结果存储同步本地数据
|
||||
* @param json
|
||||
*/
|
||||
storageByBrowser(json) {
|
||||
if ($A.isSoftware) {
|
||||
json = Object.assign({}, this.__storageByBrowser, json)
|
||||
const obj = {}
|
||||
Object.keys(json).sort().map(item => {
|
||||
obj[item] = json[item]
|
||||
})
|
||||
if (JSON.stringify(obj) == JSON.stringify(this.__storageByBrowser)) {
|
||||
return
|
||||
}
|
||||
this.__storageByBrowser = obj
|
||||
const value = encodeURIComponent(JSON.stringify(this.__storageByBrowser))
|
||||
const url = $A.apiUrl(`../storage/synch?value=${value}`)
|
||||
if ($A.isEEUiApp) {
|
||||
$A.eeuiAppSendMessage({
|
||||
action: 'storageBrowser',
|
||||
url,
|
||||
});
|
||||
} else {
|
||||
$A.Electron.sendMessage('storageBrowser', {
|
||||
url
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
__storageByBrowser: {}
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -12,15 +12,22 @@ export default {
|
||||
|
||||
mounted() {
|
||||
if (/^https*:/i.test(window.location.protocol)) {
|
||||
let redirect = null
|
||||
if (this.$router.mode === "hash") {
|
||||
if ($A.stringLength(window.location.pathname) > 2) {
|
||||
window.location.href = `${window.location.origin}/#${window.location.pathname}${window.location.search}`
|
||||
redirect = `${window.location.origin}/#${window.location.pathname}${window.location.search}`
|
||||
}
|
||||
} else if (this.$router.mode === "history") {
|
||||
if ($A.strExists(window.location.href, "/#/")) {
|
||||
window.location.href = window.location.href.replace("/#/", "/")
|
||||
redirect = window.location.href.replace("/#/", "/")
|
||||
}
|
||||
}
|
||||
if (redirect) {
|
||||
this.$store.dispatch("userUrl", redirect).then(redirect => {
|
||||
window.location.href = redirect
|
||||
})
|
||||
throw SyntaxError()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -238,7 +238,8 @@ export default {
|
||||
this.getNeedStartHome();
|
||||
//
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('subWindowDestroyAll')
|
||||
this.$Electron.sendMessage('webTabDestroyAll')
|
||||
this.$Electron.sendMessage('childWindowDestroyAll')
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -537,7 +537,7 @@ export default {
|
||||
}
|
||||
if (/^https*:\/\//i.test(text)) {
|
||||
// 打开链接
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: ' ',
|
||||
url: 'web.js',
|
||||
|
||||
@ -2977,7 +2977,7 @@ export default {
|
||||
}
|
||||
const path = `/single/file/msg/${data.id}`;
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `file-msg-${data.id}`,
|
||||
path: path,
|
||||
userAgent: "/hideenOfficeTitle/",
|
||||
@ -2994,7 +2994,7 @@ export default {
|
||||
},
|
||||
});
|
||||
} else if (this.$isEEUiApp) {
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: `${msg.name} (${$A.bytesToSize(msg.size)})`,
|
||||
url: 'web.js',
|
||||
@ -3003,7 +3003,7 @@ export default {
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
},
|
||||
});
|
||||
})
|
||||
} else {
|
||||
window.open($A.apiUrl(`..${path}`))
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ export default {
|
||||
case 'preview':
|
||||
const path = `/single/file/${this.fileId}?history_id=${row.id}&history_at=${row.created_at}`;
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `file-${this.fileId}-${row.id}`,
|
||||
path: path,
|
||||
userAgent: "/hideenOfficeTitle/",
|
||||
@ -197,7 +197,7 @@ export default {
|
||||
},
|
||||
});
|
||||
} else if (this.$isEEUiApp) {
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: $A.getFileName(this.file) + ` [${row.created_at}]`,
|
||||
url: 'web.js',
|
||||
@ -206,7 +206,7 @@ export default {
|
||||
allowAccess: true,
|
||||
url: $A.rightDelete(window.location.href, window.location.hash) + `#${path}`
|
||||
},
|
||||
});
|
||||
})
|
||||
} else {
|
||||
window.open($A.apiUrl(`..${path}`))
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ export default {
|
||||
width: Math.min(window.screen.availWidth, 1440),
|
||||
height: Math.min(window.screen.availHeight, 900),
|
||||
}
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `report-detail-${row.id}`,
|
||||
path: `/single/report/detail/${row.id}`,
|
||||
force: false,
|
||||
@ -134,7 +134,7 @@ export default {
|
||||
width: Math.min(window.screen.availWidth, 1440),
|
||||
height: Math.min(window.screen.availHeight, 900),
|
||||
}
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `report-edit-${id}`,
|
||||
path: `/single/report/edit/${id}`,
|
||||
force: false,
|
||||
|
||||
@ -1551,7 +1551,7 @@ export default {
|
||||
config.minWidth = 800;
|
||||
config.minHeight = 600;
|
||||
}
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `task-${this.taskDetail.id}`,
|
||||
path: `/single/task/${this.taskDetail.id}?navActive=${this.navActive}`,
|
||||
force: false,
|
||||
@ -1609,7 +1609,7 @@ export default {
|
||||
}
|
||||
const path = `/single/file/task/${file.id}`;
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `file-task-${file.id}`,
|
||||
path: path,
|
||||
userAgent: "/hideenOfficeTitle/",
|
||||
@ -1626,7 +1626,7 @@ export default {
|
||||
},
|
||||
});
|
||||
} else if (this.$isEEUiApp) {
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: `${file.name} (${$A.bytesToSize(file.size)})`,
|
||||
url: 'web.js',
|
||||
|
||||
@ -1121,7 +1121,7 @@ export default {
|
||||
openFileSingle(item) {
|
||||
const path = `/single/file/${item.id}`;
|
||||
if (this.$Electron) {
|
||||
this.$Electron.sendMessage('windowRouter', {
|
||||
this.$store.dispatch('openChildWindow', {
|
||||
name: `file-${item.id}`,
|
||||
path: path,
|
||||
userAgent: "/hideenOfficeTitle/",
|
||||
@ -1138,7 +1138,7 @@ export default {
|
||||
},
|
||||
});
|
||||
} else if (this.$isEEUiApp) {
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: $A.getFileName(item),
|
||||
url: 'web.js',
|
||||
|
||||
@ -182,7 +182,7 @@ export default {
|
||||
openPrivacy() {
|
||||
const url = $A.apiUrl('privacy')
|
||||
if (this.$isEEUiApp) {
|
||||
$A.eeuiAppOpenPage({
|
||||
this.$store.dispatch('openAppChildPage', {
|
||||
pageType: 'app',
|
||||
pageTitle: ' ',
|
||||
url: 'web.js',
|
||||
|
||||
78
resources/assets/js/store/actions.js
vendored
78
resources/assets/js/store/actions.js
vendored
@ -50,6 +50,16 @@ export default {
|
||||
state.userToken = state.userInfo.token
|
||||
state.userIsAdmin = $A.inArray("admin", state.userInfo.identity)
|
||||
}
|
||||
const localId = $A.runNum(window.localStorage.getItem("__system:userId__"))
|
||||
const localToken = window.localStorage.getItem("__system:userToken__") || ""
|
||||
if (localId || localToken) {
|
||||
if (!state.userId && !state.userToken) {
|
||||
state.userId = localId
|
||||
state.userToken = localToken
|
||||
}
|
||||
window.localStorage.removeItem("__system:userId__")
|
||||
window.localStorage.removeItem("__system:userToken__")
|
||||
}
|
||||
|
||||
// ServerUrl
|
||||
if (state.cacheServerUrl) {
|
||||
@ -85,7 +95,6 @@ export default {
|
||||
`language/web/key.js`,
|
||||
`language/web/${languageName}.js`,
|
||||
])
|
||||
$A.storageByBrowser({languageName})
|
||||
|
||||
resolve(action)
|
||||
})
|
||||
@ -365,6 +374,10 @@ export default {
|
||||
*/
|
||||
needHome({dispatch, state}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if ($A.isSoftware) {
|
||||
reject()
|
||||
return
|
||||
}
|
||||
dispatch("systemSetting").then(data => {
|
||||
if (data.start_home === 'open') {
|
||||
resolve()
|
||||
@ -524,7 +537,6 @@ export default {
|
||||
themeName: state.themeName,
|
||||
});
|
||||
}
|
||||
$A.storageByBrowser({themeConf: state.themeConf})
|
||||
},
|
||||
|
||||
/**
|
||||
@ -900,6 +912,66 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
/** *************************************** 新窗口打开 ****************************************/
|
||||
/** *****************************************************************************************/
|
||||
|
||||
/**
|
||||
* 链接添加用户身份
|
||||
* @param state
|
||||
* @param url
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
userUrl({state}, url) {
|
||||
return new Promise(resolve => {
|
||||
const newUrl = $A.urlAddParams(url, {
|
||||
language: languageName,
|
||||
theme: state.themeConf,
|
||||
userid: state.userId,
|
||||
token: state.userToken,
|
||||
})
|
||||
resolve(newUrl)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 打开子窗口(App)
|
||||
* @param dispatch
|
||||
* @param objects
|
||||
*/
|
||||
openAppChildPage({dispatch}, objects) {
|
||||
dispatch("userUrl", objects.params.url).then(url => {
|
||||
objects.params.url = url
|
||||
$A.eeuiAppOpenPage(objects)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 打开子窗口(客户端)
|
||||
* @param dispatch
|
||||
* @param params
|
||||
*/
|
||||
openChildWindow({dispatch}, params) {
|
||||
dispatch("userUrl", params.path).then(path => {
|
||||
$A.Electron.sendMessage('openChildWindow', Object.assign(params, {path}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 打开新标签窗口(客户端)
|
||||
* @param dispatch
|
||||
* @param url
|
||||
*/
|
||||
openWebTabWindow({dispatch}, url) {
|
||||
if ($A.getDomain(url) != $A.getDomain($A.apiUrl('../'))) {
|
||||
$A.Electron.sendMessage('openWebTabWindow', {url})
|
||||
return
|
||||
}
|
||||
dispatch("userUrl", url).then(url => {
|
||||
$A.Electron.sendMessage('openWebTabWindow', {url})
|
||||
})
|
||||
},
|
||||
|
||||
/** *****************************************************************************************/
|
||||
/** ************************************** 文件 **********************************************/
|
||||
/** *****************************************************************************************/
|
||||
@ -1900,7 +1972,7 @@ export default {
|
||||
}
|
||||
if ($A.isSubElectron) {
|
||||
if (task_id > 0) {
|
||||
$A.Electron.sendMessage('updateRouter', {
|
||||
$A.Electron.sendMessage('updateChildWindow', {
|
||||
name: `task-${task_id}`,
|
||||
path: `/single/task/${task_id}`,
|
||||
});
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<script>
|
||||
function isArray(obj) {
|
||||
return typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == '[object array]' && typeof obj.length == "number";
|
||||
}
|
||||
|
||||
function isJson(obj) {
|
||||
return typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() == "[object object]" && typeof obj.length == "undefined";
|
||||
}
|
||||
|
||||
let storages = {!! $value !!};
|
||||
if (isArray(storages)) {
|
||||
storages.forEach(storage => {
|
||||
window.localStorage.setItem(`__system:${storage.key}__`, storage.value);
|
||||
})
|
||||
} else if (isJson(storages)) {
|
||||
for (let key in storages) {
|
||||
let value = storages[key];
|
||||
window.localStorage.setItem(`__system:${key}__`, value);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user