-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27e8f4b
commit 430e3dd
Showing
55 changed files
with
21,812 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import YAML from 'yaml'; | ||
function isJson(text: string) { | ||
if (text.length < 30) { | ||
return false; | ||
} | ||
|
||
if (!text.trim().startsWith('{') && !text.trim().startsWith('\\{')) { | ||
return false; | ||
} | ||
|
||
try { | ||
JSON.parse(text); | ||
} catch { | ||
return false; | ||
} | ||
return true; | ||
} | ||
export function isYaml(text: string) { | ||
if (text.length < 30) { | ||
return false; | ||
} | ||
|
||
if (text.search(': ') === -1 || text.split('\n').length <= 1 || isJson(text)) { | ||
return false; | ||
} | ||
|
||
try { | ||
YAML.parse(text); | ||
} catch { | ||
return false; | ||
} | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createI18n } from 'vue-i18n'; | ||
import en from './lang/en.json'; | ||
import de from './lang/de.json'; | ||
import es from './lang/es.json'; | ||
import fr from './lang/fr.json'; | ||
import it from './lang/it.json'; | ||
import ja from './lang/ja.json'; | ||
import ko from './lang/ko.json'; | ||
import pt from './lang/pt.json'; | ||
import ru from './lang/ru.json'; | ||
import zh_tw from './lang/zh-tw.json'; | ||
import zh from './lang/zh.json'; | ||
|
||
export const i18n = createI18n({ | ||
locale: window?.$he3?.lang ?? 'en', | ||
messages: { | ||
de, | ||
en, | ||
es, | ||
fr, | ||
it, | ||
ja, | ||
ko, | ||
pt, | ||
ru, | ||
zh_tw, | ||
zh, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "Die JSON -Analyse ist fehlgeschlagen", | ||
"yamlParseError": "Die YAML -Analyse ist fehlgeschlagen" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "JSON Parse Error", | ||
"yamlParseError": "YAML Parse Error" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "El análisis JSON falló", | ||
"yamlParseError": "El análisis YAML falló" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "L'analyse JSON a échoué", | ||
"yamlParseError": "L'analyse YAML a échoué" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "L'analisi JSON non è riuscita", | ||
"yamlParseError": "L'analisi YAML non è riuscita" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "JSON分析に失敗しました", | ||
"yamlParseError": "YAML分析に失敗しました" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "JSON 분석에 실패했습니다", | ||
"yamlParseError": "YAML 분석에 실패했습니다" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "A análise JSON falhou", | ||
"yamlParseError": "A análise YAML falhou" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "Анализ JSON потерпел неудачу", | ||
"yamlParseError": "Анализ YAML не удался" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "JSON 解析失敗", | ||
"yamlParseError": "YAML 解析失敗" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"jsonParseError": "JSON 解析失败", | ||
"yamlParseError": "YAML 解析失败" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { transformTool } from '@he3-kit/utils'; | ||
import prettyJson from 'json-stringify-pretty-compact'; | ||
import yaml, { JSON_SCHEMA } from 'js-yaml'; | ||
import { propertiesExample } from './utils/utils'; | ||
import { JSONToProperty, jsonToYaml, propertyToJSON } from './utils/utils'; | ||
import { ErrorLine } from './utils/ErrorLine'; | ||
import { isYaml } from './isYaml'; | ||
export default transformTool({ | ||
inputLang: 'PROPERTIES', | ||
/** 输出语法格式 */ | ||
outputLang: 'YAML', | ||
inputHandler(str: string) { | ||
return jsonToYaml(prettyJson(propertyToJSON(str), { maxLength: 20 })); | ||
}, | ||
/** 输出转换函数 */ | ||
resultHandler(str: string) { | ||
try { | ||
const obj = yaml.load(str, { schema: JSON_SCHEMA }); | ||
return JSONToProperty(obj as { [x: string]: any }).join('\n'); | ||
} catch (err: any) { | ||
if (err.mark) { | ||
throw new (ErrorLine as any)(err.message, err.mark.line + 1); | ||
} else { | ||
throw new Error(err.message); | ||
} | ||
} | ||
}, | ||
/** 默认值 */ | ||
sampleData: propertiesExample, | ||
autoFillInputCondition: isYaml, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** 用于实现报错时添加line信息 */ | ||
export function ErrorLine( | ||
this: { | ||
message: string; | ||
line: number; | ||
}, | ||
message: string, | ||
line: number | ||
) { | ||
this.message = message; | ||
this.line = line; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export enum OutputType { | ||
JSON = 'json', | ||
YAML = 'yaml', | ||
GO = 'go', | ||
CPLUS = 'c++', | ||
SWIFT = 'swift', | ||
PYTHON = 'python', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { parse } from 'yaml'; | ||
export function handleMinify(str: string) { | ||
if (!str) { | ||
return ''; | ||
} | ||
return JSON.stringify(parse(str)); | ||
} |
Oops, something went wrong.