diff --git a/src/laoyou_backend/public/img/avatar/045c24b5aed8778f2d040d44acaef061.jpg b/src/laoyou_backend/public/img/avatar/045c24b5aed8778f2d040d44acaef061.jpg
new file mode 100644
index 0000000..3a11775
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/045c24b5aed8778f2d040d44acaef061.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/258634abefc9e607cb60124cea10c9568.jpg b/src/laoyou_backend/public/img/avatar/258634abefc9e607cb60124cea10c9568.jpg
new file mode 100644
index 0000000..1914adf
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/258634abefc9e607cb60124cea10c9568.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/3a386d7b50a98aab5b10bdc3102bb323e4.jpg b/src/laoyou_backend/public/img/avatar/3a386d7b50a98aab5b10bdc3102bb323e4.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/3a386d7b50a98aab5b10bdc3102bb323e4.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/68597652ddc386767f3652fe28b52b12.jpg b/src/laoyou_backend/public/img/avatar/68597652ddc386767f3652fe28b52b12.jpg
new file mode 100644
index 0000000..d82c801
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/68597652ddc386767f3652fe28b52b12.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/76ac71772544863105a2e79f4f9791f94.jpg b/src/laoyou_backend/public/img/avatar/76ac71772544863105a2e79f4f9791f94.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/76ac71772544863105a2e79f4f9791f94.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/82c62d3ad5103739a5f8863cddce6b9a6.jpg b/src/laoyou_backend/public/img/avatar/82c62d3ad5103739a5f8863cddce6b9a6.jpg
new file mode 100644
index 0000000..16f5a3f
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/82c62d3ad5103739a5f8863cddce6b9a6.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/8b13365e8b8f910b9dafcb31f25982e03.jpg b/src/laoyou_backend/public/img/avatar/8b13365e8b8f910b9dafcb31f25982e03.jpg
new file mode 100644
index 0000000..3a11775
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/8b13365e8b8f910b9dafcb31f25982e03.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/ad26eda311010853ba3560dea811058446.jpg b/src/laoyou_backend/public/img/avatar/ad26eda311010853ba3560dea811058446.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/ad26eda311010853ba3560dea811058446.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/da40eb71769c31d9c53247f925a8681e.jpg b/src/laoyou_backend/public/img/avatar/da40eb71769c31d9c53247f925a8681e.jpg
new file mode 100644
index 0000000..4c3787e
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/da40eb71769c31d9c53247f925a8681e.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/dfdf4d8324f4b2108cfbf9f28d16f7648.jpg b/src/laoyou_backend/public/img/avatar/dfdf4d8324f4b2108cfbf9f28d16f7648.jpg
new file mode 100644
index 0000000..4c3787e
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/dfdf4d8324f4b2108cfbf9f28d16f7648.jpg differ
diff --git a/src/laoyou_backend/public/img/avatar/e6f5eb3b8f493f3cb46c62110ec242756.jpg b/src/laoyou_backend/public/img/avatar/e6f5eb3b8f493f3cb46c62110ec242756.jpg
new file mode 100644
index 0000000..1914adf
Binary files /dev/null and b/src/laoyou_backend/public/img/avatar/e6f5eb3b8f493f3cb46c62110ec242756.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/13586821031941439cec6aa10694a510913.jpg b/src/laoyou_backend/public/img/commonshare/13586821031941439cec6aa10694a510913.jpg
new file mode 100644
index 0000000..4c3787e
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/13586821031941439cec6aa10694a510913.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/1bb6e7f6cc5bb6c3a10ac1dcf10d7cf839.jpg b/src/laoyou_backend/public/img/commonshare/1bb6e7f6cc5bb6c3a10ac1dcf10d7cf839.jpg
new file mode 100644
index 0000000..16f5a3f
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/1bb6e7f6cc5bb6c3a10ac1dcf10d7cf839.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/31163698e2bc17e2dd2f591d910cd9a26.jpg b/src/laoyou_backend/public/img/commonshare/31163698e2bc17e2dd2f591d910cd9a26.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/31163698e2bc17e2dd2f591d910cd9a26.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/34fbddefd10a452331088a78af14a336fe.jpg b/src/laoyou_backend/public/img/commonshare/34fbddefd10a452331088a78af14a336fe.jpg
new file mode 100644
index 0000000..4c3787e
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/34fbddefd10a452331088a78af14a336fe.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/3c890c44b8adcd416f47f615feba14bb.jpg b/src/laoyou_backend/public/img/commonshare/3c890c44b8adcd416f47f615feba14bb.jpg
new file mode 100644
index 0000000..b8bfd4b
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/3c890c44b8adcd416f47f615feba14bb.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/3e34e8ceb8cde9db4d10b396d971afca4.jpg b/src/laoyou_backend/public/img/commonshare/3e34e8ceb8cde9db4d10b396d971afca4.jpg
new file mode 100644
index 0000000..1914adf
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/3e34e8ceb8cde9db4d10b396d971afca4.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/531e48ddc9ef3e2a9a310453127bf3949.jpg b/src/laoyou_backend/public/img/commonshare/531e48ddc9ef3e2a9a310453127bf3949.jpg
new file mode 100644
index 0000000..9386476
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/531e48ddc9ef3e2a9a310453127bf3949.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/6c297e4a287e9534bed097d9a8a79345.jpg b/src/laoyou_backend/public/img/commonshare/6c297e4a287e9534bed097d9a8a79345.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/6c297e4a287e9534bed097d9a8a79345.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/7b8c4d73108e6452f1efc8ce5c1ac28bc.jpg b/src/laoyou_backend/public/img/commonshare/7b8c4d73108e6452f1efc8ce5c1ac28bc.jpg
new file mode 100644
index 0000000..d6d5e2e
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/7b8c4d73108e6452f1efc8ce5c1ac28bc.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/8e3b8ba4e9f1a6932b6c2b7d1f63c4b9.jpg b/src/laoyou_backend/public/img/commonshare/8e3b8ba4e9f1a6932b6c2b7d1f63c4b9.jpg
new file mode 100644
index 0000000..3a11775
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/8e3b8ba4e9f1a6932b6c2b7d1f63c4b9.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/a1952628910f33e8385248ec868c4c47e.jpg b/src/laoyou_backend/public/img/commonshare/a1952628910f33e8385248ec868c4c47e.jpg
new file mode 100644
index 0000000..1914adf
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/a1952628910f33e8385248ec868c4c47e.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/b228bdad3fc949e80a8f3b6af038f693.jpg b/src/laoyou_backend/public/img/commonshare/b228bdad3fc949e80a8f3b6af038f693.jpg
new file mode 100644
index 0000000..3a11775
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/b228bdad3fc949e80a8f3b6af038f693.jpg differ
diff --git a/src/laoyou_backend/public/img/commonshare/dcad958cc3388cba949899d010f56762b.jpg b/src/laoyou_backend/public/img/commonshare/dcad958cc3388cba949899d010f56762b.jpg
new file mode 100644
index 0000000..d82c801
Binary files /dev/null and b/src/laoyou_backend/public/img/commonshare/dcad958cc3388cba949899d010f56762b.jpg differ
diff --git a/src/laoyou_backend/src/dto/user/user.ts b/src/laoyou_backend/src/dto/user/user.ts
index 059d4b7..0b0d0e8 100644
--- a/src/laoyou_backend/src/dto/user/user.ts
+++ b/src/laoyou_backend/src/dto/user/user.ts
@@ -1,6 +1,6 @@
-class UserDto {
+export class UserDto {
id?: number;
- openId?: string
+ openid?: string
nickname?: string;
avatar?: string;
birth?: string;
diff --git a/src/laoyou_backend/src/file-upload/file-upload.controller.ts b/src/laoyou_backend/src/file-upload/file-upload.controller.ts
index eb9fee3..f9425b7 100644
--- a/src/laoyou_backend/src/file-upload/file-upload.controller.ts
+++ b/src/laoyou_backend/src/file-upload/file-upload.controller.ts
@@ -4,6 +4,7 @@ import { diskStorage } from 'multer';
import path, { extname } from 'path';
import { base_url } from '../utils/config/index'
import { InvalidFileTypeException, FileTooLargeException, EmptyFileException } from '../error/fileError';
+import { AuthInterceptor } from 'src/interceptor/auth.interceptor';
@Controller('upload')
@@ -12,6 +13,7 @@ export class FileUploadController {
@Post('img')
@UseInterceptors(
+ AuthInterceptor,
FileInterceptor('img', {
fileFilter(req, file, callback) {
// 检查图片类型
@@ -26,7 +28,11 @@ export class FileUploadController {
callback(null, true)
},
storage: diskStorage({
- destination: './public/temp/img',
+ destination: (req, file, callback) => {
+ const pic_type = req.body.pic_type;
+ console.log(pic_type);
+ callback(null, `./public/img/${pic_type}`);
+ },
filename(req, file, callback) {
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
callback(null, `${randomName}${extname(file.originalname)}`);
@@ -34,7 +40,7 @@ export class FileUploadController {
})
})
)
- async uploadImage(@UploadedFile() file) {
+ uploadImage(@UploadedFile() file) {
if (!file) {
throw new EmptyFileException();
}
@@ -48,44 +54,4 @@ export class FileUploadController {
}
-
- // 多图上传
- @Post('imgs')
- @UseInterceptors(
- FilesInterceptor('imgs', 9, {
- fileFilter(req, file, callback) {
- // 检查图片类型
- const allowedMimes = ['image/jpeg', 'image/png', 'image/gif'];
- if (!allowedMimes.includes(file.mimetype)) {
- callback(new InvalidFileTypeException('图片'), false)
- }
- // 检查图片大小
- if (file.size > 2 * 1024 * 1024) {
- callback(new FileTooLargeException(), false)
- }
- callback(null, true)
- },
- storage: diskStorage({
- destination: './public/temp/img',
- filename(req, file, callback) {
- const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('');
- callback(null, `${randomName}${extname(file.originalname)}`);
- }
- })
- })
- )
- async uploadImages(@UploadedFiles() files) {
- if (!files) {
- throw new EmptyFileException();
- }
- console.log(files);
- const paths = files.map(file => {
- const changePath = file.path.replace(/\\/g, '/').replace('public/', '/');
- return base_url + '/static' + changePath
- })
-
- return paths;
- }
-
-
}
diff --git a/src/laoyou_backend/src/post/post.controller.ts b/src/laoyou_backend/src/post/post.controller.ts
index 733c59e..58a9ff7 100644
--- a/src/laoyou_backend/src/post/post.controller.ts
+++ b/src/laoyou_backend/src/post/post.controller.ts
@@ -33,6 +33,11 @@ export class PostController {
}
try {
await this.postService.createCommonShare(commonShare);
+ // 获取图片名称
+ const pic_list = body.pic_list.map(item => item.url.split('/').pop());
+ // 将/public/temp/img 下的图片移动到 /public/commonshare/img
+
+
return 'common share 上传成功';
} catch (error) {
console.log(error);
diff --git a/src/laoyou_backend/src/user/user.controller.ts b/src/laoyou_backend/src/user/user.controller.ts
index 562b30c..1f024c2 100644
--- a/src/laoyou_backend/src/user/user.controller.ts
+++ b/src/laoyou_backend/src/user/user.controller.ts
@@ -1,6 +1,7 @@
-import { Body, Controller, Post, UseInterceptors } from '@nestjs/common';
+import { Body, Controller, Head, Headers, Post, UseInterceptors } from '@nestjs/common';
import { UserService } from './user.service';
import { AuthInterceptor } from 'src/interceptor/auth.interceptor';
+import { UserDto } from 'src/dto/user/user';
@Controller('user')
export class UserController {
@@ -31,12 +32,28 @@ export class UserController {
return user;
}
+
+ // {
+ // openId: 'oyBXy5ZPz7etmnwy34TICz2QT0O4',
+ // sessionKey: 'xj7jGKXKTZ1IefZ3OJBS0A=='
+ // }
+ // avatar
+ // {
+ // avatar: 'http://localhost:3000/api/v1/static/img/avatar/3a386d7b50a98aab5b10bdc3102bb323e4.jpg'
+ // }
+
//修改用户信息
@UseInterceptors(AuthInterceptor)
@Post('updateuser')
- async updateUser(@Body() userDto: UserDto) {
- console.log(userDto);
- return 'ok'
+ async updateUser(@Headers() Header, @Body() body) {
+ // from header get openId and sessionKey
+ const openId = Header.openid
+ const avatar = body.avatar
+ const userDto: UserDto = {
+ openid: openId,
+ avatar: avatar
+ }
+ return await this.userService.updateUser(userDto)
}
}
diff --git a/src/laoyou_backend/src/user/user.service.ts b/src/laoyou_backend/src/user/user.service.ts
index 3fa42d0..72d93f7 100644
--- a/src/laoyou_backend/src/user/user.service.ts
+++ b/src/laoyou_backend/src/user/user.service.ts
@@ -1,7 +1,10 @@
import { Injectable } from '@nestjs/common';
+import { Prisma } from '@prisma/client';
+import { UserDto } from 'src/dto/user/user';
import { PrismaService } from 'src/prisma/prisma.service';
import { getSessionKey, setUserLoginMap, hasUser, deleteUser } from 'src/store/index'
+
const S = 1000
@Injectable()
@@ -61,5 +64,16 @@ export class UserService {
return user
}
+ //update
+ async updateUser(userDto: UserDto) {
+ const user = await this.prismaService.user.update({
+ where: {
+ openid: userDto.openid
+ },
+ data: userDto
+ })
+ return user
+
+ }
}
diff --git a/src/laoyou_backend/src/utils/fs/index.ts b/src/laoyou_backend/src/utils/fs/index.ts
new file mode 100644
index 0000000..941f150
--- /dev/null
+++ b/src/laoyou_backend/src/utils/fs/index.ts
@@ -0,0 +1,7 @@
+import fs from 'fs';
+
+function moveFile() {
+ fs.rename('./test.jpg', './public/img/commonShare/test.jpg', (res) => {
+ console.log(res);
+ });
+}
diff --git a/src/laoyou_backend/test.js b/src/laoyou_backend/test.js
new file mode 100644
index 0000000..c0e0cba
--- /dev/null
+++ b/src/laoyou_backend/test.js
@@ -0,0 +1,10 @@
+const fs = require('fs');
+const path = require('path');
+
+function moveFile() {
+ fs.rename('./test.jpg', './public/img/commonShare/test.jpg', (res) => {
+ console.log(res);
+ });
+}
+
+moveFile();
diff --git a/src/laoyou_client/pnpm-lock.yaml b/src/laoyou_client/pnpm-lock.yaml
index 667aad6..a3be24a 100644
--- a/src/laoyou_client/pnpm-lock.yaml
+++ b/src/laoyou_client/pnpm-lock.yaml
@@ -55,9 +55,6 @@ dependencies:
pinia:
specifier: 2.0.33
version: registry.npmmirror.com/pinia@2.0.33(vue@3.2.45)
- remixicon:
- specifier: ^3.5.0
- version: registry.npmmirror.com/remixicon@3.5.0
sass:
specifier: ^1.66.1
version: registry.npmmirror.com/sass@1.66.1
@@ -7145,12 +7142,6 @@ packages:
jsesc: registry.npmmirror.com/jsesc@0.5.0
dev: true
- registry.npmmirror.com/remixicon@3.5.0:
- resolution: {integrity: sha512-wNzWGKf4frb3tEmgvP5shry0n1OdTjjEk9RHLuRuAhfA50bvEdpKH1XWNUYrHUSjAQQkkdyIm+lf4mOuysIKTQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/remixicon/-/remixicon-3.5.0.tgz}
- name: remixicon
- version: 3.5.0
- dev: false
-
registry.npmmirror.com/require-directory@2.1.1:
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/require-directory/-/require-directory-2.1.1.tgz}
name: require-directory
diff --git a/src/laoyou_client/src/component/drawer/drawer.vue b/src/laoyou_client/src/component/drawer/drawer.vue
new file mode 100644
index 0000000..723c227
--- /dev/null
+++ b/src/laoyou_client/src/component/drawer/drawer.vue
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/laoyou_client/src/pages.json b/src/laoyou_client/src/pages.json
index f37d5a5..7e5ea61 100644
--- a/src/laoyou_client/src/pages.json
+++ b/src/laoyou_client/src/pages.json
@@ -1,7 +1,7 @@
{
"pages": [
{
- "path": "pages/setting/userSetting",
+ "path": "pages/function/function",
"style": {
"navigationStyle": "custom"
}
@@ -12,6 +12,13 @@
"navigationStyle": "custom"
}
},
+ {
+ "path": "pages/setting/userSetting",
+ "style": {
+ "navigationStyle": "custom"
+ }
+ },
+
{
"path": "pages/learn/learn",
"style": {
@@ -45,14 +52,6 @@
"navigationStyle": "custom"
}
},
-
- {
- "path": "pages/function/function",
- "style": {
- "navigationStyle": "custom"
- }
- },
-
{
"path": "pages/verify/verify",
"style": {
diff --git a/src/laoyou_client/src/pages/function/function.vue b/src/laoyou_client/src/pages/function/function.vue
index fb5dec2..c068127 100644
--- a/src/laoyou_client/src/pages/function/function.vue
+++ b/src/laoyou_client/src/pages/function/function.vue
@@ -26,10 +26,7 @@
v-if="loginStatus"
width="50px"
height="50px"
- :img-src="
- avatar ||
- '/static/icon/user.png'
- "
+ :img-src="avatar || '/static/icon/user.png'"
radius="50%"
>
{{ nickname || "微信用户" }}
加入老友16天
-
- 立即登陆
+
+ 立即登陆
期待与你相见,我的挚友
@@ -92,22 +87,19 @@