no message

This commit is contained in:
kuaifan 2021-12-27 21:04:35 +08:00
parent 6c458b81b2
commit c6eb850abe
14 changed files with 278 additions and 70 deletions

68
electron/main.js vendored
View File

@ -104,6 +104,7 @@ function createRouter(arg) {
parent: mainWindow, parent: mainWindow,
webPreferences: { webPreferences: {
preload: path.join(__dirname, 'preload.js'), preload: path.join(__dirname, 'preload.js'),
devTools: arg.devTools !== false,
nodeIntegration: true, nodeIntegration: true,
contextIsolation: false contextIsolation: false
} }
@ -133,41 +134,82 @@ function createRouter(arg) {
app.whenReady().then(() => { app.whenReady().then(() => {
createWindow() createWindow()
app.on('activate', function () { app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow() if (BrowserWindow.getAllWindows().length === 0) createWindow()
}) })
}) })
app.on('window-all-closed', function () { app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit() if (process.platform !== 'darwin') {
app.quit()
}
}) })
app.on('before-quit', () => { app.on('before-quit', () => {
willQuitApp = true willQuitApp = true
}) })
ipcMain.on('inheritClose', () => { ipcMain.on('inheritClose', (event) => {
inheritClose = true inheritClose = true
event.returnValue = "ok"
}) })
ipcMain.on('windowRouter', (event, arg) => { ipcMain.on('windowRouter', (event, arg) => {
createRouter(arg) createRouter(arg)
event.returnValue = "ok"
}) })
ipcMain.on('windowHidden', () => { ipcMain.on('windowHidden', (event) => {
app.hide(); app.hide();
event.returnValue = "ok"
}) })
ipcMain.on('windowClose', () => { ipcMain.on('windowClose', (event) => {
mainWindow.close() const win = BrowserWindow.fromWebContents(event.sender);
win.close()
event.returnValue = "ok"
}) })
ipcMain.on('windowMax', function () { ipcMain.on('windowSize', (event, arg) => {
if (mainWindow.isMaximized()) { const win = BrowserWindow.fromWebContents(event.sender);
mainWindow.restore(); if (win) {
} else { if (arg.width || arg.height) {
mainWindow.maximize(); win.setSize(arg.width || win.getSize()[0], arg.height || win.getSize()[1])
} }
if (arg.minWidth || arg.minHeight) {
win.setMinimumSize(arg.minWidth || win.getMinimumSize()[0], arg.minHeight || win.getMinimumSize()[1])
}
if (arg.maxWidth || arg.maxHeight) {
win.setMaximumSize(arg.maxWidth || win.getMaximumSize()[0], arg.maxHeight || win.getMaximumSize()[1])
}
}
event.returnValue = "ok"
})
ipcMain.on('windowMinSize', (event, arg) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (win) {
win.setMinimumSize(arg.width || win.getMinimumSize()[0], arg.height || win.getMinimumSize()[1])
}
event.returnValue = "ok"
})
ipcMain.on('windowMaxSize', (event, arg) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (win) {
win.setMaximumSize(arg.width || win.getMaximumSize()[0], arg.height || win.getMaximumSize()[1])
}
event.returnValue = "ok"
})
ipcMain.on('windowMax', (event) => {
const win = BrowserWindow.fromWebContents(event.sender);
if (win.isMaximized()) {
win.restore();
} else {
win.maximize();
}
event.returnValue = "ok"
}) })
ipcMain.on('setDockBadge', (event, arg) => { ipcMain.on('setDockBadge', (event, arg) => {
@ -180,6 +222,7 @@ ipcMain.on('setDockBadge', (event, arg) => {
} else { } else {
app.dock.setBadge("") app.dock.setBadge("")
} }
event.returnValue = "ok"
}) })
ipcMain.on('saveSheet', (event, data, filename, opts) => { ipcMain.on('saveSheet', (event, data, filename, opts) => {
@ -194,4 +237,5 @@ ipcMain.on('saveSheet', (event, data, filename, opts) => {
}).then(o => { }).then(o => {
XLSX.writeFile(data, o.filePath, opts); XLSX.writeFile(data, o.filePath, opts);
}); });
event.returnValue = "ok"
}) })

View File

