🌀: fix linter

This commit is contained in:
sight 2022-06-24 14:55:50 +08:00
parent d28a4a7c82
commit a0fd9345a2
16 changed files with 256 additions and 213 deletions

View File

@ -416,9 +416,7 @@ defineExpose({open, hide, toggle});
@focusout="handleFocusout()" @focusout="handleFocusout()"
:class="{ 'layui-dropdown-up': openState }" :class="{ 'layui-dropdown-up': openState }"
> >
<div <div @click="handleClick()" @contextmenu.prevent="handleContextMenuClick()">
@click="handleClick()"
@contextmenu.prevent="handleContextMenuClick()">
<slot></slot> <slot></slot>
</div> </div>
<dl <dl

View File

@ -1,7 +1,7 @@
import { createApp } from './main' import { createApp } from "./main";
const { app, router } = createApp() const { app, router } = createApp();
router.isReady().then(() => { router.isReady().then(() => {
app.mount('#app') app.mount("#app");
}) });

View File

@ -1,24 +1,24 @@
import Layout from './App.vue' import Layout from "./App.vue";
import { App, createApp as _createApp } from 'vue' import { App, createApp as _createApp } from "vue";
import { createRouter } from './src/router/index' import { createRouter } from "./src/router/index";
import { Router } from 'vue-router' import { Router } from "vue-router";
import LayCode from './src/components/LayCode.vue' import LayCode from "./src/components/LayCode.vue";
import Children1 from './src/components/Children1.vue' import Children1 from "./src/components/Children1.vue";
import Children2 from './src/components/Children2.vue' import Children2 from "./src/components/Children2.vue";
import './src/assets/css/index.css' import "./src/assets/css/index.css";
export function createApp(): { export function createApp(): {
app: App<Element> app: App<Element>;
router: Router router: Router;
} { } {
const app = _createApp(Layout); const app = _createApp(Layout);
const router = createRouter(); const router = createRouter();
app.use(router) app
.component('LayCode', LayCode) .use(router)
.component('Children1',Children1) .component("LayCode", LayCode)
.component('Children2', Children2) .component("Children1", Children1)
.component("Children2", Children2);
return { app, router } return { app, router };
} }

View File

@ -4,13 +4,11 @@
</form> </form>
</template> </template>
<script setup> <script setup>
const emit = defineEmits("called");
const emit = defineEmits('called')
const props = defineProps({ const props = defineProps({
data: Object data: Object,
}) });
</script> </script>
<style scoped> <style scoped>

View File

