@tomjs/create-app 5.0.0 → 5.2.0
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.mjs +1 -1
- package/package.json +5 -5
- package/templates/config/base/package.json +3 -0
- package/templates/config/electron/package.json +2 -2
- package/templates/config/hbuilderx/extension/index.ts +22 -0
- package/templates/config/hbuilderx/extension/webview.ts +71 -0
- package/templates/config/hbuilderx/package.json +96 -0
- package/templates/config/hbuilderx/tsconfig.node.json +15 -0
- package/templates/config/package.json +26 -15
- package/templates/config/react/package.json +3 -3
- package/templates/{web-react → config/react}/tsconfig.app.json +3 -1
- package/templates/config/style/package.json +2 -2
- package/templates/config/style/stylelint.config.mjs +4 -0
- package/templates/config/vscode/package.json +1 -1
- package/templates/config/vue/_eslint.config.mjs +5 -0
- package/templates/config/vue/env.d.ts +3 -0
- package/templates/config/vue/package.json +8 -2
- package/templates/{vscode-vue → config/vue}/tsconfig.app.json +8 -3
- package/templates/config/vue/uno.config.ts +9 -0
- package/templates/electron-react/vite.config.ts +7 -3
- package/templates/electron-vue/package.json +3 -1
- package/templates/electron-vue/vite.config.ts +16 -2
- package/templates/hbuilderx-base/README.md +20 -0
- package/templates/hbuilderx-base/package.json +52 -0
- package/templates/hbuilderx-base/src/env.d.ts +1 -0
- package/templates/hbuilderx-base/src/index.ts +17 -0
- package/templates/hbuilderx-base/tsconfig.json +7 -0
- package/templates/hbuilderx-base/tsdown.config.ts +13 -0
- package/templates/hbuilderx-react/README.md +25 -0
- package/templates/hbuilderx-react/index.html +13 -0
- package/templates/hbuilderx-react/package.json +12 -0
- package/templates/hbuilderx-react/pnpm-workspace.yaml +5 -0
- package/templates/hbuilderx-react/src/App.css +45 -0
- package/templates/hbuilderx-react/src/App.tsx +41 -0
- package/templates/hbuilderx-react/src/assets/react.svg +1 -0
- package/templates/hbuilderx-react/src/assets/vite.svg +1 -0
- package/templates/hbuilderx-react/src/index.css +73 -0
- package/templates/hbuilderx-react/src/main.tsx +10 -0
- package/templates/hbuilderx-react/tsconfig.app.json +18 -0
- package/templates/hbuilderx-react/vite.config.ts +20 -0
- package/templates/hbuilderx-vue/README.md +26 -0
- package/templates/hbuilderx-vue/index.html +13 -0
- package/templates/hbuilderx-vue/package.json +12 -0
- package/templates/hbuilderx-vue/pnpm-workspace.yaml +4 -0
- package/templates/hbuilderx-vue/src/App.vue +32 -0
- package/templates/hbuilderx-vue/src/assets/vite.svg +1 -0
- package/templates/hbuilderx-vue/src/assets/vue.svg +1 -0
- package/templates/hbuilderx-vue/src/components/HelloWorld.vue +29 -0
- package/templates/hbuilderx-vue/src/main.ts +5 -0
- package/templates/hbuilderx-vue/src/style.css +68 -0
- package/templates/hbuilderx-vue/tsconfig.app.json +18 -0
- package/templates/hbuilderx-vue/vite.config.ts +31 -0
- package/templates/node-vite/examples/vue/src/App.vue +3 -3
- package/templates/node-vite/examples/vue/src/components/HelloWorld.vue +6 -4
- package/templates/vscode-react/package.json +1 -1
- package/templates/vscode-react/vite.config.ts +6 -2
- package/templates/vscode-vue/package.json +1 -1
- package/templates/vscode-vue/vite.config.ts +16 -2
- package/templates/web-react/public/vite.svg +1 -0
- package/templates/web-react/vite.config.ts +3 -1
- package/templates/web-vue/package.json +3 -0
- package/templates/web-vue/public/vite.svg +1 -0
- package/templates/web-vue/src/App.vue +3 -3
- package/templates/web-vue/src/components/HelloWorld.vue +6 -4
- package/templates/web-vue/src/main.ts +1 -1
- package/templates/web-vue/vite.config.ts +19 -1
- package/templates/vscode-react/tsconfig.app.json +0 -8
- package/templates/vscode-vue/tsconfig.node.json +0 -8
- package/templates/web-vue/tsconfig.app.json +0 -9
- /package/templates/{vscode-react → config/hbuilderx}/tsconfig.json +0 -0
- /package/templates/{vscode-vue → config/react}/tsconfig.json +0 -0
- /package/templates/{web-react → config/react}/tsconfig.node.json +0 -0
- /package/templates/{web-react → config/vscode}/tsconfig.json +0 -0
- /package/templates/{vscode-react → config/vscode}/tsconfig.node.json +0 -0
- /package/templates/{web-vue → config/vue}/tsconfig.json +0 -0
- /package/templates/{web-vue → config/vue}/tsconfig.node.json +0 -0
- /package/templates/{config/react → electron-react}/public/vite.svg +0 -0
- /package/templates/{config/vue → electron-vue}/public/vite.svg +0 -0
- /package/templates/web-vue/src/{style.css → style.scss} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"publisher": "tomjs",
|
|
3
|
+
"name": "ext-simple",
|
|
4
|
+
"displayName": "简单插件",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"version": "0.0.0",
|
|
7
|
+
"description": "简单插件",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"HBuilderX"
|
|
10
|
+
],
|
|
11
|
+
"categories": [
|
|
12
|
+
"Other"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=16.17.0",
|
|
17
|
+
"HBuilderX": "^2.7.0"
|
|
18
|
+
},
|
|
19
|
+
"activationEvents": [],
|
|
20
|
+
"contributes": {
|
|
21
|
+
"commands": [
|
|
22
|
+
{
|
|
23
|
+
"command": "tomjs.xxx.showHello",
|
|
24
|
+
"title": "Hello World"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"menus": {
|
|
28
|
+
"editor/context": [
|
|
29
|
+
{
|
|
30
|
+
"command": "tomjs.xxx.showHello",
|
|
31
|
+
"group": "z_commands",
|
|
32
|
+
"when": "editorTextFocus"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"group": "z_commands"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "tsdown --watch",
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"lint": "eslint --fix"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@tomjs/hbuilderx": "^1.2.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^20.19.27",
|
|
50
|
+
"tsdown": "^0.18.4"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@tomjs/hbuilderx/types" />
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ExtensionContext } from 'hbuilderx';
|
|
2
|
+
import { isAlphaVersion, setContext } from '@tomjs/hbuilderx';
|
|
3
|
+
import { commands, window } from 'hbuilderx';
|
|
4
|
+
|
|
5
|
+
export function activate(context: ExtensionContext) {
|
|
6
|
+
setContext(context);
|
|
7
|
+
|
|
8
|
+
context.subscriptions.push(
|
|
9
|
+
commands.registerCommand('tomjs.xxx.showHello', async () => {
|
|
10
|
+
window.showInformationMessage(`Hello World!这是 ${isAlphaVersion ? '测试' : '正式'}版本的 HBuilderX。`, ['确定1', '取消2']).then((result) => {
|
|
11
|
+
window.showInformationMessage(`你点击了${result}`);
|
|
12
|
+
});
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function deactivate() { }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from 'tsdown';
|
|
2
|
+
import pkg from './package.json';
|
|
3
|
+
|
|
4
|
+
export default defineConfig((cfg) => {
|
|
5
|
+
return {
|
|
6
|
+
entry: 'src/index.ts',
|
|
7
|
+
target: 'node16.17',
|
|
8
|
+
format: 'cjs',
|
|
9
|
+
external: ['hbuilderx'],
|
|
10
|
+
noExternal: cfg.watch ? [] : Object.keys(pkg.dependencies || {}),
|
|
11
|
+
fixedExtension: false,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# hbuilderx-react
|
|
2
|
+
|
|
3
|
+
`window.createWebView` 或 `window.createWebViewDialog` 创建 `react` 网页视图
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 开发模式,不压缩代码
|
|
9
|
+
pnpm dev
|
|
10
|
+
# 生产模式,压缩代码
|
|
11
|
+
pnpm build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 调试
|
|
15
|
+
|
|
16
|
+
根据以下步骤调试插件,具体参考官方[插件教程](https://hx.dcloud.net.cn/ExtensionTutorial/firstExtension)
|
|
17
|
+
|
|
18
|
+
- 将当前项目 `hbuilderx-react` 拖拽到 `HBuilderX` 中
|
|
19
|
+
- 点击左上 `运行` 图标,选择点击 `运行插件-[hbuilderx-react]` 或 `调试插件-[hbuilderx-react]`,会打开的 `HBuilderX` 窗口调试插件。
|
|
20
|
+
- 在调试导入或创建任意项目,打开任意文件,在文件编辑器中点击鼠标右唤出菜单,选择 `触发左侧视图`、`触发右侧视图`、`触发弹框视图`,会分别打开或弹出视图。
|
|
21
|
+
|
|
22
|
+
网页调试
|
|
23
|
+
|
|
24
|
+
- 可以使用 [react-devtools](https://www.npmjs.com/package/react-devtools) 这个独立应用调试 `webview`
|
|
25
|
+
- 可以使用 `Google Chrome`,在地址栏输入 `chrome://inspect/#devices` 访问。如果 `Remote Target` 不显示,打开 `HBuilderX` 调试插件的控制台,查看会看到 `DevTools listening on ws://127.0.0.1:9500/devtools/browser/e964a967-04da-48f2-8656-9ba933f39e59`, 配置 `Discover network targets` 对应的 `localhost:9500` 即可。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>vite+react</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"publisher": "tomjs",
|
|
3
|
+
"name": "hbuilderx-react",
|
|
4
|
+
"displayName": "hbuilderx react插件",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"version": "0.0.0",
|
|
7
|
+
"description": "hbuilderx react插件",
|
|
8
|
+
"main": "dist/extension/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc -b && vite build"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#root {
|
|
2
|
+
max-width: 1280px;
|
|
3
|
+
padding: 2rem;
|
|
4
|
+
margin: 0 auto;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.logo {
|
|
9
|
+
height: 6em;
|
|
10
|
+
padding: 1.5em;
|
|
11
|
+
transition: filter 300ms;
|
|
12
|
+
will-change: filter;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.logo:hover {
|
|
16
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.logo.react:hover {
|
|
20
|
+
filter: drop-shadow(0 0 2em #61dafbaa);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@keyframes logo-spin {
|
|
24
|
+
from {
|
|
25
|
+
transform: rotate(0deg);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
to {
|
|
29
|
+
transform: rotate(360deg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
34
|
+
a:nth-of-type(2) .logo {
|
|
35
|
+
animation: logo-spin infinite 20s linear;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.card {
|
|
40
|
+
padding: 2em;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.read-the-docs {
|
|
44
|
+
color: #888;
|
|
45
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import reactLogo from '@/assets/react.svg';
|
|
3
|
+
import viteLogo from '@/assets/vite.svg';
|
|
4
|
+
import './App.css';
|
|
5
|
+
|
|
6
|
+
function App() {
|
|
7
|
+
const [count, setCount] = useState(0);
|
|
8
|
+
|
|
9
|
+
function onPostMessage() {
|
|
10
|
+
hbuilderx.postMessage({
|
|
11
|
+
command: 'alert',
|
|
12
|
+
text: `HelloWorld-${Date.now()}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<div>
|
|
19
|
+
<a href="https://vite.dev" target="_blank">
|
|
20
|
+
<img src={viteLogo} className="logo" alt="Vite logo" />
|
|
21
|
+
</a>
|
|
22
|
+
<a href="https://react.dev" target="_blank">
|
|
23
|
+
<img src={reactLogo} className="logo react" alt="React logo" />
|
|
24
|
+
</a>
|
|
25
|
+
</div>
|
|
26
|
+
<h1>Vite + React</h1>
|
|
27
|
+
<div className="card">
|
|
28
|
+
<button onClick={() => setCount(count => count + 1)}>
|
|
29
|
+
count is
|
|
30
|
+
{' '}
|
|
31
|
+
{count}
|
|
32
|
+
</button>
|
|
33
|
+
<button style={{ marginLeft: 12 }} onClick={onPostMessage}>
|
|
34
|
+
发送消息
|
|
35
|
+
</button>
|
|
36
|
+
</div>
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
font-weight: 400;
|
|
4
|
+
|
|
5
|
+
font-synthesis: none;
|
|
6
|
+
line-height: 1.5;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
background-color: #242424;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
a:hover {
|
|
23
|
+
color: #535bf2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
body {
|
|
27
|
+
display: flex;
|
|
28
|
+
place-items: center;
|
|
29
|
+
min-width: 320px;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
margin: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 3.2em;
|
|
36
|
+
line-height: 1.1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
button {
|
|
40
|
+
padding: 0.6em 1.2em;
|
|
41
|
+
font-family: inherit;
|
|
42
|
+
font-size: 1em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
background-color: #1a1a1a;
|
|
46
|
+
border: 1px solid transparent;
|
|
47
|
+
border-radius: 8px;
|
|
48
|
+
transition: border-color 0.25s;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
button:hover {
|
|
52
|
+
border-color: #646cff;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
button:focus,
|
|
56
|
+
button:focus-visible {
|
|
57
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (prefers-color-scheme: light) {
|
|
61
|
+
:root {
|
|
62
|
+
color: #213547;
|
|
63
|
+
background-color: #ffffff;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
a:hover {
|
|
67
|
+
color: #747bff;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
button {
|
|
71
|
+
background-color: #f9f9f9;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tomjs/tsconfig/react.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": [
|
|
7
|
+
"./src/*"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"types": [
|
|
11
|
+
"vite/client",
|
|
12
|
+
"@tomjs/hbuilderx/client"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
3
|
+
import hbuilderx from '@tomjs/vite-plugin-hbuilderx';
|
|
4
|
+
import react from '@vitejs/plugin-react-swc';
|
|
5
|
+
import { defineConfig } from 'vite';
|
|
6
|
+
|
|
7
|
+
// https://vite.dev/config/
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
12
|
+
// https://github.com/facebook/react/issues/24928#issuecomment-2267624188
|
|
13
|
+
'react': path.resolve(process.cwd(), 'node_modules/react'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
build: {
|
|
17
|
+
assetsInlineLimit: 1024 * 100,
|
|
18
|
+
},
|
|
19
|
+
plugins: [react(), hbuilderx({ devtools: true })],
|
|
20
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# hbuilderx-vue
|
|
2
|
+
|
|
3
|
+
`window.createWebView` 或 `window.createWebViewDialog` 创建 `vue` 网页视图
|
|
4
|
+
|
|
5
|
+
## 使用
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 开发模式,不压缩代码
|
|
9
|
+
pnpm dev
|
|
10
|
+
# 生产模式,压缩代码
|
|
11
|
+
pnpm build
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## 调试
|
|
15
|
+
|
|
16
|
+
根据以下步骤调试插件,具体参考官方[插件教程](https://hx.dcloud.net.cn/ExtensionTutorial/firstExtension)
|
|
17
|
+
|
|
18
|
+
- 将当前项目 `hbuilderx-vue` 拖拽到 `HBuilderX` 中
|
|
19
|
+
- 点击左上 `运行` 图标,选择点击 `运行插件-[hbuilderx-vue]` 或 `调试插件-[hbuilderx-vue]`,会打开的 `HBuilderX` 窗口调试插件。
|
|
20
|
+
- 在调试导入或创建任意项目,打开任意文件,在文件编辑器中点击鼠标右唤出菜单,选择 `触发左侧视图`、`触发右侧视图`、`触发弹框视图`,会分别打开或弹出视图。
|
|
21
|
+
|
|
22
|
+
网页调试
|
|
23
|
+
|
|
24
|
+
- 可以使用 [vite-plugin-vue-devtools](https://devtools.vuejs.org/guide/vite-plugin) 这个 `vite` 插件直接在页面调试
|
|
25
|
+
- 可以使用 [vue-devtools](https://devtools.vuejs.org/guide/standalone) 这个独立应用调试 `webview`
|
|
26
|
+
- 可以使用 `Google Chrome`,在地址栏输入 `chrome://inspect/#devices` 访问。如果 `Remote Target` 不显示,打开 `HBuilderX` 调试插件的控制台,查看会看到 `DevTools listening on ws://127.0.0.1:9500/devtools/browser/e964a967-04da-48f2-8656-9ba933f39e59`, 配置 `Discover network targets` 对应的 `localhost:9500` 即可。
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>vite+vue</title>
|
|
7
|
+
</head>
|
|
8
|
+
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"publisher": "tomjs",
|
|
3
|
+
"name": "hbuilderx-vue",
|
|
4
|
+
"displayName": "hbuilderx vue插件",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"version": "0.0.0",
|
|
7
|
+
"description": "hbuilderx vue插件",
|
|
8
|
+
"main": "dist/extension/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "vue-tsc --noEmit && vite build"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import HelloWorld from '@/components/HelloWorld.vue';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div>
|
|
7
|
+
<a href="https://vite.dev" target="_blank">
|
|
8
|
+
<img src="@/assets/vite.svg" class="logo" alt="Vite logo">
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://vuejs.org/" target="_blank">
|
|
11
|
+
<img src="@/assets/vue.svg" class="logo vue" alt="Vue logo">
|
|
12
|
+
</a>
|
|
13
|
+
</div>
|
|
14
|
+
<HelloWorld msg="Vite + Vue" />
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<style scoped>
|
|
18
|
+
.logo {
|
|
19
|
+
height: 6em;
|
|
20
|
+
padding: 1.5em;
|
|
21
|
+
transition: filter 300ms;
|
|
22
|
+
will-change: filter;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.logo:hover {
|
|
26
|
+
filter: drop-shadow(0 0 2em #646cffaa);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.logo.vue:hover {
|
|
30
|
+
filter: drop-shadow(0 0 2em #42b883aa);
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
defineProps<{ msg: string }>();
|
|
5
|
+
|
|
6
|
+
const count = ref(0);
|
|
7
|
+
|
|
8
|
+
function onPostMessage() {
|
|
9
|
+
hbuilderx.postMessage({
|
|
10
|
+
command: 'alert',
|
|
11
|
+
text: `HelloWorld-${Date.now()}`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<h1>{{ msg }}</h1>
|
|
18
|
+
|
|
19
|
+
<div class="card">
|
|
20
|
+
<button type="button" @click="count++">
|
|
21
|
+
count is {{ count }}
|
|
22
|
+
</button>
|
|
23
|
+
<button type="button" style="margin-left: 12px;" @click="onPostMessage">
|
|
24
|
+
发送消息
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style scoped></style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
font-weight: 400;
|
|
4
|
+
|
|
5
|
+
font-synthesis: none;
|
|
6
|
+
line-height: 1.5;
|
|
7
|
+
color: #213547;
|
|
8
|
+
|
|
9
|
+
color-scheme: light dark;
|
|
10
|
+
text-rendering: optimizeLegibility;
|
|
11
|
+
-webkit-font-smoothing: antialiased;
|
|
12
|
+
-moz-osx-font-smoothing: grayscale;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a {
|
|
16
|
+
font-weight: 500;
|
|
17
|
+
color: #646cff;
|
|
18
|
+
text-decoration: inherit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #747bff;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
display: flex;
|
|
27
|
+
place-items: center;
|
|
28
|
+
min-width: 320px;
|
|
29
|
+
min-height: 100vh;
|
|
30
|
+
margin: 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 {
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
button {
|
|
39
|
+
padding: 0.6em 1.2em;
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
font-size: 1em;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
background-color: #f9f9f9;
|
|
45
|
+
border: 1px solid transparent;
|
|
46
|
+
border-radius: 8px;
|
|
47
|
+
transition: border-color 0.25s;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
button:hover {
|
|
51
|
+
border-color: #646cff;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button:focus,
|
|
55
|
+
button:focus-visible {
|
|
56
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.card {
|
|
60
|
+
padding: 2em;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#app {
|
|
64
|
+
max-width: 1280px;
|
|
65
|
+
padding: 2rem;
|
|
66
|
+
margin: 0 auto;
|
|
67
|
+
text-align: center;
|
|
68
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@tomjs/tsconfig/vue-dom.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
5
|
+
"paths": {
|
|
6
|
+
"@/*": ["./src/*"]
|
|
7
|
+
},
|
|
8
|
+
"types": [
|
|
9
|
+
"vite/client",
|
|
10
|
+
"@tomjs/hbuilderx/client"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"env.d.ts",
|
|
15
|
+
"src/**/*",
|
|
16
|
+
"src/**/*.vue"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
2
|
+
import hbuilderx from '@tomjs/vite-plugin-hbuilderx';
|
|
3
|
+
import vue from '@vitejs/plugin-vue';
|
|
4
|
+
import UnoCSS from 'unocss/vite';
|
|
5
|
+
import AutoImport from 'unplugin-auto-import/vite';
|
|
6
|
+
import Components from 'unplugin-vue-components/vite';
|
|
7
|
+
import { defineConfig } from 'vite';
|
|
8
|
+
import devtools from 'vite-plugin-vue-devtools';
|
|
9
|
+
|
|
10
|
+
// https://vite.dev/config/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
resolve: {
|
|
13
|
+
alias: {
|
|
14
|
+
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
build: {
|
|
18
|
+
chunkSizeWarningLimit: 102400,
|
|
19
|
+
reportCompressedSize: false,
|
|
20
|
+
},
|
|
21
|
+
plugins: [
|
|
22
|
+
vue(),
|
|
23
|
+
AutoImport({
|
|
24
|
+
imports: ['vue'],
|
|
25
|
+
}),
|
|
26
|
+
Components(),
|
|
27
|
+
hbuilderx(),
|
|
28
|
+
UnoCSS(),
|
|
29
|
+
devtools(),
|
|
30
|
+
],
|
|
31
|
+
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import HelloWorld from './components/HelloWorld.vue'
|
|
2
|
+
import HelloWorld from './components/HelloWorld.vue';
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<template>
|
|
6
6
|
<div>
|
|
7
7
|
<a href="https://vite.dev" target="_blank">
|
|
8
|
-
<img src="/vite.svg" class="logo" alt="Vite logo"
|
|
8
|
+
<img src="/vite.svg" class="logo" alt="Vite logo">
|
|
9
9
|
</a>
|
|
10
10
|
<a href="https://vuejs.org/" target="_blank">
|
|
11
|
-
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo"
|
|
11
|
+
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo">
|
|
12
12
|
</a>
|
|
13
13
|
</div>
|
|
14
14
|
<HelloWorld msg="Vite + Vue" />
|