Skip to content

Commit ba710e6

Browse files
committed
docs: 添加规则测试
1 parent 51a0e5c commit ba710e6

File tree

10 files changed

+97
-24
lines changed

10 files changed

+97
-24
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div>
3+
<div class="details custom-block !p-10px">
4+
<input class="w-full" v-model="inputText" placeholder="这里输入原始文本, 比如网页源码" />
5+
</div>
6+
<div class="details custom-block !p-10px">
7+
<input class="w-full" v-model="rule" placeholder="这里输入规则, 比如 xpath, jsonpath 等等组合" />
8+
</div>
9+
<div class="details custom-block !p-10px">
10+
<div class="min-h-40px">
11+
{{ outputText || '' }}
12+
</div>
13+
</div>
14+
</div>
15+
</template>
16+
17+
18+
<script setup>
19+
import { ref, watch, nextTick } from 'vue'
20+
import { createAnalyzerManager } from '@any-reader/core/browser'
21+
22+
const analyzerManager = createAnalyzerManager()
23+
24+
const inputText = ref('')
25+
const rule = ref('')
26+
const outputText = ref('')
27+
28+
watch([inputText, rule], v => {
29+
nextTick(async () => {
30+
outputText.value = await analyzerManager.getString(rule.value, inputText.value)
31+
})
32+
})
33+
</script>

docs/.vitepress/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default withMermaid({
3030
logo: '/logo.svg',
3131
nav: [
3232
{ text: '指南', link: '/desktop/' },
33-
{ text: '规则', link: '/rule/' }
33+
{ text: '规则', link: '/rule/' },
34+
{ text: '规则测试', link: '/play/' },
3435
],
3536
search: {
3637
provider: 'local'

docs/.vitepress/theme/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import Theme from "vitepress/theme";
2-
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
3-
import '@shikijs/vitepress-twoslash/style.css'
1+
import Theme from 'vitepress/theme';
2+
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client';
3+
import '@shikijs/vitepress-twoslash/style.css';
4+
import 'uno.css'
5+
import RulePlay from '../components/RulePlay/index.vue';
46

57
export default {
68
...Theme,
79

810
enhanceApp({ app }) {
9-
app.use(TwoslashFloatingVue)
10-
},
11+
app.use(TwoslashFloatingVue);
12+
app.component('RulePlay', RulePlay);
13+
}
1114
};

docs/play/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
> 开发中, 目前规则部分不支持 `@filter` `@js`, 暂不支持解析流程测试
2+
3+
<RulePlay />
4+

docs/tsconfig.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": ["**.ts"]
4+
}

docs/uno.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineConfig, presetUno } from 'unocss';
2+
3+
export default defineConfig({
4+
content: {
5+
pipeline: {
6+
exclude: ['node_modules', '.git', '.husky', '.vscode', 'public', 'dist', 'dist-electron', 'mock']
7+
}
8+
},
9+
presets: [presetUno({ dark: 'class' })],
10+
11+
postprocess: (util) => {
12+
util.entries.forEach((i) => {
13+
const value = i[1];
14+
if (value && typeof value === 'string' && /^-?[.\d]+rem$/.test(value)) i[1] = `${+value.slice(0, -3) * 4}px`;
15+
});
16+
},
17+
18+
// 映射组合
19+
shortcuts: {
20+
'vsc-toolbar-btn': 'hover:bg-[--toolbar-hoverBackground] hover:op-70 cursor-pointer',
21+
'wh-full': 'w-full h-full',
22+
'flex-center': 'flex justify-center items-center'
23+
}
24+
});

docs/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { defineConfig } from 'vite';
2+
import UnoCSS from 'unocss/vite';
23
import { alias } from '../alias';
34

45
export default defineConfig({
56
optimizeDeps: {
67
exclude: ['vitepress']
78
},
9+
10+
plugins: [UnoCSS()],
11+
812
server: {
913
hmr: {
1014
overlay: false

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore --cache"
6565
},
6666
"dependencies": {
67+
"@unocss/reset": "^0.62.3",
6768
"sql.js": "^1.11.0",
6869
"sqlite3": "5.1.6"
6970
},
@@ -89,6 +90,7 @@
8990
"tsup": "^8.2.4",
9091
"tsx": "^4.19.0",
9192
"unbuild": "^2.0.0",
93+
"unocss": "^0.62.3",
9294
"vite-tsconfig-paths": "^5.0.1",
9395
"vitest": "^2.0.5"
9496
},

packages/web/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"@any-reader/core": "workspace:^",
4343
"@any-reader/rule-utils": "workspace:^",
4444
"@any-reader/shared": "workspace:^",
45-
"@unocss/reset": "^0.62.3",
4645
"@v-c/utils": "^0.0.26",
4746
"@vscode/codicons": "^0.0.36",
4847
"@vscode/webview-ui-toolkit": "^1.4.0",
@@ -90,7 +89,6 @@
9089
"sass": "^1.78.0",
9190
"sass-loader": "^13.3.3",
9291
"typescript": "^5.5.4",
93-
"unocss": "^0.62.3",
9492
"unplugin-auto-import": "^0.18.2",
9593
"unplugin-vue-components": "^0.27.4",
9694
"vite": "^5.4.3",

pnpm-lock.yaml

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)