mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-18 17:01:31 +00:00
Merge pull request #10659 from jumpserver/pr@dev@perf_applet
perf: 添加 edition 字段
This commit is contained in:
commit
f372f1e417
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:a93b6a850b251ea2ee17b6b9dbdee93130f745ce8278faaecbf60d74f934f1b5
|
oid sha256:7db1805061d28a0ba931846140e9f106b71ed5ebeb414f741b68d6c3d93130be
|
||||||
size 143780
|
size 142961
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:f236155485cdb4b453ff317d3c932ef4455d29e856ef3c2902a349d430992404
|
oid sha256:4a22b436e9707729e51614e9942bb9715084ddf613152fa35be7a092a77daca7
|
||||||
size 117637
|
size 117063
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,31 @@
|
|||||||
// content_script.js
|
// content_script.js
|
||||||
|
|
||||||
|
// 创建一个 Mutation Observer 实例
|
||||||
|
const observer = new MutationObserver(function (mutationsList) {
|
||||||
|
// 遍历每个发生变化的 mutation
|
||||||
|
for (let mutation of mutationsList) {
|
||||||
|
// 检查是否有节点添加
|
||||||
|
if (mutation.type === 'childList') {
|
||||||
// 获取所有的 <a> 标签元素
|
// 获取所有的 <a> 标签元素
|
||||||
const links = document.getElementsByTagName('a');
|
const links = document.getElementsByTagName('a');
|
||||||
|
|
||||||
// 遍历 <a> 标签元素并修改链接属性
|
// 遍历 <a> 标签元素并修改链接属性
|
||||||
|
console.log("开始替换标签")
|
||||||
for (let i = 0; i < links.length; i++) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
links[i].target = '_self'; // 将 target 属性设置为 _self,当前窗口打开
|
links[i].target = '_self'; // 将 target 属性设置为 _self,当前窗口打开
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 停止监听,已经完成替换操作
|
||||||
|
observer.disconnect();
|
||||||
|
|
||||||
|
// 退出循环,不再处理后续的 mutations
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 开始观察 document.body 的子节点变化
|
||||||
|
observer.observe(document.body, {childList: true, subtree: true});
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(
|
chrome.runtime.onMessage.addListener(
|
||||||
function (request, sender, sendResponse) {
|
function (request, sender, sendResponse) {
|
||||||
@ -18,7 +36,7 @@ chrome.runtime.onMessage.addListener(
|
|||||||
)
|
)
|
||||||
|
|
||||||
document.addEventListener("contextmenu", function (event) {
|
document.addEventListener("contextmenu", function (event) {
|
||||||
console.log('On contextmenu event')
|
console.log('On context')
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,6 +49,21 @@ window.addEventListener("keydown", function (e) {
|
|||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
// 保存原始的 window.open 函数引用
|
||||||
|
var originalOpen = window.open;
|
||||||
|
|
||||||
|
// 修改 window.open 函数
|
||||||
|
window.open = function (url, target, features) {
|
||||||
|
// 将 target 强制设置为 "_self",使得新页面在当前标签页中打开
|
||||||
|
target = "_self";
|
||||||
|
|
||||||
|
// 修改当前页面的 URL
|
||||||
|
location.href = url;
|
||||||
|
|
||||||
|
// 调用原始的 window.open 函数
|
||||||
|
return originalOpen.call(this, url, target, features);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
chrome.runtime.sendMessage({greeting: "hello"}, function (response) {
|
chrome.runtime.sendMessage({greeting: "hello"}, function (response) {
|
||||||
});
|
});
|
||||||
|
18
apps/terminal/migrations/0062_applet_edition.py
Normal file
18
apps/terminal/migrations/0062_applet_edition.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 3.2.17 on 2023-06-09 02:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('terminal', '0061_applet_can_concurrent'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='applet',
|
||||||
|
name='edition',
|
||||||
|
field=models.CharField(default='community', max_length=128, verbose_name='Edition'),
|
||||||
|
),
|
||||||
|
]
|
@ -25,10 +25,16 @@ class Applet(JMSBaseModel):
|
|||||||
general = 'general', _('General')
|
general = 'general', _('General')
|
||||||
web = 'web', _('Web')
|
web = 'web', _('Web')
|
||||||
|
|
||||||
|
class Edition(models.TextChoices):
|
||||||
|
community = 'community', _('Community')
|
||||||
|
enterprise = 'enterprise', _('Enterprise')
|
||||||
|
|
||||||
name = models.SlugField(max_length=128, verbose_name=_('Name'), unique=True)
|
name = models.SlugField(max_length=128, verbose_name=_('Name'), unique=True)
|
||||||
display_name = models.CharField(max_length=128, verbose_name=_('Display name'))
|
display_name = models.CharField(max_length=128, verbose_name=_('Display name'))
|
||||||
version = models.CharField(max_length=16, verbose_name=_('Version'))
|
version = models.CharField(max_length=16, verbose_name=_('Version'))
|
||||||
author = models.CharField(max_length=128, verbose_name=_('Author'))
|
author = models.CharField(max_length=128, verbose_name=_('Author'))
|
||||||
|
edition = models.CharField(max_length=128, choices=Edition.choices, default=Edition.community,
|
||||||
|
verbose_name=_('Edition'))
|
||||||
type = models.CharField(max_length=16, verbose_name=_('Type'), default='general', choices=Type.choices)
|
type = models.CharField(max_length=16, verbose_name=_('Type'), default='general', choices=Type.choices)
|
||||||
is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
|
is_active = models.BooleanField(default=True, verbose_name=_('Is active'))
|
||||||
builtin = models.BooleanField(default=False, verbose_name=_('Builtin'))
|
builtin = models.BooleanField(default=False, verbose_name=_('Builtin'))
|
||||||
|
@ -27,6 +27,7 @@ class AppletPublicationSerializer(serializers.ModelSerializer):
|
|||||||
class AppletSerializer(serializers.ModelSerializer):
|
class AppletSerializer(serializers.ModelSerializer):
|
||||||
icon = serializers.ReadOnlyField(label=_("Icon"))
|
icon = serializers.ReadOnlyField(label=_("Icon"))
|
||||||
type = LabeledChoiceField(choices=Applet.Type.choices, label=_("Type"))
|
type = LabeledChoiceField(choices=Applet.Type.choices, label=_("Type"))
|
||||||
|
edition = LabeledChoiceField(choices=Applet.Edition.choices, label=_("Edition"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Applet
|
model = Applet
|
||||||
@ -35,6 +36,6 @@ class AppletSerializer(serializers.ModelSerializer):
|
|||||||
'icon', 'readme', 'date_created', 'date_updated',
|
'icon', 'readme', 'date_created', 'date_updated',
|
||||||
]
|
]
|
||||||
fields = fields_mini + [
|
fields = fields_mini + [
|
||||||
'version', 'author', 'type', 'protocols',
|
'version', 'author', 'type', 'edition',
|
||||||
'tags', 'comment'
|
'can_concurrent', 'protocols', 'tags', 'comment',
|
||||||
] + read_only_fields
|
] + read_only_fields
|
||||||
|
Loading…
Reference in New Issue
Block a user