@lingxia/cli 0.0.9 → 0.1.1
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/bin/lingxia.js +207 -32
- package/dist/builder/commands/build.d.ts +1 -1
- package/dist/builder/commands/build.d.ts.map +1 -1
- package/dist/builder/commands/build.js +138 -103
- package/dist/builder/commands/build.js.map +1 -1
- package/dist/builder/core/builders/logic.d.ts +3 -3
- package/dist/builder/core/builders/logic.d.ts.map +1 -1
- package/dist/builder/core/builders/logic.js +55 -46
- package/dist/builder/core/builders/logic.js.map +1 -1
- package/dist/builder/core/builders/page-functions.d.ts.map +1 -1
- package/dist/builder/core/builders/page-functions.js +43 -35
- package/dist/builder/core/builders/page-functions.js.map +1 -1
- package/dist/builder/core/builders/page-path-injector.js +27 -27
- package/dist/builder/core/builders/page-path-injector.js.map +1 -1
- package/dist/builder/core/builders/page-types.d.ts +22 -0
- package/dist/builder/core/builders/page-types.d.ts.map +1 -0
- package/dist/builder/core/builders/page-types.js +374 -0
- package/dist/builder/core/builders/page-types.js.map +1 -0
- package/dist/builder/core/builders/page.d.ts +5 -4
- package/dist/builder/core/builders/page.d.ts.map +1 -1
- package/dist/builder/core/builders/page.js +54 -52
- package/dist/builder/core/builders/page.js.map +1 -1
- package/dist/builder/core/builders/view-validator.d.ts +9 -0
- package/dist/builder/core/builders/view-validator.d.ts.map +1 -0
- package/dist/builder/core/builders/view-validator.js +58 -0
- package/dist/builder/core/builders/view-validator.js.map +1 -0
- package/dist/builder/core/builders/view.d.ts +40 -3
- package/dist/builder/core/builders/view.d.ts.map +1 -1
- package/dist/builder/core/builders/view.js +406 -55
- package/dist/builder/core/builders/view.js.map +1 -1
- package/dist/builder/core/config/alias-config.d.ts +1 -1
- package/dist/builder/core/config/alias-config.d.ts.map +1 -1
- package/dist/builder/core/config/alias-config.js +8 -8
- package/dist/builder/core/config/alias-config.js.map +1 -1
- package/dist/builder/core/config/framework.d.ts +1 -1
- package/dist/builder/core/config/framework.d.ts.map +1 -1
- package/dist/builder/core/config/framework.js +14 -11
- package/dist/builder/core/config/framework.js.map +1 -1
- package/dist/builder/core/config/lxapp-config.d.ts +74 -0
- package/dist/builder/core/config/lxapp-config.d.ts.map +1 -0
- package/dist/builder/core/config/lxapp-config.js +195 -0
- package/dist/builder/core/config/lxapp-config.js.map +1 -0
- package/dist/builder/core/config/view-build-schema.d.ts +2 -2
- package/dist/builder/core/config/view-config.d.ts +3 -3
- package/dist/builder/core/config/view-config.d.ts.map +1 -1
- package/dist/builder/core/config/view-config.js +16 -16
- package/dist/builder/core/config/view-config.js.map +1 -1
- package/dist/builder/core/config.d.ts +1 -1
- package/dist/builder/core/config.js +11 -11
- package/dist/builder/core/constants/source-dirs.d.ts +1 -1
- package/dist/builder/core/constants/source-dirs.js +9 -9
- package/dist/builder/core/constants/source-dirs.js.map +1 -1
- package/dist/builder/core/constants/static-dirs.d.ts +1 -1
- package/dist/builder/core/constants/static-dirs.d.ts.map +1 -1
- package/dist/builder/core/constants/static-dirs.js +11 -11
- package/dist/builder/core/constants/static-dirs.js.map +1 -1
- package/dist/builder/core/frameworks/base.d.ts +1 -1
- package/dist/builder/core/frameworks/base.d.ts.map +1 -1
- package/dist/builder/core/frameworks/base.js +13 -11
- package/dist/builder/core/frameworks/base.js.map +1 -1
- package/dist/builder/core/frameworks/factory.d.ts +1 -1
- package/dist/builder/core/frameworks/factory.d.ts.map +1 -1
- package/dist/builder/core/frameworks/factory.js +9 -9
- package/dist/builder/core/frameworks/factory.js.map +1 -1
- package/dist/builder/core/frameworks/html.d.ts +2 -2
- package/dist/builder/core/frameworks/html.d.ts.map +1 -1
- package/dist/builder/core/frameworks/html.js +10 -10
- package/dist/builder/core/frameworks/html.js.map +1 -1
- package/dist/builder/core/frameworks/react.d.ts +3 -3
- package/dist/builder/core/frameworks/react.d.ts.map +1 -1
- package/dist/builder/core/frameworks/react.js +45 -43
- package/dist/builder/core/frameworks/react.js.map +1 -1
- package/dist/builder/core/frameworks/templates.d.ts +1 -1
- package/dist/builder/core/frameworks/templates.d.ts.map +1 -1
- package/dist/builder/core/frameworks/templates.js +1 -1
- package/dist/builder/core/frameworks/templates.js.map +1 -1
- package/dist/builder/core/frameworks/vue.d.ts +3 -3
- package/dist/builder/core/frameworks/vue.d.ts.map +1 -1
- package/dist/builder/core/frameworks/vue.js +48 -43
- package/dist/builder/core/frameworks/vue.js.map +1 -1
- package/dist/builder/core/registry.d.ts.map +1 -1
- package/dist/builder/core/registry.js +34 -25
- package/dist/builder/core/registry.js.map +1 -1
- package/dist/builder/core/template.d.ts +1 -1
- package/dist/builder/core/template.d.ts.map +1 -1
- package/dist/builder/core/template.js +19 -14
- package/dist/builder/core/template.js.map +1 -1
- package/dist/builder/core/templates/embedded.d.ts +3 -3
- package/dist/builder/core/templates/embedded.d.ts.map +1 -1
- package/dist/builder/core/templates/embedded.js +62 -31
- package/dist/builder/core/templates/embedded.js.map +1 -1
- package/dist/builder/core/type-generator.d.ts +17 -0
- package/dist/builder/core/type-generator.d.ts.map +1 -0
- package/dist/builder/core/type-generator.js +172 -0
- package/dist/builder/core/type-generator.js.map +1 -0
- package/dist/builder/core/utils/file.js +4 -4
- package/dist/builder/core/utils/incremental.d.ts +59 -0
- package/dist/builder/core/utils/incremental.d.ts.map +1 -0
- package/dist/builder/core/utils/incremental.js +177 -0
- package/dist/builder/core/utils/incremental.js.map +1 -0
- package/dist/builder/core/utils/page.d.ts +12 -2
- package/dist/builder/core/utils/page.d.ts.map +1 -1
- package/dist/builder/core/utils/page.js +63 -8
- package/dist/builder/core/utils/page.js.map +1 -1
- package/dist/builder/index.d.ts +1 -1
- package/dist/builder/index.js +1 -1
- package/dist/builder/types/index.d.ts +7 -6
- package/dist/builder/types/index.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/templates/AppIcon.png +0 -0
- package/templates/android-native/app/src/main/java/MainActivity.kt +2 -2
- package/templates/android-native/app/src/main/res/values/strings.xml +1 -1
- package/templates/android-native/settings.gradle.kts +4 -0
- package/templates/harmony-native/AppScope/app.json5 +10 -0
- package/templates/harmony-native/AppScope/resources/base/element/string.json +8 -0
- package/templates/harmony-native/build-profile.json5 +41 -0
- package/templates/harmony-native/entry/build-profile.json5 +8 -0
- package/templates/harmony-native/entry/hvigorfile.ts +6 -0
- package/templates/harmony-native/entry/oh-package.json5 +11 -0
- package/templates/harmony-native/entry/src/main/ets/entryability/EntryAbility.ets +38 -0
- package/templates/harmony-native/entry/src/main/ets/pages/Index.ets +15 -0
- package/templates/harmony-native/entry/src/main/module.json5 +38 -0
- package/templates/harmony-native/entry/src/main/resources/base/element/color.json +8 -0
- package/templates/harmony-native/entry/src/main/resources/base/element/string.json +16 -0
- package/templates/harmony-native/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/templates/harmony-native/entry/src/main/resources/dark/element/color.json +8 -0
- package/templates/harmony-native/hvigor/hvigor-config.json5 +13 -0
- package/templates/harmony-native/hvigorfile.ts +6 -0
- package/templates/harmony-native/oh-package.json5 +10 -0
- package/templates/ios-native/App.entitlements +10 -0
- package/templates/ios-native/Info.plist +8 -0
- package/templates/ios-native/Package.swift +31 -0
- package/templates/ios-native/Sources/App.swift +44 -0
- package/templates/lxapp-create/html/global.d.ts +1 -0
- package/templates/lxapp-create/html/lxapp.config.ts +5 -0
- package/templates/lxapp-create/html/lxapp.json +8 -0
- package/templates/lxapp-create/html/lxapp.ts +8 -0
- package/templates/lxapp-create/html/package.json +20 -0
- package/templates/lxapp-create/html/pages/home/index.html +32 -0
- package/templates/lxapp-create/html/pages/home/index.json +3 -0
- package/templates/lxapp-create/html/pages/home/index.ts +14 -0
- package/templates/lxapp-create/html/tsconfig.json +13 -0
- package/templates/lxapp-create/html/view/home.ts +19 -0
- package/templates/lxapp-create/react/app.css +20 -0
- package/templates/lxapp-create/react/lxapp.config.ts +8 -0
- package/templates/lxapp-create/react/lxapp.json +1 -1
- package/templates/lxapp-create/react/package.json +2 -0
- package/templates/lxapp-create/react/pages/home/index.json +1 -1
- package/templates/lxapp-create/react/pages/home/index.ts +8 -3
- package/templates/lxapp-create/react/pages/home/index.tsx +113 -42
- package/templates/lxapp-create/react/tsconfig.json +5 -2
- package/templates/lxapp-create/vue/app.css +20 -0
- package/templates/lxapp-create/vue/lxapp.config.ts +8 -0
- package/templates/lxapp-create/vue/lxapp.json +1 -1
- package/templates/lxapp-create/vue/package.json +2 -0
- package/templates/lxapp-create/vue/pages/home/index.json +1 -1
- package/templates/lxapp-create/vue/pages/home/index.ts +8 -3
- package/templates/lxapp-create/vue/pages/home/index.vue +124 -37
- package/templates/lxapp-create/vue/tsconfig.json +5 -2
- package/templates/macos-native/Info.plist +40 -0
- package/templates/macos-native/Package.swift +30 -0
- package/templates/macos-native/Sources/main.swift +23 -0
- package/templates/rust-lib/Cargo.toml +16 -1
- package/templates/rust-lib/README.md +1 -1
- package/templates/rust-lib/src/lib.rs +39 -1
- package/vendor/lingxia +0 -0
- package/templates/lxapp-create/react/lxapp.config.json +0 -8
- package/templates/lxapp-create/react/public/.gitkeep +0 -0
- package/templates/lxapp-create/vue/lxapp.config.json +0 -8
- package/templates/lxapp-create/vue/public/.gitkeep +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const nameInput = document.getElementById('name') as HTMLInputElement;
|
|
2
|
+
const btn = document.getElementById('btn')!;
|
|
3
|
+
const greetingEl = document.getElementById('greeting')!;
|
|
4
|
+
|
|
5
|
+
btn.onclick = () => {
|
|
6
|
+
const name = nameInput.value.trim();
|
|
7
|
+
if (name) greet({ name });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
nameInput.onkeydown = (e) => {
|
|
11
|
+
if (e.key === 'Enter') btn.click();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
window.LingXiaBridge?.subscribe((data: { greeting: string }) => {
|
|
15
|
+
if (data.greeting) {
|
|
16
|
+
greetingEl.textContent = data.greeting;
|
|
17
|
+
greetingEl.style.display = 'block';
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* Reset */
|
|
2
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
3
|
+
html, body { width: 100%; min-height: 100%; }
|
|
4
|
+
body {
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
background: #f5f5f7;
|
|
8
|
+
color: #1d1d1f;
|
|
9
|
+
/* Disable text selection by default (like native apps) */
|
|
10
|
+
-webkit-user-select: none;
|
|
11
|
+
user-select: none;
|
|
12
|
+
-webkit-touch-callout: none;
|
|
13
|
+
}
|
|
14
|
+
#root { min-height: 100%; }
|
|
15
|
+
input, button { font: inherit; }
|
|
16
|
+
button:disabled { opacity: 0.5; }
|
|
17
|
+
|
|
18
|
+
/* Enable text selection for specific elements */
|
|
19
|
+
[selectable], .selectable { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
|
|
20
|
+
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
Page({
|
|
2
2
|
data: {
|
|
3
|
-
greeting: '
|
|
3
|
+
greeting: '',
|
|
4
4
|
greetCount: 0
|
|
5
5
|
},
|
|
6
6
|
|
|
7
|
-
greet(
|
|
7
|
+
greet: function(payload: { name: string }) {
|
|
8
8
|
const count = this.data.greetCount + 1;
|
|
9
|
+
const time = new Date().toLocaleTimeString('en-US', {
|
|
10
|
+
hour: '2-digit',
|
|
11
|
+
minute: '2-digit',
|
|
12
|
+
second: '2-digit'
|
|
13
|
+
});
|
|
9
14
|
this.setData({
|
|
10
15
|
greetCount: count,
|
|
11
|
-
greeting:
|
|
16
|
+
greeting: 'Hello, ' + payload.name + '! 👋\nGreeting #' + count + ' at ' + time
|
|
12
17
|
});
|
|
13
18
|
}
|
|
14
19
|
});
|
|
@@ -1,60 +1,131 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { LxNavigator } from '@lingxia/components/react';
|
|
3
|
+
import '../../app.css';
|
|
2
4
|
|
|
3
|
-
type PageState = {
|
|
4
|
-
|
|
5
|
-
greetCount: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type PageActions = {
|
|
9
|
-
data: PageState;
|
|
10
|
-
greet(payload: { name: string }): void;
|
|
11
|
-
};
|
|
12
|
-
|
|
5
|
+
type PageState = { greeting: string; greetCount: number };
|
|
6
|
+
type PageActions = { data: PageState; greet(payload: { name: string }): void };
|
|
13
7
|
declare function useLingXia(): PageActions;
|
|
14
8
|
|
|
15
9
|
export default function HomePage() {
|
|
16
10
|
const { data, greet } = useLingXia();
|
|
17
11
|
const [name, setName] = React.useState('');
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
if (pending) {
|
|
22
|
-
const timer = setTimeout(() => setPending(false), 500);
|
|
23
|
-
return () => clearTimeout(timer);
|
|
24
|
-
}
|
|
25
|
-
}, [data.greetCount, pending]);
|
|
26
|
-
|
|
27
|
-
const submit = () => {
|
|
28
|
-
const value = name.trim();
|
|
29
|
-
if (!value) return;
|
|
30
|
-
setPending(true);
|
|
31
|
-
greet({ name: value });
|
|
32
|
-
};
|
|
12
|
+
const submit = () => name.trim() && greet({ name: name.trim() });
|
|
33
13
|
|
|
34
14
|
return (
|
|
35
|
-
<div
|
|
36
|
-
<div
|
|
37
|
-
<
|
|
38
|
-
<h1>Hello
|
|
39
|
-
<p
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<div className="form-row">
|
|
15
|
+
<div style={S.page}>
|
|
16
|
+
<div style={S.card}>
|
|
17
|
+
<img src="/public/AppIcon.png" style={S.logo} />
|
|
18
|
+
<h1 style={S.title}>Hello, LingXia</h1>
|
|
19
|
+
<p style={S.subtitle}>Build once, run everywhere</p>
|
|
20
|
+
|
|
21
|
+
<div style={S.form}>
|
|
43
22
|
<input
|
|
44
23
|
value={name}
|
|
45
|
-
placeholder="Enter
|
|
46
|
-
onChange={
|
|
47
|
-
onKeyDown={
|
|
48
|
-
|
|
49
|
-
}}
|
|
24
|
+
placeholder="Enter your name"
|
|
25
|
+
onChange={e => setName(e.target.value)}
|
|
26
|
+
onKeyDown={e => e.key === 'Enter' && submit()}
|
|
27
|
+
style={S.input}
|
|
50
28
|
/>
|
|
51
|
-
<button
|
|
52
|
-
|
|
29
|
+
<button onClick={submit} disabled={!name.trim()} style={S.btn}>
|
|
30
|
+
Say Hello
|
|
53
31
|
</button>
|
|
54
32
|
</div>
|
|
55
|
-
|
|
56
|
-
<
|
|
33
|
+
|
|
34
|
+
{data.greeting && <p style={S.greeting}>{data.greeting}</p>}
|
|
35
|
+
|
|
36
|
+
<div style={S.footer}>
|
|
37
|
+
<LxNavigator url="https://www.lingxia.app" style={S.link}>
|
|
38
|
+
Documentation →
|
|
39
|
+
</LxNavigator>
|
|
40
|
+
</div>
|
|
57
41
|
</div>
|
|
58
42
|
</div>
|
|
59
43
|
);
|
|
60
44
|
}
|
|
45
|
+
|
|
46
|
+
const S: Record<string, React.CSSProperties> = {
|
|
47
|
+
page: {
|
|
48
|
+
minHeight: '100vh',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
padding: 20,
|
|
53
|
+
},
|
|
54
|
+
card: {
|
|
55
|
+
width: '100%',
|
|
56
|
+
maxWidth: 360,
|
|
57
|
+
padding: 32,
|
|
58
|
+
background: '#fff',
|
|
59
|
+
borderRadius: 20,
|
|
60
|
+
boxShadow: '0 4px 24px rgba(0,0,0,0.08)',
|
|
61
|
+
textAlign: 'center',
|
|
62
|
+
},
|
|
63
|
+
logo: {
|
|
64
|
+
width: 72,
|
|
65
|
+
height: 72,
|
|
66
|
+
borderRadius: 16,
|
|
67
|
+
boxShadow: '0 2px 12px rgba(0,0,0,0.1)',
|
|
68
|
+
},
|
|
69
|
+
title: {
|
|
70
|
+
margin: '20px 0 6px',
|
|
71
|
+
fontSize: 26,
|
|
72
|
+
fontWeight: 700,
|
|
73
|
+
color: '#1d1d1f',
|
|
74
|
+
},
|
|
75
|
+
subtitle: {
|
|
76
|
+
margin: 0,
|
|
77
|
+
fontSize: 15,
|
|
78
|
+
color: '#86868b',
|
|
79
|
+
},
|
|
80
|
+
form: {
|
|
81
|
+
display: 'flex',
|
|
82
|
+
flexDirection: 'column',
|
|
83
|
+
gap: 12,
|
|
84
|
+
marginTop: 28,
|
|
85
|
+
},
|
|
86
|
+
input: {
|
|
87
|
+
width: '100%',
|
|
88
|
+
height: 48,
|
|
89
|
+
padding: '0 16px',
|
|
90
|
+
border: '1px solid #d2d2d7',
|
|
91
|
+
borderRadius: 12,
|
|
92
|
+
fontSize: 16,
|
|
93
|
+
outline: 'none',
|
|
94
|
+
background: '#fafafa',
|
|
95
|
+
transition: 'border-color 0.2s',
|
|
96
|
+
},
|
|
97
|
+
btn: {
|
|
98
|
+
width: '100%',
|
|
99
|
+
height: 48,
|
|
100
|
+
border: 'none',
|
|
101
|
+
borderRadius: 12,
|
|
102
|
+
background: '#007aff',
|
|
103
|
+
color: '#fff',
|
|
104
|
+
fontSize: 16,
|
|
105
|
+
fontWeight: 600,
|
|
106
|
+
cursor: 'pointer',
|
|
107
|
+
transition: 'background 0.2s',
|
|
108
|
+
},
|
|
109
|
+
greeting: {
|
|
110
|
+
marginTop: 24,
|
|
111
|
+
padding: 16,
|
|
112
|
+
background: '#f0fdf4',
|
|
113
|
+
border: '1px solid #bbf7d0',
|
|
114
|
+
borderRadius: 12,
|
|
115
|
+
color: '#166534',
|
|
116
|
+
fontSize: 15,
|
|
117
|
+
whiteSpace: 'pre-line',
|
|
118
|
+
textAlign: 'left',
|
|
119
|
+
},
|
|
120
|
+
footer: {
|
|
121
|
+
marginTop: 28,
|
|
122
|
+
paddingTop: 20,
|
|
123
|
+
borderTop: '1px solid #f0f0f0',
|
|
124
|
+
},
|
|
125
|
+
link: {
|
|
126
|
+
color: '#007aff',
|
|
127
|
+
fontSize: 14,
|
|
128
|
+
fontWeight: 500,
|
|
129
|
+
textDecoration: 'none',
|
|
130
|
+
},
|
|
131
|
+
};
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
"isolatedModules": true,
|
|
14
14
|
"noEmit": true,
|
|
15
15
|
"allowSyntheticDefaultImports": true,
|
|
16
|
-
"baseUrl": "."
|
|
16
|
+
"baseUrl": ".",
|
|
17
|
+
"paths": {
|
|
18
|
+
"@lingxia/page-types/*": ["./.lingxia/types/*"]
|
|
19
|
+
}
|
|
17
20
|
},
|
|
18
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
21
|
+
"include": ["**/*.ts", "**/*.tsx", ".lingxia/types/**/*.d.ts"],
|
|
19
22
|
"exclude": ["node_modules", "dist"]
|
|
20
23
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* Reset */
|
|
2
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
3
|
+
html, body { width: 100%; min-height: 100%; }
|
|
4
|
+
body {
|
|
5
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
background: #f5f5f7;
|
|
8
|
+
color: #1d1d1f;
|
|
9
|
+
/* Disable text selection by default (like native apps) */
|
|
10
|
+
-webkit-user-select: none;
|
|
11
|
+
user-select: none;
|
|
12
|
+
-webkit-touch-callout: none;
|
|
13
|
+
}
|
|
14
|
+
#app { min-height: 100%; }
|
|
15
|
+
input, button { font: inherit; }
|
|
16
|
+
button:disabled { opacity: 0.5; }
|
|
17
|
+
|
|
18
|
+
/* Enable text selection for specific elements */
|
|
19
|
+
[selectable], .selectable { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
|
|
20
|
+
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; }
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
Page({
|
|
2
2
|
data: {
|
|
3
|
-
greeting: '
|
|
3
|
+
greeting: '',
|
|
4
4
|
greetCount: 0
|
|
5
5
|
},
|
|
6
6
|
|
|
7
|
-
greet(
|
|
7
|
+
greet: function(payload: { name: string }) {
|
|
8
8
|
const count = this.data.greetCount + 1;
|
|
9
|
+
const time = new Date().toLocaleTimeString('en-US', {
|
|
10
|
+
hour: '2-digit',
|
|
11
|
+
minute: '2-digit',
|
|
12
|
+
second: '2-digit'
|
|
13
|
+
});
|
|
9
14
|
this.setData({
|
|
10
15
|
greetCount: count,
|
|
11
|
-
greeting:
|
|
16
|
+
greeting: 'Hello, ' + payload.name + '! 👋\nGreeting #' + count + ' at ' + time
|
|
12
17
|
});
|
|
13
18
|
}
|
|
14
19
|
});
|
|
@@ -1,48 +1,135 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import
|
|
2
|
+
import '../../app.css';
|
|
3
|
+
import { LxNavigator } from '@lingxia/components/vue';
|
|
4
|
+
import { computed, ref } from 'vue';
|
|
3
5
|
|
|
4
6
|
const { data, greet } = useLingXia();
|
|
5
|
-
const state = computed(() => data ?? { greeting: '', greetCount: 0 });
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const state = computed(() => data.value ?? { greeting: '', greetCount: 0 });
|
|
8
|
+
const inputName = ref('');
|
|
9
|
+
const canSubmit = computed(() => inputName.value.trim().length > 0);
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
()
|
|
12
|
-
if (pending.value) {
|
|
13
|
-
pending.value = false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
function submit() {
|
|
19
|
-
const value = name.value.trim();
|
|
20
|
-
if (!value) return;
|
|
21
|
-
pending.value = true;
|
|
22
|
-
greet({ name: value });
|
|
11
|
+
function handleSubmit() {
|
|
12
|
+
const v = inputName.value.trim();
|
|
13
|
+
if (v) greet({ name: v });
|
|
23
14
|
}
|
|
24
15
|
</script>
|
|
25
16
|
|
|
26
17
|
<template>
|
|
27
|
-
<div class="
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
<h1>Hello
|
|
31
|
-
<p class="
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
18
|
+
<div class="page">
|
|
19
|
+
<div class="card">
|
|
20
|
+
<img :src="'/public/AppIcon.png'" class="logo" />
|
|
21
|
+
<h1 class="title">Hello, LingXia</h1>
|
|
22
|
+
<p class="subtitle">Build once, run everywhere</p>
|
|
23
|
+
|
|
24
|
+
<div class="form">
|
|
25
|
+
<input v-model="inputName" placeholder="Enter your name" class="input" @keydown.enter.prevent="handleSubmit" />
|
|
26
|
+
<button :disabled="!canSubmit" class="btn" @click="handleSubmit">Say Hello</button>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<p v-if="state.greeting" class="greeting">{{ state.greeting }}</p>
|
|
30
|
+
|
|
31
|
+
<div class="footer">
|
|
32
|
+
<LxNavigator url="https://www.lingxia.app" class="link">
|
|
33
|
+
Documentation →
|
|
34
|
+
</LxNavigator>
|
|
43
35
|
</div>
|
|
44
|
-
|
|
45
|
-
<div class="meta">Invoked {{ state.greetCount }} times</div>
|
|
46
|
-
</section>
|
|
36
|
+
</div>
|
|
47
37
|
</div>
|
|
48
38
|
</template>
|
|
39
|
+
|
|
40
|
+
<style scoped>
|
|
41
|
+
.page {
|
|
42
|
+
min-height: 100vh;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
padding: 20px;
|
|
47
|
+
}
|
|
48
|
+
.card {
|
|
49
|
+
width: 100%;
|
|
50
|
+
max-width: 360px;
|
|
51
|
+
padding: 32px;
|
|
52
|
+
background: #fff;
|
|
53
|
+
border-radius: 20px;
|
|
54
|
+
box-shadow: 0 4px 24px rgba(0,0,0,0.08);
|
|
55
|
+
text-align: center;
|
|
56
|
+
}
|
|
57
|
+
.logo {
|
|
58
|
+
width: 72px;
|
|
59
|
+
height: 72px;
|
|
60
|
+
border-radius: 16px;
|
|
61
|
+
box-shadow: 0 2px 12px rgba(0,0,0,0.1);
|
|
62
|
+
}
|
|
63
|
+
.title {
|
|
64
|
+
margin: 20px 0 6px;
|
|
65
|
+
font-size: 26px;
|
|
66
|
+
font-weight: 700;
|
|
67
|
+
color: #1d1d1f;
|
|
68
|
+
}
|
|
69
|
+
.subtitle {
|
|
70
|
+
margin: 0;
|
|
71
|
+
font-size: 15px;
|
|
72
|
+
color: #86868b;
|
|
73
|
+
}
|
|
74
|
+
.form {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
gap: 12px;
|
|
78
|
+
margin-top: 28px;
|
|
79
|
+
}
|
|
80
|
+
.input {
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 48px;
|
|
83
|
+
padding: 0 16px;
|
|
84
|
+
border: 1px solid #d2d2d7;
|
|
85
|
+
border-radius: 12px;
|
|
86
|
+
font-size: 16px;
|
|
87
|
+
outline: none;
|
|
88
|
+
background: #fafafa;
|
|
89
|
+
transition: border-color 0.2s;
|
|
90
|
+
}
|
|
91
|
+
.input:focus {
|
|
92
|
+
border-color: #007aff;
|
|
93
|
+
}
|
|
94
|
+
.btn {
|
|
95
|
+
width: 100%;
|
|
96
|
+
height: 48px;
|
|
97
|
+
border: none;
|
|
98
|
+
border-radius: 12px;
|
|
99
|
+
background: #007aff;
|
|
100
|
+
color: #fff;
|
|
101
|
+
font-size: 16px;
|
|
102
|
+
font-weight: 600;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
transition: background 0.2s;
|
|
105
|
+
}
|
|
106
|
+
.btn:hover:not(:disabled) {
|
|
107
|
+
background: #0066d6;
|
|
108
|
+
}
|
|
109
|
+
.btn:disabled {
|
|
110
|
+
opacity: 0.5;
|
|
111
|
+
cursor: not-allowed;
|
|
112
|
+
}
|
|
113
|
+
.greeting {
|
|
114
|
+
margin-top: 24px;
|
|
115
|
+
padding: 16px;
|
|
116
|
+
background: #f0fdf4;
|
|
117
|
+
border: 1px solid #bbf7d0;
|
|
118
|
+
border-radius: 12px;
|
|
119
|
+
color: #166534;
|
|
120
|
+
font-size: 15px;
|
|
121
|
+
white-space: pre-line;
|
|
122
|
+
text-align: left;
|
|
123
|
+
}
|
|
124
|
+
.footer {
|
|
125
|
+
margin-top: 28px;
|
|
126
|
+
padding-top: 20px;
|
|
127
|
+
border-top: 1px solid #f0f0f0;
|
|
128
|
+
}
|
|
129
|
+
.link {
|
|
130
|
+
color: #007aff;
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
font-weight: 500;
|
|
133
|
+
text-decoration: none;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
"isolatedModules": true,
|
|
14
14
|
"noEmit": true,
|
|
15
15
|
"allowSyntheticDefaultImports": true,
|
|
16
|
-
"baseUrl": "."
|
|
16
|
+
"baseUrl": ".",
|
|
17
|
+
"paths": {
|
|
18
|
+
"@lingxia/page-types/*": ["./.lingxia/types/*"]
|
|
19
|
+
}
|
|
17
20
|
},
|
|
18
|
-
"include": ["**/*.ts", "**/*.tsx", "**/*.vue"],
|
|
21
|
+
"include": ["**/*.ts", "**/*.tsx", "**/*.vue", ".lingxia/types/**/*.d.ts"],
|
|
19
22
|
"exclude": ["node_modules", "dist"]
|
|
20
23
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
|
6
|
+
<string>en</string>
|
|
7
|
+
<key>CFBundleExecutable</key>
|
|
8
|
+
<string>{{SWIFT_TARGET_NAME}}</string>
|
|
9
|
+
<key>CFBundleIconName</key>
|
|
10
|
+
<string>AppIcon</string>
|
|
11
|
+
<key>CFBundleIdentifier</key>
|
|
12
|
+
<string>{{PACKAGE_ID}}</string>
|
|
13
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
|
14
|
+
<string>6.0</string>
|
|
15
|
+
<key>CFBundleName</key>
|
|
16
|
+
<string>{{PRODUCT_NAME}}</string>
|
|
17
|
+
<key>CFBundleDisplayName</key>
|
|
18
|
+
<string>{{PRODUCT_NAME}}</string>
|
|
19
|
+
<key>CFBundlePackageType</key>
|
|
20
|
+
<string>APPL</string>
|
|
21
|
+
<key>CFBundleShortVersionString</key>
|
|
22
|
+
<string>1.0</string>
|
|
23
|
+
<key>CFBundleVersion</key>
|
|
24
|
+
<string>1</string>
|
|
25
|
+
<key>LSMinimumSystemVersion</key>
|
|
26
|
+
<string>11.0</string>
|
|
27
|
+
<key>NSHumanReadableCopyright</key>
|
|
28
|
+
<string>Copyright © 2024 LingXia. All rights reserved.</string>
|
|
29
|
+
<key>NSMainStoryboardFile</key>
|
|
30
|
+
<string>Main</string>
|
|
31
|
+
<key>NSPrincipalClass</key>
|
|
32
|
+
<string>NSApplication</string>
|
|
33
|
+
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
|
34
|
+
<true/>
|
|
35
|
+
<key>NSHighResolutionCapable</key>
|
|
36
|
+
<true/>
|
|
37
|
+
<key>LSApplicationCategoryType</key>
|
|
38
|
+
<string>public.app-category.productivity</string>
|
|
39
|
+
</dict>
|
|
40
|
+
</plist>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "{{PROJECT_NAME}}",
|
|
6
|
+
platforms: [
|
|
7
|
+
.macOS(.v12)
|
|
8
|
+
],
|
|
9
|
+
products: [
|
|
10
|
+
.executable(
|
|
11
|
+
name: "{{SWIFT_TARGET_NAME}}",
|
|
12
|
+
targets: ["{{SWIFT_TARGET_NAME}}"]
|
|
13
|
+
),
|
|
14
|
+
],
|
|
15
|
+
dependencies: [
|
|
16
|
+
.package(name: "lingxia", path: "../target/spm/lingxia"),
|
|
17
|
+
],
|
|
18
|
+
targets: [
|
|
19
|
+
.executableTarget(
|
|
20
|
+
name: "{{SWIFT_TARGET_NAME}}",
|
|
21
|
+
dependencies: [
|
|
22
|
+
"lingxia",
|
|
23
|
+
],
|
|
24
|
+
path: "Sources",
|
|
25
|
+
resources: [
|
|
26
|
+
.copy("Resources")
|
|
27
|
+
]
|
|
28
|
+
),
|
|
29
|
+
]
|
|
30
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import AppKit
|
|
2
|
+
import lingxia
|
|
3
|
+
|
|
4
|
+
class LingXiaAppDelegate: NSObject, NSApplicationDelegate {
|
|
5
|
+
|
|
6
|
+
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
7
|
+
// Enable WebView debugging BEFORE LxApp.initialize()
|
|
8
|
+
// This ensures debugging is enabled before the first WebView is created
|
|
9
|
+
LxApp.enableWebViewDebugging()
|
|
10
|
+
|
|
11
|
+
LxApp.initialize()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
|
15
|
+
return true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Entry point
|
|
20
|
+
let app = NSApplication.shared
|
|
21
|
+
let delegate = LingXiaAppDelegate()
|
|
22
|
+
app.delegate = delegate
|
|
23
|
+
app.run()
|