神仙都没用 před 1 rokem
rodič
revize
3e2060dd8c

+ 2 - 2
package.json

@@ -9,7 +9,7 @@
 		"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .eslintignore"
 	},
 	"dependencies": {
-		"@cool-vue/crud": "^7.1.26",
+		"@cool-vue/crud": "^7.1.27",
 		"@element-plus/icons-vue": "^2.3.1",
 		"@vueuse/core": "^10.4.0",
 		"@wangeditor/editor": "^5.1.23",
@@ -38,7 +38,7 @@
 	},
 	"devDependencies": {
 		"@rushstack/eslint-patch": "^1.8.0",
-		"@cool-vue/vite-plugin": "^7.1.6",
+		"@cool-vue/vite-plugin": "^7.1.7",
 		"@types/file-saver": "^2.0.7",
 		"@types/lodash-es": "^4.17.8",
 		"@types/mockjs": "^1.0.7",

+ 1 - 1
packages/crud/package.json

@@ -1,6 +1,6 @@
 {
 	"name": "@cool-vue/crud",
-	"version": "7.1.26",
+	"version": "7.1.27",
 	"private": false,
 	"main": "./dist/index.umd.min.js",
 	"typings": "types/index.d.ts",

+ 3 - 0
packages/crud/src/static/index.scss

@@ -508,6 +508,9 @@
 }
 
 .cl-dialog {
+	display: flex;
+	flex-direction: column;
+
 	&.el-dialog {
 		border-radius: 6px;
 		padding: 0;

+ 1 - 1
packages/crud/types/index.d.ts

@@ -1,5 +1,5 @@
 /// <reference types="../index" />
-import { App } from "vue";
+import type { App } from "vue";
 import "./static/index.scss";
 declare const Crud: {
     install(app: App, options?: Options): {

+ 1 - 1
packages/crud/types/provide.d.ts

@@ -1,3 +1,3 @@
 /// <reference types="../index" />
-import { App } from "vue";
+import { type App } from "vue";
 export declare function useProvide(app: App, options?: Options): void;

+ 19 - 1
packages/vite-plugin/dist/index.js

@@ -694,7 +694,9 @@
     }
 
     async function createCtx() {
-        let ctx = {};
+        let ctx = {
+            serviceLang: "Node",
+        };
         if (config.type == "app") {
             const manifest = readFile(rootDir("manifest.json"), true);
             // 文件路径
@@ -753,6 +755,22 @@
         if (config.type == "admin") {
             const list = fs.readdirSync(rootDir("./src/modules"));
             ctx.modules = list.filter((e) => !e.includes("."));
+            await axios
+                .get(config.reqUrl + "/admin/base/comm/program", {
+                timeout: 5000,
+            })
+                .then((res) => {
+                const { code, data, message } = res.data;
+                if (code === 1000) {
+                    ctx.serviceLang = data || "Node";
+                }
+                else {
+                    error(`[cool-ctx] ${message}`);
+                }
+            })
+                .catch((err) => {
+                // console.error(['[cool-ctx] ', err.message])
+            });
         }
         return ctx;
     }

+ 1 - 1
packages/vite-plugin/package.json

@@ -1,6 +1,6 @@
 {
 	"name": "@cool-vue/vite-plugin",
-	"version": "7.1.6",
+	"version": "7.1.7",
 	"description": "cool-admin/cool-uni builder",
 	"main": "/dist/index.js",
 	"scripts": {

+ 22 - 2
packages/vite-plugin/src/ctx/index.ts

@@ -1,13 +1,16 @@
 import { join } from "path";
-import { readFile, rootDir, writeFile } from "../utils";
+import { readFile, rootDir, writeFile, error } from "../utils";
 import { glob } from "glob";
 import { assign, cloneDeep, isEqual, orderBy } from "lodash";
 import { config } from "../config";
 import fs from "fs";
+import axios from "axios";
 import type { Ctx } from "../../types";
 
 export async function createCtx() {
-	let ctx: Ctx.Data = {};
+	let ctx: Ctx.Data = {
+		serviceLang: "Node",
+	};
 
 	if (config.type == "app") {
 		const manifest = readFile(rootDir("manifest.json"), true);
@@ -82,6 +85,23 @@ export async function createCtx() {
 	if (config.type == "admin") {
 		const list = fs.readdirSync(rootDir("./src/modules"));
 		ctx.modules = list.filter((e) => !e.includes("."));
+
+		await axios
+			.get(config.reqUrl + "/admin/base/comm/program", {
+				timeout: 5000,
+			})
+			.then((res) => {
+				const { code, data, message } = res.data;
+
+				if (code === 1000) {
+					ctx.serviceLang = data || "Node";
+				} else {
+					error(`[cool-ctx] ${message}`);
+				}
+			})
+			.catch((err) => {
+				// console.error(['[cool-ctx] ', err.message])
+			});
 	}
 
 	return ctx;

+ 1 - 0
packages/vite-plugin/types/index.d.ts

@@ -54,6 +54,7 @@ export namespace Ctx {
 		pages?: Ctx.Pages;
 		subPackages?: Ctx.SubPackages;
 		modules?: string[];
+		serviceLang: "Node" | "Java" | "Go" | "Python";
 		[key: string]: any;
 	}
 }

+ 4 - 3
src/modules/helper/views/ai-code.vue

@@ -296,6 +296,7 @@ import { sleep, storage } from "/@/cool/utils";
 import dayjs from "dayjs";
 import type { CodeItem, EpsColumn } from "../types";
 import { useClipboard } from "@vueuse/core";
+import { ctx } from "virtual:ctx";
 
 const { service, refs, setRefs, router } = useCool();
 const menu = useMenu();
@@ -369,10 +370,10 @@ const step = reactive({
 
 // 语言
 const lang = reactive({
-	value: "Node" as "Node" | "Java" | "Go" | "Python",
+	value: "Node",
 
-	async get() {
-		lang.value = await service.base.comm.program();
+	get() {
+		lang.value = ctx.serviceLang;
 		code.active = lang.value.toLocaleLowerCase() + "-entity";
 	},