diff --git a/APP/.idea/.gitignore b/APP/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/APP/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/APP/.idea/APP.iml b/APP/.idea/APP.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/APP/.idea/APP.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/APP/.idea/inspectionProfiles/Project_Default.xml b/APP/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..f281ec3 --- /dev/null +++ b/APP/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/APP/.idea/inspectionProfiles/profiles_settings.xml b/APP/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/APP/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/APP/.idea/misc.xml b/APP/.idea/misc.xml new file mode 100644 index 0000000..ba24381 --- /dev/null +++ b/APP/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/APP/.idea/modules.xml b/APP/.idea/modules.xml new file mode 100644 index 0000000..e0b4e73 --- /dev/null +++ b/APP/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/APP/.idea/vcs.xml b/APP/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/APP/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/APP/server.py b/APP/server.py index 3cf9245..01c43cb 100644 --- a/APP/server.py +++ b/APP/server.py @@ -1,16 +1,24 @@ from flask import request, Flask, jsonify -import json -from flask_sqlalchemy import SQLAlchemy -from APP.view import collection, block from APP.view.auth import bp_auth from APP.view.block import bp_block +from APP.view.start import bp_start from APP.view.collection import bp_collection from APP.view.database import init_db +from flask_cors import * -app = Flask(__name__) +class CustomFlask(Flask): + + jinja_options = Flask.jinja_options.copy() + jinja_options.update(dict( + variable_start_string='%%', # Default is '{{', I'm changing this because Vue.js uses '{{' / '}}' + variable_end_string='%%', + )) +app = CustomFlask(__name__) +CORS(app, supports_credentials=True) app.register_blueprint(bp_auth) +app.register_blueprint(bp_start) app.register_blueprint(bp_block) app.register_blueprint(bp_collection) -init_db() +#init_db() app.run(debug=True) diff --git a/APP/static/js/wsy.js b/APP/static/js/wsy.js index a02f891..b71eed8 100644 --- a/APP/static/js/wsy.js +++ b/APP/static/js/wsy.js @@ -1,5 +1,26 @@ var url_prefix = "http://127.0.0.1:5000/"; + +var cookie = { + setCookie: function (name, value) { + document.cookie = name + '=' + value + ';'; + }, + getCookie: function (name) { + var arr = document.cookie.split('; '); + for (var i = 0; i < arr.length; i++) { + var arr2 = arr[i].split('='); + if (arr2[0] == name) { + return arr2[1]; + } + } + + return ''; + }, + removeCookie: function (name) { + cookie.setCookie(name, '', -1) + } + }; + function sendRequest(url_suffix, data, func) { var url = url_prefix + url_suffix; $.ajax({ @@ -218,7 +239,9 @@ var page = new Vue({ } }, jump_to: function (url, block_name, collection_id) { - window.location.href = url + "?name=" + block_name + "&id=" + collection_id; + cookie.setCookie('name',block_name); + cookie.setCookie('id',collection_id); + window.location.href = "/add"; }, edit: function (order, type) { var obj = this.textList[order] @@ -306,7 +329,9 @@ var recommend = new Vue({ }, methods: { jump_to: function (url, block_name) { - window.location.href = url + "?name=" + block_name + "&id=null"; + cookie.setCookie('name',block_name); + cookie.setCookie('id',null); + window.location.href = "%%url_for('"+url+"')%%"; }, like: function (order) { var obj = this.textList[order]; diff --git a/APP/templates/add.html b/APP/templates/add.html index a2db5b1..053ec1f 100644 --- a/APP/templates/add.html +++ b/APP/templates/add.html @@ -572,7 +572,8 @@ name: null }, created() { - this.name = GetRequest()['name']; + this.name = cookie.getCookie('name'); + page.id = cookie.getCookie('id'); console.log(this.name); }, } diff --git a/APP/templates/forget.html b/APP/templates/forget.html index 18c64df..1dd67ab 100644 --- a/APP/templates/forget.html +++ b/APP/templates/forget.html @@ -27,6 +27,9 @@ if(data.code == 1){ window.location = "login.html"; } + else{ + window.location = "forget.html"; + } }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status); diff --git a/APP/templates/login.html b/APP/templates/login.html index 1957ef5..b425b57 100644 --- a/APP/templates/login.html +++ b/APP/templates/login.html @@ -47,16 +47,16 @@ cookie.setCookie('phonenum', phonenum, 30); alert(data.msg); if(data.code != 1){ - window.location = "login.html"; + window.location = "%%url_for('start.login')%%"; }else{ - window.location = "personal.html"; + window.location = "%%url_for('start.personal')%%"; } }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status); alert(XMLHttpRequest.readyState); alert(textStatus); - window.location = "login.html"; + window.location = "%%url_for('start.login')%%"; } }); } @@ -83,8 +83,8 @@

- 立即注册 - 忘记密码 + 立即注册 + 忘记密码
diff --git a/APP/templates/personal.html b/APP/templates/personal.html index 2b73acf..8ca549c 100644 --- a/APP/templates/personal.html +++ b/APP/templates/personal.html @@ -423,14 +423,14 @@