发布6.0

This commit is contained in:
icssoa 2023-03-09 12:16:15 +08:00
parent 43f37ca564
commit dfb576bee3
18 changed files with 893 additions and 175 deletions

View File

@ -14,11 +14,9 @@
## 地址 ## 地址
- [⚡️ vue2.x + element-ui](https://github.com/cool-team-official/cool-admin-vue) - [📌 vue6.x + element-plus + ts + vite](https://github.com/cool-team-official/cool-admin-vue/tree/6.x)
- [⚡️ vue3.x + element-plus + ts + webpack](https://github.com/cool-team-official/cool-admin-vue/tree/vue3-ts-webpack) - [⚡️ vue5.x + element-plus + ts + vite](https://github.com/cool-team-official/cool-admin-vue/tree/5.x)
- [📌 vue3.x + element-plus + ts + vite](https://github.com/cool-team-official/cool-admin-vue/tree/vue3-ts-vite)
- [🌐 码云仓库地址](https://gitee.com/cool-team-official/cool-admin-vue) - [🌐 码云仓库地址](https://gitee.com/cool-team-official/cool-admin-vue)
@ -46,12 +44,6 @@
yarn yarn
``` ```
解决 `node-sass` 网络慢的方法:
```shell
yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
```
## 运行应用程序 ## 运行应用程序
安装过程完成后,运行以下命令启动服务。您可以在浏览器中预览网站 [http://localhost:9000](http://localhost:9000) 安装过程完成后,运行以下命令启动服务。您可以在浏览器中预览网站 [http://localhost:9000](http://localhost:9000)

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,6 @@ export default {
proxy = storage.get("proxy") || "dev"; proxy = storage.get("proxy") || "dev";
} }
return `/${proxy}/`; return `/${proxy}`;
} }
}; };

View File

@ -9,5 +9,11 @@ export const proxy = {
target: "https://show.cool-admin.com", target: "https://show.cool-admin.com",
changeOrigin: true, changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/prod/, "/api") rewrite: (path: string) => path.replace(/^\/prod/, "/api")
},
"/ap/": {
target: "https://ap.cool-js.cloud",
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/ap/, "")
} }
}; };

View File

