diff --git a/package-lock.json b/package-lock.json index 94586c2..d0d8eca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "hasInstallScript": true, "dependencies": { - "@bytetrade/core": "0.3.57", + "@bytetrade/core": "0.3.60", "axios": "^0.21.1", "uuid": "9.0.1" }, @@ -142,9 +142,9 @@ } }, "node_modules/@bytetrade/core": { - "version": "0.3.57", - "resolved": "https://registry.npmjs.org/@bytetrade/core/-/core-0.3.57.tgz", - "integrity": "sha512-X+nyMwLNgHVbPb6lKDDV9oHnnNsgLM875om0rk02e9UqbTKx6mJ/BF0SD6o0Sz31Rup2cDazZUtpfcBbYkuzyw==", + "version": "0.3.60", + "resolved": "https://registry.npmjs.org/@bytetrade/core/-/core-0.3.60.tgz", + "integrity": "sha512-2n2i/d7p0LoPWoDG05KA2bjmiZPlHCmJu/HO04Hi8ugX7OZUdodySQODt7uDU9vfehEF6S5xpjBc7sQAonoD6g==", "dependencies": { "axios": "0.21.4", "chai": "^4.3.7", @@ -2271,7 +2271,7 @@ }, "node_modules/assertion-error": { "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "resolved": "https://registry.npmmirror.com/assertion-error/-/assertion-error-1.1.0.tgz", "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "engines": { "node": "*" @@ -2417,7 +2417,7 @@ }, "node_modules/bundle-require": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-2.3.0.tgz", + "resolved": "https://registry.npmmirror.com/bundle-require/-/bundle-require-2.3.0.tgz", "integrity": "sha512-kH8vyERJv0Td4Odu2KQyooYyeXDx2FbhGwSfkEGdyHmkTCahvwVI8w/pE2stbsp6G/W5/3kIC7ErdBg/30OAkw==", "peerDependencies": { "esbuild": ">=0.13" @@ -2509,17 +2509,17 @@ } }, "node_modules/chai": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", - "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "version": "4.5.0", + "resolved": "https://registry.npmmirror.com/chai/-/chai-4.5.0.tgz", + "integrity": "sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==", "dependencies": { "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^4.1.2", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.1.0" }, "engines": { "node": ">=4" @@ -2548,9 +2548,12 @@ "dev": true }, "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "dependencies": { + "get-func-name": "^2.0.2" + }, "engines": { "node": "*" } @@ -3043,7 +3046,7 @@ }, "node_modules/date-fns": { "version": "2.22.1", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.22.1.tgz", + "resolved": "https://registry.npmmirror.com/date-fns/-/date-fns-2.22.1.tgz", "integrity": "sha512-yUFPQjrxEmIsMqlHhAhmxkuH769baF21Kk+nZwZGyrMoyLA+LugaQtC0+Tqf9CBUUULWwUJt6Q5ySI3LJDDCGg==", "engines": { "node": ">=0.11" @@ -3129,9 +3132,9 @@ "dev": true }, "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "version": "4.1.4", + "resolved": "https://registry.npmmirror.com/deep-eql/-/deep-eql-4.1.4.tgz", + "integrity": "sha512-SUwdGfqdKOwxCPeVYjwSyRpJ7Z+fhpwIAtmCUdZIWZ/YP5R9WAsyuSgpLVDi9bjWoN2LXHNss/dk3urXtdQxGg==", "dependencies": { "type-detect": "^4.0.0" }, @@ -3324,7 +3327,7 @@ }, "node_modules/esbuild": { "version": "0.13.15", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.13.15.tgz", + "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.13.15.tgz", "integrity": "sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==", "hasInstallScript": true, "bin": { @@ -3350,9 +3353,33 @@ "esbuild-windows-arm64": "0.13.15" } }, + "node_modules/esbuild-android-arm64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.13.15.tgz", + "integrity": "sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/esbuild-darwin-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.13.15.tgz", + "integrity": "sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, "node_modules/esbuild-darwin-arm64": { "version": "0.13.15", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz", + "resolved": "https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.13.15.tgz", "integrity": "sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==", "cpu": [ "arm64" @@ -3362,6 +3389,174 @@ "darwin" ] }, + "node_modules/esbuild-freebsd-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.13.15.tgz", + "integrity": "sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/esbuild-freebsd-arm64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.13.15.tgz", + "integrity": "sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/esbuild-linux-32": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.13.15.tgz", + "integrity": "sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-linux-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.13.15.tgz", + "integrity": "sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-linux-arm": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.13.15.tgz", + "integrity": "sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-linux-arm64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.13.15.tgz", + "integrity": "sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-linux-mips64le": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.13.15.tgz", + "integrity": "sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-linux-ppc64le": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.13.15.tgz", + "integrity": "sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/esbuild-netbsd-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.13.15.tgz", + "integrity": "sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ] + }, + "node_modules/esbuild-openbsd-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.13.15.tgz", + "integrity": "sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/esbuild-sunos-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.13.15.tgz", + "integrity": "sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ] + }, + "node_modules/esbuild-windows-32": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.13.15.tgz", + "integrity": "sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/esbuild-windows-64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.13.15.tgz", + "integrity": "sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/esbuild-windows-arm64": { + "version": "0.13.15", + "resolved": "https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.13.15.tgz", + "integrity": "sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -3881,9 +4076,9 @@ "dev": true }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "hasInstallScript": true, "optional": true, "os": [ @@ -3928,9 +4123,9 @@ } }, "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/get-func-name/-/get-func-name-2.0.2.tgz", + "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", "engines": { "node": "*" } @@ -5300,11 +5495,11 @@ } }, "node_modules/loupe": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", - "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "version": "2.3.7", + "resolved": "https://registry.npmmirror.com/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", "dependencies": { - "get-func-name": "^2.0.0" + "get-func-name": "^2.0.1" } }, "node_modules/lru-cache": { @@ -5878,7 +6073,7 @@ }, "node_modules/multiformats": { "version": "9.6.4", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.6.4.tgz", + "resolved": "https://registry.npmmirror.com/multiformats/-/multiformats-9.6.4.tgz", "integrity": "sha512-fCCB6XMrr6CqJiHNjfFNGT0v//dxOBMrOMqUIzpPc/mmITweLEyhvMpY9bF+jZ9z3vaMAau5E8B68DW77QMXkg==" }, "node_modules/multimatch": { @@ -7106,7 +7301,7 @@ }, "node_modules/pathval": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "resolved": "https://registry.npmmirror.com/pathval/-/pathval-1.1.1.tgz", "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "engines": { "node": "*" @@ -7810,7 +8005,7 @@ }, "node_modules/rollup": { "version": "2.79.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", + "resolved": "https://registry.npmmirror.com/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", "bin": { "rollup": "dist/bin/rollup" @@ -8484,9 +8679,9 @@ } }, "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/type-detect/-/type-detect-4.1.0.tgz", + "integrity": "sha512-Acylog8/luQ8L7il+geoSxhEkazvkslg7PSNKOX59mbB9cOveP5aq9h74Y7YU8yDpJwetzQQrfIwtf4Wp4LKcw==", "engines": { "node": ">=4" } @@ -9000,7 +9195,7 @@ }, "node_modules/yaup": { "version": "1.8.0", - "resolved": "https://registry.npmjs.org/yaup/-/yaup-1.8.0.tgz", + "resolved": "https://registry.npmmirror.com/yaup/-/yaup-1.8.0.tgz", "integrity": "sha512-KKF6B8cwv0dtJwJH/coFbSlx1UAaumZt0AyvSg32135uMpV0Tbe/UwBbDMByBlcfGyv2qLqkCyYYM9/gpzicpg==", "dependencies": { "bundle-require": "^2.1.2", diff --git a/packages/frontend/src/pages/Search/TextSearch.vue b/packages/frontend/src/pages/Search/TextSearch.vue index d0d6a6c..2a928f8 100644 --- a/packages/frontend/src/pages/Search/TextSearch.vue +++ b/packages/frontend/src/pages/Search/TextSearch.vue @@ -58,7 +58,11 @@ file @@ -240,12 +244,28 @@ const keydownEnter = (event: any) => { const open = (item: any) => { const commandList = JSON.parse(JSON.stringify(props.commandList)); - if (props.item?.name === 'Drive') { - const url = '/Files' + item.path; + if (props.item?.title === 'Drive') { + const url = '/Files' + item.path + '/' + item.title; + + const filesApp = commandList.find( + (el: { appid: string }) => el.appid && el.appid === 'files' + ); + filesApp.url = filesApp.url + url; + + const openUrl = filesApp.url.startsWith('https') + ? filesApp.url + : 'https://' + filesApp.url; + + window.open(openUrl); + } else if (props.item?.title === 'Sync') { + const url = `/Seahub${item.path}/${item.title}${item.isDir ? '/' : ''}?id=${ + item.repo_id + }`; const filesApp = commandList.find( (el: { appid: string }) => el.appid && el.appid === 'files' ); + filesApp.url = filesApp.url + url; const openUrl = filesApp.url.startsWith('https') @@ -253,7 +273,7 @@ const open = (item: any) => { : 'https://' + filesApp.url; window.open(openUrl); - } else if (props.item?.name === 'Wise') { + } else if (props.item?.title === 'Wise') { const filesApp = commandList.find( (el: { appid: string }) => el.appid && el.appid === 'wise' ); @@ -265,7 +285,10 @@ const open = (item: any) => { ? filesApp.url : 'https://' + filesApp.url; - window.open(openUrl); + let enterUrl = new URL(openUrl); + enterUrl.searchParams.append('preview_name', item.title); + + window.open(enterUrl); } // emits('openCommand', resource_uri); diff --git a/packages/frontend/src/stores/search.ts b/packages/frontend/src/stores/search.ts index 524f5b9..ee27183 100644 --- a/packages/frontend/src/stores/search.ts +++ b/packages/frontend/src/stores/search.ts @@ -49,6 +49,9 @@ export interface TextSearchItem { resource_uri?: string; fileType: string; fileIcon: string; + repo_id?: string; + path: string; + isDir: boolean; } export enum SecondFactorMethod { @@ -180,9 +183,7 @@ export const useSearchStore = defineStore('search', { if (serviceType === ServiceType.Sync) { const repo_list = await this.getSyncRepoList(); - console.log('repo_list', repo_list); - const res = await this.fetchSyncData(params, repo_list); - console.log('getContent res', res); + const res = await this.fetchSyncData(params, repo_list, query); return res; } else { return await this.fetchData(params); @@ -194,7 +195,6 @@ export const useSearchStore = defineStore('search', { tokenStore.url + '/server/search', params ); - console.log('fetchData res', res); const newRes = []; for (let i = 0; i < res.length; i++) { @@ -208,7 +208,11 @@ export const useSearchStore = defineStore('search', { return res; }, - async fetchSyncData(params: ServiceParamsType, repo_list: any[]) { + async fetchSyncData( + params: ServiceParamsType, + repo_list: any[], + query: string + ) { const results: TextSearchItem[] = []; for (let j = 0; j < repo_list.length; j++) { const repo_item = repo_list[j]; @@ -219,13 +223,14 @@ export const useSearchStore = defineStore('search', { params ); - console.log('resres', res); if (res && res.length > 0) { const resArr: TextSearchItem[] = []; for (let i = 0; i < res.length; i++) { const el = res[i]; + el.repo_id = repo_item.repo_id; + el.repo_name = repo_item.repo_name; const id = `id_${j}_${i}`; - resArr.push(this.formatSyncToSearch(id, el)); + resArr.push(this.formatSyncToSearch(id, el, query)); } results.push(...resArr); @@ -237,21 +242,27 @@ export const useSearchStore = defineStore('search', { return results; }, - formatSyncToSearch(id: string, data: any) { - const name = data.path.startsWith('/') ? data.path.slice(1) : data.path; - const fileType = getFileType(name); + formatSyncToSearch(id: string, data: any, query: string) { + const lastIndex = data.path.lastIndexOf('/'); + const path = lastIndex !== -1 ? data.path.slice(0, lastIndex) : data.path; + const name = + lastIndex !== -1 ? data.path.slice(lastIndex + 1) : data.path; + const fileType = getFileType(name) || 'blob'; const fileIcon = getFileIcon(name); const searchRes: TextSearchItem = { id: id, - highlight: name, + highlight: name.replace(query, `${query}`), highlight_field: 'title', title: name, - fileType: fileType || 'blob', + fileType: fileType, fileIcon: fileIcon || 'other', + repo_id: data.repo_id, + path: '/' + data.repo_name + path, meta: { updated: new Date(data.mtime).getTime() / 1000 - } + }, + isDir: data.type === 'file' ? false : true }; return searchRes; },