简单整合
This commit is contained in:
parent
ddc2bff2d5
commit
b2f2a713d0
4
main.js
4
main.js
@ -18,8 +18,8 @@ function createWindow(){
|
|||||||
//创建窗口
|
//创建窗口
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
//指定窗口大小
|
//指定窗口大小
|
||||||
width: 1000,
|
width: 1200,
|
||||||
height: 800,
|
height: 900,
|
||||||
//指定窗口位置
|
//指定窗口位置
|
||||||
// x: 0, y: 0,
|
// x: 0, y: 0,
|
||||||
// alwaysOnTop: true,
|
// alwaysOnTop: true,
|
||||||
|
|||||||
@ -7,9 +7,9 @@
|
|||||||
<link rel="stylesheet" href="./css/index.css"/>
|
<link rel="stylesheet" href="./css/index.css"/>
|
||||||
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
||||||
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
||||||
<meta
|
<!-- <meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" />
|
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">贡献题目</li></a>
|
<a onclick="jumpOrNot('contrib.html')"><li class="sub-menu-item clp">贡献题目</li></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<a href="news.html"><span>考试资讯</span></a>
|
<a href="news.html"><span>考试资讯</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="menu-item">
|
<li class="menu-item">
|
||||||
<span><a href="login.html">登录/注册</a></span>
|
<span id="user-pannel"><a href="login.html">登录/注册</a></span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -43,30 +43,30 @@
|
|||||||
<div class="exam-box">
|
<div class="exam-box">
|
||||||
<div class="question-box">
|
<div class="question-box">
|
||||||
<h1 class="red-light">题目:</h1>
|
<h1 class="red-light">题目:</h1>
|
||||||
<p class="blue-light">
|
<p class="blue-light question-text">
|
||||||
这里是问题<br>
|
这里是问题<br>
|
||||||
这里将会包含一些文本来描述题目内容,题目与赛博朋克2077游戏中一些设定有关。部分题目也会摘抄自全国高等教育考试中的数学科目选择题。
|
这里将会包含一些文本来描述题目内容,题目与赛博朋克2077游戏中一些设定有关。部分题目也会摘抄自全国高等教育考试中的数学科目选择题。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="question-img-box">
|
<div class="question-img-box">
|
||||||
<img src="" alt="">
|
<img src="" alt="">
|
||||||
</div> -->
|
</div>
|
||||||
<div class="form-box">
|
<div class="form-box">
|
||||||
<div class="choice-box">
|
<div class="choice-box">
|
||||||
<input name="choice" type="radio" id="A">
|
<input name="choice" type="radio" id="A">
|
||||||
<label for="A" class="blue-light"><span class="red-light">A: </span>点击整个选项框都有效!</label>
|
<label for="A" class="blue-light"><span class="red-light">A: </span><span id="A-text">点击整个选项框都有效!</span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="choice-box">
|
<div class="choice-box">
|
||||||
<input name="choice" type="radio" id="B">
|
<input name="choice" type="radio" id="B">
|
||||||
<label for="B" class="blue-light"><span class="red-light">B: </span>提交时用js收集结果使用ajax获取回答是否正确</label>
|
<label for="B" class="blue-light"><span class="red-light">B: </span><span id="B-text">提交时用js收集结果使用ajax获取回答是否正确</span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="choice-box">
|
<div class="choice-box">
|
||||||
<input name="choice" type="radio" id="C">
|
<input name="choice" type="radio" id="C">
|
||||||
<label for="C" class="blue-light"><span class="red-light">C: </span>如果是考试模式就直接下一题,不显示回答结果</label>
|
<label for="C" class="blue-light"><span class="red-light">C: </span><span id="C-text">如果是考试模式就直接下一题,不显示回答结果</span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="choice-box">
|
<div class="choice-box">
|
||||||
<input name="choice" type="radio" id="D">
|
<input name="choice" type="radio" id="D">
|
||||||
<label for="D" class="blue-light"><span class="red-light">D: </span>题库模式时就立即显示回答是否正确,错误则停留,正确则3秒后下一题</label>
|
<label for="D" class="blue-light"><span class="red-light">D: </span><span id="D-text">题库模式时就立即显示回答是否正确,错误则停留,正确则3秒后下一题</span></label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-buttons">
|
<div class="form-buttons">
|
||||||
<button class="yellow-btn" onclick="last_question()">上一题</button>
|
<button class="yellow-btn" onclick="last_question()">上一题</button>
|
||||||
@ -76,4 +76,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="js/common.js"></script>
|
||||||
</html>
|
</html>
|
||||||
@ -7,9 +7,9 @@
|
|||||||
<link rel="stylesheet" href="./css/index.css"/>
|
<link rel="stylesheet" href="./css/index.css"/>
|
||||||
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
||||||
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
||||||
<meta
|
<!-- <meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" />
|
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">贡献题目</li></a>
|
<a onclick="jumpOrNot('contrib.html')"><li class="sub-menu-item clp">贡献题目</li></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -61,4 +61,5 @@
|
|||||||
<button id="read">读取文件内容</button> -->
|
<button id="read">读取文件内容</button> -->
|
||||||
</body>
|
</body>
|
||||||
<script src="./js/render.js"></script>
|
<script src="./js/render.js"></script>
|
||||||
|
<script src="js/common.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
82
pages/js/common.js
Normal file
82
pages/js/common.js
Normal file
@ -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地址)。');
|
||||||
|
}
|
||||||
@ -7,9 +7,9 @@
|
|||||||
<link rel="stylesheet" href="./css/index.css"/>
|
<link rel="stylesheet" href="./css/index.css"/>
|
||||||
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
||||||
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
||||||
<meta
|
<!-- <meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" />
|
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">贡献题目</li></a>
|
<a onclick="jumpOrNot('contrib.html')"><li class="sub-menu-item clp">贡献题目</li></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -53,4 +53,5 @@
|
|||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
<script src="js/common.js"></script>
|
||||||
</html>
|
</html>
|
||||||
@ -7,9 +7,9 @@
|
|||||||
<link rel="stylesheet" href="./css/index.css"/>
|
<link rel="stylesheet" href="./css/index.css"/>
|
||||||
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
<!-- <link rel="stylesheet" href="http://cdn.staticfile.org/pure/1.0.0/pure-min.css"/> -->
|
||||||
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
<!-- <link rel="stylesheet" href="./pure-min.css"> -->
|
||||||
<meta
|
<!-- <meta
|
||||||
http-equiv="Content-Security-Policy"
|
http-equiv="Content-Security-Policy"
|
||||||
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" />
|
content="default-src 'self' *.awin-x.top;style-src 'self' *.awin-x.top; img-src *;script-src 'self'" /> -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
<a href="exam.html"><li class="sub-menu-item clp">模拟考试</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
<a href="#"><li class="sub-menu-item clp">历年真题</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
<a href="#"><li class="sub-menu-item clp">试卷下载</li></a>
|
||||||
<a href="#"><li class="sub-menu-item clp">贡献题目</li></a>
|
<a onclick="jumpOrNot('contrib.html')"><li class="sub-menu-item clp">贡献题目</li></a>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -40,4 +40,5 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="end-block"></div>
|
<div class="end-block"></div>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="js/common.js"></script>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user