This repository has been archived by the owner on Jul 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6f8d1b
commit 58dfea5
Showing
6 changed files
with
368 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider: github | ||
owner: kewool | ||
repo: ebs_desktop_app | ||
token: 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 |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,166 @@ | ||
version https://git-lfs.github.com/spec/v1 | ||
oid sha256:f8e5be8cfe09071ce31bee4e8358b986494d5ecf4211740fb33047b88a47d458 | ||
size 4820 | ||
const { ipcMain } = require('electron'); | ||
const { Wrapper } = require('ebsoc'); | ||
const ebs = require('ebsoc'); | ||
const puppeteer = require('puppeteer'); | ||
|
||
let userdata = {}; | ||
let browser; | ||
|
||
(async() => { | ||
let chromePaths = [ | ||
`%ProgramFiles%\\Google\\Chrome\\Application\\chrome.exe`, | ||
`%ProgramFiles(x86)%\\Google\\Chrome\\Application\\chrome.exe`, | ||
`%LocalAppData%\\Google\\Chrome\\Application\\chrome.exe`, | ||
`C:\Program Files (x86)\Google\Application\chrome.exe` | ||
]; | ||
})(); | ||
|
||
const createBrowser = async function(){ | ||
browser = await puppeteer.launch({ | ||
args: [], | ||
headless: false, | ||
defaultViewport: null, | ||
ignoreDefaultArgs: ["--disable-extensions", "--enable-automation"] | ||
}); | ||
browser.on('disconnected', () => browser = null); | ||
browser.on('targetcreated', async function cb() { | ||
let pages = await browser.pages(); | ||
if (pages.length > 1) { | ||
//await pages[0].close(); | ||
browser.off('targetcreated', cb); | ||
} | ||
}); | ||
return browser; | ||
}; | ||
|
||
const COMMON = require('./events/common'); | ||
|
||
ipcMain.on(COMMON.OPEN_AT_CHROME, async (event, url) => { | ||
try { | ||
if (!browser) | ||
browser = await createBrowser(); | ||
if (!userdata.memberInfo) { | ||
userdata = await ebs.Common.member(userdata.token); | ||
} | ||
const page = await browser.newPage(); | ||
await page.setCookie(...[ | ||
{ | ||
name: 'access', | ||
value: userdata.token, | ||
domain: ".ebsoc.co.kr", | ||
secure: false | ||
}, | ||
{ | ||
name: 'host', | ||
value: userdata.memberInfo.memberSchoolInfo.hostName, | ||
domain: ".ebsoc.co.kr", | ||
secure: false | ||
}, | ||
{ | ||
name: 'memberSchoolCode', | ||
value: userdata.memberInfo.memberSchoolCode, | ||
domain: ".ebsoc.co.kr", | ||
secure: false | ||
} | ||
]); | ||
await page.goto(url); | ||
event.reply(COMMON.OPEN_AT_CHROME, { code: "OK" }); | ||
} | ||
catch (err) { | ||
event.reply(COMMON.OPEN_AT_CHROME, { code: "ERR", err: err }); | ||
} | ||
}); | ||
|
||
const LOGIN = require('./events/login'); | ||
|
||
ipcMain.on(LOGIN.SIGNIN_REQUEST, async (event, args) => { | ||
let { id, pwd } = args; | ||
try { | ||
let data = await ebs.Auth.login(id, pwd); | ||
userdata = data.data; | ||
event.reply(LOGIN.SIGNIN_COMPLETE); | ||
} | ||
catch (err) { | ||
event.reply(LOGIN.SIGNIN_FAILURE, err); | ||
} | ||
}); | ||
|
||
ipcMain.on(LOGIN.SIGNIN_WITH_TOKEN, async (event, args) => { | ||
try { | ||
userdata = await ebs.Common.member(args); | ||
event.reply(LOGIN.SIGNIN_COMPLETE); | ||
} | ||
catch (err) { | ||
event.reply(LOGIN.SIGNIN_FAILURE, err); | ||
} | ||
}); | ||
|
||
const CLASS = require('./events/class'); | ||
|
||
ipcMain.on(CLASS.CLASS_LIST_REQUEST, async (event, args) => { | ||
try { | ||
let data = await Wrapper.fetchClassList(userdata.token, { | ||
schoolAffairsYear: new Date().getFullYear(), | ||
searchType: Wrapper.SEARCH_TYPE.NONE, | ||
searchWord: "", | ||
tabType: Wrapper.TAB_TYPE.SBSCE | ||
}); | ||
event.reply(CLASS.CLASS_LIST_RESPONSE, data.data); | ||
} catch (err) { | ||
event.reply(CLASS.CLASS_LIST_FAILURE); | ||
} | ||
}); | ||
|
||
const LESSON = require('./events/lesson'); | ||
|
||
ipcMain.on(LESSON.LESSON_REQUEST, async (event, args) => { | ||
try { | ||
let { classUrlPath, lessonSeq } = args; | ||
/* | ||
let detail = await ebs.Cls.lctClass.detail(userdata.token, { classUrlPath: classUrlPath }); | ||
let classSqno = detail.data.classSqno; | ||
*/ | ||
let lessons = await ebs.Lecture.$classUrlPath.lesson.lecture.attend.list.$lessonSeq(userdata.token, | ||
{ classUrlPath: classUrlPath, lessonSeq: lessonSeq }); | ||
event.reply(LESSON.LESSON_RESPONSE, lessons); | ||
} catch (err) { | ||
console.log(err); | ||
event.reply(LESSON.LESSON_FAILURE); | ||
} | ||
}); | ||
|
||
const COURSE = require('./events/course'); | ||
|
||
ipcMain.on(COURSE.COURSE_REQUEST, async (event, args) => { | ||
let data = await Wrapper.fetchCourse( | ||
userdata.token, | ||
args.classUrlPath, | ||
{ | ||
status: Wrapper.COURSE_STATUS.ALL, | ||
orderBy: Wrapper.COURSE_ORDER_BY.REGISTRATION_DATE | ||
} | ||
); | ||
if (data.err) { | ||
console.log(data); | ||
event.reply(COURSE.COURSE_FAILURE); | ||
} | ||
event.reply(COURSE.COURSE_RESPONSE, data); | ||
}); | ||
|
||
const PLAYER = require('./events/player'); | ||
|
||
ipcMain.on(PLAYER.PLAYER, async (event, args) => { | ||
let Player = new Wrapper.SimplePlayer( | ||
userdata.token, | ||
args.classUrlPath, | ||
args.lessonSeq, | ||
args.subLessonSeq | ||
); | ||
let data = await Player.create(); | ||
let detail = await Player.lectureDetailData(); | ||
if (data.err) { | ||
console.log(data); | ||
event.reply(COURSE.PLAYER, { status: "err", err: data.err }); | ||
} | ||
event.reply(PLAYER.PLAYER, { status: "ok", player: Player, create_data: data, detail_data: detail }); | ||
}); |
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<html> | ||
|
||
<head> | ||
|
||
</head> | ||
|
||
<body> | ||
<p>Current version: <span id="current-version"></span></p> | ||
<p id="message"></p> | ||
<script> | ||
var { ipcRenderer } = require("electron"); | ||
|
||
const replaceText = (selector, text) => { | ||
const element = document.getElementById(selector); | ||
if (element) element.innerText = text; | ||
}; | ||
|
||
replaceText('current-version', window.location.hash.substr(1)); | ||
ipcRenderer.on("message", function (event, data) { | ||
const element = document.getElementById("message"); | ||
if (element) element.innerText = data; | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const { app, BrowserWindow } = require('electron'); | ||
const { autoUpdater } = require("electron-updater"); | ||
|
||
let updateWin; | ||
|
||
function sendStatusToWindow(text) { | ||
if (updateWin.webContents) | ||
updateWin.webContents.send("message", text); | ||
} | ||
|
||
function createDefaultUpdateWindow() { | ||
updateWin = new BrowserWindow({ | ||
backgroundColor: "#eeeeee", | ||
webPreferences: { nodeIntegration: true, contextIsolation: false }, | ||
}); | ||
|
||
updateWin.on("closed", () => { | ||
updateWin = null; | ||
}); | ||
updateWin.loadURL(`file://${__dirname}/pages/version.html#v${app.getVersion()}`); | ||
return updateWin; | ||
} | ||
|
||
autoUpdater.on("checking-for-update", () => { | ||
sendStatusToWindow("Checking for update..."); | ||
}); | ||
autoUpdater.on("update-available", (info) => { | ||
sendStatusToWindow("Update available."); | ||
}); | ||
autoUpdater.on("update-not-available", (info) => { | ||
sendStatusToWindow("Update not available."); | ||
}); | ||
autoUpdater.on("error", (err) => { | ||
sendStatusToWindow("Error in auto-updater. " + err); | ||
}); | ||
autoUpdater.on("download-progress", (progressObj) => { | ||
let log_message = "Download speed: " + progressObj.bytesPerSecond; | ||
log_message = log_message + " - Downloaded " + progressObj.percent + "%"; | ||
log_message = log_message + " (" + progressObj.transferred + "/" + progressObj.total + ")"; | ||
sendStatusToWindow(log_message); | ||
}); | ||
autoUpdater.on("update-downloaded", (info) => { | ||
sendStatusToWindow("Update downloaded"); | ||
|
||
const option = { | ||
type: "question", | ||
buttons: ["업데이트", "취소"], | ||
defaultId: 0, | ||
title: "electron-updater", | ||
message: "업데이트가 있습니다. 프로그램을 업데이트 하시겠습니까?", | ||
}; | ||
let btnIndex = dialog.showMessageBoxSync(updateWin, option); | ||
|
||
if (btnIndex === 0) { | ||
autoUpdater.quitAndInstall(); | ||
} | ||
}); | ||
|
||
app.on("ready", async () => { | ||
createDefaultUpdateWindow(); | ||
autoUpdater.checkForUpdates(); | ||
}); |