Skip to content

Commit 2f502b5

Browse files
committed
新增模块
1 parent b4886a7 commit 2f502b5

File tree

22 files changed

+5376
-32
lines changed

22 files changed

+5376
-32
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0"
1111
/>
1212
<title></title>
13-
<link rel="icon" href="favicon.ico" />
13+
<link rel="icon" href="./favicon.ico" />
1414
<style>
1515
html,
1616
body,

src/modules/base/layout/components/amenu.vue

+25-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</template>
1616

1717
<script lang="ts" name="a-menu" setup>
18-
import { onMounted, ref } from "vue";
18+
import { ref, watch } from "vue";
1919
import { useBase } from "/$/base";
2020
import { useCool } from "/@/cool";
2121
import { Menu } from "../../types";
@@ -27,16 +27,16 @@ const { menu } = useBase();
2727
const active = ref("");
2828
2929
// 选择导航
30-
function select(index: number) {
30+
function select(index: any) {
3131
menu.setMenu(index);
3232
3333
// 获取第一个菜单地址
3434
const url = menu.getPath(menu.group[index]);
3535
router.push(url);
3636
}
3737
38-
onMounted(function () {
39-
// 设置默认
38+
// 刷新
39+
function refresh() {
4040
function deep(e: Menu.Item, i: number) {
4141
switch (e.type) {
4242
case 0:
@@ -56,10 +56,27 @@ onMounted(function () {
5656
}
5757
}
5858
59-
menu.group.forEach((e, i) => {
60-
deep(e, i);
61-
});
62-
});
59+
menu.group.forEach(deep);
60+
}
61+
62+
// 监听分组
63+
watch(
64+
() => menu.group.length,
65+
() => {
66+
refresh();
67+
},
68+
{
69+
immediate: true
70+
}
71+
);
72+
73+
// 监听路由
74+
watch(
75+
() => route.path,
76+
() => {
77+
refresh();
78+
}
79+
);
6380
</script>
6481

6582
<style lang="scss" scoped>

src/modules/base/views/menu.vue

+3
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ import { setFocus, useCrud, useTable, useUpsert } from "@cool-vue/crud";
9595
import { useCool } from "/@/cool";
9696
import { deepTree } from "/@/cool/utils";
9797
import AutoMenu from "/$/magic/components/auto-menu/index.vue";
98+
import { useStore } from "../store";
9899
99100
const { service, mitt } = useCool();
101+
const { menu } = useStore();
100102
101103
// cl-table
102104
const Table = useTable({
@@ -341,6 +343,7 @@ const Crud = useCrud(
341343
});
342344
343345
render(deepTree(list));
346+
menu.get();
344347
});
345348
}
346349
},

src/modules/cloud/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ModuleConfig } from "/@/cool";
2-
import { addDeclare } from "/$/editor";
2+
import { addDeclare } from "/$/extend";
33
import { CodeDeclare } from "./dict";
44

55
export default (): ModuleConfig => {

src/modules/demo/views/crud.vue

+3-8
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,14 @@ const Upsert = useUpsert({
199199
// });
200200
201201
// 直接取列表的数据返回
202-
done({
203-
...data,
204-
age: 18
205-
});
202+
done(data);
206203
},
207204
208205
// 提交钩子
209206
onSubmit(data, { next, close, done }) {
207+
console.log("onSubmit", data);
210208
// 继续请求 update/add 接口
211-
next({
212-
...data,
213-
code: "615206459"
214-
});
209+
next(data);
215210
},
216211
217212
// 打开后

src/modules/editor/index.ts

-1
This file was deleted.

src/modules/editor/config.ts renamed to src/modules/extend/config.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ export default (): ModuleConfig => {
55
// 根据使用情况选择组件注释,避免资源过大问题
66
components: [
77
// 富文本编辑器 https://www.npmjs.com/package/@wangeditor/editor
8-
() => import("./components/wang.vue"),
8+
() => import("./editor/wang.vue"),
99
// 富文本编辑器 https://www.npmjs.com/package/quill
10-
() => import("./components/quill.vue"),
10+
() => import("./editor/quill.vue"),
1111
// 代码编辑器 https://www.npmjs.com/package/monaco-editor
12-
() => import("./components/monaco/index.vue"),
13-
() => import("./components/preview.vue")
12+
() => import("./editor/monaco/index.vue"),
13+
// 文本预览
14+
() => import("./editor/preview.vue"),
15+
// 省市区选择 https://github.com/modood/Administrative-divisions-of-China
16+
() => import("./distpicker/index")
1417
]
1518
};
1619
};
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { defineComponent } from "vue";
2+
import { registerFormHook } from "@cool-vue/crud";
3+
import data from "./pca.json";
4+
5+
registerFormHook("pca", (value, { method, form, prop }) => {
6+
if (method == "bind") {
7+
return [form.province, form.city, form.district];
8+
} else {
9+
const [province, city, district] = value || [];
10+
form.province = province;
11+
form.city = city;
12+
form.district = district;
13+
form[prop] = undefined;
14+
}
15+
});
16+
17+
export default defineComponent({
18+
name: "cl-distpicker",
19+
20+
props: {
21+
props: Object
22+
},
23+
24+
setup(props) {
25+
return () => {
26+
return (
27+
<el-cascader options={data} props={{ label: "name", value: "name", ...props }} />
28+
);
29+
};
30+
}
31+
});

0 commit comments

Comments
 (0)