diff --git a/README.md b/README.md index 39f69bd..64aa397 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,34 @@ 前端编程题挑战 +## 创建题目 + +在项目根目录下运行 + +```sh +pnpm qs:create <你的题目名> + +# 例如我创建 demo 题目 +pnpm qs:create demo +``` + +运行完之后会在 question/FrontEnd 目录下生成以下文件 + +- demo + - answer.md + - answer.mjs + - index.md + - index.mjs + - test.mjs + +## 将新添加的文件写入数据库 + +在项目根目录下运行 + +```sh +pnpm qs:generate +``` + ## 开发 前置条件 @@ -132,6 +160,12 @@ sql 结构文件在 /server/sql 下 pnpm i ``` +3. generate + +```sh +pnpm generate +``` + 3. 启动 ```sh diff --git a/client/.npmrc b/client/.npmrc new file mode 100644 index 0000000..0453efc --- /dev/null +++ b/client/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org \ No newline at end of file diff --git a/question/FrontEnd/cache.json b/question/FrontEnd/cache.json deleted file mode 100644 index aeeed7a..0000000 --- a/question/FrontEnd/cache.json +++ /dev/null @@ -1 +0,0 @@ -{"amountThousandthsFormat":"f1be069939db2f6677b73ff7a57cfb11e20c574b409a1755549a2adf84d0d879","deepClone":"cc3ded25433e3a3ec9cfb3cc36ca20ee5f161bc98935ee2c4fafaa75794892fa","deepMerge":"8d4e5060036a6331f5ce7235994615b04c0cd24182a6b030eb443f2efa8825f7","flatten":"76a30d04acdf5c9d72d9562dffee30f0812f4af7475ddff8dd4c51f53c054302","indexOf":"9367eaf8e0cdd40a39441e412069109deb763aefbbcfce26a813063ba579c38b","ipAddress":"ce4d1b975319224dbf28fd3161cc71287feb4cafa869b1472e956f5e42b31572","sort":"0726aad693538629bfd8145206aa8380e683b7559994bd794292d59bb0b29574","unique":"c6c4503f7f3995874ab07f60460f064f782b6d07ac8b70a47bd69826cf86f187","compose":"6767dc6b8a228a7e9eaaa4e8349b7ba5d2081d4ae1080692603d7ff52b01e936","curry":"e4823d48ff06235c1130d15295b7e6a64bac875f77adccd5895d6079f9c8a90b","flattenTree":"88a894bf835a36d1e6d02adbd09a7a95dee280364de7790678016e8daa31a85f"} \ No newline at end of file diff --git a/server/.npmrc b/server/.npmrc index f87a044..a648e23 100644 --- a/server/.npmrc +++ b/server/.npmrc @@ -1 +1,2 @@ -auto-install-peers=true \ No newline at end of file +auto-install-peers=true +registry=https://registry.npmjs.org \ No newline at end of file diff --git a/server/sql/runcode.sql b/server/sql/runcode.sql index 6a5eb95..e8f9a9e 100644 --- a/server/sql/runcode.sql +++ b/server/sql/runcode.sql @@ -1,58 +1,61 @@ /* Navicat Premium Data Transfer - Source Server : 107 + Source Server : 42 Source Server Type : MySQL - Source Server Version : 80031 - Source Host : 107.182.25.135:3306 + Source Server Version : 80030 (8.0.30) + Source Host : 42.193.148.96:3306 Source Schema : runcode Target Server Type : MySQL - Target Server Version : 80031 + Target Server Version : 80030 (8.0.30) File Encoding : 65001 - Date: 02/11/2022 01:02:39 + Date: 24/03/2023 15:36:32 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- --- Table structure for stat +-- Table structure for question -- ---------------------------- -DROP TABLE IF EXISTS `stat`; -CREATE TABLE `stat` ( +DROP TABLE IF EXISTS `question`; +CREATE TABLE `question` ( `id` int UNSIGNED NOT NULL AUTO_INCREMENT, - `ip` varchar(128) NOT NULL DEFAULT '' COMMENT 'ip address', - `userAgent` varchar(256) NOT NULL DEFAULT '' COMMENT '设备信息', - `country` varchar(128) NOT NULL DEFAULT '' COMMENT '国家', - `province` varchar(128) NOT NULL DEFAULT '' COMMENT '省', - `city` varchar(128) NOT NULL DEFAULT '' COMMENT '城市', - `isp` varchar(128) NOT NULL DEFAULT '' COMMENT '城市运营商', - `channel` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源渠道: 0: 自来, 1: v2ex, 2: 掘金, 3: tools.fun 4: github 5: google 6: baidu 7: bing', - `source` varchar(128) NOT NULL DEFAULT '' COMMENT '来源 referrer 字段, 未记录到来源则记录 referrer 用于 数据统计', + `type` int NOT NULL COMMENT '大分类', + `name` varchar(1280) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '题目名', + `introduce` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '简述', + `desc` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '详情', + `level` int UNSIGNED NOT NULL COMMENT '难度', + `template` varchar(1280) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '模板', + `test` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '测试文件', + `answermd` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '参考答案', + `answer` varchar(1280) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '答案', + `tag` int UNSIGNED NULL DEFAULT NULL COMMENT '标签', `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 0 COMMENT = '访问数据' ROW_FORMAT = Dynamic; +) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '题库' ROW_FORMAT = Dynamic; -- ---------------------------- --- Table structure for question +-- Table structure for stat -- ---------------------------- -DROP TABLE IF EXISTS `question`; -CREATE TABLE `question` ( +DROP TABLE IF EXISTS `stat`; +CREATE TABLE `stat` ( `id` int UNSIGNED NOT NULL AUTO_INCREMENT, - `type` int NOT NULL COMMENT '大分类', - `name` varchar(1280) NOT NULL COMMENT '题目名', - `introduce` varchar(1280) NOT NULL DEFAULT '' COMMENT '简述', - `desc` varchar(1280) NOT NULL DEFAULT '' COMMENT '详情', - `level` int UNSIGNED NOT NULL COMMENT '难度', - `template` varchar(1280) NOT NULL DEFAULT '' COMMENT '模板', - `test` varchar(1280) NOT NULL DEFAULT '' COMMENT '测试文件', - `answermd` varchar(1280) NOT NULL DEFAULT '' COMMENT '参考答案', - `answer` varchar(1280) NOT NULL DEFAULT '' COMMENT '答案', - `tag` int UNSIGNED COMMENT '标签', + `ip` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT 'ip address', + `userAgent` varchar(256) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '_utf8mb4\\\'\\\'' COMMENT '设备信息', + `country` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '国家', + `province` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '省', + `city` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '城市', + `isp` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '城市运营商', `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY(`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 0 COMMENT = '题库'; + `updatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `channel` int NOT NULL DEFAULT 0 COMMENT '来源渠道: 0: 自来, 1: v2ex, 2: 掘金, 3: tools.fun', + `source` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '来源 referrer 字段, 未记录到来源则记录 referrer 用于 数据统计', + `latestAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '最新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5471 CHARACTER SET = utf8mb3 COLLATE = utf8mb3_general_ci COMMENT = '访问数据' ROW_FORMAT = DYNAMIC; SET FOREIGN_KEY_CHECKS = 1;