Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
[submodule "vendor/grammars/Alloy.tmbundle"]
path = vendor/grammars/Alloy.tmbundle
url = https://github.com/macekond/Alloy.tmbundle
[submodule "vendor/grammars/ArkTS"]
path = vendor/grammars/ArkTS
url = https://github.com/ohosvscode/arkTS
[submodule "vendor/grammars/Assembly-Syntax-Definition"]
path = vendor/grammars/Assembly-Syntax-Definition
url = https://github.com/calculuswhiz/Assembly-Syntax-Definition
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ vendor/grammars/AL:
- source.al
vendor/grammars/Alloy.tmbundle:
- source.alloy
vendor/grammars/ArkTS:
- source.ets
vendor/grammars/Assembly-Syntax-Definition:
- source.x86
vendor/grammars/Atom-PostScript:
Expand Down
10 changes: 10 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,16 @@ Arc:
tm_scope: none
ace_mode: text
language_id: 20
ArkTS:
type: programming
color: "#0080ff"
extensions:
- ".ets"
tm_scope: source.ets
ace_mode: typescript
codemirror_mode: javascript
codemirror_mime_type: application/typescript
language_id: 56341321
AsciiDoc:
type: prose
color: "#73a0c5"
Expand Down
44 changes: 44 additions & 0 deletions samples/ArkTS/EntryAbility.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';

const DOMAIN = 0x0000;

export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}

onDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}

onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');

windowStage.loadContent('pages/Index', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
}

onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}

onForeground(): void {
// Ability has brought to foreground
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
}

onBackground(): void {
// Ability has back to background
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
}
}
16 changes: 16 additions & 0 deletions samples/ArkTS/EntryBackupAbility.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';

const DOMAIN = 0x0000;

export default class EntryBackupAbility extends BackupExtensionAbility {
async onBackup() {
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
await Promise.resolve();
}

async onRestore(bundleVersion: BundleVersion) {
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
await Promise.resolve();
}
}
191 changes: 191 additions & 0 deletions samples/ArkTS/Index.ets
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
import { hilog } from '@kit.PerformanceAnalysisKit'

@Entry
@Component
struct Index {
@State currentTime: string = ''
@State isConnected: boolean = false
@State systemInfo: SystemInfo | null = null

aboutToAppear() {
this.updateTime()
this.checkNetworkStatus()
this.getSystemInfo()

setInterval(() => {
this.updateTime()
}, 1000)
}

build() {
Column() {
// 顶部状态栏
this.buildStatusBar()

// 主要内容区域
this.buildMainContent()

// 底部操作区域
this.buildActionArea()
}
.width('100%')
.height('100%')
.backgroundColor('#F5F5F5')
.padding(16)
}

@Builder
buildStatusBar() {
Row() {
Text('My App')
.fontSize(18)
.fontWeight(FontWeight.Bold)
.fontColor('#333333')

Blank()

Row() {
Image("icon.png")
.width(16)
.height(16)
.fillColor(this.isConnected ? '#00C851' : '#FF4444')

Text(this.isConnected ? 'Connected' : 'Disconnected')
.fontSize(12)
.fontColor(this.isConnected ? '#00C851' : '#FF4444')
.margin({ left: 4 })
}
}
.width('100%')
.padding({ bottom: 16 })
}

@Builder
buildMainContent() {
Column() {
// 时间显示
Text(this.currentTime)
.fontSize(32)
.fontWeight(FontWeight.Bold)
.fontColor('#007AFF')
.margin({ bottom: 24 })

// 系统信息卡片
if (this.systemInfo) {
this.buildSystemInfoCard()
}

// 功能按钮区域
this.buildFeatureButtons()
}
.width('100%')
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
}

@Builder
buildSystemInfoCard() {
Column() {
Text('System information')
.fontSize(16)
.fontWeight(FontWeight.Medium)
.margin({ bottom: 12 })

Row() {
Text('Device model:')
.fontSize(14)
.fontColor('#666666')

Text(this.systemInfo?.deviceModel || 'Unknown')
.fontSize(14)
.fontColor('#333333')
.margin({ left: 8 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
.margin({ bottom: 8 })

Row() {
Text('System version:')
.fontSize(14)
.fontColor('#666666')

Text(this.systemInfo?.osVersion || 'Unknown')
.fontSize(14)
.fontColor('#333333')
.margin({ left: 8 })
}
.width('100%')
.justifyContent(FlexAlign.SpaceBetween)
}
.width('100%')
.backgroundColor(Color.White)
.borderRadius(12)
.padding(16)
.margin({ bottom: 24 })
}

@Builder
buildFeatureButtons() {
Row() {
Button('Refresh status')
.onClick(() => {
this.checkNetworkStatus()
this.getSystemInfo()
})
.backgroundColor('#007AFF')
.borderRadius(8)
.layoutWeight(1)
.margin({ right: 8 })

Button('Settings')
.onClick(() => {
hilog.info(0x0000, 'testTag', 'Navigate to settings...')
})
.backgroundColor(Color.Transparent)
.border({ width: 1, color: '#007AFF' })
.borderRadius(8)
.layoutWeight(1)
}
.width('100%')
}

@Builder
buildActionArea() {
Row() {
Text('My footer')
.fontSize(12)
.fontColor('#999999')
}
.width('100%')
.justifyContent(FlexAlign.Center)
}

private updateTime() {
const now = new Date()
this.currentTime = now.toLocaleTimeString('zh-CN', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
}

private checkNetworkStatus() {
this.isConnected = Math.random() > 0.3
}

private getSystemInfo() {
this.systemInfo = {
deviceModel: 'HarmonyOS Device',
osVersion: 'HarmonyOS 6.0.0',
apiLevel: 20
}
}
}

interface SystemInfo {
deviceModel: string
osVersion: string
apiLevel: number
}
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Apex:** [forcedotcom/apex-tmLanguage](https://github.com/forcedotcom/apex-tmLanguage)
- **Apollo Guidance Computer:** [Alhadis/language-agc](https://github.com/Alhadis/language-agc)
- **AppleScript:** [textmate/applescript.tmbundle](https://github.com/textmate/applescript.tmbundle)
- **ArkTS:** [ohosvscode/arkTS](https://github.com/ohosvscode/arkTS)
- **AsciiDoc:** [zuckschwerdt/asciidoc.tmbundle](https://github.com/zuckschwerdt/asciidoc.tmbundle)
- **AspectJ:** [pchaigno/sublime-aspectj](https://github.com/pchaigno/sublime-aspectj)
- **Assembly:** [Nessphoro/sublimeassembly](https://github.com/Nessphoro/sublimeassembly)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/ArkTS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Subproject commit 107a21c78819540405549c9e65d9447d313c165a
10 changes: 10 additions & 0 deletions vendor/licenses/git_submodule/ArkTS.dep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: ArkTS
version: 107a21c78819540405549c9e65d9447d313c165a
type: git_submodule
homepage: https://github.com/ohosvscode/arkTS
license: mit
licenses:
- sources: LICENSE
text: "MIT License\n\nCopyright (c) 2025 Naily Zero\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
notices: []