@ -35,8 +35,9 @@
"@electron-forge/maker-zip": "^6.0.0-beta.61", "@electron-forge/maker-zip": "^6.0.0-beta.61",
"dmg-license": "^1.0.10", "dmg-license": "^1.0.10",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"electron": "^16.0.4", "electron": "^16.0.5",
"electron-builder": "^22.14.5" "electron-builder": "^22.14.5",
"electron-log": "^4.4.3"
}, },
"dependencies": { "dependencies": {
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",

View File

@ -36,6 +36,7 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"css-loader": "^6.5.1", "css-loader": "^6.5.1",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"electron": "^16.0.5",
"element-ui": "^2.15.6", "element-ui": "^2.15.6",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"inquirer": "^8.2.0", "inquirer": "^8.2.0",

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -145,7 +145,7 @@
}" }"
@on-visible-change="taskVisibleChange" @on-visible-change="taskVisibleChange"
footer-hide> footer-hide>
<TaskDetail :open-task="taskData"/> <TaskDetail :task-id="taskId" :open-task="taskData"/>
</Modal> </Modal>
<!--查看所有团队--> <!--查看所有团队-->

View File

@ -100,6 +100,7 @@
<p v-if="columnName"><span>{{columnName}}</span></p> <p v-if="columnName"><span>{{columnName}}</span></p>
<p v-if="taskDetail.id"><span>{{taskDetail.id}}</span></p> <p v-if="taskDetail.id"><span>{{taskDetail.id}}</span></p>
</div> </div>
<div class="function">
<Poptip <Poptip
v-if="getOwner.length === 0" v-if="getOwner.length === 0"
confirm confirm
@ -111,6 +112,9 @@
transfer> transfer>
<Button type="primary">{{$L('我要领取任务')}}</Button> <Button type="primary">{{$L('我要领取任务')}}</Button>
</Poptip> </Poptip>
<ETooltip v-if="isElectron" :content="$L('新窗口打开')">
<i class="taskfont open" @click="openNewWin">&#xe776;</i>
</ETooltip>
<EDropdown <EDropdown
trigger="click" trigger="click"
placement="bottom" placement="bottom"
@ -140,6 +144,7 @@
</EDropdownMenu> </EDropdownMenu>
</EDropdown> </EDropdown>
</div> </div>
</div>
<div class="scroller overlay-y" :style="scrollerStyle"> <div class="scroller overlay-y" :style="scrollerStyle">
<div class="title"> <div class="title">
<Input <Input
@ -310,7 +315,7 @@
<i class="taskfont">&#xe6f0;</i>{{$L('子任务')}} <i class="taskfont">&#xe6f0;</i>{{$L('子任务')}}
</div> </div>
<ul class="item-content subtask"> <ul class="item-content subtask">
<TaskDetail v-for="(task, key) in subList" :key="key" :open-task="task"/> <TaskDetail v-for="(task, key) in subList" :key="key" :task-id="task.id" :open-task="task"/>
</ul> </ul>
<ul :class="['item-content', subList.length === 0 ? 'nosub' : '']"> <ul :class="['item-content', subList.length === 0 ? 'nosub' : '']">
<li> <li>
@ -412,6 +417,10 @@ export default {
name: "TaskDetail", name: "TaskDetail",
components: {ProjectLog, DialogWrapper, TaskUpload, UserInput, TaskPriority, TEditor}, components: {ProjectLog, DialogWrapper, TaskUpload, UserInput, TaskPriority, TEditor},
props: { props: {
taskId: {
type: Number,
default: 0
},
openTask: { openTask: {
type: Object, type: Object,
default: () => { default: () => {
@ -509,7 +518,6 @@ export default {
'userId', 'userId',
'projects', 'projects',
'columns', 'columns',
'taskId',
'taskSubs', 'taskSubs',
'taskContents', 'taskContents',
'taskFiles', 'taskFiles',
@ -1114,6 +1122,10 @@ export default {
}).then(({data}) => { }).then(({data}) => {
this.$store.dispatch("saveTask", data); this.$store.dispatch("saveTask", data);
this.$store.dispatch("getDialogOne", data.dialog_id); this.$store.dispatch("getDialogOne", data.dialog_id);
if (this.isElectron) {
this.resizeDialog();
return;
}
this.$nextTick(() => { this.$nextTick(() => {
if (this.$store.state.windowMax768) { if (this.$store.state.windowMax768) {
this.goForward({path: '/manage/messenger', query: {sendmsg: this.msgText}}); this.goForward({path: '/manage/messenger', query: {sendmsg: this.msgText}});
@ -1144,6 +1156,10 @@ export default {
this.sendLoad = false; this.sendLoad = false;
this.$store.dispatch("saveTask", data); this.$store.dispatch("saveTask", data);
this.$store.dispatch("getDialogOne", data.dialog_id); this.$store.dispatch("getDialogOne", data.dialog_id);
if (this.isElectron) {
this.resizeDialog();
return;
}
this.$nextTick(() => { this.$nextTick(() => {
this.goForward({path: '/manage/messenger', query: {sendmsg: this.msgText}}); this.goForward({path: '/manage/messenger', query: {sendmsg: this.msgText}});
this.$store.state.method.setStorage("messenger::dialogId", data.dialog_id) this.$store.state.method.setStorage("messenger::dialogId", data.dialog_id)
@ -1169,6 +1185,54 @@ export default {
$A.modalError(msg); $A.modalError(msg);
this.$store.dispatch("getTaskFiles", this.taskDetail.id) this.$store.dispatch("getTaskFiles", this.taskDetail.id)
}); });
},
openNewWin() {
if (!this.isElectron) {
return;
}
let config = {
parent: null,
width: Math.min(window.screen.availWidth, this.$el.clientWidth + 72),
height: Math.min(window.screen.availHeight, this.$el.clientHeight + 72),
};
if (this.hasOpenDialog) {
config.minWidth = 800;
config.minHeight = 600;
}
this.$electron.ipcRenderer.send('windowRouter', {
name: 'task-' + this.taskDetail.id,
path: "/single/task/" + this.taskDetail.id,
force: false, //
devTools: false,
config
});
this.$store.dispatch('openTask', 0);
},
resizeDialog() {
if (!this.isElectron) {
return;
}
this.$electron.ipcRenderer.sendSync('windowSize', {
width: Math.max(1100, window.innerWidth),
height: Math.max(720, window.innerHeight),
minWidth: 800,
minHeight: 600
});
if (this.msgText) {
let num = 0;
let interval = setInterval(() => {
num++;
if (this.$refs.dialog || num > 20) {
clearInterval(interval);
if (this.$refs.dialog) {
this.$refs.dialog.sendMsg(this.msgText);
this.msgText = "";
}
}
}, 100);
}
} }
} }
} }

View File

@ -0,0 +1,85 @@
<template>
<div class="electron-task">
<PageTitle :title="taskInfo.name"/>
<Loading v-if="loadIng > 0"/>
<TaskDetail v-else :task-id="taskInfo.id" :open-task="taskInfo"/>
</div>
</template>
<style lang="scss" scoped>
.electron-task {
height: 100%;
display: flex;
flex-direction: column;
overflow: auto;
.task-detail {
flex: 1;
margin: 0;
padding: 18px 22px;
border-radius: 0;
}
}
</style>
<style lang="scss">
.electron-task {
.task-detail {
.task-info {
.head {
.function {
margin-right: 0;
.open {
display: none;
}
}
}
}
}
}
</style>
<script>
import TaskDetail from "../manage/components/TaskDetail";
export default {
components: {TaskDetail},
data() {
return {
loadIng: 0,
taskInfo: {},
}
},
mounted() {
//
},
watch: {
'$route': {
handler() {
this.getInfo();
},
immediate: true
},
},
methods: {
getInfo() {
let id = $A.runNum(this.$route.params.id);
if (id <= 0) {
return;
}
this.loadIng++;
this.$store.dispatch("getTaskOne", id).then(({data}) => {
this.loadIng--;
this.taskInfo = data;
}).catch(({msg}) => {
this.loadIng--;
$A.modalError({
content: msg,
onOk: () => {
if (this.isElectron) {
window.close();
}
}
});
});
}
}
}
</script>

View File

@ -80,6 +80,11 @@ export default [
path: '/single/file/:id', path: '/single/file/:id',
component: () => import('./pages/single/file.vue'), component: () => import('./pages/single/file.vue'),
}, },
{
name: 'single-task',
path: '/single/task/:id',
component: () => import('./pages/single/task.vue'),
},
{ {
name: 'login', name: 'login',
path: '/login', path: '/login',

View File

@ -10,7 +10,7 @@
.head { .head {
display: flex; display: flex;
align-items: center; align-items: center;
height: 40px; height: 42px;
padding-bottom: 10px; padding-bottom: 10px;
color: #888888; color: #888888;
position: relative; position: relative;
@ -60,16 +60,27 @@
} }
} }
} }
.function {
display: flex;
align-items: center;
margin: 0 32px;
.pick { .pick {
margin-left: 16px; margin-left: 12px;
margin-right: -16px; margin-right: 10px;
}
.open {
margin-top: -2px;
margin-left: 12px;
font-size: 22px;
cursor: pointer;
} }
.menu { .menu {
margin-left: 12px;
font-size: 22px; font-size: 22px;
margin: 0 32px;
cursor: pointer; cursor: pointer;
} }
} }
}
.scroller { .scroller {
margin-left: 36px; margin-left: 36px;
padding-right: 36px; padding-right: 36px;
@ -365,7 +376,7 @@
} }
} }
.task-dialog { .task-dialog {
flex: 1; flex-shrink: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-top: 22px; margin-top: 22px;
@ -481,11 +492,8 @@
.task-info { .task-info {
overflow: auto; overflow: auto;
.head { .head {
.menu { .function {
margin: 0 2px; margin-right: 2px;
}
.pick {
margin-right: 12px;
} }
} }
} }