您的位置:首页 > 游戏 > 游戏 > 网络技术服务包括哪些范围_工程项目管理软件哪个好_南宁最新消息今天_百度问一问客服人工在线咨询

网络技术服务包括哪些范围_工程项目管理软件哪个好_南宁最新消息今天_百度问一问客服人工在线咨询

2025/4/26 15:00:28 来源:https://blog.csdn.net/sonichty/article/details/147481664  浏览:    关键词:网络技术服务包括哪些范围_工程项目管理软件哪个好_南宁最新消息今天_百度问一问客服人工在线咨询
网络技术服务包括哪些范围_工程项目管理软件哪个好_南宁最新消息今天_百度问一问客服人工在线咨询

 Getting Started | GNOME JavaScript

1.扩展路径

~/.local/share/gnome-shell/extensions/

2.新建文件夹

datetime@sonichy

3.metadata.json

{"uuid": "datetime@sonichy","name": "datetime","description": "Display date and time on GNOME taskbar","author": "sonichy","version": "1.0","shell-version": [ "45", "46", "47", "48" ],"url": "https://github.com/sonichy/Cinnamon_Applet"
}

4.extension.js

import GLib from "gi://GLib";
import St from 'gi://St';import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';export default class DatetimeExtension extends Extension {enable() {// Create a panel buttonthis._indicator = new PanelMenu.Button(0.0, this.metadata.name, false);var label = new St.Label({ text: '00:00\n1/1 一' });label.set_style('text-align:center');        this._indicator.add_child(label);        // Add the indicator to the panelMain.panel.addToStatusArea(this.uuid, this._indicator);const menuItem = new PopupMenu.PopupMenuItem('');this._indicator.menu.addMenuItem(menuItem);this._timeout = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 1, () => {var date = new Date();var h = date.getHours();if (h < 10)h = "0" + h;var m = date.getMinutes();if (m < 10)m = "0" + m;var day = date.getDay();var weekday = ["日", "一", "二", "三", "四", "五", "六"];var weekday1 = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];const text = h + ' : ' + m + '\n' + (date.getMonth() + 1) + '/' + date.getDate() + ' ' + weekday[day];            label.set_text(text);menuItem.label.text = date.toLocaleString() + ' ' + weekday1[day];// Run as loop, not once.return GLib.SOURCE_CONTINUE;});}disable() {this._indicator?.destroy();this._indicator = null;if (this._timeout) {GLib.source_remove(this._timeout);this._timeout = null;}}}

5.调试

dbus-run-session -- gnome-shell --nested --wayland

6.重载

注销

7.预览图

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com