-
+
+
diff --git a/src/layout/menu/index.vue b/src/layout/menu/index.vue
index dce0724..062b37b 100644
--- a/src/layout/menu/index.vue
+++ b/src/layout/menu/index.vue
@@ -76,4 +76,4 @@ export default {
name: 'Menu',
}
-
\ No newline at end of file
+
diff --git a/src/main.ts b/src/main.ts
index 2b137c7..2ee398d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -19,6 +19,8 @@ import 'virtual:svg-icons-register'
// 获取并创建实例对象
const app = createApp(App)
// 引入自动注册全局组件脚本
+//持久化
+
import gloablComponent from '@/components/index'
app.use(gloablComponent)
// 注册仓库
diff --git a/src/permission.ts b/src/permission.ts
index ef214eb..367c7ad 100644
--- a/src/permission.ts
+++ b/src/permission.ts
@@ -9,64 +9,65 @@ import 'nprogress/nprogress.css'
const userStore = useUserStore(pinia)
const usePermissionStore = permissionStore(pinia)
// const whitelist = ['/login', '/404']
-// router.beforeEach(async (to, form, next) => {
-// // 进度条开始\
-// nprogress.configure({ showSpinner: false })
-// nprogress.start()
-// // 判断是否登录
-// if (userStore.token) {
-// // 登录成功访问登录页则跳转到首页
-// if (to.path == '/login') {
-// next({ path: '/' })
-// } else {
-// // 登录成功判断是否获取到了用户信息
-// if (userStore.userName) {
-// next()
-// } else {
-// try {
-// // 没有获取到用户信息 就获取用户信息 然后放行
-// await userStore.getUserInfo()
-// // 获取筛选到的路由
-// const asyncRouter = await usePermissionStore.getAsyncRoutes(
-// userStore.routes,
-// )
-// // 遍历筛选出来的路由通过addRoute添加到路由表
-// asyncRouter.forEach((item: any) => {
-// router.addRoute(item)
-// })
-// // 在最后向路由表添加一个404规则
-// // 切记不要写到路由表内 否者刷新页面会跳转到404页面
-// router.addRoute({
-// path: '/:pathMatch(.*)*',
-// component: () => import('@/views/404/index.vue'),
-// name: 'Any',
-// meta: {
-// title: '任意',
-// hidden: true,
-// },
-// })
-// next({ ...to, replace: true }) // 这里相当于push到一个页面 不在进入路由拦截
-// } catch (error) {
-// // 如果获取用户信息失败了则执行登出操作让重新登录
-// console.log(error)
-// userStore.logout()
-// next({ path: '/login' })
-// }
-// }
-// }
-// } else {
-// // 没有token访问登录页放行
-// if (to.path == '/login') {
-// next()
-// } else {
-// // 访问其他页面则阻止
-// next({ path: '/login', query: { redirect: to.path } })
-// }
-// }
-// })
-router.beforeEach((to,form,next) => {
- next()
+router.beforeEach(async (to, form, next) => {
+ // 进度条开始\
+ nprogress.configure({ showSpinner: false })
+ nprogress.start()
+ // 判断是否登录
+ if (userStore.token) {
+ // 登录成功访问登录页则跳转到首页
+ if (to.path == '/login') {
+ next({ path: '/' })
+ } else {
+ // 登录成功判断是否获取到了用户信息
+ if (userStore.userName) {
+ next()
+ } else {
+ try {
+ // 没有获取到用户信息 就获取用户信息 然后放行
+ await userStore.getUserInfo()
+ // 获取筛选到的路由
+ const asyncRouter = await usePermissionStore.getAsyncRoutes(
+ userStore.routes,
+ )
+ // 遍历筛选出来的路由通过addRoute添加到路由表
+ asyncRouter.forEach((item: any) => {
+ router.addRoute(item)
+ })
+ // 在最后向路由表添加一个404规则
+ // 切记不要写到路由表内 否者刷新页面会跳转到404页面
+ router.addRoute({
+ path: '/:pathMatch(.*)*',
+ component: () => import('@/views/404/index.vue'),
+ name: 'Any',
+ meta: {
+ title: '任意',
+ hidden: true,
+ },
+ })
+ next({ ...to, replace: true }) // 这里相当于push到一个页面 不在进入路由拦截
+ } catch (error) {
+ // 如果获取用户信息失败了则执行登出操作让重新登录
+ console.log(error)
+ userStore.logout()
+ next({ path: '/login' })
+ }
+ }
+ }
+ } else {
+ // 没有token访问登录页放行
+ if (to.path == '/login') {
+ next()
+ } else {
+ // 访问其他页面则阻止
+ next({ path: '/login', query: { redirect: to.path } })
+ }
+ }
})
+// router.beforeEach((to, form, next) => {
+// console.log(to, 'to')
+// next()
+// })
router.afterEach((to, form, next) => {
nprogress.done()
})
diff --git a/src/store/index.ts b/src/store/index.ts
index 2a205ca..68dd922 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -1,6 +1,9 @@
// 引入仓库
import { createPinia } from 'pinia'
+import persist from 'pinia-plugin-persistedstate'
// 创建仓库
const pinia = createPinia()
// 暴露仓库
+pinia.use(persist)
export default pinia
+export * from './modules/user'
diff --git a/src/store/modules/type/types.ts b/src/store/modules/type/types.ts
index 5e613b1..80b21aa 100644
--- a/src/store/modules/type/types.ts
+++ b/src/store/modules/type/types.ts
@@ -5,4 +5,5 @@ export interface LoginStoreType {
userName: string // 用户姓名
avatar: string // 用户头像
routes: string
+ phone: string
}
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 8fabbfd..9ff67ca 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -14,68 +14,108 @@ import { GET_TKOEN, SET_TKOEN, REMOVE_TOKEN } from '@/utils/token'
import { constantRoute } from '@/router/routers'
import permissionStore from './permission'
// 引入路由
-const useUserStore = defineStore('User', {
- state: (): LoginStoreType => {
- return {
- token: GET_TKOEN('TOKEN') || '',
- menuRoutes: constantRoute, //存储生成菜单路由数据
- userName: '', // 用户姓名
- avatar: '', // 用户头像
- routes: '',
- }
- },
- actions: {
- // 登录事件
- async userLogin(data: loginType) {
- const res: loginResponseType = await reqLogin(data)
- this.token = res.data.token as string
+import {
+ userRegisterService,
+ userLoginService,
+ userGetInfoService,
+ userPhoneLoginService,
+} from '@/api/user/user.js'
- if (res.code === 200) {
- SET_TKOEN('TOKEN', this.token)
- // localStorage.setItem('TOKEN', this.token)
- ElNotification({
- type: 'success',
- message: '登录成功!',
- title: `Hi ${getTime()}!`,
- })
- return 'ok'
- } else {
- ElNotification({
- type: 'error',
- message: res.data.message,
- })
- return Promise.reject(new Error(res.data.message))
+const useUserStore = defineStore(
+ 'User',
+ {
+ state: (): LoginStoreType => {
+ return {
+ token: GET_TKOEN('TOKEN') || '',
+ menuRoutes: constantRoute, //存储生成菜单路由数据
+ userName: '', // 用户姓名
+ avatar: '', // 用户头像
+ routes: '',
}
},
- // 获取用户信息事件
- async getUserInfo() {
- const result = await getUserInfo()
- if (result.code === 200) {
- console.log(result)
-
- this.userName = result.data.checkUser.username
- this.avatar = result.data.checkUser.avatar
- this.routes = result.data.checkUser.routes
-
- return 'ok'
- } else {
- return Promise.reject('登录过期')
- }
- },
- // 退出登录事件
- logout() {
- const usePermissionStore = permissionStore()
- console.log(usePermissionStore)
-
- // 清除token
- REMOVE_TOKEN('TOKEN')
- ;(this.userName = ''), (this.avatar = '')
- this.token = ''
- this.routes = ''
- usePermissionStore.removeRouter()
- location.reload()
+ actions: {
+ // 登录事件
+ async userLogin(data: loginType) {
+ console.log(data, 'pinia')
+ const res: loginResponseType = await userLoginService(data)
+ this.token = res.data.token as string
+ console.log(res, '传回的值1')
+ if (res.code === 200) {
+ SET_TKOEN('TOKEN', this.token)
+ // localStorage.setItem('TOKEN', this.token)
+ ElNotification({
+ type: 'success',
+ message: '登录成功!',
+ title: `Hi ${getTime()}!`,
+ })
+ return 'ok'
+ } else {
+ console.log(res, '33333')
+ ElNotification({
+ // type: 'error',
+ message: res.message,
+ })
+ return Promise.reject(new Error(res.data.message))
+ }
+ },
+ //手机号登录
+ async userPhoneLogin(data: loginType) {
+ const res: loginResponseType = await userPhoneLoginService(data)
+ this.token = res.data.token as string //接收返回的token
+ console.log(res, 11111)
+ if (res.code === 200) {
+ SET_TKOEN('TOKEN', this.token)
+ // localStorage.setItem('TOKEN', this.token)
+ ElNotification({
+ type: 'success',
+ message: '登录成功!',
+ title: `Hi ${getTime()}!`,
+ })
+ return 'ok'
+ } else {
+ ElNotification({
+ type: 'error',
+ message: res.data.message,
+ })
+ return Promise.reject(new Error(res.data.message))
+ }
+ },
+ // 获取用户信息事件
+ async getUserInfo() {
+ const result = await userGetInfoService(GET_TKOEN('TOKEN'))
+ if (result.code === 200) {
+ // console.log(result)
+ this.userName = result.data.username
+ // this.avatar = result.data.checkUser.avatar
+ this.routes = result.data.menus.map((item) => {
+ return item.name
+ })
+ return {
+ result,
+ }
+ } else {
+ return Promise.reject('登录过期')
+ }
+ },
+ // 退出登录事件
+ logout() {
+ const usePermissionStore = permissionStore()
+ console.log(usePermissionStore)
+ // 清除token
+ REMOVE_TOKEN('TOKEN'),
+ // ;(this.userName = ''), (this.avatar = '')
+ (this.userName = ''),
+ (this.avatar = '')
+ this.token = ''
+ this.routes = ''
+ usePermissionStore.removeRouter()
+ location.reload()
+ },
},
+ getters: {},
+ },
+ {
+ persist: true, // 持久化
},
- getters: {},
-})
+)
export default useUserStore
diff --git a/src/utils/img.js b/src/utils/img.js
new file mode 100644
index 0000000..4fa8d95
--- /dev/null
+++ b/src/utils/img.js
@@ -0,0 +1,25 @@
+import OSS from 'ali-oss'
+import { nanoid } from 'nanoid'
+export const client = new OSS({
+ region: 'oss-cn-beijing', //创建的时候,bucket所在的区域,华北2->oss-cn-beijing ;其他的可以去百度
+ accessKeyId: 'LTAI5tPutTqQcDZjPXTVmuLy', // 阿里云控制台创建的AccessKey
+ accessKeySecret: '3PmB75969OJt6uOMkRJTZjpSbVI4iL', //阿里云控制台创建的AccessSecret
+ bucket: 'teaching-edu123', //创建的bucket的名称
+ endpoint: 'oss-cn-beijing.aliyuncs.com', //地域节点
+ secure: false, //http:false,https:ture
+})
+export const tool = {
+ oss: {
+ async upload(file) {
+ // // console.log(11, file, client)
+ // 文件名
+ const uuid = nanoid() // 文件后缀名
+ const index = file.name.lastIndexOf('.')
+ const suffix = file.name.substring(index + 1)
+ let fileName = uuid + '.' + suffix
+ console.log(uuid, file, suffix) // return await client.multipartUpload(fileName, file, {
+
+ return await client.put(fileName, file)
+ },
+ },
+}
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 7c7c3a5..7e76580 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -2,7 +2,6 @@ import axios from 'axios'
import { ElMessage } from 'element-plus'
// 获取用户相关小仓库
import useUserStore from '@/store/modules/user'
-
//创建axios实例
const request = axios.create({
baseURL: import.meta.env.VITE_APP_BASE_API,
diff --git a/src/views/MyCourseStudy/Courselikes.vue b/src/views/MyCourseStudy/Courselikes.vue
index b21f044..e7d0913 100644
--- a/src/views/MyCourseStudy/Courselikes.vue
+++ b/src/views/MyCourseStudy/Courselikes.vue
@@ -1,14 +1,9 @@
-
- 课程点赞
-
+ 课程点赞
-
-
+
diff --git a/src/views/MyCourseStudy/courseCollections.vue b/src/views/MyCourseStudy/courseCollections.vue
index 0c2f435..f71132a 100644
--- a/src/views/MyCourseStudy/courseCollections.vue
+++ b/src/views/MyCourseStudy/courseCollections.vue
@@ -1,14 +1,9 @@
-
- 课程收藏
-
+ 课程收藏
-
-
+
diff --git a/src/views/MyCourseStudy/learningProcess.vue b/src/views/MyCourseStudy/learningProcess.vue
index 5aeb410..de79071 100644
--- a/src/views/MyCourseStudy/learningProcess.vue
+++ b/src/views/MyCourseStudy/learningProcess.vue
@@ -1,14 +1,9 @@
-
- 学习过程
-
+ 学习过程
-
-
+
diff --git a/src/views/course/CourseObjectives.vue b/src/views/course/CourseObjectives.vue
index 64135f7..87b0412 100644
--- a/src/views/course/CourseObjectives.vue
+++ b/src/views/course/CourseObjectives.vue
@@ -1,14 +1,9 @@
-
- 课程目标
-
+ 课程目标
-
-
+
diff --git a/src/views/course/curriculumMap.vue b/src/views/course/curriculumMap.vue
index c2054be..5c43bcd 100644
--- a/src/views/course/curriculumMap.vue
+++ b/src/views/course/curriculumMap.vue
@@ -1,14 +1,9 @@
-
- 课程图谱
-
+ 课程图谱
-
-
+
diff --git a/src/views/group/index.vue b/src/views/group/index.vue
index 2e95b1d..4fc55f6 100644
--- a/src/views/group/index.vue
+++ b/src/views/group/index.vue
@@ -1,9 +1,181 @@
- 分组
+
+
+
+
+
智慧物业管理平台
+
+
+
+
+
-
-
+
diff --git a/src/views/home/components/Class.vue b/src/views/home/components/Class.vue
index fb59a47..15f461f 100644
--- a/src/views/home/components/Class.vue
+++ b/src/views/home/components/Class.vue
@@ -1,10 +1,46 @@
-
+
+
+
+
+
+
{{ course.name }}
+
{{ course.hours }}
+
+
+
+
diff --git a/src/views/home/components/ConHeader.vue b/src/views/home/components/ConHeader.vue
index fe205c6..a358b8b 100644
--- a/src/views/home/components/ConHeader.vue
+++ b/src/views/home/components/ConHeader.vue
@@ -2,9 +2,10 @@
{{ props.title }}
-
+
+
diff --git a/src/views/home/components/Echarts.vue b/src/views/home/components/Echarts.vue
index f738792..ba53699 100644
--- a/src/views/home/components/Echarts.vue
+++ b/src/views/home/components/Echarts.vue
@@ -4,9 +4,7 @@ import conheader from '@/views/home/components/ConHeader.vue'
-
-
-
+
@@ -18,33 +16,13 @@ import conheader from '@/views/home/components/ConHeader.vue'
flex-direction: column;
justify-content: space-between;
}
-.info_content {
- display: grid;
- display: wrap;
- grid-template-columns: repeat(4, 1fr);
- gap: 10px; /* 设置元素之间的间隔 */
-}
.echarts {
background: #ffffff;
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.1);
border-radius: 6px 6px 6px 6px;
margin-bottom: 16px;
display: flex;
-
justify-content: center;
align-items: center;
- .info_container {
- display: flex;
-
- justify-content: space-between;
- }
-}
-
-.echarts {
- width: 1321px;
- height: 444px;
- background: #ffffff;
- box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.1);
- border-radius: 6px 6px 6px 6px;
}
diff --git a/src/views/home/components/Info.vue b/src/views/home/components/Info.vue
index fd93438..5f2de25 100644
--- a/src/views/home/components/Info.vue
+++ b/src/views/home/components/Info.vue
@@ -1,7 +1,75 @@
-
-
-
+
+
+
+
+ 个人信息
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 确认
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 取消
+ 保存
+
+
+
+
+
+
+
{{ item.name }}
{{ item.content }}
@@ -62,4 +199,16 @@ const products = [
font-style: normal;
text-transform: none;
}
+.table {
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+}
+.custom-input {
+ margin-bottom: 20px;
+ height: 40px; /* 自定义输入框高度 */
+ padding: 0 10px; /* 自定义输入框内边距 */
+ font-size: 16px; /* 自定义输入框字体大小 */
+ /* 其他样式自定义 */
+}
diff --git a/src/views/home/components/Status.vue b/src/views/home/components/Status.vue
index ae8423e..bde7a7b 100644
--- a/src/views/home/components/Status.vue
+++ b/src/views/home/components/Status.vue
@@ -1,21 +1,149 @@
-
T
-
+
+
+
+
-
-
王亚楠
+
+
{{ props.data.username }}
身份:某某专业教师
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/home/components/Student.vue b/src/views/home/components/Student.vue
index ee7e622..370c8c9 100644
--- a/src/views/home/components/Student.vue
+++ b/src/views/home/components/Student.vue
@@ -1,10 +1,53 @@
-
-
+
+ 编辑
+
+
+
+ 78
+
+
+
+
+
+
+ cancel
+
+ confirm
+
+
+
+
+
+
+
diff --git a/src/views/home/components/Welcome.vue b/src/views/home/components/Welcome.vue
index b5077b0..d1b6557 100644
--- a/src/views/home/components/Welcome.vue
+++ b/src/views/home/components/Welcome.vue
@@ -1,7 +1,13 @@
-
+
-
王亚楠
+
+ {{ props.username }}
+
今天是你的第一天~~
@@ -14,7 +20,6 @@
align-items: center;
}
.name {
- width: 91px;
height: 28px;
font-family: Inter, Inter;
font-weight: bold;
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index e152c81..f892985 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -5,22 +5,43 @@ import Info from './components/Info.vue'
import echarts from './components/Echarts.vue'
import Class from './components/Class.vue'
import Student from './components/Student.vue'
+import useUserStore from '@/store/modules/user'
+import { ref, onMounted } from 'vue'
+import { toRaw } from 'vue'
+const userStore = useUserStore()
+// const info = userStore.getUserInfo()
+// console.log(info)
+const username = ref()
+const data = ref(null)
+const flag = ref(false)
+const getData = async () => {
+ await userStore.getUserInfo().then((response) => {
+ const res = toRaw(response.result.data)
+ username.value = res.username
+ data.value = res
+ flag.value = true
+ console.log(data.value, 333333)
+ })
+}
+onMounted(() => {
+ getData()
+})
-
+
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 65390e1..42287d5 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -1,6 +1,5 @@
-
Hello
- 同学!
-
-
-
-
-
+
+
+
账号
+ 手机号
+
+
+
+
+
+
+
+
+
+
+
+ 登录
+
+
+
+
+
+
+
+
+
+
+
+
+ 发送验证码
+
+
+
+
+ 登录
+
+
+
+
+
+ 注册
+
-
-
+
+
+
+ Hello
+
+
账号
+ 手机号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 注册
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 发送验证码
+
+
+
+
+ 注册
+
+
+
+
+
+
+
+
+
+ 确认
+
+
+
+
+
+
登录
-
+
@@ -56,19 +257,53 @@
+
diff --git a/src/views/portal/courseHomepage.vue b/src/views/portal/courseHomepage.vue
index 78ee628..65390e1 100644
--- a/src/views/portal/courseHomepage.vue
+++ b/src/views/portal/courseHomepage.vue
@@ -1,14 +1,173 @@
-
- 课程首页
-
-
+
-
-
diff --git a/src/views/student/index.vue b/src/views/student/index.vue
index 368df54..4516860 100644
--- a/src/views/student/index.vue
+++ b/src/views/student/index.vue
@@ -1,9 +1,536 @@
+
- 学生
+
+
+
+
+
+
+
+ Hello
+
+
+
账号
+ 手机号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 登录
+
+
+
+
+ 注册 →
+
+
+
+
+
+ Hello
+
+
账号
+ 手机号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 注册
+
+
+
+
+ 登录 →
+
+
+
+
+
+
+
-
+
diff --git a/src/views/student/login.vue b/src/views/student/login.vue
new file mode 100644
index 0000000..89bfa2a
--- /dev/null
+++ b/src/views/student/login.vue
@@ -0,0 +1,68 @@
+
+
+
Open Drawer
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+ Save
+
+
+
+
+
+
+