-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: tanstack query demos #4276
Conversation
|
WalkthroughThe changes introduce new features to enhance data handling in a Vue application. A new dependency, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant App
participant API
User->>App: Initiates data fetch
App->>API: Sends request
API-->>App: Returns response
App->>User: Displays data
User->>App: Triggers retry on failure
App->>API: Resends request
API-->>App: Returns response
App->>User: Displays data
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (4)
playground/src/views/demos/features/vue-query/query-retries.vue (1)
8-15
: Remove the unused_resolve
parameter.The
_resolve
parameter is unused in thefetchApi
function and can be removed.Apply this diff to remove the unused parameter:
-return new Promise((_resolve, reject) => { +return new Promise((reject) => {playground/package.json (1)
48-49
: Nitpick: Reorder the keys in thedependencies
object.To improve the readability and maintainability of the
package.json
file, consider reordering the keys in thedependencies
object in ascending order.Apply this diff to reorder the keys:
- "vue-router": "^4.4.3", - "@tanstack/vue-query": "^5.53.1" + "@tanstack/vue-query": "^5.53.1", + "vue-router": "^4.4.3"Tools
GitHub Check: Lint (ubuntu-latest)
[failure] 49-49:
Expected object keys to be in ascending order. '@tanstack/vue-query' should be before 'vue-router'playground/src/views/demos/features/vue-query/paginated-queries.vue (2)
45-45
: Add a uniquekey
attribute to the<li>
elements for better accessibility and performance.- <li v-for="item in data.products"> + <li v-for="item in data.products" :key="item.id">
42-42
: Improve the error message to provide a better user experience.Consider providing a more user-friendly error message instead of displaying the raw error. You can also provide a way for the user to retry the request.
- <div v-else-if="isError">出错了: {{ error }}</div> + <div v-else-if="isError"> + <p>Oops! Something went wrong.</p> + <Button @click="refetch">Retry</Button> + </div>
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (9)
- packages/effects/request/package.json (1 hunks)
- playground/package.json (1 hunks)
- playground/src/bootstrap.ts (2 hunks)
- playground/src/router/routes/modules/demos.ts (1 hunks)
- playground/src/views/demos/features/vue-query/index.vue (1 hunks)
- playground/src/views/demos/features/vue-query/infinite-queries.vue (1 hunks)
- playground/src/views/demos/features/vue-query/paginated-queries.vue (1 hunks)
- playground/src/views/demos/features/vue-query/query-retries.vue (1 hunks)
- playground/src/views/demos/features/vue-query/typing.ts (1 hunks)
Additional context used
GitHub Check: Lint (ubuntu-latest)
playground/package.json
[failure] 49-49:
Expected object keys to be in ascending order. '@tanstack/vue-query' should be before 'vue-router'
Additional comments not posted (18)
playground/src/views/demos/features/vue-query/typing.ts (1)
1-18
: LGTM!The
IProducts
interface is well-defined and follows TypeScript best practices:
- The interface name is prefixed with
I
to indicate it's an interface.- The properties have appropriate types.
- The
products
property is defined as an array of objects with specific properties.The code changes are approved.
packages/effects/request/package.json (1)
25-26
: LGTM!The addition of the
axios-retry
library is a great choice for enhancing the reliability of API calls made throughaxios
. The version constraint^4.5.0
allows for minor and patch updates, ensuring compatibility with the latest bug fixes and improvements. This change aligns well with the PR objectives and the linked issue, which aim to integrate theaxios-retry
library for automatic request retries.playground/src/bootstrap.ts (2)
8-8
: LGTM!The code changes are approved.
30-31
: LGTM!The code changes are approved.
playground/src/views/demos/features/vue-query/index.vue (5)
1-9
: LGTM!The script section correctly imports the required dependencies and child components.
11-25
: LGTM!The template section correctly uses the
Page
component to wrap the content and a grid layout to display the child components. TheCard
component is used to wrap each child component.
14-16
: LGTM!The
PaginatedQueries
component is correctly used and wrapped inside aCard
component with the title "分页查询".
17-19
: LGTM!The
InfiniteQueries
component is correctly used and wrapped inside aCard
component with the title "无限滚动". The additional classes are correctly used to set a fixed height and enable overflow scrolling.
20-22
: LGTM!The
QueryRetries
component is correctly used and wrapped inside aCard
component with the title "错误重试".playground/src/views/demos/features/vue-query/query-retries.vue (3)
1-28
: LGTM!The script setup section is correctly implemented. The
fetchApi
function simulates a failed API request, and theuseQuery
hook is correctly configured to retry failed requests 3 times before displaying an error.
30-34
: LGTM!The template section is correctly implemented. The button's loading state is correctly bound to the
isFetching
property, and the retry count and error message are correctly displayed based on the component's state.
24-27
: LGTM!The
onClick
function is correctly implemented. Resetting thecount
value ensures that the retry count is accurately displayed, and awaiting therefetch
call ensures that the query is refetched before the function returns.playground/package.json (1)
49-49
: LGTM!The addition of the
@tanstack/vue-query
dependency is a valid change that enhances the project's data fetching and state management capabilities. The version constraint^5.53.1
ensures compatibility with future minor and patch releases of the library.Tools
GitHub Check: Lint (ubuntu-latest)
[failure] 49-49:
Expected object keys to be in ascending order. '@tanstack/vue-query' should be before 'vue-router'playground/src/views/demos/features/vue-query/paginated-queries.vue (2)
1-32
: LGTM!The script setup section follows best practices and correctly uses the
@tanstack/vue-query
library to manage paginated data fetching.
34-51
: LGTM!The template section correctly renders the pagination buttons, handles the loading/error/data states, and renders the list of products using
v-for
directive.playground/src/views/demos/features/vue-query/infinite-queries.vue (2)
1-35
: LGTM!The script section follows best practices and correctly sets up the
useInfiniteQuery
hook for infinite scrolling.
37-58
: LGTM!The template section correctly renders the list of products and handles different states of the query using conditional rendering.
playground/src/router/routes/modules/demos.ts (1)
186-194
: LGTM!The new route declaration for
VueQueryDemo
is correctly implemented and expands the functionality of the routing module.
playground/src/views/demos/features/vue-query/infinite-queries.vue
Outdated
Show resolved
Hide resolved
playground/src/views/demos/features/vue-query/infinite-queries.vue
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- playground/package.json (1 hunks)
- playground/src/views/demos/features/vue-query/paginated-queries.vue (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- playground/package.json
- playground/src/views/demos/features/vue-query/paginated-queries.vue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (2)
- playground/package.json (1 hunks)
- playground/src/views/demos/features/vue-query/infinite-queries.vue (1 hunks)
Files skipped from review due to trivial changes (1)
- playground/package.json
Files skipped from review as they are similar to previous changes (1)
- playground/src/views/demos/features/vue-query/infinite-queries.vue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (1)
- playground/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
- playground/package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (1)
- playground/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
- playground/package.json
* chore(@vben/request): add axios-retry * feat: error retry * feat: paginated queries * feat: infinite queries * chore: update * chore: update * fix: ci error * chore: update * chore: remove axios-retry * chore: update deps * chore: update deps * chore: update deps * chore: update pnpm.lock --------- Co-authored-by: vince <vince292007@gmail.com>
Description
closes #4257
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit
New Features
axios-retry
for improved handling of failed HTTP requests.@tanstack/vue-query
for enhanced data fetching and state management.Documentation
These updates enhance user experience by offering more reliable data handling and interactive features.