@ -5,17 +5,15 @@
</form> </form>
</template> </template>
<script setup> <script setup>
const emit = defineEmits("add", "sub");
const emit = defineEmits('add','sub')
const add = () => { const add = () => {
emit('add') emit("add");
} };
const sub = () => { const sub = () => {
emit('sub') emit("sub");
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -12,27 +12,57 @@
</div> </div>
</div> </div>
<div :class="{ 'is-fixed': isFixContorl }" class="control"> <div :class="{ 'is-fixed': isFixContorl }" class="control">
<i class="layui-icon layui-icon-file btn" @click="copy"><svg t="1646244236057" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5505" width="18" height="18"><path d="M768 682.666667V170.666667a85.333333 85.333333 0 0 0-85.333333-85.333334H170.666667a85.333333 85.333333 0 0 0-85.333334 85.333334v512a85.333333 85.333333 0 0 0 85.333334 85.333333h512a85.333333 85.333333 0 0 0 85.333333-85.333333zM170.666667 170.666667h512v512H170.666667z m682.666666 85.333333v512a85.333333 85.333333 0 0 1-85.333333 85.333333H256a85.333333 85.333333 0 0 0 85.333333 85.333334h426.666667a170.666667 170.666667 0 0 0 170.666667-170.666667V341.333333a85.333333 85.333333 0 0 0-85.333334-85.333333z" p-id="5506"></path></svg></i> <i class="layui-icon layui-icon-file btn" @click="copy"
<i class="layui-icon layui-icon-fonts-code btn" @click="toggle"><svg t="1646244296040" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7127" width="18" height="18"><path d="M217.301333 414.933333a21.333333 21.333333 0 0 1-1.066666-30.165333l29.098666-31.232a21.333333 21.333333 0 0 1 30.165334-1.024l236.117333 220.16 236.16-220.16a21.333333 21.333333 0 0 1 30.122667 1.024l29.098666 31.232a21.333333 21.333333 0 0 1-1.024 30.165333L541.738667 661.333333l-13.44 14.421334a21.290667 21.290667 0 0 1-16.725334 6.741333 21.290667 21.290667 0 0 1-16.64-6.741333l-13.44-14.506667z" p-id="7128"></path></svg></i> ><svg
t="1646244236057"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="5505"
width="18"
height="18"
>
<path
d="M768 682.666667V170.666667a85.333333 85.333333 0 0 0-85.333333-85.333334H170.666667a85.333333 85.333333 0 0 0-85.333334 85.333334v512a85.333333 85.333333 0 0 0 85.333334 85.333333h512a85.333333 85.333333 0 0 0 85.333333-85.333333zM170.666667 170.666667h512v512H170.666667z m682.666666 85.333333v512a85.333333 85.333333 0 0 1-85.333333 85.333333H256a85.333333 85.333333 0 0 0 85.333333 85.333334h426.666667a170.666667 170.666667 0 0 0 170.666667-170.666667V341.333333a85.333333 85.333333 0 0 0-85.333334-85.333333z"
p-id="5506"
></path></svg
></i>
<i class="layui-icon layui-icon-fonts-code btn" @click="toggle"
><svg
t="1646244296040"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="7127"
width="18"
height="18"
>
<path
d="M217.301333 414.933333a21.333333 21.333333 0 0 1-1.066666-30.165333l29.098666-31.232a21.333333 21.333333 0 0 1 30.165334-1.024l236.117333 220.16 236.16-220.16a21.333333 21.333333 0 0 1 30.122667 1.024l29.098666 31.232a21.333333 21.333333 0 0 1-1.024 30.165333L541.738667 661.333333l-13.44 14.421334a21.290667 21.290667 0 0 1-16.725334 6.741333 21.290667 21.290667 0 0 1-16.64-6.741333l-13.44-14.506667z"
p-id="7128"
></path></svg
></i>
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref, watch } from 'vue' import { onMounted, onUnmounted, ref, watch } from "vue";
const meta = ref<HTMLElement>({} as HTMLElement) const meta = ref<HTMLElement>({} as HTMLElement);
const isFixContorl = ref(false) const isFixContorl = ref(false);
const codeAreaHeight = ref(0) const codeAreaHeight = ref(0);
const show = ref(false) const show = ref(false);
const toggle = function () { const toggle = function () {
show.value = !show.value show.value = !show.value;
} };
const copy = function () { const copy = function () {
const foundCodes = meta.value.getElementsByClassName('language-html') const foundCodes = meta.value.getElementsByClassName("language-html");
const foundCode = foundCodes[0]; const foundCode = foundCodes[0];
let successful = false; let successful = false;
if (navigator.clipboard && document.hasFocus()) { if (navigator.clipboard && document.hasFocus()) {
@ -45,7 +75,7 @@ const copy = function () {
if (show.value) { if (show.value) {
range.selectNode(foundCode); range.selectNode(foundCode);
} else { } else {
copyDiv = document.createElement('div'); copyDiv = document.createElement("div");
copyDiv.innerHTML = foundCode.innerHTML; copyDiv.innerHTML = foundCode.innerHTML;
copyDiv.style.position = "fixed"; copyDiv.style.position = "fixed";
copyDiv.style.left = "-9999px"; copyDiv.style.left = "-9999px";
@ -54,7 +84,7 @@ const copy = function () {
} }
window.getSelection()?.addRange(range); window.getSelection()?.addRange(range);
try { try {
successful = document.execCommand('copy'); successful = document.execCommand("copy");
} catch (err) { } catch (err) {
successful = false; successful = false;
console.error(err); console.error(err);
@ -64,43 +94,41 @@ const copy = function () {
} }
if (successful) { if (successful) {
} else { } else {
}
} }
};
onMounted(() => { onMounted(() => {
const foundDescs = meta.value.getElementsByClassName('description') const foundDescs = meta.value.getElementsByClassName("description");
const foundCodes = meta.value.getElementsByClassName('language-html') const foundCodes = meta.value.getElementsByClassName("language-html");
if (foundDescs.length) { if (foundDescs.length) {
codeAreaHeight.value = codeAreaHeight.value =
foundDescs[0].clientHeight + foundCodes[0].clientHeight + 30 foundDescs[0].clientHeight + foundCodes[0].clientHeight + 30;
} else { } else {
codeAreaHeight.value = foundCodes[0].clientHeight + 20 codeAreaHeight.value = foundCodes[0].clientHeight + 20;
} }
}) });
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener('scroll', handleScroll) window.removeEventListener("scroll", handleScroll);
}) });
watch(show, (value) => { watch(show, (value) => {
if (value) { if (value) {
meta.value.style.height = `${codeAreaHeight.value}px` meta.value.style.height = `${codeAreaHeight.value}px`;
window.addEventListener('scroll', handleScroll) window.addEventListener("scroll", handleScroll);
setTimeout(handleScroll, 100) setTimeout(handleScroll, 100);
} else { } else {
meta.value.style.height = '0' meta.value.style.height = "0";
window.removeEventListener('scroll', handleScroll) window.removeEventListener("scroll", handleScroll);
} }
}) });
function handleScroll() { function handleScroll() {
const { top, bottom } = meta.value.getBoundingClientRect() const { top, bottom } = meta.value.getBoundingClientRect();
isFixContorl.value = isFixContorl.value =
bottom > window.innerHeight && top + 44 <= window.innerHeight bottom > window.innerHeight && top + 44 <= window.innerHeight;
} }
</script> </script>
@ -189,6 +217,6 @@ function handleScroll() {
padding-right: 10px; padding-right: 10px;
} }
.btn:hover::before { .btn:hover::before {
color: #5FB878; color: #5fb878;
} }
</style> </style>

View File

@ -2,8 +2,20 @@
<div class="markdown-body light-scheme"> <div class="markdown-body light-scheme">
<div class="alone-header"> <div class="alone-header">
<img class="alone-logo" src="../assets/logo.png" /> <img class="alone-logo" src="../assets/logo.png" />
<a style="position: absolute; right: 16%; line-height: 60px;color:white;font-size:15px;">1.3.10</a> <a
<a href="https://gitee.com/layui-vue/layer-vue" style="position: absolute; right: 10%; line-height: 75px"> style="
position: absolute;
right: 16%;
line-height: 60px;
color: white;
font-size: 15px;
"
>1.3.10</a
>
<a
href="https://gitee.com/layui-vue/layer-vue"
style="position: absolute; right: 10%; line-height: 75px"
>
<svg width="1.7em" height="1.7em" viewBox="0 0 24 24"> <svg width="1.7em" height="1.7em" viewBox="0 0 24 24">
<path <path
fill="#fff" fill="#fff"

View File

@ -18,7 +18,7 @@ const plugins = [
highlight, highlight,
}, },
markdownItSetup(md) { markdownItSetup(md) {
md.use(snippet).use(preWrapper).use(container, "demo", demo) md.use(snippet).use(preWrapper).use(container, "demo", demo);
}, },
}), }),
] as any; ] as any;

