From 3e2060dd8cc875e53cd977502c298b6fdc6eb151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Sat, 27 Jul 2024 15:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- packages/crud/package.json | 2 +- packages/crud/src/static/index.scss | 3 +++ packages/crud/types/index.d.ts | 2 +- packages/crud/types/provide.d.ts | 2 +- packages/vite-plugin/dist/index.js | 20 +++++++++++++++++++- packages/vite-plugin/package.json | 2 +- packages/vite-plugin/src/ctx/index.ts | 24 ++++++++++++++++++++++-- packages/vite-plugin/types/index.d.ts | 1 + src/modules/helper/views/ai-code.vue | 7 ++++--- 10 files changed, 55 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index e39dc30..04ccfcb 100644 --- a/package.json +++ b/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", diff --git a/packages/crud/package.json b/packages/crud/package.json index 243c554..8a0b277 100644 --- a/packages/crud/package.json +++ b/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", diff --git a/packages/crud/src/static/index.scss b/packages/crud/src/static/index.scss index 440333d..e2fd941 100644 --- a/packages/crud/src/static/index.scss +++ b/packages/crud/src/static/index.scss @@ -508,6 +508,9 @@ } .cl-dialog { + display: flex; + flex-direction: column; + &.el-dialog { border-radius: 6px; padding: 0; diff --git a/packages/crud/types/index.d.ts b/packages/crud/types/index.d.ts index 907e276..05744cd 100644 --- a/packages/crud/types/index.d.ts +++ b/packages/crud/types/index.d.ts @@ -1,5 +1,5 @@ /// -import { App } from "vue"; +import type { App } from "vue"; import "./static/index.scss"; declare const Crud: { install(app: App, options?: Options): { diff --git a/packages/crud/types/provide.d.ts b/packages/crud/types/provide.d.ts index 01f0963..aa336b8 100644 --- a/packages/crud/types/provide.d.ts +++ b/packages/crud/types/provide.d.ts @@ -1,3 +1,3 @@ /// -import { App } from "vue"; +import { type App } from "vue"; export declare function useProvide(app: App, options?: Options): void; diff --git a/packages/vite-plugin/dist/index.js b/packages/vite-plugin/dist/index.js index 00ce09f..e8f99a0 100644 --- a/packages/vite-plugin/dist/index.js +++ b/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; } diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 3edbbda..24f57c3 100644 --- a/packages/vite-plugin/package.json +++ b/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": { diff --git a/packages/vite-plugin/src/ctx/index.ts b/packages/vite-plugin/src/ctx/index.ts index 08ab329..e149260 100644 --- a/packages/vite-plugin/src/ctx/index.ts +++ b/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; diff --git a/packages/vite-plugin/types/index.d.ts b/packages/vite-plugin/types/index.d.ts index aad12a2..e5c0ec4 100644 --- a/packages/vite-plugin/types/index.d.ts +++ b/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; } } diff --git a/src/modules/helper/views/ai-code.vue b/src/modules/helper/views/ai-code.vue index eab0316..8ca50c2 100644 --- a/src/modules/helper/views/ai-code.vue +++ b/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"; },