-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bbcc2f
commit 2979294
Showing
18 changed files
with
255 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,54 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { fetchGoodsList, GoodsRecord } from './service'; | ||
|
||
export default function Home() { | ||
const [mounted, setMounted] = useState(false); | ||
|
||
useEffect(() => { | ||
setMounted(true); | ||
}, []); | ||
const onAddToCart = (item: GoodsRecord) => { | ||
console.log('onAddToCart', JSON.stringify(item)); | ||
// await reportTrack().select('reportAdapter').track('addCart', { | ||
// price: 25.99, | ||
// goodsId: '23432252', | ||
// goodsName: 'Long Chair', | ||
// count: 1, | ||
// }); | ||
}; | ||
|
||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-between p-24"> | ||
<div> | ||
Hello @hyperse/track | ||
</div> | ||
<main className="flex min-h-screen flex-col items-center justify-between gap-4"> | ||
{mounted && | ||
fetchGoodsList().map((item, index: number) => { | ||
return ( | ||
<div | ||
key={index} | ||
className="flex h-80 w-4/5 max-w-md flex-col gap-1 rounded-2xl bg-gray-50 p-3" | ||
> | ||
<div className="h-48 rounded-xl bg-gray-700"></div> | ||
<div className="flex flex-col gap-4"> | ||
<div className="flex flex-row justify-between"> | ||
<div className="flex flex-col"> | ||
<span className="text-xl font-bold text-gray-700"> | ||
{item.goodsName} | ||
</span> | ||
<p className="text-xs text-gray-700">ID: {item.goodsId}</p> | ||
</div> | ||
<span className="font-bold text-red-600">${item.price}</span> | ||
</div> | ||
<button | ||
className="rounded-md bg-sky-800 py-2 text-gray-50 hover:bg-sky-700" | ||
onClick={() => onAddToCart(item)} | ||
> | ||
Add to cart | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Mock from 'mockjs'; | ||
|
||
export interface GoodsRecord { | ||
goodsName: string; | ||
goodsId: string; | ||
price: number; | ||
} | ||
|
||
export const fetchGoodsList = (): GoodsRecord[] => { | ||
const data = Mock.mock({ | ||
'list|10-20': [ | ||
{ | ||
goodsName: '@cword(3,5)', | ||
goodsId: '@id()', | ||
price: '@float(10, 100, 2, 2)', | ||
}, | ||
], | ||
}); | ||
return data.list; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Don't be scared of the generics here. | ||
* All they do is to give us autocompletion when using this. | ||
* @type {import("next").NextConfig} | ||
*/ | ||
export default { | ||
reactStrictMode: true, | ||
eslint: { | ||
ignoreDuringBuilds: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const reportTrack = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export type ReportAdapterOptions<Context, EventData> = { | ||
setup?: <EventType extends keyof EventData>( | ||
ctx: Context, | ||
eventTYpe: EventType, | ||
eventData: EventData[EventType] | ||
) => Promise<{ | ||
timeStamp: number; | ||
}>; | ||
}; | ||
|
||
export type ReportTrackData = { | ||
env: 'prod' | 'uat'; | ||
platform: 'android' | 'ios'; | ||
ip: string; | ||
}; | ||
|
||
export type ReportEventData = { | ||
pv?: { | ||
url: string; | ||
timeStamp: number; | ||
userName: string; | ||
userId: string; | ||
}; | ||
addCart?: { | ||
price: number; | ||
goodsId: string; | ||
goodsName: string; | ||
count: number; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ | |
], | ||
"workspaces": [ | ||
"website", | ||
"examples/next-example", | ||
"examples/*", | ||
"./" | ||
], | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './type-union-tuple.js'; | ||
export * from './types-adapter.js'; | ||
export * from './types-create.js'; | ||
export * from './types-logger.js'; | ||
export * from './types-track.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.