more specific price seach should be working
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { WebviewTag } from 'electron';
|
||||
import * as _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { ItemTextService } from '../services';
|
||||
import { PoeService } from '../services/poe.service';
|
||||
import { LoginWebview } from './login-webview';
|
||||
import { PriceListItem } from './price-list-item/price-list-item';
|
||||
@@ -44,9 +46,13 @@ export class Home extends React.Component<any, IState> {
|
||||
if (json === null || json['error']) {
|
||||
this.setState({ showLogin: true });
|
||||
} else if (json.items) {
|
||||
this.setState({ showLogin: false, data: json.items });
|
||||
this.getItemPrice(json.items, 0);
|
||||
console.log(json.items);
|
||||
const items = _.map(json.items, item => {
|
||||
item.fullText = ItemTextService.parseItem(item);
|
||||
return item;
|
||||
});
|
||||
|
||||
this.setState({ showLogin: false, data: items });
|
||||
this.getItemPrice(items, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +66,10 @@ export class Home extends React.Component<any, IState> {
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await PoeService.priceCheck(data[index].typeLine);
|
||||
if (res.currency_rec && res.min_price) {
|
||||
console.log(data[index]);
|
||||
console.log(data[index].fullText + '\n\n\n');
|
||||
const res = await PoeService.priceCheck(data[index].fullText);
|
||||
if ((res.min && res.currency) || (res.currency_rec && res.min_price)) {
|
||||
const dataCopy: any = [...data];
|
||||
dataCopy[index].priceInfo = res;
|
||||
await new Promise(resolve => this.setState({ data: dataCopy }, resolve));
|
||||
@@ -79,6 +87,10 @@ export class Home extends React.Component<any, IState> {
|
||||
public render() {
|
||||
const { data, showLogin } = this.state;
|
||||
|
||||
const url =
|
||||
'https://www.pathofexile.com/character-window/get-stash-items' +
|
||||
'?league=Incursion&tabs=1&tabIndex=0&accountName=DoctorCoctor';
|
||||
|
||||
return (
|
||||
<div style={{ padding: '20px' }}>
|
||||
{showLogin && <LoginWebview onSuccess={this.onLogin} />}
|
||||
@@ -88,7 +100,7 @@ export class Home extends React.Component<any, IState> {
|
||||
ref="webview"
|
||||
partition="persist:poe"
|
||||
preload="ipc-renderer.js"
|
||||
src="https://www.pathofexile.com/character-window/get-stash-items?league=Incursion&tabs=1&tabIndex=13&accountName=DoctorCoctor"
|
||||
src={url}
|
||||
style={{ opacity: 0, width: '0', height: '0' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +30,7 @@ export class LoginWebview extends React.Component<IProps, any> {
|
||||
ref="webview"
|
||||
partition="persist:poe"
|
||||
src="https://www.pathofexile.com/login"
|
||||
style={{ height: '100%', width: '100%' }}
|
||||
style={{ height: '500px', width: '100%' }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,17 +18,20 @@ export class PriceListItem extends React.Component<IProps, IState> {
|
||||
componentDidMount() {}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
const { fullText, icon, priceInfo, typeLine } = this.props.data;
|
||||
|
||||
return (
|
||||
<div className="pli">
|
||||
<div className="pli" title={fullText}>
|
||||
<div style={{ width: '100px' }}>
|
||||
<img src={data.icon} className="pli__img" />
|
||||
<img src={icon} className="pli__img" />
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<div style={{ marginBottom: '10px' }}>
|
||||
<b>{data.typeLine}</b>
|
||||
<b>{typeLine}</b>
|
||||
</div>
|
||||
<div>
|
||||
{priceInfo ? `${priceInfo.min || priceInfo.min_price} ${priceInfo.currency || priceInfo.currency_rec}` : ''}
|
||||
</div>
|
||||
<div>{data.priceInfo ? `${data.priceInfo.min_price} ${data.priceInfo.currency_rec}` : ''}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
12
app/model/frame-type.ts
Normal file
12
app/model/frame-type.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
export const FrameType: { [key: number]: string } = {
|
||||
0: 'Normal',
|
||||
1: 'Magic',
|
||||
2: 'Rare',
|
||||
3: 'Unique',
|
||||
4: 'Gem',
|
||||
5: 'Currency',
|
||||
6: 'Divination Card',
|
||||
7: 'Quest Item',
|
||||
8: 'Prophecy',
|
||||
9: 'Relic',
|
||||
};
|
||||
2
app/services/index.ts
Normal file
2
app/services/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './item-text.service';
|
||||
export * from './poe.service';
|
||||
107
app/services/item-text.service.ts
Normal file
107
app/services/item-text.service.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import * as _ from 'lodash';
|
||||
import { FrameType } from '../model/frame-type';
|
||||
|
||||
const lineBreak = '--------\n';
|
||||
|
||||
const parseItem = (item: any): string => {
|
||||
let name = '';
|
||||
|
||||
name += `Rarity: ${FrameType[item.frameType]}\n`;
|
||||
name += item.name ? filterName(item.name) + '\n' : '';
|
||||
name += filterName(item.typeLine) + '\n';
|
||||
name += getProperties(item.properties);
|
||||
name += getProperties(item.requirements, 'Requirements:\n');
|
||||
// sockets
|
||||
name += getSockets(item.sockets);
|
||||
name += item.ilvl ? `${lineBreak}Item Level: ${item.ilvl}\n` : '';
|
||||
name += getMods(item.implicitMods);
|
||||
name += getMods(item.explicitMods);
|
||||
|
||||
if (!item.identified) {
|
||||
name += lineBreak;
|
||||
name += 'Unidentified\n';
|
||||
}
|
||||
|
||||
if (item.corrupted) {
|
||||
name += lineBreak;
|
||||
name += 'Corrupted\n';
|
||||
}
|
||||
|
||||
if (item.elder) {
|
||||
name += lineBreak;
|
||||
name += 'Elder Item\n';
|
||||
}
|
||||
|
||||
if (item.shaper) {
|
||||
name += lineBreak;
|
||||
name += 'Shaper Item\n';
|
||||
}
|
||||
|
||||
if (item.descrText) {
|
||||
name += lineBreak;
|
||||
name += `${item.descrText}\n`;
|
||||
}
|
||||
|
||||
return name;
|
||||
};
|
||||
|
||||
const getSockets = (sockets: any[]): string => {
|
||||
if (!sockets) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let content = lineBreak;
|
||||
content += 'Sockets: ';
|
||||
|
||||
const grp = _.groupBy(sockets, 'group');
|
||||
|
||||
_.each(_.keys(grp), key => {
|
||||
content += grp[key].map(g => g.sColour).join('-');
|
||||
content += ' ';
|
||||
});
|
||||
|
||||
return content.trim() + '\n';
|
||||
};
|
||||
|
||||
const filterName = (name: string): string => {
|
||||
const index = name.lastIndexOf('>');
|
||||
if (index < 0) {
|
||||
return name;
|
||||
}
|
||||
|
||||
return name
|
||||
.slice(index + 4, name.length)
|
||||
.replace('{', '')
|
||||
.replace('}', '');
|
||||
};
|
||||
|
||||
const getMods = (mods: string[]): string => {
|
||||
if (!mods || mods.length === 0) {
|
||||
return '';
|
||||
}
|
||||
let content = lineBreak;
|
||||
content += _.map(mods, filterName).join('\n') + '\n';
|
||||
return content;
|
||||
};
|
||||
|
||||
const getProperties = (p?: any[], precedingText?: string): string => {
|
||||
if (!p) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let content = lineBreak;
|
||||
content += precedingText || '';
|
||||
p.forEach(item => {
|
||||
content += item.name;
|
||||
if (item.values && item.values.length > 0) {
|
||||
content += `: ${item.values[0][0]}`;
|
||||
}
|
||||
content += '\n';
|
||||
});
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
export const ItemTextService = {
|
||||
parseItem,
|
||||
};
|
||||
@@ -3,7 +3,8 @@ import { http } from '../http';
|
||||
export class PoeService {
|
||||
public static async getStash(): Promise<any> {
|
||||
const res = await http.get(
|
||||
'https://pathofexile.com/character-window/get-stash-items?league=Incursion&tabs=1&tabIndex=6&accountName=DoctorCoctor',
|
||||
'https://pathofexile.com/character-window/get-stash-items?' +
|
||||
'league=Incursion&tabs=1&tabIndex=6&accountName=DoctorCoctor',
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -11,11 +12,7 @@ export class PoeService {
|
||||
public static async priceCheck(item: any) {
|
||||
const res = await http.get(`https://poeprices.info/api?l=Incursion&i=${encodeURI(btoa(item))}`, {
|
||||
headers: {
|
||||
// Host: 'poeprices.info',
|
||||
// Connection: 'keep-alive',
|
||||
'Cache-Control': 'max-age=600',
|
||||
// Origin: 'https://poeprices.info',
|
||||
// Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
|
||||
},
|
||||
});
|
||||
return res.data;
|
||||
|
||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -84,6 +84,11 @@
|
||||
"vue-template-es2015-compiler": "1.6.0"
|
||||
}
|
||||
},
|
||||
"@types/lodash": {
|
||||
"version": "4.14.116",
|
||||
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.116.tgz",
|
||||
"integrity": "sha512-lRnAtKnxMXcYYXqOiotTmJd74uawNWuPnsnPrrO7HiFuE3npE2iQhfABatbYDyxTNqZNuXzcKGhw37R7RjBFLg=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "7.0.69",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-7.0.69.tgz",
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/lodash": "^4.14.116",
|
||||
"@types/react": "^16.4.9",
|
||||
"@types/react-dom": "^16.0.7",
|
||||
"autoprefixer": "^9.1.1",
|
||||
@@ -63,6 +64,7 @@
|
||||
"file-loader": "^1.1.11",
|
||||
"font-awesome": "^4.7.0",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"lodash": "^4.17.10",
|
||||
"node-sass": "^4.9.3",
|
||||
"normalize.css": "^8.0.0",
|
||||
"open-color": "^1.6.3",
|
||||
|
||||
Reference in New Issue
Block a user