ハッシュ計算関数にフィールド引数を追加, k-tune'でコンフィギュレーションを変更すると、キャッシュも無効になります。
This commit is contained in:
@@ -45,7 +45,7 @@ interface IField {
|
|||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ドロップダウンメニューの<EFBFBD><EFBFBD><EFBFBD>書タイプ、ドロップダウンオプションの検索を高速化するために使用
|
// ドロップダウンメニューの辞書タイプ、ドロップダウンオプションの検索を高速化するために使用
|
||||||
// キーの形式は: ドロップダウンメニューの階層_value
|
// キーの形式は: ドロップダウンメニューの階層_value
|
||||||
// 例: 2番目の階層で結果aを選択した場合、1_aを使用して、値aの次の階層(3番目の階層)のオプションを取得できます
|
// 例: 2番目の階層で結果aを選択した場合、1_aを使用して、値aの次の階層(3番目の階層)のオプションを取得できます
|
||||||
type DropdownDictionary = Record<string, string[]>;
|
type DropdownDictionary = Record<string, string[]>;
|
||||||
@@ -67,8 +67,8 @@ namespace DropDownConfig {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ドロップダウンメニューの辞書を一度構築するコストが高いため、レコードのハッシュ値を計算してキャッシュキーとして使用
|
// ドロップダウンメニューの辞書を一度構築するコストが高いため、レコードのハッシュ値を計算してキャッシュキーとして使用
|
||||||
// kintoneのデータが変更されていない場合、辞書を再構築<EFBFBD><EFBFBD><EFBFBD>る必要はありません
|
// kintoneのデータが変更されていない場合、辞書を再構築する必要はありません。
|
||||||
const hash = await calculateHash(records);
|
const hash = await calculateHash(records, fields);
|
||||||
const storageKey = `dropdown_dictionary::${props.dropDownApp.id}_${hash}`;
|
const storageKey = `dropdown_dictionary::${props.dropDownApp.id}_${hash}`;
|
||||||
|
|
||||||
// ローカルストレージから辞書を取得しようとし、存在しない場合は再構築
|
// ローカルストレージから辞書を取得しようとし、存在しない場合は再構築
|
||||||
@@ -88,8 +88,11 @@ namespace DropDownConfig {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Web Crypto APIを使用してハッシュ値を計算
|
// Web Crypto APIを使用してハッシュ値を計算
|
||||||
const calculateHash = async (records: KTRecord[]): Promise<string> => {
|
const calculateHash = async (
|
||||||
const str = JSON.stringify(records);
|
records: KTRecord[],
|
||||||
|
fields: string[]
|
||||||
|
): Promise<string> => {
|
||||||
|
const str = JSON.stringify(records) + JSON.stringify(fields);
|
||||||
const encoder = new TextEncoder();
|
const encoder = new TextEncoder();
|
||||||
const data = encoder.encode(str);
|
const data = encoder.encode(str);
|
||||||
const hashBuffer = await crypto.subtle.digest("SHA-1", data); // SHA-1を使用、パフォーマンスが良く、セキュリティは不要
|
const hashBuffer = await crypto.subtle.digest("SHA-1", data); // SHA-1を使用、パフォーマンスが良く、セキュリティは不要
|
||||||
@@ -193,9 +196,6 @@ export class CascadingDropDownAction implements IAction {
|
|||||||
this.actionProps = actionNode.actionProps;
|
this.actionProps = actionNode.actionProps;
|
||||||
this.props = actionNode.ActionValue as ICascadingDropDownProps;
|
this.props = actionNode.ActionValue as ICascadingDropDownProps;
|
||||||
|
|
||||||
console.log(this.actionProps);
|
|
||||||
console.log(this.props);
|
|
||||||
|
|
||||||
const result: IActionResult = { canNext: true, result: "" };
|
const result: IActionResult = { canNext: true, result: "" };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user