create-ones-app 0.0.2 → 0.0.3
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/dist/index.cjs +16 -6
- package/dist/index.js +16 -6
- package/dist/types/action.d.ts +1 -1
- package/dist/types/action.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -2
- package/template/example/.template.json +18 -0
- package/template/example/AGENTS.md +1 -0
- package/template/example/README.md +1 -0
- package/template/example/api/app_manifest.d.ts +115 -0
- package/template/example/api/app_manifest.js +69 -0
- package/template/example/api/app_setting_pages.d.ts +14 -0
- package/template/example/api/app_setting_pages.js +27 -0
- package/template/example/api/events.js +14 -0
- package/template/example/api/install.js +14 -0
- package/template/example/api/metadata.js +16 -0
- package/template/example/public/index.html +20 -0
- package/template/example/public/logo.svg +4 -0
- package/template/example/public/script.js +56 -0
- package/template/example/public/style.css +66 -0
- package/template/example/vercel.json +23 -0
- package/template/example/test.json +0 -3
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const commander = require("commander");
|
|
4
|
-
const
|
|
4
|
+
const node_process = require("node:process");
|
|
5
5
|
const node_path = require("node:path");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const fsExtra = require("fs-extra");
|
|
8
|
+
const node_fs = require("node:fs");
|
|
6
9
|
const node_url = require("node:url");
|
|
7
10
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
8
|
-
const action = (value) => {
|
|
9
|
-
console.log("value", value);
|
|
10
|
-
};
|
|
11
11
|
const getPackageJSONPath = () => {
|
|
12
12
|
const __dirname = node_path.dirname(node_url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("index.cjs", document.baseURI).href));
|
|
13
13
|
return node_path.join(__dirname, "../package.json");
|
|
@@ -34,11 +34,21 @@ const getTemplateChoices = () => {
|
|
|
34
34
|
const getTemplateDefault = () => {
|
|
35
35
|
return "example";
|
|
36
36
|
};
|
|
37
|
+
const action = async (value) => {
|
|
38
|
+
console.log(`template-name: ${chalk.green(value)}`);
|
|
39
|
+
console.log("creating template...");
|
|
40
|
+
try {
|
|
41
|
+
await fsExtra.copy(node_path.join(getTemplatePath(), value), node_process.cwd());
|
|
42
|
+
console.log(chalk.green("Create template successfully!"));
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(chalk.red(error));
|
|
45
|
+
}
|
|
46
|
+
};
|
|
37
47
|
const create = new commander.Command("create");
|
|
38
48
|
create.description("description").addArgument(new commander.Argument("[template-name]", "specify a template for the created project").choices(getTemplateChoices()).default(getTemplateDefault())).action(action);
|
|
39
|
-
async
|
|
49
|
+
const runCommandCreate = async () => {
|
|
40
50
|
const version = `${getPackageJSON().version}`;
|
|
41
51
|
create.version(version);
|
|
42
52
|
await create.parse();
|
|
43
|
-
}
|
|
53
|
+
};
|
|
44
54
|
exports.runCommandCreate = runCommandCreate;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Command, Argument } from "commander";
|
|
2
|
-
import {
|
|
2
|
+
import { cwd } from "node:process";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import { copy } from "fs-extra";
|
|
6
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
4
7
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
const action = (value) => {
|
|
6
|
-
console.log("value", value);
|
|
7
|
-
};
|
|
8
8
|
const getPackageJSONPath = () => {
|
|
9
9
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
return join(__dirname, "../package.json");
|
|
@@ -31,13 +31,23 @@ const getTemplateChoices = () => {
|
|
|
31
31
|
const getTemplateDefault = () => {
|
|
32
32
|
return "example";
|
|
33
33
|
};
|
|
34
|
+
const action = async (value) => {
|
|
35
|
+
console.log(`template-name: ${chalk.green(value)}`);
|
|
36
|
+
console.log("creating template...");
|
|
37
|
+
try {
|
|
38
|
+
await copy(join(getTemplatePath(), value), cwd());
|
|
39
|
+
console.log(chalk.green("Create template successfully!"));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(chalk.red(error));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
34
44
|
const create = new Command("create");
|
|
35
45
|
create.description("description").addArgument(new Argument("[template-name]", "specify a template for the created project").choices(getTemplateChoices()).default(getTemplateDefault())).action(action);
|
|
36
|
-
async
|
|
46
|
+
const runCommandCreate = async () => {
|
|
37
47
|
const version = `${getPackageJSON().version}`;
|
|
38
48
|
create.version(version);
|
|
39
49
|
await create.parse();
|
|
40
|
-
}
|
|
50
|
+
};
|
|
41
51
|
export {
|
|
42
52
|
runCommandCreate
|
|
43
53
|
};
|
package/dist/types/action.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const action: (value: string) => void
|
|
1
|
+
export declare const action: (value: string) => Promise<void>;
|
|
2
2
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,MAAM,UAAiB,MAAM,kBASzC,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const runCommandCreate: () => Promise<void>;
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gBAAgB,qBAI5B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ones-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -49,7 +49,12 @@
|
|
|
49
49
|
"registry": "https://registry.npmjs.org",
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/fs-extra": "^11.0.4"
|
|
54
|
+
},
|
|
52
55
|
"dependencies": {
|
|
53
|
-
"
|
|
56
|
+
"chalk": "^5.0.1",
|
|
57
|
+
"commander": "~9.4.0",
|
|
58
|
+
"fs-extra": "^11.3.0"
|
|
54
59
|
}
|
|
55
60
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# AGENTS.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# README.md
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONES Application Manifest Schema Interface
|
|
3
|
+
* Defines the structure for application manifest
|
|
4
|
+
* Documentation: https://p8205-k3s-9-submodule-opendocs2.k3s-dev.myones.net/docs/guide/getting-started/quick-start-guide#build-your-app-manifest
|
|
5
|
+
*/
|
|
6
|
+
export interface AppManifest {
|
|
7
|
+
/** Application ID, format: app_ + 16 lowercase alphanumeric characters */
|
|
8
|
+
id: string
|
|
9
|
+
|
|
10
|
+
/** Application name, 1-64 characters */
|
|
11
|
+
name: string
|
|
12
|
+
|
|
13
|
+
/** Semantic version number (e.g., v1.0.0) */
|
|
14
|
+
version: string
|
|
15
|
+
|
|
16
|
+
/** Application base URL, must start with http(s):// and not contain ? or # */
|
|
17
|
+
base_url: string
|
|
18
|
+
|
|
19
|
+
/** Authentication configuration */
|
|
20
|
+
auth: {
|
|
21
|
+
/** Authentication type (currently only supports 'jwt') */
|
|
22
|
+
type: 'jwt'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Lifecycle callback configuration */
|
|
26
|
+
lifecycle_callback: {
|
|
27
|
+
/** Install callback endpoint (required) */
|
|
28
|
+
install: string
|
|
29
|
+
/** Enable callback endpoint (optional) */
|
|
30
|
+
enabled?: string
|
|
31
|
+
/** Disable callback endpoint (optional) */
|
|
32
|
+
disabled?: string
|
|
33
|
+
/** Uninstall callback endpoint (optional) */
|
|
34
|
+
uninstalled?: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Application description, maximum 1024 characters (optional) */
|
|
38
|
+
desc?: string | null
|
|
39
|
+
|
|
40
|
+
/** Application Logo URL (optional) */
|
|
41
|
+
logo?: string | null
|
|
42
|
+
|
|
43
|
+
/** Event configuration (optional) */
|
|
44
|
+
events?: {
|
|
45
|
+
/** Event callback URL, must start with / and not contain # */
|
|
46
|
+
url: string
|
|
47
|
+
/** Event type list */
|
|
48
|
+
types: Array<{
|
|
49
|
+
/** ONES defined event type, the application will listen to this event.
|
|
50
|
+
* Available event types include: ones:project:issue:created, ones:project:issue:updated,
|
|
51
|
+
* ones:project:project:created, ones:project:project:updated,
|
|
52
|
+
* ones:project:project-member:added, ones:project:project-member:deleted,
|
|
53
|
+
* ones:project:project-role:added, ones:project:project-role:deleted
|
|
54
|
+
* For complete list, see: https://developer.ones.com/docs/abilities/events/ */
|
|
55
|
+
eventType: string
|
|
56
|
+
}>
|
|
57
|
+
} | null
|
|
58
|
+
|
|
59
|
+
/** Extension configuration (optional) */
|
|
60
|
+
extensions?: {
|
|
61
|
+
/** Application setting page extensions */
|
|
62
|
+
appSettingPages?: Array<{
|
|
63
|
+
/** Unique identifier for the extension */
|
|
64
|
+
key: string
|
|
65
|
+
/** Extension functionality configuration */
|
|
66
|
+
funcs: {
|
|
67
|
+
/** Custom entries endpoint */
|
|
68
|
+
customEntries: string
|
|
69
|
+
}
|
|
70
|
+
}>
|
|
71
|
+
|
|
72
|
+
/** Manhour validator extensions */
|
|
73
|
+
manhourValidator?: Array<{
|
|
74
|
+
/** Unique identifier for the extension */
|
|
75
|
+
key: string
|
|
76
|
+
/** Extension functionality configuration */
|
|
77
|
+
funcs: {
|
|
78
|
+
/** Validation endpoint */
|
|
79
|
+
validate: string
|
|
80
|
+
}
|
|
81
|
+
}>
|
|
82
|
+
} | null
|
|
83
|
+
|
|
84
|
+
/** OAuth configuration (optional) */
|
|
85
|
+
oauth?: {
|
|
86
|
+
/** OAuth scope permissions list. Available scopes include: read:project:issue,
|
|
87
|
+
* write:project:issue, read:project:project, write:project:project,
|
|
88
|
+
* read:project:issueType, read:project:issueStatus, read:project:issueField,
|
|
89
|
+
* read:project:issueFieldGroup, read:project:issue-attachment,
|
|
90
|
+
* write:project:issue-attachment, write:project:issue-timeEstimated,
|
|
91
|
+
* write:project:issue-timeRemaining, read:project:issue-timeSpent,
|
|
92
|
+
* write:project:issue-timeSpent, write:project:issue-comment,
|
|
93
|
+
* read:project:issue-comment, write:project:issue-watcher,
|
|
94
|
+
* read:product:fields, read:project:workLog-timeEstimated,
|
|
95
|
+
* read:testcase:library, write:testcase:library, read:account:department,
|
|
96
|
+
* read:account:department-member, read:account:user, write:account:user,
|
|
97
|
+
* read:appcenter:app, write:appcenter:user, read:wiki:space,
|
|
98
|
+
* read:wiki:page, read:wiki:resource, write:wiki:page,
|
|
99
|
+
* read:wiki:template, read:system:info
|
|
100
|
+
* For complete list, see: https://developer.ones.com/docs/abilities/openapi/scope */
|
|
101
|
+
scope: string[]
|
|
102
|
+
/** OAuth type, supports 'app' and 'user' */
|
|
103
|
+
type?: ('app' | 'user')[] | null
|
|
104
|
+
/** OAuth redirect URL, must start with / and not contain # (optional) */
|
|
105
|
+
redirect_url?: string | null
|
|
106
|
+
} | null
|
|
107
|
+
|
|
108
|
+
/** ONES version compatibility (optional) */
|
|
109
|
+
ones_version?: {
|
|
110
|
+
/** Minimum compatible ONES version (e.g., v6.42.0) */
|
|
111
|
+
min?: string
|
|
112
|
+
/** Maximum compatible ONES version (e.g., v6.88.0) */
|
|
113
|
+
max?: string
|
|
114
|
+
} | null
|
|
115
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** @type { import("./app_manifest.d.ts").AppManifest } */
|
|
2
|
+
const example = {
|
|
3
|
+
// Required fields
|
|
4
|
+
id: 'app_01234567890abcdef',
|
|
5
|
+
name: 'ONES App',
|
|
6
|
+
version: 'v1.0.0',
|
|
7
|
+
base_url: 'https://your-domain',
|
|
8
|
+
auth: {
|
|
9
|
+
type: 'jwt',
|
|
10
|
+
},
|
|
11
|
+
lifecycle_callback: {
|
|
12
|
+
install: '/api/install',
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// Optional fields
|
|
16
|
+
desc: 'ONES App example with some features.',
|
|
17
|
+
logo: 'https://your-domain/logo.png',
|
|
18
|
+
|
|
19
|
+
// Event configuration
|
|
20
|
+
events: {
|
|
21
|
+
url: '/api/events',
|
|
22
|
+
types: [{ eventType: 'ones:project:issue:created' }],
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// Extension configuration
|
|
26
|
+
extensions: {
|
|
27
|
+
appSettingPages: [
|
|
28
|
+
{
|
|
29
|
+
key: 'myCustomEntries',
|
|
30
|
+
funcs: {
|
|
31
|
+
customEntries: '/api/app_setting_pages',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// OAuth configuration
|
|
38
|
+
oauth: {
|
|
39
|
+
scope: ['read:project:project'],
|
|
40
|
+
type: ['app', 'user'],
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function handler(req, res) {
|
|
45
|
+
// Set CORS headers to allow cross-origin requests
|
|
46
|
+
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
47
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
|
48
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
|
|
49
|
+
|
|
50
|
+
// Handle preflight requests
|
|
51
|
+
if (req.method === 'OPTIONS') {
|
|
52
|
+
res.status(200).end()
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Get host from request headers
|
|
57
|
+
const host = req.headers.host
|
|
58
|
+
|
|
59
|
+
// Clone data from example
|
|
60
|
+
const data = JSON.parse(JSON.stringify(example))
|
|
61
|
+
|
|
62
|
+
// Update data's base_url field with host
|
|
63
|
+
data.base_url = `https://${host}`
|
|
64
|
+
|
|
65
|
+
// Update data's logo field with logo.svg
|
|
66
|
+
data.logo = `https://${host}/logo.svg`
|
|
67
|
+
|
|
68
|
+
res.status(200).json(data)
|
|
69
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ONES Application Setting Pages Configuration Interface
|
|
3
|
+
* Defines the structure for application setting page entries
|
|
4
|
+
* Documentation: https://p8205-k3s-9-submodule-opendocs2.k3s-dev.myones.net/
|
|
5
|
+
*/
|
|
6
|
+
export interface AppSettingPages {
|
|
7
|
+
/** Array of setting page entries */
|
|
8
|
+
entries: Array<{
|
|
9
|
+
/** URL of the setting page, must start with / and not contain # */
|
|
10
|
+
page_url: string
|
|
11
|
+
/** Display title for the setting page entry */
|
|
12
|
+
title: string
|
|
13
|
+
}>
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @type { import("./app_setting_pages.d.ts").AppSettingPages } */
|
|
2
|
+
const example = {
|
|
3
|
+
entries: [
|
|
4
|
+
{
|
|
5
|
+
page_url: '/',
|
|
6
|
+
title: 'Example Page',
|
|
7
|
+
},
|
|
8
|
+
],
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function handler(req, res) {
|
|
12
|
+
// Set CORS headers to allow cross-origin requests
|
|
13
|
+
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
14
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
|
15
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
|
|
16
|
+
|
|
17
|
+
// Handle preflight requests
|
|
18
|
+
if (req.method === 'OPTIONS') {
|
|
19
|
+
res.status(200).end()
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Clone data from example
|
|
24
|
+
const data = JSON.parse(JSON.stringify(example))
|
|
25
|
+
|
|
26
|
+
res.status(200).json(data)
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function handler(req, res) {
|
|
2
|
+
// Set CORS headers to allow cross-origin requests
|
|
3
|
+
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
4
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
|
5
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
|
|
6
|
+
|
|
7
|
+
// Handle preflight requests
|
|
8
|
+
if (req.method === 'OPTIONS') {
|
|
9
|
+
res.status(200).end()
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
res.status(200).json({})
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default function handler(req, res) {
|
|
2
|
+
// Set CORS headers to allow cross-origin requests
|
|
3
|
+
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
4
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
|
5
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
|
|
6
|
+
|
|
7
|
+
// Handle preflight requests
|
|
8
|
+
if (req.method === 'OPTIONS') {
|
|
9
|
+
res.status(200).end()
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
res.status(200).json({})
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default function handler(req, res) {
|
|
2
|
+
// Set CORS headers to allow cross-origin requests
|
|
3
|
+
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
4
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
|
|
5
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization')
|
|
6
|
+
|
|
7
|
+
// Handle preflight requests
|
|
8
|
+
if (req.method === 'OPTIONS') {
|
|
9
|
+
res.status(200).end()
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
res.status(200).json({
|
|
14
|
+
metadata: 'example metadata',
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Hello World - Vercel</title>
|
|
7
|
+
<link rel="stylesheet" href="style.css" />
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div class="container">
|
|
11
|
+
<h1>Hello World!</h1>
|
|
12
|
+
<p>欢迎来到Vercel部署的Hello World应用</p>
|
|
13
|
+
<button id="app-api-button" class="api-button">调用 App API 接口</button>
|
|
14
|
+
<button id="open-api-button" class="api-button">使用 Open API 接口</button>
|
|
15
|
+
<div id="result" class="result" style="display: none"></div>
|
|
16
|
+
</div>
|
|
17
|
+
<script src="https://unpkg.com/@ones-open/sdk/dist/index.iife.js"></script>
|
|
18
|
+
<script src="script.js"></script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<rect width="16" height="16" rx="2" fill="#0064FF"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.43816 2.66672C6.82458 2.66672 6.31279 3.17606 6.31279 3.82228V4.4445C6.31279 4.68996 6.11381 4.88894 5.86835 4.88894H3.55556V6.70091H4.56017C5.68056 6.70091 6.57443 7.62426 6.57443 8.74535C6.57443 9.83706 5.70842 10.8718 4.56017 10.8718H3.55556V12.4445H10.6667V10.4274C10.6667 10.1819 10.8657 9.98296 11.1111 9.98296H12.208C12.7937 9.98296 13.3333 9.42095 13.3333 8.74535C13.3333 8.09914 12.8215 7.5898 12.208 7.5898H11.1111C10.8657 7.5898 10.6667 7.39081 10.6667 7.14535V4.88894H9.00797C8.76251 4.88894 8.56353 4.68996 8.56353 4.4445V3.82228C8.56353 3.17606 8.05174 2.66672 7.43816 2.66672ZM5.4239 3.82228C5.4239 2.70118 6.31778 1.77783 7.43816 1.77783C8.55854 1.77783 9.45242 2.70118 9.45242 3.82228V4.00005H11.1111C11.3566 4.00005 11.5556 4.19904 11.5556 4.4445V6.70091H12.208C13.3284 6.70091 14.2222 7.62426 14.2222 8.74535C14.2222 9.83706 13.3562 10.8718 12.208 10.8718H11.5556V12.8889C11.5556 13.1344 11.3566 13.3334 11.1111 13.3334H3.11112C2.86566 13.3334 2.66667 13.1344 2.66667 12.8889V10.4274C2.66667 10.1819 2.86566 9.98296 3.11112 9.98296H4.56017C5.14589 9.98296 5.68554 9.42095 5.68554 8.74535C5.68554 8.09914 5.17375 7.5898 4.56017 7.5898H3.11112C2.86566 7.5898 2.66667 7.39081 2.66667 7.14535V4.4445C2.66667 4.32662 2.7135 4.21358 2.79685 4.13023C2.8802 4.04688 2.99324 4.00005 3.11112 4.00005H5.4239V3.82228Z" fill="white"/>
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
;(function () {
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
if (!window.SDK) {
|
|
5
|
+
console.error('Web SDK not initialized')
|
|
6
|
+
// see: https://developer.ones.com/docs/abilities/events/
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!window.SDK.ONES) {
|
|
11
|
+
console.error('Web SDK is only supported on ONES extension context')
|
|
12
|
+
// see: https://developer.ones.com/docs/abilities/events/
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log('Web SDK initialized successfully')
|
|
17
|
+
|
|
18
|
+
// Get DOM elements
|
|
19
|
+
const appApiButton = document.getElementById('app-api-button')
|
|
20
|
+
const openApiButton = document.getElementById('open-api-button')
|
|
21
|
+
|
|
22
|
+
// App API button click handler
|
|
23
|
+
appApiButton.addEventListener('click', async function () {
|
|
24
|
+
const resultDiv = document.getElementById('result')
|
|
25
|
+
resultDiv.style.display = 'block'
|
|
26
|
+
resultDiv.innerHTML = '<div class="loading">正在调用 App API...</div>'
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// see: https://developer.ones.com/docs/abilities/events/
|
|
30
|
+
const response = await window.SDK.ONES.fetchApp('/api/metadata')
|
|
31
|
+
const data = await response.json()
|
|
32
|
+
resultDiv.innerHTML = `App API 响应:\n${JSON.stringify(data, null, 2)}`
|
|
33
|
+
} catch (error) {
|
|
34
|
+
resultDiv.innerHTML = `App API 错误: ${error.message}`
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// Open API button click handler
|
|
39
|
+
openApiButton.addEventListener('click', async function () {
|
|
40
|
+
const resultDiv = document.getElementById('result')
|
|
41
|
+
resultDiv.style.display = 'block'
|
|
42
|
+
resultDiv.innerHTML = '<div class="loading">正在调用 Open API...</div>'
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// see: https://developer.ones.com/docs/abilities/events/
|
|
46
|
+
const teamInfo = await window.SDK.ONES.getTeamInfo()
|
|
47
|
+
const teamUUID = teamInfo.teamUUID
|
|
48
|
+
// see: https://developer.ones.com/docs/abilities/events/
|
|
49
|
+
const response = await window.SDK.ONES.fetchOpenAPI(`/v2/project/projects?teamID=${teamUUID}`)
|
|
50
|
+
const data = await response.json()
|
|
51
|
+
resultDiv.innerHTML = `Open API 响应:\n${JSON.stringify(data, null, 2)}`
|
|
52
|
+
} catch (error) {
|
|
53
|
+
resultDiv.innerHTML = `Open API 错误: ${error.message}`
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
})()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
body {
|
|
2
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
6
|
+
min-height: 100vh;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.container {
|
|
13
|
+
text-align: center;
|
|
14
|
+
background: white;
|
|
15
|
+
padding: 3rem;
|
|
16
|
+
border-radius: 20px;
|
|
17
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
|
|
18
|
+
max-width: 600px;
|
|
19
|
+
margin: 2rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
h1 {
|
|
23
|
+
color: #333;
|
|
24
|
+
font-size: 3rem;
|
|
25
|
+
margin-bottom: 1rem;
|
|
26
|
+
background: linear-gradient(45deg, #667eea, #764ba2);
|
|
27
|
+
-webkit-background-clip: text;
|
|
28
|
+
-webkit-text-fill-color: transparent;
|
|
29
|
+
background-clip: text;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
p {
|
|
33
|
+
color: #666;
|
|
34
|
+
font-size: 1.2rem;
|
|
35
|
+
margin-bottom: 2rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.api-button {
|
|
39
|
+
background: linear-gradient(45deg, #667eea, #764ba2);
|
|
40
|
+
color: white;
|
|
41
|
+
border: none;
|
|
42
|
+
padding: 1rem 2rem;
|
|
43
|
+
border-radius: 50px;
|
|
44
|
+
font-size: 1.1rem;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
transition: transform 0.2s;
|
|
47
|
+
margin: 0.5rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.api-button:hover {
|
|
51
|
+
transform: translateY(-2px);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.result {
|
|
55
|
+
margin-top: 2rem;
|
|
56
|
+
padding: 1rem;
|
|
57
|
+
background: #f8f9fa;
|
|
58
|
+
border-radius: 10px;
|
|
59
|
+
text-align: left;
|
|
60
|
+
font-family: monospace;
|
|
61
|
+
white-space: pre-wrap;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.loading {
|
|
65
|
+
color: #667eea;
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"builds": [
|
|
4
|
+
{
|
|
5
|
+
"src": "api/**/*.js",
|
|
6
|
+
"use": "@vercel/node"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"src": "public/**/*",
|
|
10
|
+
"use": "@vercel/static"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"routes": [
|
|
14
|
+
{
|
|
15
|
+
"src": "/api/(.*)",
|
|
16
|
+
"dest": "/api/$1.js"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"src": "/(.*)",
|
|
20
|
+
"dest": "/public/$1"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|