import * as vscode from 'vscode' export function activate(context: vscode.ExtensionContext) { console.log('Congratulations, your extension "jokes" is now active!') let disposable = vscode.commands.registerCommand('extension.saveData', () => { const myData = 'Hello, VSCode!' const storageKey = 'myDataKey' // 获取全局存储的 Memento 对象 const globalState = context.globalState // 存储数据 globalState.update(storageKey, myData).then( () => { vscode.window.showInformationMessage('Data saved!') }, (error) => { console.error('Failed to save data:', error) } ) }) context.subscriptions.push(disposable) disposable = vscode.commands.registerCommand('extension.retrieveData', () => { const storageKey = 'myDataKey' // 获取全局存储的 Memento 对象 const globalState = context.globalState // 检索数据 const myData = globalState.get(storageKey) if (myData) { vscode.window.showInformationMessage(`Retrieved Data: ${myData}`) } else { vscode.window.showInformationMessage('No data found.') } }) context.subscriptions.push(disposable) } export function deactivate() {}