Compare commits
5 Commits
v1.1
...
46f2d69800
| Author | SHA1 | Date | |
|---|---|---|---|
| 46f2d69800 | |||
| 24790d8e69 | |||
| 07205396c8 | |||
| 433c6cf2f8 | |||
| 37435eeb66 |
10
ROADMAP.md
Normal file
10
ROADMAP.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Roadmap
|
||||||
|
|
||||||
|
1. 前后端分离,将前端静态文件和后端Python分装到两个文件夹中。同时辅助类文件夹改换位置。
|
||||||
|
1. 后端使用Astral UV重构,使得项目可以跑起来。
|
||||||
|
1. 定为1.1版本。1.0版本也要打tag然后提交。然后分叉v1-maintain分支。后续在master上开发v2。
|
||||||
|
1. 后端数据库字段重命名。
|
||||||
|
1. 前后端通信API命名格式修改。
|
||||||
|
1. 使用Vue重写前端
|
||||||
|
1. 使用Tailwind重写前端CSS
|
||||||
|
1. 使用Go重写后端。
|
||||||
@@ -9,7 +9,7 @@ import utils
|
|||||||
import database
|
import database
|
||||||
|
|
||||||
|
|
||||||
def GetUsernamePassword():
|
def GetUsernamePassword() -> tuple[str, str]:
|
||||||
print("What is the first username of this calendar system?")
|
print("What is the first username of this calendar system?")
|
||||||
cache = input()
|
cache = input()
|
||||||
while not utils.IsValidUsername(cache):
|
while not utils.IsValidUsername(cache):
|
||||||
@@ -27,14 +27,19 @@ def GetUsernamePassword():
|
|||||||
return (username, password)
|
return (username, password)
|
||||||
|
|
||||||
|
|
||||||
|
def SetLoggingStyle(level: int) -> None:
|
||||||
|
logging.basicConfig(format="[%(levelname)s] %(message)s", level=level)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Coconut-leaf")
|
# Set as INFO level in default first,
|
||||||
print("A self-host, multi-account calendar system.")
|
# and we will change it once we load the configuration file.
|
||||||
print("Project: https://github.com/yyc12345/coconut-leaf")
|
SetLoggingStyle(logging.INFO)
|
||||||
print("===================")
|
|
||||||
|
|
||||||
# Receive arguments
|
# Receive arguments
|
||||||
parser = ArgumentParser(description="Coconut-leaf")
|
parser = ArgumentParser(
|
||||||
|
description="The server of light, self-host and multi-account calendar system."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--config",
|
"--config",
|
||||||
@@ -54,16 +59,22 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Show splash
|
||||||
|
logging.info("Coconut-leaf")
|
||||||
|
logging.info("A light, self-host and multi-account calendar system")
|
||||||
|
logging.info("Project: https://github.com/yyc12345/coconut-leaf")
|
||||||
|
logging.info("===================")
|
||||||
|
|
||||||
# Load config file
|
# Load config file
|
||||||
try:
|
try:
|
||||||
config.setup_config(cast(Path, args.config))
|
config.setup_config(cast(Path, args.config))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error loading config file: {e}")
|
logging.critical(f"Error loading config file: {e}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Setup logging level
|
# Change logging level again according to whether enable debug mode
|
||||||
logging_level = logging.DEBUG if config.get_config().others.debug else logging.INFO
|
logging_level = logging.DEBUG if config.get_config().others.debug else logging.INFO
|
||||||
logging.basicConfig(format='[%(levelname)s] %(message)s', level=logging_level)
|
SetLoggingStyle(logging_level)
|
||||||
|
|
||||||
# Initialize the calendar system if needed
|
# Initialize the calendar system if needed
|
||||||
if cast(bool, args.init):
|
if cast(bool, args.init):
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ path = "coconut-leaf.db"
|
|||||||
# database = "coconut_leaf"
|
# database = "coconut_leaf"
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
port = 8888
|
port = 8848
|
||||||
|
|
||||||
[others]
|
[others]
|
||||||
auto-token-clean-duration = 86400
|
auto-token-clean-duration = 86400
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"database-type": "sqlite",
|
|
||||||
"database-config": {
|
|
||||||
"user": "",
|
|
||||||
"password": "",
|
|
||||||
"db": "",
|
|
||||||
"url": "",
|
|
||||||
"port": 3306
|
|
||||||
},
|
|
||||||
"web": {
|
|
||||||
"port": 8888
|
|
||||||
},
|
|
||||||
"debug": true
|
|
||||||
}
|
|
||||||
@@ -1,107 +1,23 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
# from flask import g
|
|
||||||
from flask import render_template
|
|
||||||
from flask import url_for
|
|
||||||
from flask import request
|
from flask import request
|
||||||
# from flask import abort
|
|
||||||
from flask import redirect
|
|
||||||
|
|
||||||
# from functools import reduce
|
|
||||||
# import json
|
|
||||||
# import os
|
|
||||||
|
|
||||||
import config
|
import config
|
||||||
import database
|
import database
|
||||||
import utils
|
import utils
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
_FRONTEND_PATH = Path(__file__).resolve().parent.parent / "frontend"
|
app = Flask(__name__)
|
||||||
app = Flask(
|
|
||||||
__name__,
|
|
||||||
static_folder=_FRONTEND_PATH / "static",
|
|
||||||
template_folder=_FRONTEND_PATH / "templates",
|
|
||||||
)
|
|
||||||
calendar_db = database.CalendarDatabase()
|
calendar_db = database.CalendarDatabase()
|
||||||
|
|
||||||
# render_static_resources = None
|
# region: API Route
|
||||||
|
|
||||||
# =============================================database
|
# region: Common
|
||||||
|
|
||||||
# def get_database():
|
@app.route('/common/salt', methods=['POST'])
|
||||||
# db = getattr(g, '_database', None)
|
|
||||||
# if db is None:
|
|
||||||
# db = database.CalendarDatabase()
|
|
||||||
# db.open()
|
|
||||||
# return db
|
|
||||||
|
|
||||||
# @app.teardown_appcontext
|
|
||||||
# def close_database(exception):
|
|
||||||
# db = getattr(g, '_database', None)
|
|
||||||
# if db is not None:
|
|
||||||
# db.close()
|
|
||||||
|
|
||||||
|
|
||||||
# ============================================= static page route
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET'])
|
|
||||||
def nospecHandle():
|
|
||||||
return redirect(url_for('web_homeHandle'))
|
|
||||||
|
|
||||||
@app.route('/web/home', methods=['GET'])
|
|
||||||
def web_homeHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("home.html")
|
|
||||||
|
|
||||||
@app.route('/web/calendar', methods=['GET'])
|
|
||||||
def web_calendarHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("calendar.html")
|
|
||||||
|
|
||||||
@app.route('/web/todo', methods=['GET'])
|
|
||||||
def web_todoHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("todo.html")
|
|
||||||
|
|
||||||
@app.route('/web/admin', methods=['GET'])
|
|
||||||
def web_adminHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("admin.html")
|
|
||||||
|
|
||||||
@app.route('/web/login', methods=['GET'])
|
|
||||||
def web_loginHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("login.html")
|
|
||||||
|
|
||||||
@app.route('/web/collection', methods=['GET'])
|
|
||||||
def web_collectionHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("collection.html")
|
|
||||||
|
|
||||||
@app.route('/web/eventAdd', methods=['GET'])
|
|
||||||
def web_eventAddHandle():
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("event.html",
|
|
||||||
uuidPath=''
|
|
||||||
)
|
|
||||||
|
|
||||||
@app.route('/web/eventUpdate/<path:uuidPath>', methods=['GET'])
|
|
||||||
def web_eventUpdateHandle(uuidPath):
|
|
||||||
# UpdateStaticResources()
|
|
||||||
return render_template("event.html",
|
|
||||||
uuidPath = uuidPath
|
|
||||||
)
|
|
||||||
|
|
||||||
# ============================================= query page route
|
|
||||||
|
|
||||||
# ================================ common
|
|
||||||
|
|
||||||
@app.route('/api/common/salt', methods=['POST'])
|
|
||||||
def api_common_saltHandle():
|
def api_common_saltHandle():
|
||||||
return SmartDbCaller(calendar_db.common_salt,
|
return SmartDbCaller(calendar_db.common_salt,
|
||||||
(('username', str, False), ),
|
(('username', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/common/login', methods=['POST'])
|
@app.route('/common/login', methods=['POST'])
|
||||||
def api_common_loginHandle():
|
def api_common_loginHandle():
|
||||||
# construct client data first
|
# construct client data first
|
||||||
clientUa = request.user_agent.string
|
clientUa = request.user_agent.string
|
||||||
@@ -120,7 +36,7 @@ def api_common_loginHandle():
|
|||||||
'clientIp': clientIp
|
'clientIp': clientIp
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.route('/api/common/webLogin', methods=['POST'])
|
@app.route('/common/webLogin', methods=['POST'])
|
||||||
def api_common_webLoginHandle():
|
def api_common_webLoginHandle():
|
||||||
# construct client data first
|
# construct client data first
|
||||||
clientUa = request.user_agent.string
|
clientUa = request.user_agent.string
|
||||||
@@ -139,21 +55,23 @@ def api_common_webLoginHandle():
|
|||||||
'clientIp': clientIp
|
'clientIp': clientIp
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.route('/api/common/logout', methods=['POST'])
|
@app.route('/common/logout', methods=['POST'])
|
||||||
def api_common_logoutHandle():
|
def api_common_logoutHandle():
|
||||||
return SmartDbCaller(calendar_db.common_logout,
|
return SmartDbCaller(calendar_db.common_logout,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/common/tokenValid', methods=['POST'])
|
@app.route('/common/tokenValid', methods=['POST'])
|
||||||
def api_common_tokenValidHandle():
|
def api_common_tokenValidHandle():
|
||||||
return SmartDbCaller(calendar_db.common_tokenValid,
|
return SmartDbCaller(calendar_db.common_tokenValid,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# ================================ calendar
|
# endregion
|
||||||
|
|
||||||
@app.route('/api/calendar/getFull', methods=['POST'])
|
# region: Calendar
|
||||||
|
|
||||||
|
@app.route('/calendar/getFull', methods=['POST'])
|
||||||
def api_calendar_getFullHandle():
|
def api_calendar_getFullHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_getFull,
|
return SmartDbCaller(calendar_db.calendar_getFull,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -161,7 +79,7 @@ def api_calendar_getFullHandle():
|
|||||||
('endDateTime', int, False)),
|
('endDateTime', int, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/calendar/getList', methods=['POST'])
|
@app.route('/calendar/getList', methods=['POST'])
|
||||||
def api_calendar_getListHandle():
|
def api_calendar_getListHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_getList,
|
return SmartDbCaller(calendar_db.calendar_getList,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -169,14 +87,14 @@ def api_calendar_getListHandle():
|
|||||||
('endDateTime', int, False)),
|
('endDateTime', int, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/calendar/getDetail', methods=['POST'])
|
@app.route('/calendar/getDetail', methods=['POST'])
|
||||||
def api_calendar_getDetailHandle():
|
def api_calendar_getDetailHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_getDetail,
|
return SmartDbCaller(calendar_db.calendar_getDetail,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('uuid', str, False)),
|
('uuid', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/calendar/update', methods=['POST'])
|
@app.route('/calendar/update', methods=['POST'])
|
||||||
def api_calendar_updateHandle():
|
def api_calendar_updateHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_update,
|
return SmartDbCaller(calendar_db.calendar_update,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -191,7 +109,7 @@ def api_calendar_updateHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/calendar/add', methods=['POST'])
|
@app.route('/calendar/add', methods=['POST'])
|
||||||
def api_calendar_addHandle():
|
def api_calendar_addHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_add,
|
return SmartDbCaller(calendar_db.calendar_add,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -204,7 +122,7 @@ def api_calendar_addHandle():
|
|||||||
('timezoneOffset', int, False)),
|
('timezoneOffset', int, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/calendar/delete', methods=['POST'])
|
@app.route('/calendar/delete', methods=['POST'])
|
||||||
def api_calendar_deleteHandle():
|
def api_calendar_deleteHandle():
|
||||||
return SmartDbCaller(calendar_db.calendar_delete,
|
return SmartDbCaller(calendar_db.calendar_delete,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -212,35 +130,37 @@ def api_calendar_deleteHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# ================================ collection
|
# endregion
|
||||||
|
|
||||||
@app.route('/api/collection/getFullOwn', methods=['POST'])
|
# region: Collection
|
||||||
|
|
||||||
|
@app.route('/collection/getFullOwn', methods=['POST'])
|
||||||
def api_collection_getFullOwnHandle():
|
def api_collection_getFullOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_getFullOwn,
|
return SmartDbCaller(calendar_db.collection_getFullOwn,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/getListOwn', methods=['POST'])
|
@app.route('/collection/getListOwn', methods=['POST'])
|
||||||
def api_collection_getListOwnHandle():
|
def api_collection_getListOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_getListOwn,
|
return SmartDbCaller(calendar_db.collection_getListOwn,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/getDetailOwn', methods=['POST'])
|
@app.route('/collection/getDetailOwn', methods=['POST'])
|
||||||
def api_collection_getDetailOwnHandle():
|
def api_collection_getDetailOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_getDetailOwn,
|
return SmartDbCaller(calendar_db.collection_getDetailOwn,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('uuid', str, False)),
|
('uuid', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/addOwn', methods=['POST'])
|
@app.route('/collection/addOwn', methods=['POST'])
|
||||||
def api_collection_addOwnHandle():
|
def api_collection_addOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_addOwn,
|
return SmartDbCaller(calendar_db.collection_addOwn,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('name', str, False)),
|
('name', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/updateOwn', methods=['POST'])
|
@app.route('/collection/updateOwn', methods=['POST'])
|
||||||
def api_collection_updateOwnHandle():
|
def api_collection_updateOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_updateOwn,
|
return SmartDbCaller(calendar_db.collection_updateOwn,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -249,7 +169,7 @@ def api_collection_updateOwnHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/deleteOwn', methods=['POST'])
|
@app.route('/collection/deleteOwn', methods=['POST'])
|
||||||
def api_collection_deleteOwnHandle():
|
def api_collection_deleteOwnHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_deleteOwn,
|
return SmartDbCaller(calendar_db.collection_deleteOwn,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -258,14 +178,14 @@ def api_collection_deleteOwnHandle():
|
|||||||
None)
|
None)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/collection/getSharing', methods=['POST'])
|
@app.route('/collection/getSharing', methods=['POST'])
|
||||||
def api_collection_getSharingHandle():
|
def api_collection_getSharingHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_getSharing,
|
return SmartDbCaller(calendar_db.collection_getSharing,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('uuid', str, False)),
|
('uuid', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/deleteSharing', methods=['POST'])
|
@app.route('/collection/deleteSharing', methods=['POST'])
|
||||||
def api_collection_deleteSharingHandle():
|
def api_collection_deleteSharingHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_deleteSharing,
|
return SmartDbCaller(calendar_db.collection_deleteSharing,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -274,7 +194,7 @@ def api_collection_deleteSharingHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/collection/addSharing', methods=['POST'])
|
@app.route('/collection/addSharing', methods=['POST'])
|
||||||
def api_collection_addSharingHandle():
|
def api_collection_addSharingHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_addSharing,
|
return SmartDbCaller(calendar_db.collection_addSharing,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -284,40 +204,42 @@ def api_collection_addSharingHandle():
|
|||||||
None)
|
None)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/collection/getShared', methods=['POST'])
|
@app.route('/collection/getShared', methods=['POST'])
|
||||||
def api_collection_getSharedHandle():
|
def api_collection_getSharedHandle():
|
||||||
return SmartDbCaller(calendar_db.collection_getShared,
|
return SmartDbCaller(calendar_db.collection_getShared,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# ================================ todo
|
# endregion
|
||||||
|
|
||||||
@app.route('/api/todo/getFull', methods=['POST'])
|
# region: Todo
|
||||||
|
|
||||||
|
@app.route('/todo/getFull', methods=['POST'])
|
||||||
def api_todo_getFullHandle():
|
def api_todo_getFullHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getFull,
|
return SmartDbCaller(calendar_db.todo_getFull,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/todo/getList', methods=['POST'])
|
@app.route('/todo/getList', methods=['POST'])
|
||||||
def api_todo_getListHandle():
|
def api_todo_getListHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getList,
|
return SmartDbCaller(calendar_db.todo_getList,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/todo/getDetail', methods=['POST'])
|
@app.route('/todo/getDetail', methods=['POST'])
|
||||||
def api_todo_getDetailHandle():
|
def api_todo_getDetailHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_getDetail,
|
return SmartDbCaller(calendar_db.todo_getDetail,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('uuid', str, False)),
|
('uuid', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/todo/add', methods=['POST'])
|
@app.route('/todo/add', methods=['POST'])
|
||||||
def api_todo_addHandle():
|
def api_todo_addHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_add,
|
return SmartDbCaller(calendar_db.todo_add,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/todo/update', methods=['POST'])
|
@app.route('/todo/update', methods=['POST'])
|
||||||
def api_todo_updateHandle():
|
def api_todo_updateHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_update,
|
return SmartDbCaller(calendar_db.todo_update,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -326,7 +248,7 @@ def api_todo_updateHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/todo/delete', methods=['POST'])
|
@app.route('/todo/delete', methods=['POST'])
|
||||||
def api_todo_deleteHandle():
|
def api_todo_deleteHandle():
|
||||||
return SmartDbCaller(calendar_db.todo_delete,
|
return SmartDbCaller(calendar_db.todo_delete,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -334,22 +256,24 @@ def api_todo_deleteHandle():
|
|||||||
('lastChange', str, False)),
|
('lastChange', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# ================================ admin
|
# endregion
|
||||||
|
|
||||||
@app.route('/api/admin/get', methods=['POST'])
|
# region: Admin
|
||||||
|
|
||||||
|
@app.route('/admin/get', methods=['POST'])
|
||||||
def api_admin_getHandle():
|
def api_admin_getHandle():
|
||||||
return SmartDbCaller(calendar_db.admin_get,
|
return SmartDbCaller(calendar_db.admin_get,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/admin/add', methods=['POST'])
|
@app.route('/admin/add', methods=['POST'])
|
||||||
def api_admin_addHandle():
|
def api_admin_addHandle():
|
||||||
return SmartDbCaller(calendar_db.admin_add,
|
return SmartDbCaller(calendar_db.admin_add,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('username', str, False)),
|
('username', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/admin/update', methods=['POST'])
|
@app.route('/admin/update', methods=['POST'])
|
||||||
def api_admin_updateHandle():
|
def api_admin_updateHandle():
|
||||||
return SmartDbCaller(calendar_db.admin_update,
|
return SmartDbCaller(calendar_db.admin_update,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
@@ -358,60 +282,48 @@ def api_admin_updateHandle():
|
|||||||
('isAdmin', utils.Str2Bool, True)),
|
('isAdmin', utils.Str2Bool, True)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/admin/delete', methods=['POST'])
|
@app.route('/admin/delete', methods=['POST'])
|
||||||
def api_admin_deleteHandle():
|
def api_admin_deleteHandle():
|
||||||
return SmartDbCaller(calendar_db.admin_delete,
|
return SmartDbCaller(calendar_db.admin_delete,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('username', str, False)),
|
('username', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# ================================ profile
|
# endregion
|
||||||
|
|
||||||
@app.route('/api/profile/isAdmin', methods=['POST'])
|
# region: Profile
|
||||||
|
|
||||||
|
@app.route('/profile/isAdmin', methods=['POST'])
|
||||||
def api_profile_isAdminHandle():
|
def api_profile_isAdminHandle():
|
||||||
return SmartDbCaller(calendar_db.profile_isAdmin,
|
return SmartDbCaller(calendar_db.profile_isAdmin,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/profile/changePassword', methods=['POST'])
|
@app.route('/profile/changePassword', methods=['POST'])
|
||||||
def api_profile_changePasswordHandle():
|
def api_profile_changePasswordHandle():
|
||||||
return SmartDbCaller(calendar_db.profile_changePassword,
|
return SmartDbCaller(calendar_db.profile_changePassword,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('password', str, False)),
|
('password', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/profile/getToken', methods=['POST'])
|
@app.route('/profile/getToken', methods=['POST'])
|
||||||
def api_profile_getTokenHandle():
|
def api_profile_getTokenHandle():
|
||||||
return SmartDbCaller(calendar_db.profile_getToken,
|
return SmartDbCaller(calendar_db.profile_getToken,
|
||||||
(('token', str, False), ),
|
(('token', str, False), ),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
@app.route('/api/profile/deleteToken', methods=['POST'])
|
@app.route('/profile/deleteToken', methods=['POST'])
|
||||||
def api_profile_deleteTokenHandle():
|
def api_profile_deleteTokenHandle():
|
||||||
return SmartDbCaller(calendar_db.profile_deleteToken,
|
return SmartDbCaller(calendar_db.profile_deleteToken,
|
||||||
(('token', str, False),
|
(('token', str, False),
|
||||||
('deleteToken', str, False)),
|
('deleteToken', str, False)),
|
||||||
None)
|
None)
|
||||||
|
|
||||||
# =============================================main run
|
# endregion
|
||||||
|
|
||||||
'''
|
# endregion
|
||||||
def UpdateStaticResources():
|
|
||||||
global render_static_resources
|
|
||||||
if render_static_resources is not None:
|
|
||||||
return
|
|
||||||
|
|
||||||
render_static_resources = {
|
# region: Misc Functions
|
||||||
'url_js_localStorageAssist': url_for('static', filename='js/localStorageAssist.js'),
|
|
||||||
'url_js_i18n': url_for('static', filename='js/i18n.js'),
|
|
||||||
'url_js_api': url_for('static', filename='js/api.js'),
|
|
||||||
'url_js_headerNav': url_for('static', filename='js/headerNav.js'),
|
|
||||||
|
|
||||||
'url_tmpl_headerNac': url_for('static', filename='tmpl/headerNav.tmpl'),
|
|
||||||
|
|
||||||
'url_js_pageHome': url_for('static', filename='js/page/home.js')
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
def SmartDbCaller(dbMethod, paramTuple, extraDict):
|
def SmartDbCaller(dbMethod, paramTuple, extraDict):
|
||||||
result = (False, 'Invalid parameter', None)
|
result = (False, 'Invalid parameter', None)
|
||||||
@@ -454,4 +366,5 @@ def run():
|
|||||||
calendar_db.open()
|
calendar_db.open()
|
||||||
app.run(port=config.get_config().web.port)
|
app.run(port=config.get_config().web.port)
|
||||||
calendar_db.close()
|
calendar_db.close()
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|||||||
8
frontend/.editorconfig
Normal file
8
frontend/.editorconfig
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue,css,scss,sass,less,styl}]
|
||||||
|
charset = utf-8
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
max_line_length = 100
|
||||||
1
frontend/.gitattributes
vendored
Normal file
1
frontend/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
39
frontend/.gitignore
vendored
Normal file
39
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Cypress
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Vitest
|
||||||
|
__screenshots__/
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
*.timestamp-*-*.mjs
|
||||||
10
frontend/.oxlintrc.json
Normal file
10
frontend/.oxlintrc.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"$schema": "./node_modules/oxlint/configuration_schema.json",
|
||||||
|
"plugins": ["eslint", "typescript", "unicorn", "oxc", "vue"],
|
||||||
|
"env": {
|
||||||
|
"browser": true
|
||||||
|
},
|
||||||
|
"categories": {
|
||||||
|
"correctness": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
48
frontend/README.md
Normal file
48
frontend/README.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# coleaf-frontend
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
||||||
|
|
||||||
|
## Recommended Browser Setup
|
||||||
|
|
||||||
|
- Chromium-based browsers (Chrome, Edge, Brave, etc.):
|
||||||
|
- [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
|
||||||
|
- [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
|
||||||
|
- Firefox:
|
||||||
|
- [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
|
||||||
|
- [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
|
||||||
|
|
||||||
|
## Type Support for `.vue` Imports in TS
|
||||||
|
|
||||||
|
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
||||||
|
|
||||||
|
## Customize configuration
|
||||||
|
|
||||||
|
See [Vite Configuration Reference](https://vite.dev/config/).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type-Check, Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint with [ESLint](https://eslint.org/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm lint
|
||||||
|
```
|
||||||
1
frontend/env.d.ts
vendored
Normal file
1
frontend/env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
23
frontend/eslint.config.ts
Normal file
23
frontend/eslint.config.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { globalIgnores } from 'eslint/config'
|
||||||
|
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
||||||
|
import pluginVue from 'eslint-plugin-vue'
|
||||||
|
import pluginOxlint from 'eslint-plugin-oxlint'
|
||||||
|
|
||||||
|
// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
||||||
|
// import { configureVueProject } from '@vue/eslint-config-typescript'
|
||||||
|
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
||||||
|
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
||||||
|
|
||||||
|
export default defineConfigWithVueTs(
|
||||||
|
{
|
||||||
|
name: 'app/files-to-lint',
|
||||||
|
files: ['**/*.{vue,ts,mts,tsx}'],
|
||||||
|
},
|
||||||
|
|
||||||
|
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
||||||
|
|
||||||
|
...pluginVue.configs['flat/essential'],
|
||||||
|
vueTsConfigs.recommended,
|
||||||
|
|
||||||
|
...pluginOxlint.buildFromOxlintConfigFile('.oxlintrc.json'),
|
||||||
|
)
|
||||||
16
frontend/index.html
Normal file
16
frontend/index.html
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>coconut-leaf</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
44
frontend/package.json
Normal file
44
frontend/package.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "coleaf-frontend",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build",
|
||||||
|
"lint": "run-s lint:*",
|
||||||
|
"lint:oxlint": "oxlint . --fix",
|
||||||
|
"lint:eslint": "eslint . --fix --cache"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-free": "^7.2.0",
|
||||||
|
"@fortawesome/vue-fontawesome": "^3.2.0",
|
||||||
|
"bulma": "^1.0.4",
|
||||||
|
"pinia": "^3.0.4",
|
||||||
|
"vue": "^3.5.32",
|
||||||
|
"vue-router": "^5.0.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tsconfig/node24": "^24.0.4",
|
||||||
|
"@types/node": "^24.12.2",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.6",
|
||||||
|
"@vue/eslint-config-typescript": "^14.7.0",
|
||||||
|
"@vue/tsconfig": "^0.9.1",
|
||||||
|
"eslint": "^10.2.1",
|
||||||
|
"eslint-plugin-oxlint": "~1.60.0",
|
||||||
|
"eslint-plugin-vue": "~10.8.0",
|
||||||
|
"jiti": "^2.6.1",
|
||||||
|
"npm-run-all2": "^8.0.4",
|
||||||
|
"oxlint": "~1.60.0",
|
||||||
|
"typescript": "~6.0.0",
|
||||||
|
"vite": "^8.0.8",
|
||||||
|
"vite-plugin-vue-devtools": "^8.1.1",
|
||||||
|
"vue-tsc": "^3.2.6"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
3168
frontend/pnpm-lock.yaml
generated
Normal file
3168
frontend/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
BIN
frontend/public/favicon.ico
Normal file
BIN
frontend/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
0
frontend/public/index.css
Normal file
0
frontend/public/index.css
Normal file
49
frontend/src/App.vue
Normal file
49
frontend/src/App.vue
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<nav class="navbar has-shadow is-spaced bd-navbar" role="navigation" aria-label="main navigation">
|
||||||
|
<div class="navbar-brand">
|
||||||
|
<router-link class="navbar-item" to="/">
|
||||||
|
<img src="/public/favicon.ico"><b style="margin:0 0 0 14px;">coconut-leaf</b>
|
||||||
|
</router-link>
|
||||||
|
|
||||||
|
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false"
|
||||||
|
data-target="coleaf-navbar">
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
<span aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="coleaf-navbar" class="navbar-menu">
|
||||||
|
<div class="navbar-start">
|
||||||
|
<router-link class="navbar-item" to="/home">Home</router-link>
|
||||||
|
<router-link class="navbar-item" to="/collection">Collection</router-link>
|
||||||
|
<router-link class="navbar-item" to="/calendar">Calendar</router-link>
|
||||||
|
<router-link class="navbar-item" to="/todo">Todo</router-link>
|
||||||
|
<router-link class="navbar-item" to="/admin">Admin</router-link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="navbar-end">
|
||||||
|
<p class="navbar-item">
|
||||||
|
<a class="button is-primary" href="/login">Login</a>
|
||||||
|
</p>
|
||||||
|
<p class="navbar-item">
|
||||||
|
<a class="button is-primary">Logout</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
|
<a class="navbar-link"></a>
|
||||||
|
<div class="navbar-dropdown">
|
||||||
|
<a language="en-US" class="navbar-item">English</a>
|
||||||
|
<a language="zh-CN" class="navbar-item">简体中文</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<!-- The output result of router -->
|
||||||
|
<router-view></router-view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
12
frontend/src/main.ts
Normal file
12
frontend/src/main.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router'
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(createPinia())
|
||||||
|
app.use(router)
|
||||||
|
|
||||||
|
app.mount('#app')
|
||||||
29
frontend/src/router/index.ts
Normal file
29
frontend/src/router/index.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
|
|
||||||
|
import Home from '../views/Home.vue'
|
||||||
|
import Collection from '@/views/Collection.vue'
|
||||||
|
import Calendar from '@/views/Calendar.vue'
|
||||||
|
import Todo from '@/views/Todo.vue'
|
||||||
|
import Admin from '@/views/Admin.vue'
|
||||||
|
|
||||||
|
import Page404 from '@/views/Page404.vue'
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{ path: '/home', component: Home },
|
||||||
|
{ path: '/collection', component: Collection },
|
||||||
|
{ path: '/calendar', component: Calendar},
|
||||||
|
{ path: '/todo', component: Todo},
|
||||||
|
{ path: '/admin', component: Admin },
|
||||||
|
|
||||||
|
{ path: '/404', component: Page404 },
|
||||||
|
|
||||||
|
{ path: '/', redirect: '/home' },
|
||||||
|
{ path: '/:pathMatch(.*)*', redirect: '/404' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
routes: routes,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router
|
||||||
12
frontend/src/stores/counter.ts
Normal file
12
frontend/src/stores/counter.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useCounterStore = defineStore('counter', () => {
|
||||||
|
const count = ref(0)
|
||||||
|
const doubleCount = computed(() => count.value * 2)
|
||||||
|
function increment() {
|
||||||
|
count.value++
|
||||||
|
}
|
||||||
|
|
||||||
|
return { count, doubleCount, increment }
|
||||||
|
})
|
||||||
8
frontend/src/views/Admin.vue
Normal file
8
frontend/src/views/Admin.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>This is admin.</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
8
frontend/src/views/Calendar.vue
Normal file
8
frontend/src/views/Calendar.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>This is calendar.</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
8
frontend/src/views/Collection.vue
Normal file
8
frontend/src/views/Collection.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>This is collection.</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
8
frontend/src/views/Home.vue
Normal file
8
frontend/src/views/Home.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>This is home.</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
8
frontend/src/views/Page404.vue
Normal file
8
frontend/src/views/Page404.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>404 Not Found</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
8
frontend/src/views/Todo.vue
Normal file
8
frontend/src/views/Todo.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h1>Congratulations</h1>
|
||||||
|
<p>This is todo.</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
18
frontend/tsconfig.app.json
Normal file
18
frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
|
"exclude": ["src/**/__tests__/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
// Extra safety for array and object lookups, but may have false positives.
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
|
||||||
|
// Path mapping for cleaner imports.
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
},
|
||||||
|
|
||||||
|
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
||||||
|
// Specified here to keep it out of the root directory.
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
frontend/tsconfig.json
Normal file
11
frontend/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
27
frontend/tsconfig.node.json
Normal file
27
frontend/tsconfig.node.json
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
|
||||||
|
{
|
||||||
|
"extends": "@tsconfig/node24/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"vite.config.*",
|
||||||
|
"vitest.config.*",
|
||||||
|
"cypress.config.*",
|
||||||
|
"playwright.config.*",
|
||||||
|
"eslint.config.*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
// Most tools use transpilation instead of Node.js's native type-stripping.
|
||||||
|
// Bundler mode provides a smoother developer experience.
|
||||||
|
"module": "preserve",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
|
||||||
|
// Include Node.js types and avoid accidentally including other `@types/*` packages.
|
||||||
|
"types": ["node"],
|
||||||
|
|
||||||
|
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
||||||
|
// Specified here to keep it out of the root directory.
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
37
frontend/vite.config.ts
Normal file
37
frontend/vite.config.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
// https://vite.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
vueDevTools(),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// 项目基础路径(对应 Nginx 路由到的 /web 前缀)
|
||||||
|
base: '/web/',
|
||||||
|
|
||||||
|
server: {
|
||||||
|
port: 5173, // 开发服务器默认端口
|
||||||
|
open: '/web/', // 启动时自动打开 /web 路径
|
||||||
|
|
||||||
|
// 核心:代理配置(对应 Nginx 的 /api -> Go 服务)
|
||||||
|
proxy: {
|
||||||
|
// 精细控制路由,对齐生产环境
|
||||||
|
'^/api/(.*)$': {
|
||||||
|
target: 'http://127.0.0.1:8848',
|
||||||
|
changeOrigin: true,
|
||||||
|
// 路径重写/api/user -> /user
|
||||||
|
rewrite: (path) => path.replace(/^\/api\//, '/'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
})
|
||||||
61
tools/.nginx.conf
Normal file
61
tools/.nginx.conf
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# ============================
|
||||||
|
# 路由 1: /web -> 静态文件
|
||||||
|
# ============================
|
||||||
|
location /web {
|
||||||
|
# 使用 alias 精确映射
|
||||||
|
# 请求 /web/index.html -> /var/www/static/index.html
|
||||||
|
alias /var/www/static;
|
||||||
|
|
||||||
|
# 静态文件优化
|
||||||
|
expires 7d;
|
||||||
|
add_header Cache-Control "public, max-age=604800";
|
||||||
|
|
||||||
|
# 尝试返回文件,不存在则返回404(避免落入其他location)
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
|
||||||
|
# 可选:启用 gzip 压缩
|
||||||
|
gzip_static on;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================
|
||||||
|
# 路由 2: /api -> Go 程序 (8848端口)
|
||||||
|
# ============================
|
||||||
|
location /api {
|
||||||
|
# 反向代理到本地 Go 服务
|
||||||
|
proxy_pass http://127.0.0.1:8848;
|
||||||
|
|
||||||
|
# 重要:保留原始请求头
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
# WebSocket 支持(如果 Go 程序需要)
|
||||||
|
# proxy_http_version 1.1;
|
||||||
|
# proxy_set_header Upgrade $http_upgrade;
|
||||||
|
# proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
# 超时设置(根据业务调整)
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_send_timeout 60s;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
|
||||||
|
# 缓冲设置(可选,大文件上传时注意调整)
|
||||||
|
proxy_buffering on;
|
||||||
|
proxy_buffer_size 4k;
|
||||||
|
proxy_buffers 8 4k;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ============================
|
||||||
|
# 可选:根路径处理
|
||||||
|
# ============================
|
||||||
|
location = / {
|
||||||
|
# 重定向到 /web
|
||||||
|
return 302 /web/;
|
||||||
|
}
|
||||||
|
|
||||||
|
# 禁止访问隐藏文件
|
||||||
|
location ~ /\. {
|
||||||
|
deny all;
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user