nuxt-gin-tools 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/generate.js +1 -1
- package/src/nuxt-config.d.ts +4 -39
- package/src/nuxt-config.js +8 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-gin-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nuxt-gin": "index.js"
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/fs-extra": "^11.0.4",
|
|
23
23
|
"@types/node": "^24.0.14",
|
|
24
|
-
"nitro": "^0.0.0",
|
|
25
24
|
"nuxt": "^3.17.7",
|
|
26
25
|
"ts-node": "^10.9.2",
|
|
27
26
|
"typescript": "^5.8.3"
|
package/src/generate.js
CHANGED
|
@@ -31,7 +31,7 @@ const cwd = process.cwd(); // 获取当前工作目录
|
|
|
31
31
|
*/
|
|
32
32
|
let commands = [
|
|
33
33
|
{
|
|
34
|
-
command: "openapi-generator-cli generate -i openapi.yaml -g go-gin-server -c node_modules/
|
|
34
|
+
command: "openapi-generator-cli generate -i openapi.yaml -g go-gin-server -c node_modules/nuxt-gin-tools/src/go-gin-server.json -o .",
|
|
35
35
|
name: "go",
|
|
36
36
|
prefixColor: "green",
|
|
37
37
|
},
|
package/src/nuxt-config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NuxtConfig } from "nuxt/config";
|
|
1
2
|
/** API配置模式接口 */
|
|
2
3
|
export interface ServerConfig {
|
|
3
4
|
/** Gin框架端口 */
|
|
@@ -7,42 +8,6 @@ export interface ServerConfig {
|
|
|
7
8
|
/** Nuxt的BaseUrl,必须以/开头并包含至少一个单词字符 */
|
|
8
9
|
baseUrl: string;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
declare const thisBasePath: any;
|
|
16
|
-
export declare const config: {
|
|
17
|
-
ssr: boolean;
|
|
18
|
-
app: {
|
|
19
|
-
baseURL: string;
|
|
20
|
-
};
|
|
21
|
-
devServer: {
|
|
22
|
-
port: number;
|
|
23
|
-
};
|
|
24
|
-
experimental: {
|
|
25
|
-
payloadExtraction: boolean;
|
|
26
|
-
};
|
|
27
|
-
nitro: {
|
|
28
|
-
devProxy: {
|
|
29
|
-
[thisBasePath]: {
|
|
30
|
-
target: string;
|
|
31
|
-
changeOrigin: boolean;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
vite: {
|
|
36
|
-
esbuild: {
|
|
37
|
-
jsxFactory: string;
|
|
38
|
-
jsxFragment: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
rootDir: string;
|
|
42
|
-
devtools: {
|
|
43
|
-
timeline: {
|
|
44
|
-
enabled: boolean;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export default config;
|
|
11
|
+
export declare const config: NuxtConfig;
|
|
12
|
+
export declare function getServerConfig(nitro: NuxtConfig["nitro"]): NuxtConfig;
|
|
13
|
+
export default getServerConfig;
|
package/src/nuxt-config.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.config = void 0;
|
|
4
|
+
exports.getServerConfig = getServerConfig;
|
|
4
5
|
const fs_extra_1 = require("fs-extra");
|
|
5
6
|
const path_1 = require("path");
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
const api_1 = require("../../../vue/composables/api/api");
|
|
8
7
|
const cwd = process.cwd();
|
|
9
8
|
const serverConfig = (0, fs_extra_1.readJSONSync)((0, path_1.resolve)(cwd, `server.config.json`));
|
|
10
|
-
/**
|
|
11
|
-
* 处理基础路径,去除协议和域名部分,只保留路径部分
|
|
12
|
-
* 例如,将 "https://example.com/api-go" 转换为 "/api-go"
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
const thisBasePath = api_1.BASE_PATH.replace(/^https?:[/]{2}[^/]+/, "");
|
|
16
|
-
/**
|
|
17
|
-
* 定义代理目标 URL
|
|
18
|
-
* 拼接本地服务器的地址和处理后的基础路径,用于开发环境的代理
|
|
19
|
-
* 例如,当 Gin 服务器端口为 8099 时,目标 URL 可能为 "http://localhost:8099/api-go"
|
|
20
|
-
*/
|
|
21
|
-
const target = `http://localhost:${serverConfig.ginPort}${thisBasePath}`;
|
|
22
9
|
exports.config = {
|
|
23
10
|
ssr: false,
|
|
24
11
|
app: { baseURL: serverConfig.baseUrl },
|
|
25
12
|
devServer: { port: serverConfig.nuxtPort },
|
|
26
13
|
experimental: { payloadExtraction: false },
|
|
27
|
-
nitro: {
|
|
28
|
-
devProxy: {
|
|
29
|
-
[thisBasePath]: { target, changeOrigin: true },
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
14
|
vite: {
|
|
33
15
|
esbuild: { jsxFactory: "h", jsxFragment: "Fragment" },
|
|
34
16
|
},
|
|
@@ -39,4 +21,10 @@ exports.config = {
|
|
|
39
21
|
},
|
|
40
22
|
},
|
|
41
23
|
};
|
|
42
|
-
|
|
24
|
+
function getServerConfig(nitro) {
|
|
25
|
+
return {
|
|
26
|
+
...exports.config,
|
|
27
|
+
nitro,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.default = getServerConfig;
|