This commit is contained in:
2023-01-07 13:33:51 +08:00
parent c3746ad105
commit b9c6b404d3
6 changed files with 160 additions and 181 deletions

126
package-lock.json generated
View File

@@ -23,10 +23,10 @@
"prettier": "^2.8.1", "prettier": "^2.8.1",
"typescript": "^4.9.4", "typescript": "^4.9.4",
"unplugin-auto-import": "^0.12.1", "unplugin-auto-import": "^0.12.1",
"unplugin-icons": "^0.15.0", "unplugin-icons": "^0.15.1",
"unplugin-vue-components": "^0.22.12", "unplugin-vue-components": "^0.22.12",
"vite": "^4.0.4", "vite": "^4.0.4",
"vue-tsc": "^1.0.20" "vue-tsc": "^1.0.22"
} }
}, },
"node_modules/@antfu/install-pkg": { "node_modules/@antfu/install-pkg": {
@@ -584,41 +584,41 @@
} }
}, },
"node_modules/@volar/language-core": { "node_modules/@volar/language-core": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.22.tgz",
"integrity": "sha512-FU6TC+xQDLkBmp226NTeZ454MTb8VFLga6CIzWP+TsxuxGwB9Exvzof9TKpilIhTdF4IGVJJ4X1aCP6ycnLMbg==", "integrity": "sha512-hiJeCOqxNdtG/04FRGLGI9H9DVz2l6cTqPDBzwqplHXAWfMxjzUaGUrn9sfTG7YMFNZUgK4EYxJnRfhqdtbSFQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/source-map": "1.0.20", "@volar/source-map": "1.0.22",
"muggle-string": "^0.1.0" "muggle-string": "^0.1.0"
} }
}, },
"node_modules/@volar/source-map": { "node_modules/@volar/source-map": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.22.tgz",
"integrity": "sha512-6wwrvAjuy7HepvHW7CqCw5b57YIFrj9mcfJvjic1WCX9TqjnXAcuHFqiUPid7EdZ4SCRKCYQbWmWreThYbHaZw==", "integrity": "sha512-cv4gypHSP4MWVR82ed/+1IpI6794qAl0Q0+KJ+VGMVF8rVugsiF9QbyMCgjel9wNRsssQsazzsf6txOR9vHQiw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"muggle-string": "^0.1.0" "muggle-string": "^0.1.0"
} }
}, },
"node_modules/@volar/typescript": { "node_modules/@volar/typescript": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.22.tgz",
"integrity": "sha512-98D2+rC4igqPL7emqIf0NtIx3UYXZ8xqILiP/ihwP7G2T4oyoGr2vKEOwo49sUzvgUvQl2AI5p8ZQ71mFJfP7w==", "integrity": "sha512-VPyEicealSD4gqlE5/UQ1j3ietsO6Hfat40KtUEh/K+XEZ7h02b1KgFV64YEuBkBOaZ5hgvRW/WXKtQgXCl7Iw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/language-core": "1.0.20" "@volar/language-core": "1.0.22"
} }
}, },
"node_modules/@volar/vue-language-core": { "node_modules/@volar/vue-language-core": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.22.tgz",
"integrity": "sha512-Zz6yuxtA6BG6YU8KPwV4qhO5kh3e2Et6+YOu0QC43SiDgjIw2Vzzi+qAqm8UYofg9UBn82OArO1L+VrZPCCK8A==", "integrity": "sha512-Ki0G/ZdBj2/GLw+/VVH3n9XR/JL6krMIth02EekFn6JV4PGN3mNxbvoh6lOPSDZLR6biOU5nJPnnjpKy8nuXhw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/language-core": "1.0.20", "@volar/language-core": "1.0.22",
"@volar/source-map": "1.0.20", "@volar/source-map": "1.0.22",
"@vue/compiler-dom": "^3.2.45", "@vue/compiler-dom": "^3.2.45",
"@vue/compiler-sfc": "^3.2.45", "@vue/compiler-sfc": "^3.2.45",
"@vue/reactivity": "^3.2.45", "@vue/reactivity": "^3.2.45",
@@ -628,13 +628,13 @@
} }
}, },
"node_modules/@volar/vue-typescript": { "node_modules/@volar/vue-typescript": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.22.tgz",
"integrity": "sha512-FxucnAIZc503CfkdEGmUSw8EQfT31gi0DST7YmCNBK3cWOqJTF7UaHaBDpejnYGbsB568KZQbWTLNSpid5S/lA==", "integrity": "sha512-2T1o5z86PAev31OMtVOv/qp4P3ZVl9ln/2KTmykQE8Fh4A5F+868MW4nf5J7XQ6RNyx7RH9LhzgjvbqJpAfiYw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/typescript": "1.0.20", "@volar/typescript": "1.0.22",
"@volar/vue-language-core": "1.0.20" "@volar/vue-language-core": "1.0.22"
} }
}, },
"node_modules/@vue/compiler-core": { "node_modules/@vue/compiler-core": {
@@ -1931,14 +1931,14 @@
} }
}, },
"node_modules/unplugin-icons": { "node_modules/unplugin-icons": {
"version": "0.15.0", "version": "0.15.1",
"resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.15.0.tgz", "resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.15.1.tgz",
"integrity": "sha512-/BGtBL8y/2wjey4GLyb0w90mhc9d7XKlewWGMxBPROHS7mR84AV1Y0zDapYK0Q/cc/+u4WUcloreev5cABDa5w==", "integrity": "sha512-d4Gc8A4qIJYIXKueltTwoHfR3Cxsdfnmz8lSN5dsITEyai5tdb0uWpbQkn3j9HUlLDSB1ybdQIf5CItxJT3UDw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@antfu/install-pkg": "^0.1.1", "@antfu/install-pkg": "^0.1.1",
"@antfu/utils": "^0.7.2", "@antfu/utils": "^0.7.2",
"@iconify/utils": "^2.0.3", "@iconify/utils": "^2.0.9",
"debug": "^4.3.4", "debug": "^4.3.4",
"kolorist": "^1.6.0", "kolorist": "^1.6.0",
"local-pkg": "^0.4.2", "local-pkg": "^0.4.2",
@@ -1946,7 +1946,7 @@
}, },
"peerDependencies": { "peerDependencies": {
"@svgr/core": ">=5.5.0", "@svgr/core": ">=5.5.0",
"@vue/compiler-sfc": "^3.0.2", "@vue/compiler-sfc": "^3.0.2 || ^2.7.0",
"vue-template-compiler": "^2.6.12", "vue-template-compiler": "^2.6.12",
"vue-template-es2015-compiler": "^1.9.0" "vue-template-es2015-compiler": "^1.9.0"
}, },
@@ -2090,13 +2090,13 @@
} }
}, },
"node_modules/vue-tsc": { "node_modules/vue-tsc": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.22.tgz",
"integrity": "sha512-AApewYXozAD7v4Iz9I0QzQebSVgvlUvpfbGe2e9TwtBdcw5gBsGiX8Oj5BdxRRiGnOdDG3BHPK8msl7Qhmy/1A==", "integrity": "sha512-xSxwgWR3czhv7sLKHWu6lzj9Xq6AtsCURVL45AY4TLGFszv2L2YlMgygXvqslyCM5bz9cyoIKSaZnzHqHTHjzA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@volar/vue-language-core": "1.0.20", "@volar/vue-language-core": "1.0.22",
"@volar/vue-typescript": "1.0.20" "@volar/vue-typescript": "1.0.22"
}, },
"bin": { "bin": {
"vue-tsc": "bin/vue-tsc.js" "vue-tsc": "bin/vue-tsc.js"
@@ -2462,41 +2462,41 @@
"requires": {} "requires": {}
}, },
"@volar/language-core": { "@volar/language-core": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/language-core/-/language-core-1.0.22.tgz",
"integrity": "sha512-FU6TC+xQDLkBmp226NTeZ454MTb8VFLga6CIzWP+TsxuxGwB9Exvzof9TKpilIhTdF4IGVJJ4X1aCP6ycnLMbg==", "integrity": "sha512-hiJeCOqxNdtG/04FRGLGI9H9DVz2l6cTqPDBzwqplHXAWfMxjzUaGUrn9sfTG7YMFNZUgK4EYxJnRfhqdtbSFQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@volar/source-map": "1.0.20", "@volar/source-map": "1.0.22",
"muggle-string": "^0.1.0" "muggle-string": "^0.1.0"
} }
}, },
"@volar/source-map": { "@volar/source-map": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/source-map/-/source-map-1.0.22.tgz",
"integrity": "sha512-6wwrvAjuy7HepvHW7CqCw5b57YIFrj9mcfJvjic1WCX9TqjnXAcuHFqiUPid7EdZ4SCRKCYQbWmWreThYbHaZw==", "integrity": "sha512-cv4gypHSP4MWVR82ed/+1IpI6794qAl0Q0+KJ+VGMVF8rVugsiF9QbyMCgjel9wNRsssQsazzsf6txOR9vHQiw==",
"dev": true, "dev": true,
"requires": { "requires": {
"muggle-string": "^0.1.0" "muggle-string": "^0.1.0"
} }
}, },
"@volar/typescript": { "@volar/typescript": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/typescript/-/typescript-1.0.22.tgz",
"integrity": "sha512-98D2+rC4igqPL7emqIf0NtIx3UYXZ8xqILiP/ihwP7G2T4oyoGr2vKEOwo49sUzvgUvQl2AI5p8ZQ71mFJfP7w==", "integrity": "sha512-VPyEicealSD4gqlE5/UQ1j3ietsO6Hfat40KtUEh/K+XEZ7h02b1KgFV64YEuBkBOaZ5hgvRW/WXKtQgXCl7Iw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@volar/language-core": "1.0.20" "@volar/language-core": "1.0.22"
} }
}, },
"@volar/vue-language-core": { "@volar/vue-language-core": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/vue-language-core/-/vue-language-core-1.0.22.tgz",
"integrity": "sha512-Zz6yuxtA6BG6YU8KPwV4qhO5kh3e2Et6+YOu0QC43SiDgjIw2Vzzi+qAqm8UYofg9UBn82OArO1L+VrZPCCK8A==", "integrity": "sha512-Ki0G/ZdBj2/GLw+/VVH3n9XR/JL6krMIth02EekFn6JV4PGN3mNxbvoh6lOPSDZLR6biOU5nJPnnjpKy8nuXhw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@volar/language-core": "1.0.20", "@volar/language-core": "1.0.22",
"@volar/source-map": "1.0.20", "@volar/source-map": "1.0.22",
"@vue/compiler-dom": "^3.2.45", "@vue/compiler-dom": "^3.2.45",
"@vue/compiler-sfc": "^3.2.45", "@vue/compiler-sfc": "^3.2.45",
"@vue/reactivity": "^3.2.45", "@vue/reactivity": "^3.2.45",
@@ -2506,13 +2506,13 @@
} }
}, },
"@volar/vue-typescript": { "@volar/vue-typescript": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/@volar/vue-typescript/-/vue-typescript-1.0.22.tgz",
"integrity": "sha512-FxucnAIZc503CfkdEGmUSw8EQfT31gi0DST7YmCNBK3cWOqJTF7UaHaBDpejnYGbsB568KZQbWTLNSpid5S/lA==", "integrity": "sha512-2T1o5z86PAev31OMtVOv/qp4P3ZVl9ln/2KTmykQE8Fh4A5F+868MW4nf5J7XQ6RNyx7RH9LhzgjvbqJpAfiYw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@volar/typescript": "1.0.20", "@volar/typescript": "1.0.22",
"@volar/vue-language-core": "1.0.20" "@volar/vue-language-core": "1.0.22"
} }
}, },
"@vue/compiler-core": { "@vue/compiler-core": {
@@ -3515,14 +3515,14 @@
} }
}, },
"unplugin-icons": { "unplugin-icons": {
"version": "0.15.0", "version": "0.15.1",
"resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.15.0.tgz", "resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.15.1.tgz",
"integrity": "sha512-/BGtBL8y/2wjey4GLyb0w90mhc9d7XKlewWGMxBPROHS7mR84AV1Y0zDapYK0Q/cc/+u4WUcloreev5cABDa5w==", "integrity": "sha512-d4Gc8A4qIJYIXKueltTwoHfR3Cxsdfnmz8lSN5dsITEyai5tdb0uWpbQkn3j9HUlLDSB1ybdQIf5CItxJT3UDw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@antfu/install-pkg": "^0.1.1", "@antfu/install-pkg": "^0.1.1",
"@antfu/utils": "^0.7.2", "@antfu/utils": "^0.7.2",
"@iconify/utils": "^2.0.3", "@iconify/utils": "^2.0.9",
"debug": "^4.3.4", "debug": "^4.3.4",
"kolorist": "^1.6.0", "kolorist": "^1.6.0",
"local-pkg": "^0.4.2", "local-pkg": "^0.4.2",
@@ -3602,13 +3602,13 @@
} }
}, },
"vue-tsc": { "vue-tsc": {
"version": "1.0.20", "version": "1.0.22",
"resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.20.tgz", "resolved": "https://registry.npmmirror.com/vue-tsc/-/vue-tsc-1.0.22.tgz",
"integrity": "sha512-AApewYXozAD7v4Iz9I0QzQebSVgvlUvpfbGe2e9TwtBdcw5gBsGiX8Oj5BdxRRiGnOdDG3BHPK8msl7Qhmy/1A==", "integrity": "sha512-xSxwgWR3czhv7sLKHWu6lzj9Xq6AtsCURVL45AY4TLGFszv2L2YlMgygXvqslyCM5bz9cyoIKSaZnzHqHTHjzA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@volar/vue-language-core": "1.0.20", "@volar/vue-language-core": "1.0.22",
"@volar/vue-typescript": "1.0.20" "@volar/vue-typescript": "1.0.22"
} }
}, },
"webpack-sources": { "webpack-sources": {

View File

@@ -25,9 +25,9 @@
"prettier": "^2.8.1", "prettier": "^2.8.1",
"typescript": "^4.9.4", "typescript": "^4.9.4",
"unplugin-auto-import": "^0.12.1", "unplugin-auto-import": "^0.12.1",
"unplugin-icons": "^0.15.0", "unplugin-icons": "^0.15.1",
"unplugin-vue-components": "^0.22.12", "unplugin-vue-components": "^0.22.12",
"vite": "^4.0.4", "vite": "^4.0.4",
"vue-tsc": "^1.0.20" "vue-tsc": "^1.0.22"
} }
} }

