Skip to content

Commit

Permalink
修复vite编译错误
Browse files Browse the repository at this point in the history
  • Loading branch information
2234839 committed Dec 20, 2023
1 parent 00e7ed1 commit ceed2d1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 79 deletions.
5 changes: 2 additions & 3 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"dev": "vite",
"cli": "tsx ./src/cli.ts",
"cli_watch": "tsx watch ./src/cli.ts",
"build": "vue-tsc && vite build",
"preview": "vite preview",
"build-components": "vue-tsc && vite build --config vite.components.config.ts"
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"@hono/node-server": "^1.3.3",
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/data_promise/data_loading.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { Ref } from "vue";
import { PromiseObj } from "./";
import { PromiseObj } from "./index.ts";
import { NSpace, NSpin, NButton, NButtonGroup, NAlert } from "naive-ui";
const props = defineProps<{
p: Ref<PromiseObj<unknown, Error>>;
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/components/web-custom/Test_c.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { watchEffect } from "vue";
import { aElement } from "./store";
import { aElement } from "./store.ts";
watchEffect(() => {
aElement.forEach((el) => {
Expand Down
152 changes: 79 additions & 73 deletions apps/frontend/src/config/config_tab.vue
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
<script setup lang="ts">
import {
NButton,
NCard,
NDivider,
NInput,
NModal,
NSpace,
NTabPane,
NTabs,
useMessage,
} from "naive-ui";
import { configs, addConfig, loadConfigFile } from ".";
import { computed, ref } from "vue";
const message = useMessage();
import {
NButton,
NCard,
NDivider,
NInput,
NModal,
NSpace,
NTabPane,
NTabs,
useMessage,
} from "naive-ui";
import { configs, addConfig, loadConfigFile } from "./index.ts";
import { computed, ref } from "vue";
const message = useMessage();
const tabs = computed(() => {
return Object.entries(configs)
.filter(([key, vlaue]) => {
if (key.startsWith("__")) return false;
else if (typeof vlaue === "object") {
return true;
} else {
return false;
}
})
.map(([key, value]) => {
return { key, value };
});
});
const tabs = computed(() => {
return Object.entries(configs)
.filter(([key, vlaue]) => {
if (key.startsWith("__")) return false;
else if (typeof vlaue === "object") {
return true;
} else {
return false;
}
})
.map(([key, value]) => {
return { key, value };
});
});
const showModal = ref(false);
const name = ref("");
function add() {
if (name.value === "") {
message.warning("名称不能为空");
} else if (name.value in configs) {
message.warning("不能和已有的配置项重名");
} else {
addConfig(name.value);
showModal.value = false;
}
}
function validateInput(value: string) {
if (value.startsWith("__")) {
message.warning("名称不能以双下划线开头");
return false;
}
return true;
const showModal = ref(false);
const name = ref("");
function add() {
if (name.value === "") {
message.warning("名称不能为空");
} else if (name.value in configs) {
message.warning("不能和已有的配置项重名");
} else {
addConfig(name.value);
showModal.value = false;
}
function downConfig() {
const text = JSON.stringify(configs, null, 2); // 要转换的字符串
const encoder = new TextEncoder();
const data = encoder.encode(text);
const blob = new Blob([data], { type: "text/plain;charset=utf-8" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = `oceanpress.json`;
link.click();
}
function validateInput(value: string) {
if (value.startsWith("__")) {
message.warning("名称不能以双下划线开头");
return false;
}
async function importConfig() {
const fileInput: HTMLInputElement = document.createElement("input");
fileInput.type = "file";
fileInput.click();
return true;
}
function downConfig() {
const text = JSON.stringify(configs, null, 2); // 要转换的字符串
const encoder = new TextEncoder();
const data = encoder.encode(text);
const blob = new Blob([data], { type: "text/plain;charset=utf-8" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = `oceanpress.json`;
link.click();
}
async function importConfig() {
const fileInput: HTMLInputElement = document.createElement("input");
fileInput.type = "file";
fileInput.click();
const file: File = await new Promise((resolve) => {
fileInput.addEventListener("change", () => {
resolve(fileInput.files![0]);
});
const file: File = await new Promise((resolve) => {
fileInput.addEventListener("change", () => {
resolve(fileInput.files![0]);
});
});
const contents = await file.text();
const config = JSON.parse(contents);
if (typeof config === "object") {
console.log(config);
const contents = await file.text();
const config = JSON.parse(contents);
if (typeof config === "object") {
console.log(config);
loadConfigFile(config);
message.success("导入成功");
}
loadConfigFile(config);
message.success("导入成功");
}
}
</script>
<template>
<NTabs
Expand All @@ -89,12 +89,18 @@
@add="showModal = true"
@close="(key) => delete configs[key]"
>
<NTabPane :name="el.key" :tab="el.key" v-for="el of tabs"> {{ el.key }} </NTabPane>
<NTabPane :name="el.key" :tab="el.key" v-for="el of tabs">
{{ el.key }}
</NTabPane>
</NTabs>
<NDivider></NDivider>
<NSpace direction="vertical">
<NButton @click="importConfig"><template #icon>🔄</template>导入配置文件</NButton>
<NButton @click="downConfig"><template #icon>📝</template>导出配置文件</NButton>
<NButton @click="importConfig"
><template #icon>🔄</template>导入配置文件</NButton
>
<NButton @click="downConfig"
><template #icon>📝</template>导出配置文件</NButton
>
</NSpace>
<NModal v-model:show="showModal">
<NCard
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/pages/steps/step3_config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</NStep>
</template>
<script setup lang="ts">
import { currentConfig } from "@/config";
import { currentConfig } from "@/config/index.ts";
import { NCheckbox, NCollapse, NCollapseItem, NDivider, NInput, NStep } from "naive-ui";
currentConfig;
</script>

0 comments on commit ceed2d1

Please sign in to comment.