chore: use bytedance cdn default for monaco-editor

This commit is contained in:
Noah Hsu
2022-08-19 21:00:24 +08:00
parent c83520490a
commit c828360ef0
7 changed files with 17 additions and 9 deletions

View File

@@ -16,8 +16,9 @@
<script>
window.ALIST = {
cdn: "/CDN_URL",
// base_path: "/BASE_PATH",
// api: "https://console-mock.apipost.cn/app/mock/project/c1ff0991-6aca-4e1a-ffdf-cfb985292688/",
monaco_cdn: undefined,
base_path: undefined,
api: undefined,
};
</script>
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@@ -2,7 +2,13 @@ import { Box } from "@hope-ui/solid";
import { createEffect, createSignal, onCleanup, onMount } from "solid-js";
import { MaybeLoading } from "./FullLoading";
import loader from "@monaco-editor/loader";
import { monaco_cdn } from "~/utils";
loader.config({
paths: {
vs: monaco_cdn,
},
});
export interface MonacoEditorProps {
value: string;
onChange?: (value: string) => void;

View File

@@ -19,7 +19,7 @@ const TextEditor = () => {
const t = useT();
return (
<MaybeLoading loading={content.loading}>
<VStack w="$full" alignItems="start">
<VStack w="$full" alignItems="start" spacing="$2">
<MonacoEditorLoader
value={content()}
theme={theme()}

View File

@@ -1,7 +1,5 @@
// api and base_path both don't endsWith /
import { pathJoin } from "./path";
export let base_path = "";
export const setBasePath = (path: string) => {
base_path = path;
@@ -26,3 +24,7 @@ if (api === "/") {
if (api.endsWith("/")) {
api = api.slice(0, -1);
}
export const monaco_cdn =
window.ALIST.monaco_cdn ||
"https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/monaco-editor/0.33.0-dev.20220228/min/vs";

View File

@@ -1,4 +1,4 @@
export * from "./base_url";
export * from "./config";
export * from "./bus";
export * from "./log";
export * from "./notify";

View File

@@ -1,4 +1,4 @@
import { base_path } from "./base_url";
import { base_path } from ".";
export const standardizePath = (path: string, noRootSlash?: boolean) => {
if (path.endsWith("/")) {

View File

@@ -1,6 +1,5 @@
import axios from "axios";
import { api } from "./base_url";
import { log } from "./log";
import { api, log } from ".";
const instance = axios.create({
baseURL: api + "/api",