🐛: 修复 date-picker 无法解析的问题

This commit is contained in:
就眠儀式 2022-05-23 17:13:21 +08:00
parent 539af99222
commit 7eed198d10
4 changed files with 17 additions and 97 deletions

View File

@ -261,15 +261,20 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts">
import { ref, watch, computed, defineProps, defineEmits, onMounted } from "vue"; export default {
name: "LayDatePicker"
}
</script>
<script lang="ts" setup>
import "./index.less"; import "./index.less";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { LayIcon } from "@layui/icons-vue"; import { LayIcon } from "@layui/icons-vue";
import LayInput from "../input/index.vue"; import LayInput from "../input/index.vue";
import LayDropdown from "../dropdown/index.vue"; import LayDropdown from "../dropdown/index.vue";
import { getDayLength, getYears, getMonth, getYear } from "./day"; import { getDayLength, getYears, getMonth, getYear } from "./day";
import { ref, watch, computed, defineProps, defineEmits, onMounted } from "vue";
export interface LayDatePickerProps { export interface LayDatePickerProps {
modelValue?: string; modelValue?: string;
@ -312,6 +317,7 @@ const hms = ref({
mm: dayjs(props.modelValue).minute(), mm: dayjs(props.modelValue).minute(),
ss: dayjs(props.modelValue).second(), ss: dayjs(props.modelValue).second(),
}); });
const els = [ const els = [
{ count: 24, type: "hh" }, { count: 24, type: "hh" },
{ count: 60, type: "mm" }, { count: 60, type: "mm" },

View File

@ -7,7 +7,6 @@
"homepage": "http://www.layui-vue.com", "homepage": "http://www.layui-vue.com",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"dev:demand": "vite --config ./vite.config.demand.ts",
"build": "vite build" "build": "vite build"
}, },
"dependencies": { "dependencies": {

View File

@ -3,7 +3,7 @@ import { App, createApp as _createApp } from "vue";
import { createRouter } from "./router/index"; import { createRouter } from "./router/index";
import { Router } from "vue-router"; import { Router } from "vue-router";
import Store from "./store"; import Store from "./store";
// import layui from "../../component/src/index"; import layui from "../../component/src/index";
import LayCode from "./components/LayCode.vue"; import LayCode from "./components/LayCode.vue";
import LaySearch from "./components/LaySearch.vue"; import LaySearch from "./components/LaySearch.vue";
import LayTableBox from "./components/LayTableBox.vue"; import LayTableBox from "./components/LayTableBox.vue";
@ -17,31 +17,14 @@ export function createApp(): {
const app = _createApp(Layout); const app = _createApp(Layout);
const router = createRouter(); const router = createRouter();
console.log("DEV_MODE", import.meta.env.VITE_DEV_MODE ?? import.meta.env.DEV); app
.use(layui)
if (import.meta.env.VITE_DEV_MODE != "demand") { .use(router)
import("../../component/src/index").then((layui) => { .use(Store)
app .component("LayCode", LayCode)
.use(layui) .component("LaySearch", LaySearch)
.use(router) .component("LayTableBox", LayTableBox)
.use(Store) .component("LayAnchor", LayAnchor);
.component("LayCode", LayCode)
.component("LaySearch", LaySearch)
.component("LayTableBox", LayTableBox)
.component("LayAnchor", LayAnchor);
});
} else {
import("../../component/src/language").then((i18n) => {
app
.use(i18n.default)
.use(router)
.use(Store)
.component("LayCode", LayCode)
.component("LaySearch", LaySearch)
.component("LayTableBox", LayTableBox)
.component("LayAnchor", LayAnchor);
});
}
return { app, router }; return { app, router };
} }

View File

@ -1,68 +0,0 @@
import path from "path";
import { defineConfig } from "vite";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { LayuiVueResolver } from "unplugin-layui-vue-resolver";
import plugins from "./src/plugin/common-plugins";
export default defineConfig({
resolve: {
alias: {
"/@src": path.resolve(__dirname, "./src"),
},
},
mode: "demand",
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
},
},
},
},
plugins: [
AutoImport({
// 自动导入 vue 相关函数
imports: ["vue"],
// 自动导入 layer-vue 相关函数,例如 layer 等
resolvers: [
LayuiVueResolver({
exclude: [/^Lay[A-Z]/],
}),
],
dts: path.resolve(path.resolve(__dirname, "src"), "auto-imports.d.ts"),
}),
Components({
// 用于搜索组件的目录
dirs: ["src/document/zh-CN/components"],
// 允许在 'src/document/zh-CN/components' 下自动加载 markdown
extensions: ["vue", "md"],
// 允许自动导入和注册 markdown 中使用的组件
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
// 自动解析 layui-vue 组件
resolvers: [
LayuiVueResolver({
resolveIcons: true,
exclude: [
"LaySearch",
"LayAnchor",
"LayTableBox",
"LayCode",
// "component",
// "guide",
// "index",
// "resource",
],
}),
],
}),
...plugins,
],
});