Skip to content

Commit

Permalink
fix: 修改图片和钉图打不开bug、创建设置bug
Browse files Browse the repository at this point in the history
  • Loading branch information
027xiguapi committed Dec 21, 2023
1 parent ddb201b commit c3907ee
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 18 deletions.
4 changes: 4 additions & 0 deletions packages/server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @pear-rec/server

## 1.3.3

fix: 创建设置bug

## 1.3.2

fix: 配置初始 bug
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pear-rec/server",
"version": "1.3.0",
"version": "1.3.3",
"scripts": {
"build": "nest build --webpack --webpackPath=./webpack.config.js",
"webpack": "nest build",
Expand Down
3 changes: 1 addition & 2 deletions packages/server/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as jsonfile from 'jsonfile';
import * as fs from 'node:fs';
import * as path from 'node:path';
import { v5 as uuidv5 } from 'uuid';
import dayjs from 'dayjs';
import { PEAR_FILES_PATH, DB_PATH, CONFIG_FILE_PATH, DEFAULT_CONFIG_FILE_PATH } from '../contract';

export function initConfig() {
Expand All @@ -26,7 +25,7 @@ function initDefaultConfig() {
uuid: uuidv5('https://www.w3.org/', uuidv5.URL),
userName: `pear-rec:user`,
userType: 1,
createdAt: dayjs(new Date()).format(),
createdAt: new Date(),
},
isProxy: false,
proxyPort: '7890',
Expand Down
1 change: 1 addition & 0 deletions packages/server/src/records/records.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class RecordsService {

async findAll(pageNumber: number, pageSize: number): Promise<Record[]> {
const [records, totalCount] = await this.recordRepository.findAndCount({
order: { createdAt: 'DESC' },
skip: (pageNumber - 1) * pageSize,
take: pageSize,
});
Expand Down
9 changes: 4 additions & 5 deletions packages/server/src/settings/settings.controller.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Controller, Get, Post, Body, Param, UseInterceptors } from '@nestjs/common';
import { CreateSettingDto } from './dto/create-setting.dto';
import { SettingsService } from './settings.service';
import { UsersService } from 'src/users/users.service';
import { Setting } from './entity/setting.entity';

@Controller('settings')
export class SettingsController {
constructor(private settingsService: SettingsService) {}

@Post()
create(@Body() record: CreateSettingDto): Promise<Setting> {
return this.settingsService.create(record);
create(@Body() setting: CreateSettingDto): Promise<Setting> {
return this.settingsService.create(setting);
}

@Get()
Expand All @@ -29,8 +28,8 @@ export class SettingsController {
}

@Post('/edit/:id')
update(@Param('id') id: number, @Body() record: CreateSettingDto): Promise<Setting> {
return this.settingsService.update(id, record);
update(@Param('id') id: number, @Body() setting: CreateSettingDto): Promise<Setting> {
return this.settingsService.update(id, setting);
}

@Post('/delete/:id')
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/settings/settings.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { SettingsController } from './settings.controller';
import { SettingsService } from './settings.service';
import { Setting } from './entity/setting.entity';
import { UsersModule } from '../users/users.module';

@Module({
imports: [TypeOrmModule.forFeature([Setting])],
imports: [TypeOrmModule.forFeature([Setting]), UsersModule],
controllers: [SettingsController],
providers: [SettingsService],
exports: [SettingsService],
Expand Down
5 changes: 5 additions & 0 deletions packages/server/src/settings/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Setting } from './entity/setting.entity';
import { UsersService } from '../users/users.service';
import { getDefaultConfig } from '../config';

@Injectable()
export class SettingsService {
constructor(
@InjectRepository(Setting)
private readonly settingRepository: Repository<Setting>,
private readonly usersService: UsersService,
) {}

async create(setting: Setting): Promise<Setting> {
Expand All @@ -32,13 +34,16 @@ export class SettingsService {

if (setting == null) {
const defaultConfig = getDefaultConfig();
const user = await this.usersService.findOne(userId);
setting = {
isProxy: defaultConfig.isProxy,
proxyPort: defaultConfig.proxyPort,
language: defaultConfig.language,
filePath: defaultConfig.filePath,
openAtLogin: defaultConfig.openAtLogin,
serverPath: defaultConfig.serverPath,
user: user,
createdBy: user.id,
} as any;

return await this.settingRepository.save(setting);
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/users/dto/create-user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export class CreateUserDto {

// setting: ISetting;

createdAt: Date;
createdAt: number;

createdBy: string;

updatedAt: Date;
updatedAt: number;

updatedBy: string;
}
2 changes: 0 additions & 2 deletions packages/server/src/users/entity/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
import { IUser } from '../interfaces/user.interface';
import { Record } from '../../records/entity/record.entity';
import { Setting } from '../../settings/entity/setting.entity';
// import { IRecord } from '../model/IRecord';
// import { ISetting } from '../model/ISetting';

@Entity()
export class User implements IUser {
Expand Down
4 changes: 4 additions & 0 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @pear-rec/web

## 1.3.8

fix: 修改图片和钉图打不开bug

## 1.3.7

feat: 录制GIF
Expand Down
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pear-rec/web",
"private": true,
"version": "1.3.7",
"version": "1.3.8",
"scripts": {
"dev": "vite",
"build": "rimraf dist && tsc && vite build",
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/components/records/RecordsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import { useApi } from '../../api';
import { useRecordApi } from '../../api/record';
import { eventEmitter } from '../../util/bus';
import Item from 'antd/es/list/Item';

const { Content } = Layout;
const recordApi = useRecordApi();
Expand Down Expand Up @@ -127,7 +126,8 @@ const RecordAudioCard = forwardRef(() => {
}

function getAvatar(record: any) {
if (record.fileType == 'ss') {
console.log(record.fileType);
if (record.fileType == 'ss' || record.fileType == 'gif') {
return <ScissorOutlined />;
}
if (record.fileType == 'rs') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export default function VideoToGifConverter({ videoSrc, user }) {

async function handleSaveClick() {
const blob = gifBlobRef.current;
if (blob == null) {
Modal.error({ title: '提示', content: '先保存再下载' });
return false;
}
try {
const formData = new FormData();
formData.append('type', 'gif');
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/pages/editImage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const EditImage = () => {
const searchParams = new URLSearchParams(paramsString);
let imgUrl = searchParams.get('imgUrl');
if (imgUrl.substring(0, 4) != 'blob') {
imgUrl = `${window.baseURL}getFile?url=${imgUrl}`;
imgUrl = `${window.baseURL}file?url=${imgUrl}`;
}
const instance = new ImageEditor(document.querySelector('#tui-image-editor'), {
includeUI: {
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/pages/pinImage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const PinImage: React.FC = () => {
const searchParams = new URLSearchParams(paramsString);
let _imgUrl = searchParams.get('imgUrl') || defaultImg;
if (_imgUrl.substring(0, 4) != 'blob') {
_imgUrl = `${window.baseURL}getFile?url=${_imgUrl}`;
_imgUrl = `${window.baseURL}file?url=${_imgUrl}`;
}

fetch(_imgUrl)
Expand Down

0 comments on commit c3907ee

Please sign in to comment.