Skip to content

Commit

Permalink
feat: request champion list from 101.qq.com by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
cangzhang committed May 12, 2020
1 parent e694546 commit 2b8a397
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
9 changes: 7 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const App = () => {
myTeam = [],
localPlayerCellId: cellId,
} = await lcuIns.getCurrentSession();

const me = _find(myTeam, (i) => i.summonerId > 0 && i.cellId === cellId) || {};
const { championId: mChampionId } = me;
let championId;
Expand All @@ -74,14 +75,15 @@ const App = () => {
mChampionId > 0 && myTeam.length > 0 && myTeam.every((i) => i.championId === mChampionId);

championId = findUserChampion(cellId, actions);
console.log(`isRandomMode ${isRandomMode}, isVoteMode ${isVoteMode}, My pick ${cellId}`);
console.log(`isRandomMode: ${isRandomMode}, isVoteMode: ${isVoteMode}, My pick: ${cellId}`);

if (isRandomMode || isVoteMode) {
// special mode
championId = me.championId;
}

if (!championId) {
console.log(`no matched`);
console.log(`no matched.`);
throw new Error(`no active session.`);
}

Expand All @@ -90,8 +92,11 @@ const App = () => {
championId,
position: null,
});

console.log(`show popup.`);
return true;
} catch (_err) {
console.log(_err);
if (process.env.IS_DEV) return;

ipcRenderer.send(`hide-popup`);
Expand Down
8 changes: 5 additions & 3 deletions src/modules/popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import { LightTheme, BaseProvider } from 'baseui';
import { Tabs, Tab } from 'baseui/tabs';

import config from 'src/native/config';
import { getChampions, DDragonCDNUrl } from 'src/service/ddragon';
import { QQChampionAvatarPrefix, getChampions } from 'src/service/101-qq';
import LolQQ from 'src/service/data-source/lol-qq';
import Opgg from 'src/service/data-source/op-gg';
import LCUService from 'src/service/lcu';

import PerkShowcase from 'src/components/perk-showcase';
import RunePreview from 'src/components/rune-preview';

import { getChampionInfo } from './utils';
import RunePreview from 'src/components/rune-preview';

const engine = new Styletron();
const TabNames = {
Expand Down Expand Up @@ -139,7 +140,8 @@ export default function Popup() {
key={championDetail.id}
className={s.avatar}
alt={championDetail.name}
src={`${DDragonCDNUrl}/${lolVer}/img/champion/${championDetail.id}.png`}
// src={`${DDragonCDNUrl}/${lolVer}/img/champion/${championDetail.id}.png`}
src={`${QQChampionAvatarPrefix}/${championDetail.id}.png`}
/>
</div>
)}
Expand Down
14 changes: 14 additions & 0 deletions src/service/101-qq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import http from './http';

export const QQServicePrefix = `https://game.gtimg.cn`;

export const QQChampionAvatarPrefix = `${QQServicePrefix}/images/lol/act/img/champion`;

export const getChampions = () =>
http.get(`${QQServicePrefix}/images/lol/act/img/js/heroList/hero_list.js`).then((res) =>
res.hero.map((i) => ({
...i,
key: i.heroId,
id: i.alias,
})),
);
6 changes: 2 additions & 4 deletions src/service/ddragon.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ const ChampionNames = [
const DDragonCDNUrl = 'https://ddragon.leagueoflegends.com/cdn';

const getLolVer = async () => {
const resp = await http.get('https://ddragon.leagueoflegends.com/api/versions.json');
const resp = await http.get(`${DDragonCDNUrl}/api/versions.json`);
return resp[0];
};

const getChampions = async (ver, region = 'en_US') => {
const { data } = await http.get(
`https://ddragon.leagueoflegends.com/cdn/${ver}/data/${region}/champion.json`,
);
const { data } = await http.get(`${DDragonCDNUrl}/cdn/${ver}/data/${region}/champion.json`);
return data;
};

Expand Down

0 comments on commit 2b8a397

Please sign in to comment.