View File

@ -1,21 +1,21 @@
import markdown from 'markdown-it' import markdown from "markdown-it";
import highlight from './highlight' import highlight from "./highlight";
import type Token from 'markdown-it/lib/token' import type Token from "markdown-it/lib/token";
function assignScript(script: string) { function assignScript(script: string) {
const dependencies = {} as Record<string, string[]> const dependencies = {} as Record<string, string[]>;
const attrs = {} as Record<string, string> const attrs = {} as Record<string, string>;
const content = script const content = script
.replace(/import\s?\{.*\}.*/g, (item) => { .replace(/import\s?\{.*\}.*/g, (item) => {
const key = getInnerString(item.replace(/'/g, '"'), '"', '"') const key = getInnerString(item.replace(/'/g, '"'), '"', '"');
const value = getInnerString(item.replace(/\s+/g, ''), '{', '}') const value = getInnerString(item.replace(/\s+/g, ""), "{", "}");
const list = value ? value.split(',') : [] const list = value ? value.split(",") : [];
if (key && dependencies[key]) { if (key && dependencies[key]) {
dependencies[key] = dependencies[key].concat(list) dependencies[key] = dependencies[key].concat(list);
} else if (key) { } else if (key) {
dependencies[key] = list dependencies[key] = list;
} }
return '' return "";
}) })
/** /**
* const -> let * const -> let
@ -24,23 +24,23 @@ function assignScript(script: string) {
* const a = -> a = * const a = -> a =
*/ */
.replace(/(const|let|var)\s\w*\s?=/g, (item) => { .replace(/(const|let|var)\s\w*\s?=/g, (item) => {
const attr = getInnerString(item, '\\s', '\\s?=') const attr = getInnerString(item, "\\s", "\\s?=");
if (attr && !(attr in attrs)) { if (attr && !(attr in attrs)) {
attrs[attr] = attr attrs[attr] = attr;
return `let ${attr} =` return `let ${attr} =`;
} else { } else {
return attr + ' =' return attr + " =";
} }
}) })
// Remove extra line breaks // Remove extra line breaks
.replace(/\n+/gm, '\n') .replace(/\n+/gm, "\n");
// Combine the import // Combine the import
const reImport = Object.keys(dependencies).reduce((all, item) => { const reImport = Object.keys(dependencies).reduce((all, item) => {
const filterAttrs = [...new Set(dependencies[item])] const filterAttrs = [...new Set(dependencies[item])];
return all + `import {${filterAttrs + ','}} from '${item}';\n` return all + `import {${filterAttrs + ","}} from '${item}';\n`;
}, '') }, "");
return reImport + content return reImport + content;
} }
/** /**
@ -53,89 +53,89 @@ function assignScript(script: string) {
function getInnerString( function getInnerString(
string: string, string: string,
prefix: string, prefix: string,
postfix = '', postfix = "",
type: 'i' | 'g' | 'm' = 'i' type: "i" | "g" | "m" = "i"
): string | undefined { ): string | undefined {
const result = new RegExp(`${prefix}(.*)${postfix}`, type) const result = new RegExp(`${prefix}(.*)${postfix}`, type);
const match = string.match(result) const match = string.match(result);
return match ? match[1].trim() : undefined return match ? match[1].trim() : undefined;
} }
let script = '' // Record the <script> label of the current page let script = ""; // Record the <script> label of the current page
export default { export default {
render: (tokens: Token[], idx: number): string => { render: (tokens: Token[], idx: number): string => {
// the `demo` block of the current page // the `demo` block of the current page
const htmlBlock = tokens.filter((item) => item.type === 'html_block') const htmlBlock = tokens.filter((item) => item.type === "html_block");
const { nesting, info = '', map } = tokens[idx] const { nesting, info = "", map } = tokens[idx];
if (nesting === -1) { if (nesting === -1) {
return '</lay-code>' return "</lay-code>";
} }
const matchedInfo = info.trim().match(/^demo\s+(.*)$/) const matchedInfo = info.trim().match(/^demo\s+(.*)$/);
const description = matchedInfo && matchedInfo[1] const description = matchedInfo && matchedInfo[1];
const descTemplate = markdown().render(description || '') const descTemplate = markdown().render(description || "");
let str = '' // copy the current `demo` block code let str = ""; // copy the current `demo` block code
let lastLine = NaN let lastLine = NaN;
for (let i = 0; i < htmlBlock.length; i++) { for (let i = 0; i < htmlBlock.length; i++) {
const item = htmlBlock[i] const item = htmlBlock[i];
if (item.map && map && item.map[0] >= map[0] && item.map[1] <= map[1]) { if (item.map && map && item.map[0] >= map[0] && item.map[1] <= map[1]) {
const { map, content } = item const { map, content } = item;
const delta = map[0] - (lastLine || map[1]) const delta = map[0] - (lastLine || map[1]);
if (delta > 0) { if (delta > 0) {
str += '\n'.repeat(delta) str += "\n".repeat(delta);
} }
str += content str += content;
lastLine = map[1] lastLine = map[1];
if (i === 0) { if (i === 0) {
script = '' script = "";
} }
// Remove top <template> // Remove top <template>
if (/^<template>/.test(content)) { if (/^<template>/.test(content)) {
const reContent = content.match(/^<template>((\s|\S)*)<\/template>/m) const reContent = content.match(/^<template>((\s|\S)*)<\/template>/m);
htmlBlock[i].content = (reContent && reContent[1]) || '' htmlBlock[i].content = (reContent && reContent[1]) || "";
} }
// Extract the <script> label content // Extract the <script> label content
if (content.includes('<script')) { if (content.includes("<script")) {
if (/export\sdefault\s?\{/m.test(content)) { if (/export\sdefault\s?\{/m.test(content)) {
const setup = content.match( const setup = content.match(
/setup\s?\(\)\s?\{((\s|\S)*)return\s?\{/m /setup\s?\(\)\s?\{((\s|\S)*)return\s?\{/m
) );
const reContent = content.replace( const reContent = content.replace(
/export\sdefault\s?\{((\s|\S)*)\}/m, /export\sdefault\s?\{((\s|\S)*)\}/m,
(setup && setup[1]) || '' (setup && setup[1]) || ""
) );
const reScript = reContent.match( const reScript = reContent.match(
/^<script\s?.*?>((\s|\S)*)<\/script>/m /^<script\s?.*?>((\s|\S)*)<\/script>/m
) );
script += (reScript && reScript[1]) || '' script += (reScript && reScript[1]) || "";
} else { } else {
const reScript = content.match( const reScript = content.match(
/^<script\s?.*?>((\s|\S)*)<\/script>/m /^<script\s?.*?>((\s|\S)*)<\/script>/m
) );
script += (reScript && reScript[1]) || '' script += (reScript && reScript[1]) || "";
} }
htmlBlock[i].content = '' htmlBlock[i].content = "";
} }
// Change the last content to <script> of the current page // Change the last content to <script> of the current page
if (i + 1 === htmlBlock.length) { if (i + 1 === htmlBlock.length) {
htmlBlock[i].content = ` htmlBlock[i].content = `
<script setup> <script setup>
${assignScript(script)} ${assignScript(script)}
</script>` </script>`;
} }
} }
} }
return ` return `
<lay-code> <lay-code>
${description ? `<template #description>${descTemplate}</template>` : ''} ${description ? `<template #description>${descTemplate}</template>` : ""}
<template #code>${highlight(str, 'vue')}</template> <template #code>${highlight(str, "vue")}</template>
` `;
}, },
} };

View File

@ -1,44 +1,44 @@
import prism from 'prismjs' import prism from "prismjs";
import loadLanguages from 'prismjs/components/index' import loadLanguages from "prismjs/components/index";
import escapeHtml from 'escape-html' import escapeHtml from "escape-html";
loadLanguages(['markup', 'css', 'javascript']) loadLanguages(["markup", "css", "javascript"]);
function wrap(code: string, lang: string): string { function wrap(code: string, lang: string): string {
if (lang === 'text') { if (lang === "text") {
code = escapeHtml(code) code = escapeHtml(code);
} }
return `<pre v-pre><code>${code}</code></pre>` return `<pre v-pre><code>${code}</code></pre>`;
} }
export default (str: string, lang: string): string => { export default (str: string, lang: string): string => {
if (!lang) { if (!lang) {
return wrap(str, 'text') return wrap(str, "text");
} }
lang = lang.toLowerCase() lang = lang.toLowerCase();
const rawLang = lang const rawLang = lang;
if (lang === 'vue' || lang === 'html') { if (lang === "vue" || lang === "html") {
lang = 'markup' lang = "markup";
} }
if (lang === 'md') { if (lang === "md") {
lang = 'markdown' lang = "markdown";
} }
if (lang === 'ts') { if (lang === "ts") {
lang = 'typescript' lang = "typescript";
} }
if (lang === 'py') { if (lang === "py") {
lang = 'python' lang = "python";
} }
if (!prism.languages[lang]) { if (!prism.languages[lang]) {
try { try {
loadLanguages([lang]) loadLanguages([lang]);
} catch (e) { } catch (e) {
console.warn(lang, e) console.warn(lang, e);
} }
} }
if (prism.languages[lang]) { if (prism.languages[lang]) {
const code = prism.highlight(str, prism.languages[lang], lang) const code = prism.highlight(str, prism.languages[lang], lang);
return wrap(code, rawLang) return wrap(code, rawLang);
}
return wrap(str, 'text')
} }
return wrap(str, "text");
};

View File

@ -1,11 +1,11 @@
import MarkdownIt from 'markdown-it' import MarkdownIt from "markdown-it";
export default (md: MarkdownIt): void => { export default (md: MarkdownIt): void => {
const fence = md.renderer.rules.fence! const fence = md.renderer.rules.fence!;
md.renderer.rules.fence = (...args) => { md.renderer.rules.fence = (...args) => {
const [tokens, idx] = args const [tokens, idx] = args;
const token = tokens[idx] const token = tokens[idx];
const rawCode = fence(...args) const rawCode = fence(...args);
return `<div class="language-${token.info.trim()}">${rawCode}</div>` return `<div class="language-${token.info.trim()}">${rawCode}</div>`;
} };
} };

View File

@ -1,34 +1,39 @@
import fs from 'fs' import fs from "fs";
import MarkdownIt from 'markdown-it' import MarkdownIt from "markdown-it";
import { RuleBlock } from 'markdown-it/lib/parser_block' import { RuleBlock } from "markdown-it/lib/parser_block";
export default (md: MarkdownIt): void => { export default (md: MarkdownIt): void => {
const parser: RuleBlock = (state, startLine, endLine, silent) => { const parser: RuleBlock = (state, startLine, endLine, silent) => {
const CH = '<'.charCodeAt(0) const CH = "<".charCodeAt(0);
const pos = state.bMarks[startLine] + state.tShift[startLine] const pos = state.bMarks[startLine] + state.tShift[startLine];
const max = state.eMarks[startLine] const max = state.eMarks[startLine];
if (state.sCount[startLine] - state.blkIndent >= 4) { if (state.sCount[startLine] - state.blkIndent >= 4) {
return false return false;
} }
for (let i = 0; i < 3; ++i) { for (let i = 0; i < 3; ++i) {
const ch = state.src.charCodeAt(pos + i) const ch = state.src.charCodeAt(pos + i);
if (ch !== CH || pos + i >= max) return false if (ch !== CH || pos + i >= max) return false;
} }
if (silent) { if (silent) {
return true return true;
}
const start = pos + 3
const end = state.skipSpacesBack(max, pos)
const rawPath = state.src.slice(start, end).trim().replace(/^@/, process.cwd())
const content = fs.existsSync(rawPath) ? fs.readFileSync(rawPath).toString() : 'Not found: ' + rawPath
const meta = rawPath.replace(rawPath, '')
state.line = startLine + 1
const token = state.push('fence', 'code', 0)
token.info = rawPath.split('.').pop() + meta
token.content = content
token.markup = '```'
token.map = [startLine, startLine + 1]
return true
}
md.block.ruler.before('fence', 'snippet', parser)
} }
const start = pos + 3;
const end = state.skipSpacesBack(max, pos);
const rawPath = state.src
.slice(start, end)
.trim()
.replace(/^@/, process.cwd());
const content = fs.existsSync(rawPath)
? fs.readFileSync(rawPath).toString()
: "Not found: " + rawPath;
const meta = rawPath.replace(rawPath, "");
state.line = startLine + 1;
const token = state.push("fence", "code", 0);
token.info = rawPath.split(".").pop() + meta;
token.content = content;
token.markup = "```";
token.map = [startLine, startLine + 1];
return true;
};
md.block.ruler.before("fence", "snippet", parser);
};

View File

@ -1,12 +1,16 @@
import { createRouter as _createRouter, createWebHistory, Router } from 'vue-router'; import {
import zhCN from './zh-CN'; createRouter as _createRouter,
createWebHistory,
Router,
} from "vue-router";
import zhCN from "./zh-CN";
const routes = [...zhCN] const routes = [...zhCN];
export function createRouter(): Router { export function createRouter(): Router {
const baseUrl = import.meta.env.BASE_URL const baseUrl = import.meta.env.BASE_URL;
return _createRouter({ return _createRouter({
history: createWebHistory(baseUrl), history: createWebHistory(baseUrl),
routes: routes, routes: routes,
}) });
} }

View File

@ -12,7 +12,7 @@ const zhCN = [
component: () => import("../../docs/zh-CN/index.md"), component: () => import("../../docs/zh-CN/index.md"),
meta: { title: "指南" }, meta: { title: "指南" },
} },
], ],
}, },
]; ];

View File

@ -1,6 +1,6 @@
import path from 'path' import path from "path";
import { defineConfig } from 'vite' import { defineConfig } from "vite";
import plugins from './src/plugin/common-plugins' import plugins from "./src/plugin/common-plugins";
export default defineConfig({ export default defineConfig({
resolve: { resolve: {
@ -9,4 +9,4 @@ export default defineConfig({
}, },
}, },
plugins, plugins,
}) });