Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jul 15, 2024
1 parent 3a8b03a commit c1cf449
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '../../core/render/utils.js';
import Dexie from 'dexie';

let INDEXS = {};
let INDEXES = {};

const db = new Dexie('DocsifySearchDB');
db.version(1).stores({
Expand All @@ -13,7 +13,7 @@ db.version(1).stores({

async function saveData(maxAge, expireKey, indexKey) {
await db.search.put({ key: expireKey, value: Date.now() + maxAge });
await db.search.put({ key: indexKey, value: JSON.stringify(INDEXS) });
await db.search.put({ key: indexKey, value: JSON.stringify(INDEXES) });
}

async function getData(key) {
Expand Down Expand Up @@ -160,10 +160,10 @@ export function ignoreDiacriticalMarks(keyword) {
export function search(query) {
const matchingResults = [];
let data = [];
Object.keys(INDEXS).forEach(key => {
Object.keys(INDEXES).forEach(key => {
data = [
...data,
...Object.keys(INDEXS[key]).map(page => INDEXS[key][page]),
...Object.keys(INDEXES[key]).map(page => INDEXES[key][page]),
];
});

Expand Down Expand Up @@ -287,10 +287,10 @@ export async function init(config, vm) {

const isExpired = (await getData(expireKey)) < Date.now();

INDEXS = JSON.parse(await getData(indexKey));
INDEXES = JSON.parse(await getData(indexKey));

if (isExpired) {
INDEXS = {};
INDEXES = {};
} else if (!isAuto) {
return;
}
Expand All @@ -299,13 +299,13 @@ export async function init(config, vm) {
let count = 0;

paths.forEach(path => {
if (INDEXS[path]) {
if (INDEXES[path]) {
return count++;
}

Docsify.get(vm.router.getFile(path), false, vm.config.requestHeaders).then(
async result => {
INDEXS[path] = genIndex(path, result, vm.router, config.depth);
INDEXES[path] = genIndex(path, result, vm.router, config.depth);
if (len === ++count) {
await saveData(config.maxAge, expireKey, indexKey);
}
Expand Down

0 comments on commit c1cf449

Please sign in to comment.