Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
MissterHao committed May 17, 2021
2 parents ff89e70 + 2d035c9 commit 701b6d8
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dev.js
build/*
*.sqlite
config/settings.json

settings.json

.DS_Store
.env
Expand Down
26 changes: 12 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
const { app, BrowserWindow, ipcMain } = require("electron");
const { app, BrowserWindow, ipcMain, Main } = require("electron");
const path = require("path");
const fs = require("fs")

const renderer_dirpath = path.join("./", "renderer")

var settingFilePath = "settings.json"

let MainWindow = null
let SelectCourseWorkerWindow = null
var initConfigSettingJson = {"interval":2, "stage": "1"};

function readOrcreateSettingJson() {
try {
const content = fs.readFileSync("config/settings.json", "utf-8")
const content = fs.readFileSync(settingFilePath, "utf-8")
} catch (error) {

fs.writeFile("config/settings.json", JSON.stringify(initConfigSettingJson), "utf-8", function (err, data)
{

})

fs.writeFile(settingFilePath, JSON.stringify(initConfigSettingJson), "utf-8", function (err, data) {})
}

}


Expand All @@ -32,6 +27,8 @@ function createWindow() {
MainWindow = new BrowserWindow({
width: 1200,
height: 900,
winWidth: 1000,
winHeight: 800,
transparent: false,

// Remove the frame of the window
Expand All @@ -43,25 +40,26 @@ function createWindow() {
}
})

MainWindow.setMenuBarVisibility(false)
MainWindow.loadFile(path.join(renderer_dirpath, "index.html"))
MainWindow.webContents.openDevTools();
// MainWindow.webContents.openDevTools();





// 建立選課worker window
SelectCourseWorkerWindow = new BrowserWindow({
width: 1200,
height: 800,
show: true,
width: 0,
height: 0,
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false, // 預設為 true 必須設為 false
}
})
SelectCourseWorkerWindow.loadFile(path.join(renderer_dirpath, "CourseSelWorker.html"))
SelectCourseWorkerWindow.openDevTools()
// SelectCourseWorkerWindow.openDevTools()



Expand Down
3 changes: 2 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ builder.build({
config: {
"appId": "com.missterhao.wannaclass",
"productName": "Wanna Class", // 應用程式名稱 ( 顯示在應用程式與功能 )
// "copyright": "Copyright © year ${author} "
"directories": {
"output": "build/win"
},
"win": {
// "icon": path.resolve(__dirname, 'cat.png'),
"icon": path.resolve(__dirname, 'icon-512x512.png'),
}
},
})
Expand Down
Binary file added icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wannaclass",
"version": "0.8.0",
"version": "0.9.1",
"description": "Get class from yzu course api.",
"main": "app.js",
"scripts": {
Expand All @@ -9,6 +9,11 @@
"keywords": [
"electron"
],
"homepage": "https://github.com/MissterHao/WannaClass/",
"bugs": {
"url" : "https://github.com/MissterHao/WannaClass/issues",
"email" : "[email protected]"
},
"author": {
"name": "Hao-Wei, Li",
"email": "[email protected]"
Expand All @@ -21,7 +26,6 @@
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"axios": "^0.21.1",
"js-search": "^2.0.0",
"moment": "^2.29.1",
"node-rsa": "^1.1.1",
"request": "^2.88.2",
Expand Down
7 changes: 5 additions & 2 deletions renderer/CourseSelWorker.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@

var tasks = [];

var settingFilePath = "settings.json"

const fs = require('fs');
let settings = JSON.parse(fs.readFileSync('./config/settings.json'))
let settings = JSON.parse(fs.readFileSync(settingFilePath))
const database = new sqlite3.Database('db.sqlite');

var getCoursesIntervalController = null
Expand Down Expand Up @@ -50,7 +52,7 @@
}

function regetSettings(){
settings = JSON.parse(fs.readFileSync('./config/settings.json'))
settings = JSON.parse(fs.readFileSync(settingFilePath))
}

// // 被通知又有一個 Schedule 加入
Expand Down Expand Up @@ -100,6 +102,7 @@
throw err;
}
rows.forEach((element) => {
console.log(element);
apibackend.selCourseInline(element).then((res) => {
console.log(res);
if (res["data"] === "選課系統尚未開放!") {
Expand Down
35 changes: 10 additions & 25 deletions renderer/js/app_vue.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { ipcRenderer } = require("electron");
const { BackendService } = require("./js/yzu_backend");
const Enumerable = require("./js/linq")
const JsSearch = require("js-search")
const { ref, onMounted, onUpdated, computed, watch } = Vue;
var apibackend = new BackendService()

const fs = require('fs');
let settings = JSON.parse(fs.readFileSync('./config/settings.json'))
var settingFilePath = "settings.json"
let settings = JSON.parse(fs.readFileSync(settingFilePath))

var sqlite3 = require('sqlite3').verbose();
const database = new sqlite3.Database('db.sqlite');
Expand All @@ -15,6 +15,10 @@ const database = new sqlite3.Database('db.sqlite');
var year_now = new Date().getFullYear() - 1911;
var smtr_now = new Date().getMonth() >= 7 ? 1 : 2;

function saveSettingFile(){
fs.writeFileSync(settingFilePath, JSON.stringify(settings))
}

const app = Vue.createApp({
el: '#app',
// delimiters: ['@{', '}'],
Expand Down Expand Up @@ -80,7 +84,7 @@ const app = Vue.createApp({
}).then((service) => {
login_infomation.value = service.login_infomation;
settings["token"] = login_infomation.value["Token"]
fs.writeFileSync("./config/settings.json", JSON.stringify(settings))
saveSettingFile()
return service._getAppLoginccount()
}).then((service) => {
std_account_infomation.value = service.std_account_infomation[0]
Expand Down Expand Up @@ -122,25 +126,6 @@ const app = Vue.createApp({

loading_text.value = "下載完成";
isLoading.value = false;

var search = new JsSearch.Search("hashid");
search.addDocuments(CourseList);

/**
* WeekandRoom: "506(體育場地),507(體育場地),"
cd_prompt: null
ci_prompt: "中語一配班授課 (限一年級該班學生)。第三階段開放選課,退選請洽體育室。"
cos_class: "J "
cos_id: "PL101 "
cos_type_name: "共同必修"
credit: 0
dept_name: "體育室 "
name: "體育"
smtr: "2 "
teacher_id: "wu1968"
teacher_name: "吳政文"
year: "109"
*/
})

}
Expand Down Expand Up @@ -225,14 +210,13 @@ const app = Vue.createApp({

watch(StealCourseInterval, (newInterval, prevInterval) => {
settings["interval"] = parseInt(newInterval)
fs.writeFileSync("./config/settings.json", JSON.stringify(settings))
saveSettingFile()
ipcRenderer.send("regetSettings", {})
})

watch(StealCourseStage, (newStage, prevStage) => {
settings["stage"] = newStage
fs.writeFileSync("./config/settings.json", JSON.stringify(settings))

saveSettingFile()
ipcRenderer.send("regetSettings", {})
})

Expand All @@ -241,6 +225,7 @@ const app = Vue.createApp({
event.stopPropagation()
// 通知 worker 加入搶課列表
var course_obj = JSON.parse(JSON.stringify(course))
console.log(course_obj);
ipcRenderer.send("addTaskCourse", course_obj)

}
Expand Down
2 changes: 1 addition & 1 deletion renderer/js/yzu_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class BackendService {

selCourseInline(course) {

let settings = JSON.parse(fs.readFileSync('./config/settings.json'))
let settings = JSON.parse(fs.readFileSync('settings.json'))

var url = "https://isdna1.yzu.edu.tw/StdSelWebAPI/api/SelCos/Get_AddCosCheck_Str"

Expand Down

0 comments on commit 701b6d8

Please sign in to comment.