Skip to content

Commit

Permalink
fix top await
Browse files Browse the repository at this point in the history
  • Loading branch information
awkj committed Apr 29, 2022
1 parent 27bcd92 commit 4dc1013
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/api/xueqiu/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export async function searchStocks(key: string): Promise<StockMini[] | undefined
}

function getPercent(percent: number): string {
if (!percent) {
return `0.00`
}
if (percent >= 0) {
return `+${percent.toFixed(2)}`
} else {
Expand Down
9 changes: 8 additions & 1 deletion src/component/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ export const openCoinState = atom({
default: false,
})

const stocksSelector = selector({
key: 'stocksSelector',
get: async ({ get }) => {
return await getStockToStore() as string[]
}
})

export const stocksState = atom({
key: "stocks",
default: await getStockToStore() as string[]
default: stocksSelector
})


Expand Down
9 changes: 4 additions & 5 deletions src/component/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ export async function getStockToStore() {
}

export async function saveStockToStore(stockList: string[]) {
console.log("存储股票列表", stockList)
await store.set(configKey, JSON.stringify(stockList))
await store.save()
}


export function getBackgoundClass(percent: number) {
if (percent === 0) {
if (percent === 0 || percent == null) {
return `bg-neutral-700`
}
if (percent > 0) {
Expand All @@ -48,12 +47,11 @@ export function getTextClassByDiff(value: number, base: number) {
} else {
return `text-emerald-700`
}

}


export function getTextClass(percent: number) {
if (percent === 0) {
if (percent === 0 || percent == null) {
return `text-neutral-700`
}
if (percent > 0) {
Expand Down Expand Up @@ -92,4 +90,5 @@ function getDate(tm: number) {
export async function openXueqiu(symbol: string) {
console.log("symbol", symbol)
await openURL(`https://xueqiu.com/S/${symbol}`)
}
}
export { }
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
build: {
target: ['edge90', 'chrome90', 'firefox90', 'safari15']
}
})

0 comments on commit 4dc1013

Please sign in to comment.