Feature Request: Auto-generate unique ID for each route instance
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
まず、issueで説明されているF7 Routerのルート設定とpropsHistoryの動作を確認し、その後pull request #4375をレビューします。重複するURLルートインスタンスに一意のIDが自動的に割り当てられ、キャッシュの競合が回避され、報告されたpropsHistoryの初期化とホームページへの復帰のケースがハックなしで機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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?
- 主要言語
- JavaScript
- スター
- 18.8k
- フォーク
- 3.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
framework7io/framework7 のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
framework7io/framework7#4365 · コメント 1 件 ·
-
propsHistory オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
framework7io/framework7#4347 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
framework7io/framework7#4222 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
framework7io/framework7#4175 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
framework7io/framework7#3969 · コメント 3 件 ·
framework7io/framework7 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
antfu-collective/icones#398 ·
-
ECmail.com オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
wesbos/burner-email-providers#554 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
components-web-app/docs#92 ·