Skip to content

Commit

Permalink
添加部分操作提示
Browse files Browse the repository at this point in the history
  • Loading branch information
slime7 committed Dec 6, 2018
1 parent a3f6cb1 commit 2d6bf2a
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 18 deletions.
7 changes: 6 additions & 1 deletion package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kanmand",
"version": "0.1.5",
"version": "0.1.6",
"author": {
"name": "Slime7",
"url": "https://github.com/slime7"
Expand All @@ -17,6 +17,7 @@
"axios": "^0.18.0",
"qs": "^6.6.0",
"vue": "^2.5.17",
"vue-toasted": "^1.1.26",
"vuex": "^3.0.1"
},
"devDependencies": {
Expand Down
17 changes: 16 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ export default {
},
onReqReply() {
if (ipcRenderer) {
ipcRenderer.on('kancolle-command-reply', (event, { requestIndex, requests }) => {
ipcRenderer.on('kancolle-command-reply', (event, {
requestIndex,
requests,
error,
}) => {
if (error) {
this.$toasted.error(error);
return;
}
const requestsCopy = JSON.parse(JSON.stringify(requests));
if (requestsCopy.length === 0) {
this.selectEditingRequest(null);
Expand Down Expand Up @@ -190,6 +199,12 @@ export default {
text-shadow: 0 1px #000, 1px 0 #000, -1px 0 #000, 0 -1px #000;
}
.dq-frame.toasted {
border-radius: 6px;
background-color: #000;
box-shadow: 0 0 0 1px #000, 0 0 7px 3px #000 inset;
}
.dq-frame-heading, .dq-frame-body {
position: relative;
padding: 8px;
Expand Down
30 changes: 20 additions & 10 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,22 @@ function createWindow() {
reqInd,
direction,
}) => {
const reply = (requests, requestIndex) => {
event.sender.send('kancolle-command-reply', { requests, requestIndex });
const reply = (requests, requestIndex, error) => {
event.sender.send('kancolle-command-reply', { requests, requestIndex, error });
};
const init = (force) => {
if (force || !kanmand) {
kanmand = new KancolleRequest(reqData.gameLink);
kanmand.setStageEndCallback(reply);
kanmand = new KancolleRequest();
const success = kanmand.init(reqData.gameLink);
if (!success) {
kanmand = null;
reply(null, null, '游戏链接填写有误');
} else {
kanmand.setStageEndCallback(reply);
}
return !!success;
}
return true;
};

switch (type) {
Expand All @@ -88,9 +96,10 @@ function createWindow() {
break;

case 'add':
init();
kanmand.add(reqData.gameRoute, reqData.gameData);
reply(kanmand.requestInfo().requests);
if (init()) {
kanmand.add(reqData.gameRoute, reqData.gameData);
reply(kanmand.requestInfo().requests);
}
break;

case 'clear':
Expand Down Expand Up @@ -124,9 +133,10 @@ function createWindow() {
break;

case 'import':
init(true);
kanmand.importReq(reqData.importString);
reply(kanmand.requestInfo().requests);
if (init(true)) {
kanmand.importReq(reqData.importString);
reply(kanmand.requestInfo().requests);
}
break;

default:
Expand Down
2 changes: 2 additions & 0 deletions src/components/Command.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
},
addCommand() {
if (this.gameLink === '' || this.gameRoute === '' || this.gameData === '') {
this.toasted.show('内容填写不全');
return;
}
const reqData = {
Expand Down Expand Up @@ -128,6 +129,7 @@ export default {
reqInd: this.selected,
reqData,
});
this.$toasted.show('修改完成。');
},
importCommand() {
if (this.gameLink === '' || this.gameRoute === '' || this.gameData === '') {
Expand Down
1 change: 1 addition & 0 deletions src/components/RequestLine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default {
req.requests.push({ ro: r.route.name, da: r.data });
});
clipboard.writeText(btoa(JSON.stringify(req)));
this.$toasted.show('已复制到剪切板');
},
...mapMutations(['selectEditingRequest']),
},
Expand Down
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import Vue from 'vue';
import Toasted from 'vue-toasted';
import App from './App.vue';
import store from './store';

Vue.config.productionTip = false;

Vue.use(Toasted, {
className: 'dq-frame',
position: 'top-center',
duration: 2000,
});

new Vue({
store,
render: h => h(App),
Expand Down
19 changes: 14 additions & 5 deletions src/utils/KancolleRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ function parseGameLink(link) {
}

export default class KancolleRequest {
constructor(gameLink) {
this.gameInfo = {
...parseGameLink(gameLink),
gameLink,
};
constructor() {
this.gameInfo = null;
this.loading = 0;
this.requests = [];
this.requestIndex = 0;
Expand All @@ -55,6 +52,18 @@ export default class KancolleRequest {
this.stageEndCallback = stageEndCallback;
}

init(gameLink) {
const gameBaseInfo = parseGameLink(gameLink);
if (gameBaseInfo) {
this.gameInfo = {
...gameBaseInfo,
gameLink,
};
return this;
}
return false;
}

add(route, data) {
this.requests.push({ route, data });
}
Expand Down

0 comments on commit 2d6bf2a

Please sign in to comment.