diff --git a/main.js b/main.js index 313ceec..3dcd7e4 100644 --- a/main.js +++ b/main.js @@ -18,8 +18,8 @@ function createWindow(){ //创建窗口 const win = new BrowserWindow({ //指定窗口大小 - width: 1000, - height: 800, + width: 1200, + height: 900, //指定窗口位置 // x: 0, y: 0, // alwaysOnTop: true, diff --git a/pages/exam.html b/pages/exam.html index b0cfeae..a1ccf9b 100644 --- a/pages/exam.html +++ b/pages/exam.html @@ -7,9 +7,9 @@ - + content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
@@ -22,7 +22,7 @@ - +
@@ -30,7 +30,7 @@ 考试资讯 @@ -43,30 +43,30 @@

题目:

-

+

这里是问题
这里将会包含一些文本来描述题目内容,题目与赛博朋克2077游戏中一些设定有关。部分题目也会摘抄自全国高等教育考试中的数学科目选择题。

- +
- +
- +
- +
- +
@@ -76,4 +76,5 @@
+ \ No newline at end of file diff --git a/pages/index.html b/pages/index.html index 1a5ddb0..ec81fee 100644 --- a/pages/index.html +++ b/pages/index.html @@ -7,9 +7,9 @@ - + content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
@@ -22,7 +22,7 @@ - +
@@ -61,4 +61,5 @@ --> + diff --git a/pages/js/common.js b/pages/js/common.js new file mode 100644 index 0000000..2ae67f8 --- /dev/null +++ b/pages/js/common.js @@ -0,0 +1,82 @@ +var current_user=null; + +//获取用户登录状态 +var xhr1 = new XMLHttpRequest(); +xhr1.open('GET', '/login/current-user', true); +xhr1.responseType = 'json'; +xhr1.onload = function() { + if (this.status === 200) { + if (this.response.msg!='ok'){ + console.error('Error:', this.response.msg); + }else{ + current_user = this.response.user; + } + } else { + console.error('Error:', this.statusText); + } +}; +xhr1.send(); + +//登录后则跳转,没有登录则跳转到登录的函数。 +function jumpOrNot(href){ + if (current_user === null){ + alert('在部署环境将会跳转到login,文件打开将跳转错误!'); + window.location.href='/login.html'; + }else if(current_user.status==='ok'){ + window.location.href=href; + } +} + +//拉取上一题的函数 +function last_question(){ + get_question('last') +} + +//从服务端获取题目函数 +function get_question(opt){ + //将会从服务端拉取题目,这里演示直接向显示函数传入固定的json。 + alert('从服务器拉取上一题,这里演示直接向显示函数传入固定的json。'); + const test_json = { + 'question': '这里是测试题目内容', + 'choice_a': '这个是测试选项', + 'choice_b': '这个是b测试选项', + 'choice_c': '这个是测试选项测试选项测试选项测试选项测试选项', + 'choice_d': '你好,awinx!' + } + set_question(test_json); + + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/get-question?user='+current_user.username+'&&'+opt, true); + xhr.responseType = 'json'; + xhr.onload = function() { + if (this.status === 200) { + if (this.response.msg!='ok'){ + console.error('Error:', this.response.msg); + }else{ + set_question(this.response); + } + } else { + console.error('Error:', this.statusText); + } + }; + xhr.send(); +} + +//将获取到的题目显示出来的函数 +function set_question(content){ + console.log('设置题目内容'); + const question = document.querySelector('.question-text'); + const choice_a = document.getElementById('A-text'); + const choice_b = document.getElementById('B-text'); + const choice_c = document.getElementById('C-text'); + const choice_d = document.getElementById('D-text'); + question.textContent = content.question; + choice_a.textContent = content.choice_a; + choice_b.textContent = content.choice_b; + choice_c.textContent = content.choice_c; + choice_d.textContent = content.choice_d; +} + +function submit(){ + alert('尚未完成,后端还未适配该模型请访问http://exam.awin-x.top \n(仅ipv6地址)。'); +} diff --git a/pages/login.html b/pages/login.html index 520baf8..c4c2ace 100644 --- a/pages/login.html +++ b/pages/login.html @@ -7,9 +7,9 @@ - + content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
@@ -22,7 +22,7 @@ - +
@@ -53,4 +53,5 @@ + \ No newline at end of file diff --git a/pages/news.html b/pages/news.html index e2df995..2c386f2 100644 --- a/pages/news.html +++ b/pages/news.html @@ -7,9 +7,9 @@ - + content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
@@ -22,7 +22,7 @@ - +
@@ -40,4 +40,5 @@
+ \ No newline at end of file