如何解决如何将 chrome.storage 中的值分配给用于扩展的变量
所以我正在制作一个 chrome 扩展游戏。我有一个要与 const cursorPagination = (): Resolver => {
return (_parent,fieldArgs,cache,info) => {
const { parentKey: entityKey,fieldName } = info;
const allFields = cache.inspectFields(entityKey);
const fieldInfos = allFields.filter((info) => info.fieldName === fieldName);
const size = fieldInfos.length;
if (size === 0) {
return undefined
}
const fieldKey = `${fieldName}(${stringifyVariables(fieldArgs)})`
const isItInTheCache = cache.resolve(
cache.resolveFieldByKey(entityKey,fieldKey) as string,'posts'
);
info.partial = !isItInTheCache;
let hasMore = true;
const results: string[] = [];
fieldInfos.forEach(fi => {
const key = cache.resolveFieldByKey(entityKey,fi.fieldKey) as string;
const data = cache.resolve(key,'posts') as string[];
const _hasMore = cache.resolve(key,'hasMore');
if (!_hasMore) {
hasMore = _hasMore as boolean;
}
results.push(...data);
})
return {
__typename: 'PaginatedPosts',hasMore,posts: results
}
}
}
一起存储的高分变量。
在 background.js 中,我有:
chrome.storage
在 popup.js 中,我有:
chrome.storage.sync.set({"highscore": 0});
为什么?
有没有办法做我想做的事?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。