@ -96,26 +96,7 @@ import { useCool } from "/@/cool";
import { deepTree } from "/@/cool/utils"; import { deepTree } from "/@/cool/utils";
import AutoMenu from "/$/magic/components/auto-menu/index.vue"; import AutoMenu from "/$/magic/components/auto-menu/index.vue";
const { service } = useCool(); const { service, mitt } = useCool();
// cl-crud
const Crud = useCrud(
{
service: service.base.sys.menu,
onRefresh(_, { render }) {
service.base.sys.menu.list().then((list) => {
list.map((e) => {
e.permList = e.perms ? e.perms.split(",") : [];
});
render(deepTree(list));
});
}
},
(app) => {
app.refresh();
}
);
// cl-table // cl-table
const Table = useTable({ const Table = useTable({
@ -349,6 +330,30 @@ const Upsert = useUpsert({
plugins: [setFocus("name")] plugins: [setFocus("name")]
}); });
// cl-crud
const Crud = useCrud(
{
service: service.base.sys.menu,
onRefresh(_, { render }) {
service.base.sys.menu.list().then((list) => {
list.map((e) => {
e.permList = e.perms ? e.perms.split(",") : [];
});
render(deepTree(list));
});
}
},
(app) => {
app.refresh();
}
);
//
function refresh(params?: any) {
Crud.value?.refresh(params);
}
// //
function onRowClick(row: any, column: any) { function onRowClick(row: any, column: any) {
if (column?.property && row.children) { if (column?.property && row.children) {
@ -374,4 +379,6 @@ function addPermission({ id }: any) {
type: 2 type: 2
}); });
} }
mitt.on("magic.createMenu", refresh);
</script> </script>

View File

@ -0,0 +1,5 @@
import { ModuleConfig } from "/@/cool";
export default (): ModuleConfig => {
return {};
};

View File

@ -97,7 +97,7 @@ function clear() {
let stop: any = null; let stop: any = null;
mitt.on("dp-setConfig", (options: any) => { mitt.on("dp.setConfig", (options: any) => {
visible.value = false; visible.value = false;
if (stop) { if (stop) {
@ -126,7 +126,7 @@ mitt.on("dp-setConfig", (options: any) => {
}); });
}); });
mitt.on("dp-clearConfig", clear); mitt.on("dp.clearConfig", clear);
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -892,7 +892,7 @@ function onClone(item: any) {
_d = parse(item); _d = parse(item);
// //
mitt.emit("dp-pull", _d); mitt.emit("dp.pull", _d);
return _d; return _d;
} }
@ -904,7 +904,7 @@ function add(item: any) {
function onEnd() { function onEnd() {
if (_d) { if (_d) {
mitt.emit("dp-setActive", _d.id); mitt.emit("dp.setActive", _d.id);
} }
} }

View File

@ -74,18 +74,18 @@ function remove(index: number) {
} }
function onClone(data: any) { function onClone(data: any) {
mitt.emit("dp-pull", data); mitt.emit("dp.pull", data);
return data; return data;
} }
mitt.on("dp-setActive", (id: string) => { mitt.on("dp.setActive", (id: string) => {
const d = list.value?.find((e) => e.id == id); const d = list.value?.find((e) => e.id == id);
if (d) { if (d) {
dp.toDet(d); dp.toDet(d);
} }
}); });
mitt.on("dp-pull", (d) => { mitt.on("dp.pull", (d) => {
isPut.value = d?.component.name != "demo-group"; isPut.value = d?.component.name != "demo-group";
}); });

View File

@ -90,7 +90,7 @@ const form = reactive<{ active: string; list: any[] }>({
function toDet(item: any) { function toDet(item: any) {
if (item) { if (item) {
form.active = item.id; form.active = item.id;
mitt.emit("dp-setConfig", item); mitt.emit("dp.setConfig", item);
} }
} }
@ -106,7 +106,7 @@ function add(data: any) {
// //
function clearConfig(id?: string) { function clearConfig(id?: string) {
if (form.active == id || !id) { if (form.active == id || !id) {
mitt.emit("dp-clearConfig"); mitt.emit("dp.clearConfig");
} }
} }
@ -147,7 +147,7 @@ function clear() {
// //
function onClone(data: any) { function onClone(data: any) {
mitt.emit("dp-pull", data); mitt.emit("dp.pull", data);
return data; return data;
} }
@ -272,7 +272,7 @@ function scrollToBottom() {
} }
// //
mitt.on("dp-setActive", setActive); mitt.on("dp.setActive", setActive);
const dp = { const dp = {
form, form,

View File

@ -0,0 +1,5 @@
import { ModuleConfig } from "/@/cool";
export default (): ModuleConfig => {
return {};
};

View File

@ -21,7 +21,7 @@ import { deepPaths } from "/@/cool/utils";
import { computed, onMounted } from "vue"; import { computed, onMounted } from "vue";
import { useMenu } from "../../hooks"; import { useMenu } from "../../hooks";
const { service } = useCool(); const { service, mitt } = useCool();
const menu = useMenu(); const menu = useMenu();
const Form = useForm(); const Form = useForm();
@ -135,6 +135,24 @@ function open() {
"controls-position": "right" "controls-position": "right"
} }
} }
},
{
prop: "isCreateFile",
label: "是否创建文件",
value: 1,
component: {
name: "el-radio-group",
options: [
{
label: "是",
value: 1
},
{
label: "否",
value: 0
}
]
}
} }
], ],
on: { on: {
@ -150,7 +168,10 @@ function open() {
columns columns
}) })
.then((create) => { .then((create) => {
create(); if (data.isCreateFile) {
create();
}
mitt.emit("magic.createMenu");
close(); close();
}) })
.catch(() => { .catch(() => {

View File

@ -7,7 +7,9 @@ import { storage, useCool } from "/@/cool";
export function useChatGPT() { export function useChatGPT() {
const { route, router } = useCool(); const { route, router } = useCool();
const apiKey = ref(storage.get("chatgpt.apiKey") || ""); const apiKey = ref(
storage.get("chatgpt.apiKey") || "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"
);
// 余额 // 余额
const balance = reactive({ const balance = reactive({
@ -81,6 +83,8 @@ export function useChatGPT() {
socket?.on("balance", (res) => { socket?.on("balance", (res) => {
if (res == "error apiKey") { if (res == "error apiKey") {
ElMessage.error(res); ElMessage.error(res);
balance.total_granted = 0;
balance.total_used = 0;
} else { } else {
balance.total_granted = res.total_granted.toFixed(5); balance.total_granted = res.total_granted.toFixed(5);
balance.total_used = res.total_used.toFixed(5); balance.total_used = res.total_used.toFixed(5);
@ -100,7 +104,10 @@ export function useChatGPT() {
// 发送 // 发送
function send(data: { name: string; columns: string[]; module: string }) { function send(data: { name: string; columns: string[]; module: string }) {
socket?.emit("data", data); socket?.emit("data", {
...data,
apiKey: apiKey.value
});
} }
return { return {

View File

@ -14,3 +14,5 @@ export declare interface MenuData {
module: string; module: string;
[key: string]: any; [key: string]: any;
} }
export declare type CodeType = "entity" | "controller" | "vue";

View File

@ -36,7 +36,7 @@
/> />
</div> </div>
<!-- <div class="label required">Key</div> <div class="label">Key</div>
<div class="row"> <div class="row">
<el-input <el-input
@ -58,7 +58,7 @@
<Refresh /> <Refresh />
</el-icon> </el-icon>
</el-button> </el-button>
</div> --> </div>
<div class="label">其他你想做的事</div> <div class="label">其他你想做的事</div>
@ -179,7 +179,7 @@
<script lang="tsx" name="magic-ai-code" setup> <script lang="tsx" name="magic-ai-code" setup>
import { onMounted, reactive, watch } from "vue"; import { onMounted, reactive, watch } from "vue";
import { module, useCool, storage } from "/@/cool"; import { module, useCool, storage } from "/@/cool";
import { Promotion, Loading, Close, Check } from "@element-plus/icons-vue"; import { Promotion, Loading, Close, Check, Refresh } from "@element-plus/icons-vue";
import { ElLoading, ElMessage, ElMessageBox } from "element-plus"; import { ElLoading, ElMessage, ElMessageBox } from "element-plus";
import { debounce, isEmpty } from "lodash-es"; import { debounce, isEmpty } from "lodash-es";
import { useClipboard } from "@vueuse/core"; import { useClipboard } from "@vueuse/core";
@ -187,8 +187,7 @@ import { useMenu, useChatGPT, useScroll } from "../../hooks";
import { useForm } from "@cool-vue/crud"; import { useForm } from "@cool-vue/crud";
import { isDev } from "/@/cool"; import { isDev } from "/@/cool";
import Text2 from "./components/text.vue"; import Text2 from "./components/text.vue";
import { CodeType } from "../../types";
type CodeType = "entity" | "controller" | "vue";
const { service, mitt, refs, setRefs } = useCool(); const { service, mitt, refs, setRefs } = useCool();
const { copy } = useClipboard(); const { copy } = useClipboard();
@ -258,8 +257,16 @@ const codes = reactive({
// //
function next() { function next() {
if (!form.module || !form.name || isEmpty(form.columns)) { if (!form.module) {
return ElMessage.warning("请填写完整"); return ElMessage.warning("请选择模块");
}
if (!form.name) {
return ElMessage.warning("请填写实体名称");
}
if (isEmpty(form.columns)) {
return ElMessage.warning("请填写字段");
} }
function send() { function send() {

View File

@ -0,0 +1,5 @@
import { ModuleConfig } from "/@/cool";
export default (): ModuleConfig => {
return {};
};

View File

@ -0,0 +1,5 @@
import { ModuleConfig } from "/@/cool";
export default (): ModuleConfig => {
return {};
};

File diff suppressed because one or more lines are too long