Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Liu233w committed Feb 8, 2024
1 parent 41eac11 commit 9538ec9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 90 deletions.
2 changes: 1 addition & 1 deletion crawler/lib/configReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
用于读取用户的爬虫设置,用在前端时,本模块只在编译期间运行,将会返回给用户设置信息
*/

const fs = require('fs').promises
const fs = require('fs')
const yml = require('js-yaml')
const join = require('path').join
const _ = require('lodash')
Expand Down
2 changes: 1 addition & 1 deletion crawler/lib/functionGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const configReader = require('./configReader')

const fs = require('fs').promises
const fs = require('fs')
const _ = require('lodash')
const join = require('path').join

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const {readMetaConfigs, generateBrowserCrawlerFunctions} = require('crawler')
const path = require('path')
const fs = require('fs-extra')
const VirtualModulePlugin = require('webpack-virtual-modules')
const fs = require('fs')

import virtual from 'vite-plugin-virtual'

function buildSources() {
const corsModule = fs.readFileSync(path.join(__dirname, 'cors.js'), 'utf-8')
Expand All @@ -27,8 +28,6 @@ function buildSources() {
return crawlersModule
}

module.exports = function () {
this.options.build.plugins.push(new VirtualModulePlugin({
exports.plugin = virtual({
'dynamic/crawlers.js': buildSources(),
}))
}
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { sortRoutes } = require('@nuxt/utils')
import { defineNuxtModule, extendPages } from '@nuxt/kit'

const sensitiveRoutes = [
'/index.html',
Expand Down Expand Up @@ -38,13 +38,15 @@ const sensitiveRoutes = [
'/README.md',
]

module.exports = function (routes, resolve) {
for (let route of sensitiveRoutes) {
routes.push({
path: route,
component: resolve(__dirname, '../pages/jojo.vue'),
export default defineNuxtModule({
setup() {
extendPages(({ routes }) => {
for (let route of sensitiveRoutes) {
routes.push({
path: route,
component: '~/pages/jojo.vue',
})
}
})
}

sortRoutes(routes)
}
},
})
12 changes: 6 additions & 6 deletions frontend/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const _ = require('lodash')

import { defineNuxtConfig } from 'nuxt/config'

import {default as sensitiveRouter} from './configs/sensitive-url-router'

import { readMetaConfigs } from 'crawler'

module.exports = defineNuxtConfig({
Expand Down Expand Up @@ -55,8 +53,13 @@ module.exports = defineNuxtConfig({
},
},
},
vite: {
plugins: [
require('configs/crawlerLoader').plugin,
],
},
modules: [
'~/modules/crawlerLoader/index',
'~/modules/sensitiveUrlRoutes/index',
'@nuxtjs/component-cache',
['nuxt-env', {
keys: ['VERSION_NUM', 'BUILD_TIME'],
Expand All @@ -81,9 +84,6 @@ module.exports = defineNuxtConfig({
poll: 1000,
},
},
hooks: {
'page:extend': sensitiveRouter,
},
router: {
middleware: [
'auth',
Expand Down
5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"nuxt-env": "0.1.0",
"stylus": "0.62.0",
"superagent": "8.1.2",
"vue-chartjs": "5.3.0",
"webpack-virtual-modules": "0.6.1"
"vue-chartjs": "5.3.0"
},
"devDependencies": {
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@nuxt/kit": "^3.10.1",
"@nuxtjs/eslint-module": "4.1.0",
"@vue/test-utils": "2.4.4",
"@vue/vue3-jest": "^29.2.6",
Expand All @@ -51,6 +51,7 @@
"jest-serializer-vue": "3.1.0",
"stylus-loader": "8.1.0",
"typescript": "5.3.3",
"vite-plugin-virtual": "^0.2.0",
"vite-plugin-vuetify": "^2.0.1",
"vuetify": "^3.5.3"
},
Expand Down
103 changes: 39 additions & 64 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9538ec9

Please sign in to comment.