Feature Request: Auto-generate unique ID for each route instance
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu với cấu hình route của F7 Router và hành vi của propsHistory được mô tả trong issue, sau đó xem xét pull request #4375. Công việc được xem là hoàn tất khi các instance route URL trùng lặp tự động nhận được ID duy nhất, tránh được xung đột cache, và các trường hợp khởi tạo propsHistory cũng như quay lại trang chủ đã được báo cáo hoạt động mà không cần hack.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem Description
Identical URL route instances cannot be distinguished, causing conflicts in cached states like scroll positions.
Desired Solution
The F7 Router should have built-in automatic unique ID generation for each route instance.
Suggested Implementation
// Route configuration support
routes: [{
path: '/page',
options: {
routeId: true // Auto-generate
// or
routeId: (route) => customIdGenerator(route)
}
}]
Current Workaround
// Currently only this hack works
nr.options.props = {
...props,
get rid() {
return `${Date.now()}_${Math.random().toString(36).slice(2)}`;
}
};
Additional Issues (specific to hack method)
-
propsHistory Initialization Defect (hack-specific)
- When using the hack method, the propsHistory array is empty on initial page load
- The default implementation might work normally, but the hack method disrupts the normal initialization flow
-
propsHistory Home Return Issue (hack-specific)
- When returning to the homepage using the hack method, propsHistory doesn't correctly record the homepage state
- The default implementation might have handled this correctly, but the hack method requires additional fixes
I've created a comprehensive PR that implements automatic route ID generation and fixes related history management issues. Here's the complete implementation:
https://github.com/framework7io/framework7/pull/4375
Explanation
These issues are specific to using the hack method (dynamically generating rid). In the default F7 Router implementation, these functions might already work normally. But to be compatible with the hack method, corresponding fix logic needs to be added to the code.
Expected Functionality
- Automatically resolve cache conflicts for duplicate URLs
- Simplify state management for scroll positions, etc.
- No manual handling of route IDs required
Technical Detail:
I use f7-store to create and restore cache based on this id, but encounter problems during deletion. Currently can only use code similar to:
const propsHistory = f7?.views?.main?.router?.propsHistory;
if (!propsHistory) return;
const originalPop = propsHistory.pop;
propsHistory.pop = function () {
const lastItem = this[this.length - 1];
const rid = lastItem?.rid;
const result = originalPop.apply(this, arguments);
return result;
};
Is there a better method? Or can this be optimized by adding the built-in route ID functionality to avoid developers having to use such hack methods?
- Ngôn ngữ chính
- JavaScript
- Star
- 18.8k
- Fork
- 3.2k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của framework7io/framework7
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
framework7io/framework7#4365 · 1 bình luận ·
-
propsHistory Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
framework7io/framework7#4347 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
framework7io/framework7#4222 · 3 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
framework7io/framework7#4175 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
framework7io/framework7#3969 · 3 bình luận ·
Tất cả issue của framework7io/framework7
Issue tương tự
-
Update HugeIcons library Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
antfu-collective/icones#398 ·
-
ECmail.com Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
wesbos/burner-email-providers#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
components-web-app/docs#92 ·