chore: 合并代码
This commit is contained in:
parent
0060adc843
commit
b2b849a60d
@ -4,5 +4,5 @@ export type ButtonBorder = "green" | "blue" | "orange" | "red" | "black";
|
||||
export type ButtonNativeType = "button" | "submit" | "reset";
|
||||
|
||||
export const ButtonEmits = {
|
||||
click: (evt: MouseEvent) => evt instanceof MouseEvent,
|
||||
}
|
||||
click: (evt: MouseEvent) => evt instanceof MouseEvent,
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ export default {
|
||||
<script setup lang="ts">
|
||||
import "./index.less";
|
||||
import { computed } from "vue";
|
||||
import { BooleanOrString } from '../../types';
|
||||
import { BooleanOrString } from "../../types";
|
||||
|
||||
export interface LayContainerProps {
|
||||
fluid?: BooleanOrString;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { BuiltInParserName } from 'prettier'
|
||||
import type { BuiltInParserName } from "prettier";
|
||||
|
||||
const scriptRe = /<script[^>]*>([\s\S]*)<\/script>/;
|
||||
const exportDefaultRe = /export\s*default\s*\{([\s\S]*)\}\;?\s*<\/script>/;
|
||||
@ -16,7 +16,10 @@ const MAIN_FILE_NAME = "App.vue";
|
||||
* @returns 处理后的代码,URI hsah, playground 链接
|
||||
}
|
||||
*/
|
||||
export const usePlayGround = async (source: string, convertSetupSugar: boolean) => {
|
||||
export const usePlayGround = async (
|
||||
source: string,
|
||||
convertSetupSugar: boolean
|
||||
) => {
|
||||
const decodeCode = source;
|
||||
const scriptResult = decodeCode.match(scriptRe);
|
||||
|
||||
@ -98,34 +101,36 @@ function trimBr(str: string): string {
|
||||
* @returns 格式化代码
|
||||
*/
|
||||
async function formatCode(filename: string, data: string) {
|
||||
const { format } = await import('prettier/standalone')
|
||||
const parserTypeScript = await import('prettier/parser-typescript').then(
|
||||
const { format } = await import("prettier/standalone");
|
||||
const parserTypeScript = await import("prettier/parser-typescript").then(
|
||||
(m) => m.default
|
||||
)
|
||||
const parserBabel = await import('prettier/parser-babel').then(
|
||||
);
|
||||
const parserBabel = await import("prettier/parser-babel").then(
|
||||
(m) => m.default
|
||||
)
|
||||
const parserHtml = await import('prettier/parser-html').then((m) => m.default)
|
||||
);
|
||||
const parserHtml = await import("prettier/parser-html").then(
|
||||
(m) => m.default
|
||||
);
|
||||
let code = data;
|
||||
let parser: BuiltInParserName
|
||||
if (filename.endsWith('.vue')) {
|
||||
parser = 'vue'
|
||||
} else if (filename.endsWith('.js')) {
|
||||
parser = 'babel'
|
||||
} else if (filename.endsWith('.ts')) {
|
||||
parser = 'typescript'
|
||||
} else if (filename.endsWith('.json')) {
|
||||
parser = 'json'
|
||||
let parser: BuiltInParserName;
|
||||
if (filename.endsWith(".vue")) {
|
||||
parser = "vue";
|
||||
} else if (filename.endsWith(".js")) {
|
||||
parser = "babel";
|
||||
} else if (filename.endsWith(".ts")) {
|
||||
parser = "typescript";
|
||||
} else if (filename.endsWith(".json")) {
|
||||
parser = "json";
|
||||
} else {
|
||||
return
|
||||
return;
|
||||
}
|
||||
code = format(code, {
|
||||
parser,
|
||||
plugins: [parserHtml, parserTypeScript, parserBabel],
|
||||
semi: false, // 语句末尾打印分号
|
||||
singleQuote: true, // 使用单引号
|
||||
singleQuote: true, // 使用单引号
|
||||
vueIndentScriptAndStyle: false, // 是否缩进 Vue 文件中的 script 和 style 标签
|
||||
})
|
||||
});
|
||||
|
||||
return code;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user