Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

파일 시스템logger추가 #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ module.exports = {
"babel/camelcase": 1,
"babel/no-invalid-this": 1,
"babel/object-curly-spacing": 1,
"babel/quotes": 1,
"babel/quotes": 0,
"babel/semi": 1,
"babel/no-unused-expressions": 1,
"babel/valid-typeof": 1
"babel/valid-typeof": 1,
"@typescript-eslint/explicit-function-return-type":0,
"@typescript-eslint/no-use-before-define":0
}
};

Expand Down
49 changes: 48 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mockup-server",
"version": "0.2.6",
"version": "0.2.7",
"private": true,
"scripts": {
"build": "vue-cli-service build",
Expand All @@ -15,14 +15,17 @@
"@types/cors": "^2.8.6",
"@types/express": "^4.17.2",
"@types/node": "^12.12.6",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"core-js": "^2.6.10",
"cors": "^2.8.5",
"eslint-plugin-babel": "^5.3.0",
"express": "^4.17.1",
"moment": "^2.24.0",
"style-loader": "^1.0.0",
"ts-loader": "^6.2.1",
"vue": "^2.6.10",
"vue-axios": "^2.1.5",
"vue-class-component": "^7.0.2",
"vue-property-decorator": "^8.3.0",
"vue-router": "^3.0.3",
Expand Down Expand Up @@ -71,4 +74,4 @@
"last 2 versions"
],
"main": "background.js"
}
}
74 changes: 60 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,70 @@
<template lang="pug">
v-app(dark)
v-app(dark style="-webkit-app-region: drag")
v-app-bar(app)
v-toolbar-title.headline.text-uppercase
span Mockup Server
v-toolbar-title.headline
span Mockup
| {{'v'+packageVersion}}
v-spacer
v-btn(text @click="openBrowser()")
span.mr-2 Latest Release
v-icon mdi-open-in-new
v-btn(v-if="diffResult === true" text @click="openBrowser()")
v-badge(overlap='', color='red' :overlap="false")
template(v-slot:badge='')
| New {{newVersion}}
span.mr-2 Latest Release
v-icon mdi-open-in-new
v-btn(v-else)
span.mr-2 github
v-icon mdi-open-in-new
v-content
router-view
</template>
</template>  

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
const shell = require("electron").shell;
import fs from 'fs';
import {Component, Vue} from 'vue-property-decorator';
const shell = require('electron').shell;
@Component
export default class ComponentName extends Vue {
private openBrowser(): void {
shell.openExternalSync("https://github.com/joon610/mock-server/releases");
return;
}
export default class ComponentName extends Vue {
private newVersion = '';
private packageVersion = '';

private openBrowser() {
shell.openExternalSync(
'https://github.com/joon610/mock-server/releases',
);
return;
}

private created() {
this.getNewRelease();
this.getCurrentVersion();
}

private get diffResult() {
if(this.newVersion === '') return false;
if(this.packageVersion === '') return false;
console.log('this.newVersion :', this.newVersion);
console.log('this.packageVersion :', this.packageVersion);
const githubVersionNum = Number(this.removeVersion(this.removePoint(this.newVersion)));
const packageVersionNum = Number(this.removePoint(this.packageVersion));
console.log('object :', githubVersionNum > packageVersionNum ? true:false);
return githubVersionNum > packageVersionNum ? true:false;
}


private async getNewRelease(){
const url = "https://api.github.com/repos/joon610/mockup-server/releases/latest";
const response = await this.axios.get(url);
const data = response?.data?.name;
this.newVersion = data;
}

private getCurrentVersion() {
const json = JSON.parse(fs.readFileSync('package.json', 'utf8'));
this.packageVersion = json.version;
}

private removePoint = (value:string):string => (value.replace(/\./g ,''));
private removeVersion = (value:string):string => (value.replace(/v/ ,''));

}
</script>
8 changes: 5 additions & 3 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ protocol.registerSchemesAsPrivileged([
]);

function createWindow(): void {
let appWidth = 570;
let appWidth = 878;
if (process.platform === 'darwin') {
appWidth = 540;
appWidth = 840;
}
// Create the browser window.
win = new BrowserWindow({
resizable: true,
width: appWidth,
height: 600,
transparent: isDevelopment? false: true,
frame: isDevelopment? true: false,
height: 760,
webPreferences: {
nodeIntegration: true,
},
Expand Down
28 changes: 17 additions & 11 deletions src/components/ApiList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import {Component, Prop, Vue} from "vue-property-decorator";
import MockupServer from "@/utils/server/mockupServer";
import { ApiInfo } from "@/const/mockType";
import {ApiInfo} from "@/const/mockType";

import {
LOCAL_HOST,
Expand All @@ -27,7 +27,6 @@ const shell = require("electron").shell;
@Component
export default class ApiList extends Vue {
private get hasApiList(): boolean {
console.log("object :", this.$store.getters.apiInfoList);
return this.$store.getters.apiInfoList.length === 0 ? true : false;
}

Expand Down Expand Up @@ -98,12 +97,12 @@ button {
display: inline-block;

background-color: #424242;
border-radius: 5px;
margin-bottom: 5px;
padding-bottom: 5px;
justify-content: center;
vertical-align: middle;
height: 50px;
width: 510px;
border-bottom: 3px solid #303030;
/* width: 510px; */
display: flex;
}
.api-container:hover {
Expand Down Expand Up @@ -142,10 +141,6 @@ button {
text-align: left;
padding: 10px;
}

.api-list-container {
width: 340px;
}
.api-path {
width: 250px;
float: left;
Expand All @@ -157,6 +152,11 @@ button {
white-space: nowrap;
}

.api-container .radio-group .v-input__control .v-input__slot{
margin-bottom: 0 !important;
}


.http-method {
line-height: 50px;
width: 50px;
Expand All @@ -165,13 +165,19 @@ button {

.radio-style {
height: 50px;
margin-right: 10px;
padding: 0;
}

.radio-group {
margin: 0px;
padding: 0px;
display: contents;
}
.v-input__slot {
margin: 0px !important;
padding: 0px !important;
}

.loacalhost-label {
height: 48px;
line-height: 48px;
Expand Down
27 changes: 27 additions & 0 deletions src/components/Logger.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template lang="pug">
.log-container
.log-info
| GET /index.js
.log-request
| Request : {{request}}
</template>>

<script lang="ts">
import {Component, Prop, Vue} from 'vue-property-decorator';

@Component
export default class ComponentName extends Vue {
request = {
test :'hello'
};
}
</script>

<style scoped>
.log-info {
background: dimgray;
}
.log-request {
background: none;
}
</style>
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import App from './App.vue';
import router from './router';
import store from './store';
import vuetify from './plugins/vuetify';

import axios from 'axios';
import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)
Vue.config.productionTip = false;

new Vue({
Expand Down
16 changes: 16 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import Vue from 'vue';
import Vuex from 'vuex';
import { stat } from 'fs';

Vue.use(Vuex);

export default new Vuex.Store({
state: {
apiInfoList: [],
apiRequestLog: [],
rootPath: '',
},
getters: {
apiInfoList: state => {
return state.apiInfoList;
},
apiRequestLog: state => {
return state.apiRequestLog;
},
rootPath: state =>{
return state.rootPath;
}
},
mutations: {
apiInfoList(state, payload): void {
state.apiInfoList = payload;
},
rootPath(state,payload):void {
state.rootPath = payload;
},
apiRequest(state,payload):void {
state.apiRequestLog = payload;
}

},
});
2 changes: 1 addition & 1 deletion src/utils/server/jsonLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class JsonLogic {
}, false);

if (!hasKey) {
if (Object.keys(req.body).length !== 0) {
if (req.body?.id) {
restful.index.push(req.body);
}
}
Expand Down
Loading