mirror of
https://gitee.com/bootx/dax-pay-ui.git
synced 2025-09-04 03:16:02 +00:00
remove 国际化删除, 依赖精简
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import FileService from '../service/FileService';
|
||||
import FileService from '../service/FileService'
|
||||
|
||||
class FileController {
|
||||
private service: FileService = new FileService();
|
||||
private service: FileService = new FileService()
|
||||
|
||||
upload = async (ctx) => {
|
||||
const files = ctx.request.files.file;
|
||||
console.log(files);
|
||||
const files = ctx.request.files.file
|
||||
console.log(files)
|
||||
|
||||
if (files.length === undefined) {
|
||||
this.service.upload(ctx, files, false);
|
||||
this.service.upload(ctx, files, false)
|
||||
} else {
|
||||
this.service.upload(ctx, files, true);
|
||||
this.service.upload(ctx, files, true)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default new FileController();
|
||||
export default new FileController()
|
||||
|
@@ -1,15 +1,15 @@
|
||||
import UserService from '../service/UserService';
|
||||
import UserService from '../service/UserService'
|
||||
|
||||
class UserController {
|
||||
private service: UserService = new UserService();
|
||||
private service: UserService = new UserService()
|
||||
|
||||
login = async (ctx) => {
|
||||
ctx.body = await this.service.login();
|
||||
};
|
||||
ctx.body = await this.service.login()
|
||||
}
|
||||
|
||||
getUserInfoById = async (ctx) => {
|
||||
ctx.body = await this.service.getUserInfoById();
|
||||
};
|
||||
ctx.body = await this.service.getUserInfoById()
|
||||
}
|
||||
}
|
||||
|
||||
export default new UserController();
|
||||
export default new UserController()
|
||||
|
@@ -1,22 +1,22 @@
|
||||
import Koa from 'koa';
|
||||
import path from 'path';
|
||||
import Router from 'koa-router';
|
||||
import body from 'koa-body';
|
||||
import cors from 'koa2-cors';
|
||||
import koaStatic from 'koa-static';
|
||||
import websockify from 'koa-websocket';
|
||||
import route from 'koa-route';
|
||||
import Koa from 'koa'
|
||||
import path from 'path'
|
||||
import Router from 'koa-router'
|
||||
import body from 'koa-body'
|
||||
import cors from 'koa2-cors'
|
||||
import koaStatic from 'koa-static'
|
||||
import websockify from 'koa-websocket'
|
||||
import route from 'koa-route'
|
||||
|
||||
import AppRoutes from './routes';
|
||||
import AppRoutes from './routes'
|
||||
|
||||
const PORT = 3300;
|
||||
const PORT = 3300
|
||||
|
||||
const app = websockify(new Koa());
|
||||
const app = websockify(new Koa())
|
||||
|
||||
app.ws.use(function (ctx, next) {
|
||||
ctx.websocket.send('connection succeeded!');
|
||||
return next(ctx);
|
||||
});
|
||||
ctx.websocket.send('connection succeeded!')
|
||||
return next(ctx)
|
||||
})
|
||||
|
||||
app.ws.use(
|
||||
route.all('/test', function (ctx) {
|
||||
@@ -29,20 +29,20 @@ app.ws.use(
|
||||
id: Math.ceil(Math.random() * 1000),
|
||||
time: new Date().getTime(),
|
||||
res: `${message}`,
|
||||
});
|
||||
ctx.websocket.send(data);
|
||||
})
|
||||
ctx.websocket.send(data)
|
||||
}
|
||||
console.log(message);
|
||||
});
|
||||
console.log(message)
|
||||
})
|
||||
}),
|
||||
);
|
||||
)
|
||||
|
||||
const router = new Router();
|
||||
const router = new Router()
|
||||
|
||||
// router
|
||||
AppRoutes.forEach((route) => router[route.method](route.path, route.action));
|
||||
AppRoutes.forEach((route) => router[route.method](route.path, route.action))
|
||||
|
||||
app.use(cors());
|
||||
app.use(cors())
|
||||
app.use(
|
||||
body({
|
||||
encoding: 'gzip',
|
||||
@@ -53,11 +53,11 @@ app.use(
|
||||
maxFieldsSize: 20 * 1024 * 1024,
|
||||
},
|
||||
}),
|
||||
);
|
||||
app.use(router.routes());
|
||||
app.use(router.allowedMethods());
|
||||
app.use(koaStatic(path.join(__dirname)));
|
||||
)
|
||||
app.use(router.routes())
|
||||
app.use(router.allowedMethods())
|
||||
app.use(koaStatic(path.join(__dirname)))
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Application started successfully: http://localhost:${PORT}`);
|
||||
});
|
||||
console.log(`Application started successfully: http://localhost:${PORT}`)
|
||||
})
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import UserController from './controller/UserController';
|
||||
import FileController from './controller/FileController';
|
||||
import UserController from './controller/UserController'
|
||||
import FileController from './controller/FileController'
|
||||
|
||||
export default [
|
||||
// user
|
||||
@@ -20,4 +20,4 @@ export default [
|
||||
method: 'post',
|
||||
action: FileController.upload,
|
||||
},
|
||||
];
|
||||
]
|
||||
|
@@ -1,54 +1,54 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path'
|
||||
import fs from 'fs-extra'
|
||||
|
||||
const uploadUrl = 'http://localhost:3300/static/upload';
|
||||
const filePath = path.join(__dirname, '../static/upload/');
|
||||
const uploadUrl = 'http://localhost:3300/static/upload'
|
||||
const filePath = path.join(__dirname, '../static/upload/')
|
||||
|
||||
fs.ensureDir(filePath);
|
||||
fs.ensureDir(filePath)
|
||||
export default class FileService {
|
||||
async upload(ctx, files, isMultiple) {
|
||||
let fileReader, fileResource, writeStream;
|
||||
let fileReader, fileResource, writeStream
|
||||
|
||||
const fileFunc = function (file) {
|
||||
fileReader = fs.createReadStream(file.filepath);
|
||||
fileResource = filePath + `/${file.originalFilename}`;
|
||||
console.log(fileResource);
|
||||
fileReader = fs.createReadStream(file.filepath)
|
||||
fileResource = filePath + `/${file.originalFilename}`
|
||||
console.log(fileResource)
|
||||
|
||||
writeStream = fs.createWriteStream(fileResource);
|
||||
fileReader.pipe(writeStream);
|
||||
};
|
||||
writeStream = fs.createWriteStream(fileResource)
|
||||
fileReader.pipe(writeStream)
|
||||
}
|
||||
|
||||
const returnFunc = function (flag) {
|
||||
if (flag) {
|
||||
let url = '';
|
||||
let url = ''
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
url += uploadUrl + `/${files[i].originalFilename},`;
|
||||
url += uploadUrl + `/${files[i].originalFilename},`
|
||||
}
|
||||
url = url.replace(/,$/gi, '');
|
||||
url = url.replace(/,$/gi, '')
|
||||
ctx.body = {
|
||||
url: url,
|
||||
code: 0,
|
||||
message: 'upload Success!',
|
||||
};
|
||||
}
|
||||
} else {
|
||||
ctx.body = {
|
||||
url: uploadUrl + `/${files.originalFilename}`,
|
||||
code: 0,
|
||||
message: 'upload Success!',
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
console.log(isMultiple, files.length);
|
||||
}
|
||||
console.log(isMultiple, files.length)
|
||||
|
||||
if (isMultiple) {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const f1 = files[i];
|
||||
fileFunc(f1);
|
||||
const f1 = files[i]
|
||||
fileFunc(f1)
|
||||
}
|
||||
} else {
|
||||
fileFunc(files);
|
||||
fileFunc(files)
|
||||
}
|
||||
fs.ensureDir(filePath);
|
||||
returnFunc(isMultiple);
|
||||
fs.ensureDir(filePath)
|
||||
returnFunc(isMultiple)
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Result } from '../utils';
|
||||
import { Result } from '../utils'
|
||||
|
||||
const fakeUserInfo = {
|
||||
userId: '1',
|
||||
@@ -13,13 +13,13 @@ const fakeUserInfo = {
|
||||
value: 'super',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
export default class UserService {
|
||||
async login() {
|
||||
return Result.success(fakeUserInfo);
|
||||
return Result.success(fakeUserInfo)
|
||||
}
|
||||
|
||||
async getUserInfoById() {
|
||||
return Result.success(fakeUserInfo);
|
||||
return Result.success(fakeUserInfo)
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,6 @@ export class Result {
|
||||
code: 0,
|
||||
success: true,
|
||||
result: data,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user