Coder Social home page Coder Social logo

alovajs / scene Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 5.0 3.4 MB

request strategy with alova.js

Home Page: https://alova.js.org

License: MIT License

JavaScript 14.88% TypeScript 83.98% Shell 0.03% Vue 1.11%
alova axios fetch-api javascript request superagent xmlhttprequest

scene's People

Contributors

jou-amjs avatar meetinaxd avatar ordinarysf avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

scene's Issues

使用uniapp 适配器后使用usePagination 初始化会请求两页

Reproduction Link

Version

1.4.0

Describe the Bug

请详细描述bug

const { page, data: dataSource, replace, isLastPage, loading } = usePagination(
	(pageNo, pageSize) => IndexApi.deviceManagePage({ pageNo, pageSize, type: type.value}),
	{
		// 请求前的初始数据(接口返回的数据格式)
		initialData: {
			total: 0,
			list: []
		},
		data: response => response.list,
		initialPage: 1, // 初始页码,默认为1
		initialPageSize: 10, // 初始每页数据条数,默认为10
		append: true,
		watchingStates: [pickerValue],
	}
)

第一次请求的参数
pageNo=1&pageSize=10&type=0
第二次请求的参数
pageNo=2&pageSize=10&type=0

(pageNo, pageSize) => {
	console.log(pageNo);
	return IndexApi.deviceManagePage({ pageNo, pageSize, type: range.value[pickerValue.value].value })
},

输出为
image

期望的表现

No response

alova 版本

2.16.1

设备/浏览器/浏览器版本

No response

额外的说明

No response

Reproduce Steps

1、使用了uniapp 适配器 。
2、使用usePagination

Device / Browser / Browser Version

No response

[Feature Request] 分页 hook reload 函数执行逻辑问题

你在什么情况下,需要这个功能解决什么问题?

分页 hook reload 函数从cofnig 中获取initialPage页,并重新加载数据,我认为这样更加符合直觉,而不是固定从第一页开始加载。

你期望的 API 是什么样子的?

rt

[Bug Report] usePagination initialData配置项无效

Reproduction Link

https://codesandbox.io/p/devbox/alova-usepagination-564lfk?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clq0oaqne00073b6h29vkhjls%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clq0oaqnd00023b6hm7cwa98w%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clq0oaqnd00043b6hsfki2uez%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clq0oaqne00063b6hkz8cmhat%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clq0oaqnd00023b6hm7cwa98w%2522%253A%257B%2522id%2522%253A%2522clq0oaqnd00023b6hm7cwa98w%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522clq0oaqne00063b6hkz8cmhat%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clq0oaqne00053b6hl1vsdag4%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522npm%2520run%2520dev%2522%252C%2522port%2522%253A5173%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522clq0oaqne00063b6hkz8cmhat%2522%252C%2522activeTabId%2522%253A%2522clq0oaqne00053b6hl1vsdag4%2522%257D%252C%2522clq0oaqnd00043b6hsfki2uez%2522%253A%257B%2522id%2522%253A%2522clq0oaqnd00043b6hsfki2uez%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clq0oaqnd00033b6hrdmh1k1o%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522npm%2520run%2520dev%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clq0oaqnd00033b6hrdmh1k1o%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

Version

1.2.1

Describe the Bug

使用@alova/scene-vue中的usePagination, config中正确设置了initialData,total,data, 不立即请求,此时total,data并没有为initialData中预设的值。vue devtools中的显示如下:

截屏2023-12-11 17 41 54

源码中初始化data和total的时候,似乎并没有考虑根据initialData来赋值。

const data = $([], trueValue);

total = $(undefinedValue, trueValue),

Reproduce Steps

  1. const {data, total} = usePagination(getter, {initialData: { total: 3, data: [1,2,3]}, immediate: false})
  2. data, total 值不正常

Device / Browser / Browser Version

No response

[Bug Report] 在 Taro 中使用 useCaptcha 报错

Reproduction Link

Version

1.5.0

Describe the Bug

在 Taro + React + 微信小程序环境下,引入 useCaptcha 后,报错:can not call useHooks until set the 'statesHook' at alova instance

已经在创建实例的时候使用了 adapter-taro:

// 创建实例
import { createAlova } from 'alova'
import AdapterTaro from '@alova/adapter-taro'

export const user = createAlova({
  baseURL: BaseUrl.PROD,
  ...AdapterTaro(),
})

使用下面代码,在页面渲染阶段就报上面的错:

const getVerifyCode = (params) => user.Post('/verify_code/', params)

const {
  loading: sending,
  send: sendCaptcha,
  countdown,
} = useCaptcha(() => getVerifyCode({ phone }), {
  initialCountdown: 60,
})

Reproduce Steps

在 Taro + React + 微信小程序场景下引入

Device / Browser / Browser Version

No response

[Bug Report] usePagination data通过回调函数data: response => response.results的ts类型错误,仍然是Method的返回类型。

Reproduction Link

https://github.com/lanhui100/alova-bug.git

Version

1.4.3

Describe the Bug

使用usePagination hook,data使用回调函数制定为:data: (response) => response.results, 但data类型仍然是method的ts类型

以下是代码示例:
const { data, isLastPage, page, pageSize, pageCount, total, loading, error, onError, onSuccess } = usePagination( (page, pageSize) => getProjectListApi(status.value, client, location.value, page, pageSize), { total: (response) => response.count, data: (response) => response.results, initialData: { total: 0, data: [] }, initialPage: 1, initialPageSize: 10 } )

错误是:data应返回ts类型为Project[], 但实际返回的是method getProjectListApi返回的类型是ProjectPaged:
export interface ProjectPaged { count: number next: string previous: string results: Project[] }

Reproduce Steps

描述如上

Device / Browser / Browser Version

Chorme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.