diff --git a/.env_1.development b/.env_1.development new file mode 100644 index 0000000..57ed20d --- /dev/null +++ b/.env_1.development @@ -0,0 +1,4 @@ +# 变量必须以 VITE_ 为前缀才能暴露给外部读取 +NODE_ENV = 'development' +VITE_APP_TITLE = '无糖运营平台' +VITE_APP_BASE_API = '/api' \ No newline at end of file diff --git a/.env_1.production b/.env_1.production new file mode 100644 index 0000000..141fffa --- /dev/null +++ b/.env_1.production @@ -0,0 +1,3 @@ +NODE_ENV = 'production' +VITE_APP_TITLE = '无糖运营平台' +VITE_APP_BASE_API = '/prod-api' \ No newline at end of file diff --git a/.env_1.test b/.env_1.test new file mode 100644 index 0000000..536fa85 --- /dev/null +++ b/.env_1.test @@ -0,0 +1,4 @@ + # 变量必须以 VITE_ 为前缀才能暴露给外部读取 +NODE_ENV = 'test' +VITE_APP_TITLE = '无糖运营平台' +VITE_APP_BASE_API = '/test-api' \ No newline at end of file diff --git a/.eslintrc_1.cjs b/.eslintrc_1.cjs new file mode 100644 index 0000000..1f95324 --- /dev/null +++ b/.eslintrc_1.cjs @@ -0,0 +1,65 @@ +// @see https://eslint.bootcss.com/docs/rules/ + +module.exports = { + env: { + browser: true, + es2021: true, + node: true, + jest: true, + }, + globals: { + VANTA: 'readonly', //VANTA 已经cdn引入 这里拒绝eslint报错 全局声明一下 + ElMessage: 'readonly', + ElMessageBox: 'readonly', + ElLoading: 'readonly', + }, + /* 指定如何解析语法 */ + parser: 'vue-eslint-parser', + /** 优先级低于 parse 的语法解析配置 */ + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + parser: '@typescript-eslint/parser', + jsxPragma: 'React', + ecmaFeatures: { + jsx: true, + }, + }, + /* 继承已有的规则 */ + extends: [ + 'eslint:recommended', + 'plugin:vue/vue3-essential', + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + plugins: ['vue', '@typescript-eslint'], + /* + * "off" 或 0 ==> 关闭规则 + * "warn" 或 1 ==> 打开的规则作为警告(不影响代码执行) + * "error" 或 2 ==> 规则作为一个错误(代码不能执行,界面报错) + */ + rules: { + // eslint(https://eslint.bootcss.com/docs/rules/) + 'no-var': 'error', // 要求使用 let 或 const 而不是 var + 'no-multiple-empty-lines': ['warn', { max: 1 }], // 不允许多个空行 + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-unexpected-multiline': 'error', // 禁止空余的多行 + 'no-useless-escape': 'off', // 禁止不必要的转义字符 + + // typeScript (https://typescript-eslint.io/rules) + '@typescript-eslint/no-unused-vars': 'error', // 禁止定义未使用的变量 + '@typescript-eslint/prefer-ts-expect-error': 'off', // 禁止使用 @ts-ignore + '@typescript-eslint/ban-ts-ignore': 'off', + '@typescript-eslint/no-explicit-any': 'off', // 禁止使用 any 类型 + '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-namespace': 'off', // 禁止使用自定义 TypeScript 模块和命名空间。 + '@typescript-eslint/semi': 'off', + + // eslint-plugin-vue (https://eslint.vuejs.org/rules/) + 'vue/multi-word-component-names': 'off', // 要求组件名称始终为 “-” 链接的单词 + 'vue/script-setup-uses-vars': 'error', // 防止 + + + + diff --git a/mock/user_1.ts b/mock/user_1.ts new file mode 100644 index 0000000..f039b1b --- /dev/null +++ b/mock/user_1.ts @@ -0,0 +1,69 @@ +//用户信息数据 +function createUserList() { + return [ + { + userId: 1, + avatar: + 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', + username: 'admin', + password: '111111', + desc: '平台管理员', + roles: ['平台管理员'], + buttons: ['cuser.detail'], + routes: ['Home', 'Course', 'Student', 'Group', 'Message','BasicCourseInformation','CourseObjectives','CourseChapters','KnowledgePoints','CurriculumMap'], //老师权限 + token: 'Admin Token', + }, + { + userId: 2, + avatar: + 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', + username: 'student', + password: '111111', + desc: '系统管理员', + roles: ['系统管理员'], + buttons: ['cuser.detail', 'cuser.user'], + routes: ['Home', 'MyCourseStudy', 'CourseResources', 'Message','LearningProcess','CourseCollections','Courselikes','WebHome','CourseHome','LearningPathRecommendations','KnowledgePointLearning','CourseReports'], //学生权限 + token: 'System Token', + }, + ] +} + +export default [ + // 用户登录接口 + { + url: '/api/user/login', //请求地址 + method: 'post', //请求方式 + response: ({ body }) => { + //获取请求体携带过来的用户名与密码 + const { username, password } = body + //调用获取用户信息函数,用于判断是否有此用户 + const checkUser = createUserList().find( + (item) => item.username === username && item.password === password, + ) + //没有用户返回失败信息 + if (!checkUser) { + return { code: 201, data: { message: '账号或者密码不正确' } } + } + //如果有返回成功信息 + const { token } = checkUser + return { code: 200, data: { token } } + }, + }, + // 获取用户信息 + { + url: '/api/user/info', + method: 'get', + response: (request) => { + //获取请求头携带token + const token = request.headers.token + //查看用户信息是否包含有次token用户 + const checkUser = createUserList().find((item) => item.token === token) + //没有返回失败的信息 + if (!checkUser) { + return { code: 201, data: { message: '获取用户信息失败' } } + } + //如果有返回成功信息 + return { code: 200, data: { checkUser } } + }, + }, +] diff --git a/src/api/user/crouse.js b/src/api/user/crouse.js index 94c232b..3c06520 100644 --- a/src/api/user/crouse.js +++ b/src/api/user/crouse.js @@ -1,10 +1,10 @@ import request from '@/utils/request' export const getCourseListApi = () => { - return request.get('/coursesteacher/page?teacherId=2140110334') + return request.get('/coursesteacher/page?teacherId=2140110334') } export const editCourseApi = () => { -return request.put('/coursesTeacher') + return request.put('/coursesTeacher') } export const addCourseApi = (data) => { - return request.post('/courseTeacher/addCourse', data) + return request.post('/courseTeacher/addCourse', data) } diff --git a/src/views/course/basicCourseInformation.vue b/src/views/course/basicCourseInformation.vue index 54c007e..22b5074 100644 --- a/src/views/course/basicCourseInformation.vue +++ b/src/views/course/basicCourseInformation.vue @@ -215,7 +215,6 @@ const onSuccess = () => { } .course { - // display: flex; // flex: 0 0 25%; // justify-content: space-between;