View File

@@ -1,25 +1,23 @@
<script lang="ts" setup> <script lang="ts" setup>
import loader, { Monaco } from "@monaco-editor/loader" import loader, { Monaco } from "@monaco-editor/loader"
import { ref, onBeforeUnmount, onMounted, watch, reactive } from "vue" import { ref, onBeforeUnmount, onMounted, watch, reactive } from "vue"
import { onBeforeRouteLeave, useRoute } from "vue-router"
import { import {
buildProblemCodeKey,
LANGUAGE, LANGUAGE,
languageLabel, LANGUAGE_LABEL,
languageValue, LANGUAGE_VALUE,
SOURCES,
} from "../../../utils/constants" } from "../../../utils/constants"
import storage from "../../../utils/storage"
const route = useRoute() const { problem } = defineProps<{
const { languages, template } = defineProps<{ problem: {
languages: Array<LANGUAGE> languages: Array<LANGUAGE>
template: { [key in LANGUAGE]?: string } template: { [key in LANGUAGE]?: string }
}
}>() }>()
const state = reactive({ const state = reactive({
value: "", values: ref({ ...SOURCES }),
language: languages[0] || "C", language: problem.languages[0] || "C",
theme: "vs",
}) })
const monacoEditorRef = ref() const monacoEditorRef = ref()
@@ -27,78 +25,52 @@ const monacoEditorRef = ref()
let monaco: Monaco let monaco: Monaco
function reset() { function reset() {
state.values[state.language] =
problem.template[state.language] || SOURCES[state.language]
if (monaco && monaco.editor) { if (monaco && monaco.editor) {
monaco.editor.getModels()[0].setValue(template[state.language] || "") monaco.editor.getModels()[0].setValue(state.values[state.language])
} }
} }
onMounted(() => { onMounted(() => {
initValue() init()
initEditor()
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
monaco.editor.getModels().forEach((model) => model.dispose()) monaco.editor.getModels().forEach((model) => model.dispose())
}) })
onBeforeRouteLeave(() => {
const key = buildProblemCodeKey(
route.params.problemID as string,
route.params.contestID as string
)
storage.set(key, {
code: state.value,
language: state.language,
theme: state.theme,
})
})
watch( watch(
() => state.language, () => state.language,
() => { () => {
if (monaco && monaco.editor) { if (monaco && monaco.editor) {
monaco.editor.setModelLanguage( monaco.editor.setModelLanguage(
monaco.editor.getModels()[0], monaco.editor.getModels()[0],
languageValue[state.language] LANGUAGE_VALUE[state.language]
) )
reset()
} }
} }
) )
function initValue() { async function init() {
const key = buildProblemCodeKey( state.values[state.language] =
route.params.problemID as string, problem.template[state.language] || SOURCES[state.language]
route.params.contestID as string
)
const problemCode = storage.get(key)
if (problemCode) {
state.value = problemCode.code
state.language = problemCode.language
state.theme = problemCode.theme
}
if (!state.value && template[state.language]) {
state.value = template[state.language] || ""
}
}
async function initEditor() {
monaco = await loader.init() monaco = await loader.init()
monaco.editor.create(monacoEditorRef.value, { monaco.editor.create(monacoEditorRef.value, {
value: state.value, // 编辑器初始显示文字 value: state.values[state.language], // 编辑器初始显示文字
language: languageValue[state.language], language: LANGUAGE_VALUE[state.language],
automaticLayout: true, // 自适应布局 automaticLayout: true, // 自适应布局
theme: state.theme, // 官方自带三种主题vs, hc-black, or vs-dark theme: "vs", // 官方自带三种主题vs, hc-black, or vs-dark
minimap: { minimap: {
enabled: false, enabled: false,
}, },
fontSize: 24, // 字体大小 fontSize: 24, // 字体大小
scrollBeyondLastLine: false, // 取消代码后面一大段空白 scrollBeyondLastLine: false, // 取消代码后面一大段空白
overviewRulerBorder: false, // 不要滚动条的边框
}) })
// 监听值的变化
monaco.editor.getModels()[0].onDidChangeContent(() => { monaco.editor.getModels()[0].onDidChangeContent(() => {
console.log(1) state.values[state.language] = monaco.editor.getModels()[0].getValue()
state.value = monaco.editor.getModels()[0].getValue()
}) })
} }
</script> </script>
@@ -108,10 +80,10 @@ async function initEditor() {
<el-form-item label="语言" label-width="60"> <el-form-item label="语言" label-width="60">
<el-select v-model="state.language" class="language"> <el-select v-model="state.language" class="language">
<el-option <el-option
v-for="item in languages" v-for="item in problem.languages"
:key="item" :key="item"
:value="item" :value="item"
:label="languageLabel[item]" :label="LANGUAGE_LABEL[item]"
> >
</el-option> </el-option>
</el-select> </el-select>
@@ -139,7 +111,7 @@ async function initEditor() {
} }
.editor { .editor {
height: 500px; height: 70%;
} }
.actions { .actions {
margin-top: 16px; margin-top: 16px;

View File

@@ -11,7 +11,7 @@ const contestID = route.params.contestID as string
const problemID = route.params.problemID as string const problemID = route.params.problemID as string
const problem = ref({ const problem = ref({
_id: 0, _id: "",
created_by: {}, created_by: {},
io_mode: {}, io_mode: {},
languages: [], languages: [],
@@ -33,7 +33,7 @@ onMounted(() => {
<template> <template>
<el-row v-if="problem._id"> <el-row v-if="problem._id">
<el-col :span="14"> <el-col :span="12">
<el-tabs type="border-card"> <el-tabs type="border-card">
<el-tab-pane label="题目描述"> <el-tab-pane label="题目描述">
<ProblemContent :problem="problem" /> <ProblemContent :problem="problem" />
@@ -45,8 +45,8 @@ onMounted(() => {
<el-tab-pane label="提交情况">3</el-tab-pane> <el-tab-pane label="提交情况">3</el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="12">
<Editor :languages="problem.languages" :template="problem.template" /> <Editor :problem="problem" />
</el-col> </el-col>
</el-row> </el-row>
</template> </template>

View File

@@ -1,55 +0,0 @@
export const cSource =
'#include<stdio.h>\r\n\r\nint main()\r\n{\r\n printf("黄岩一职");\r\n return 0;\r\n}'
export const cppSource =
'#include<iostream>\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n cout<<"黄岩一职"<<endl;\r\n return 0;\r\n}'
export const pythonSource = 'print("黄岩一职")'
export const javaSource =
'public class Main {\r\n public static void main(String[] args) {\r\n System.out.println("黄岩一职");\r\n }\r\n}'
export const sources = {
50: cSource,
54: cppSource,
62: javaSource,
71: pythonSource,
}
export const language = {
50: "c",
54: "cpp",
62: "java",
71: "python",
}
export const deadResults = {
50: {
encoded:
"I2luY2x1ZGU8c3RkaW8uaD4NCg0KaW50IG1haW4oKQ0Kew0KICAgIHByaW50Zigi6buE5bKp5LiA6IGMIik7DQogICAgcmV0dXJuIDA7DQp9",
result: {
status: 3,
output: "黄岩一职",
},
},
54: {
encoded:
"I2luY2x1ZGU8aW9zdHJlYW0+DQoNCnVzaW5nIG5hbWVzcGFjZSBzdGQ7DQoNCmludCBtYWluKCkNCnsNCiAgICBjb3V0PDwi6buE5bKp5LiA6IGMIjw8ZW5kbDsNCiAgICByZXR1cm4gMDsNCn0=",
result: {
status: 3,
output: "黄岩一职",
},
},
71: {
encoded: "cHJpbnQoIum7hOWyqeS4gOiBjCIp",
result: {
status: 3,
output: "黄岩一职",
},
},
62: {
encoded:
"cHVibGljIGNsYXNzIE1haW4gew0KICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsNCiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLpu4TlsqnkuIDogYwiKTsNCiAgICB9DQp9",
result: {
status: 3,
output: "黄岩一职",
},
},
}

View File

@@ -143,7 +143,69 @@ export function buildProblemCodeKey(problemID: string, contestID = "") {
return `${STORAGE_KEY.PROBLEM_CODE}_NaN_${problemID}` return `${STORAGE_KEY.PROBLEM_CODE}_NaN_${problemID}`
} }
export const languageLabel = { const cSource =
'#include<stdio.h>\r\n\r\nint main()\r\n{\r\n printf("黄岩一职");\r\n return 0;\r\n}'
const cppSource =
'#include<iostream>\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n cout<<"黄岩一职"<<endl;\r\n return 0;\r\n}'
const pythonSource = 'print("黄岩一职")'
const javaSource =
'public class Main {\r\n public static void main(String[] args) {\r\n System.out.println("黄岩一职");\r\n }\r\n}'
export const SOURCES = {
C: cSource,
"C++": cppSource,
Java: javaSource,
Python3: pythonSource,
Python2: "",
JavaScript: "",
Golang: "",
}
export const LANGUAGE_ID = {
C: 50,
"C++": 54,
Java: 62,
Python3: 71,
Python2: 0,
JavaScript: 0,
Golang: 0,
}
export const DEAD_RESULTS = {
C: {
encoded:
"I2luY2x1ZGU8c3RkaW8uaD4NCg0KaW50IG1haW4oKQ0Kew0KICAgIHByaW50Zigi6buE5bKp5LiA6IGMIik7DQogICAgcmV0dXJuIDA7DQp9",
result: {
status: 3,
output: "黄岩一职",
},
},
"C++": {
encoded:
"I2luY2x1ZGU8aW9zdHJlYW0+DQoNCnVzaW5nIG5hbWVzcGFjZSBzdGQ7DQoNCmludCBtYWluKCkNCnsNCiAgICBjb3V0PDwi6buE5bKp5LiA6IGMIjw8ZW5kbDsNCiAgICByZXR1cm4gMDsNCn0=",
result: {
status: 3,
output: "黄岩一职",
},
},
Java: {
encoded:
"cHVibGljIGNsYXNzIE1haW4gew0KICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsNCiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLpu4TlsqnkuIDogYwiKTsNCiAgICB9DQp9",
result: {
status: 3,
output: "黄岩一职",
},
},
Python3: {
encoded: "cHJpbnQoIum7hOWyqeS4gOiBjCIp",
result: {
status: 3,
output: "黄岩一职",
},
},
}
export const LANGUAGE_LABEL = {
C: "C", C: "C",
"C++": "C++", "C++": "C++",
Java: "Java", Java: "Java",
@@ -153,9 +215,9 @@ export const languageLabel = {
Golang: "Go", Golang: "Go",
} }
export type LANGUAGE = keyof typeof languageLabel export type LANGUAGE = keyof typeof LANGUAGE_LABEL
export const languageValue = { export const LANGUAGE_VALUE = {
C: "c", C: "c",
"C++": "cpp", "C++": "cpp",
Java: "java", Java: "java",