Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
- 调整菜单属性(菜单名、图标、路径)的转义,现在只会对`"`、`\`进行转义(加反斜杠)
- 补充几个菜单位置
    选择状态
      - 驱动器
      - 文件夹和驱动器
    背景
      - 桌面背景
- service.php加入对请求数据的验证(必填)、请求的数据格式说明
- 生成的zip命名中包含时间日期,时区调整为PRC(中华人民共和国)
  • Loading branch information
GHJayce committed May 4, 2019
1 parent 967a7e4 commit ca79320
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 332 deletions.
243 changes: 5 additions & 238 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,239 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>生成右键菜单注册文件 - RightClickMenu</title>

<link href="https://cdn.bootcss.com/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/ant-design-vue@1.3.5/dist/antd.css">
<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">

<style>
</style>
</head>
<body class="bg-light">

<div id="app">
<nav class="navbar navbar-expand-md navbar-dark bg-dark sticky-top mb-4">
<div class="container">
<a class="navbar-brand" href="#">RightClickMenu</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="https://github.com/GHBJayce/RightClickMenu" target="_blank">
For Github
</a>
</li>
</ul>
</div>
</div>
</nav>

<main class="container">
<div class="row">
<div class="col-md-7">
<div class="p-3 bg-white rounded shadow-sm">
<h6 class="mb-4">操作台</h6>
<div class="">
<ul id="treeWrap" class="easyui-tree"></ul>
</div>
</div>
</div>
<div class="col-md-5">
<div class="p-3 bg-white rounded shadow-sm">
<h6 class="mb-4">
描述
<a href="https://ghbjayce.github.io/RightClickMenu/" class="pull-right">Online</a>
</h6>
<div class="alert alert-warning" role="alert">
<strong><i class="fa fa-exclamation-triangle"></i> 请在本地服务器环境中使用该程序</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="mb-4">
<div class="mb-2">
<a href="https://github.com/GHBJayce/RightClickMenu" class="text-success" target="_blank">
<i class="fa fa-github"></i> GHBJayce/RightClickMenu
</a>
</div>
<img class="mr-2" src="https://img.shields.io/github/stars/GHBJayce/RightClickMenu.svg" alt="stars">
<img class="mr-2" src="https://img.shields.io/github/forks/GHBJayce/RightClickMenu.svg" alt="forks">
<img src="https://img.shields.io/github/license/GHBJayce/RightClickMenu.svg" alt="license">
</div>
<p>生成右键菜单注册表文件</p>
</div>
</div>
</div>
<h4>

</h4>
<div class="alert alert-info h6" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<p><i class="fa fa-info-circle" style="font-size: 20px;"></i> 直接点击生成按钮,能够得到一个右键菜单的小功能。</p>
<p>右键<strong>选中文件或文件夹</strong>能够复制选中目标的路径,可以放心下载到本地环境中导入使用。</p>
</div>
<br>
<form class="form-horizontal">
<div class="form-group">
<label for="itemName" class="col-sm-2 control-label">注册表名</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="itemName" placeholder="在注册表显示的注册名称" value="CopyPath">
</div>
</div>
<div class="form-group">
<label for="showName" class="col-sm-2 control-label">右键菜单名</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="showName" placeholder="右键菜单显示的名称" value="复制目标路径">
</div>
</div>
<div class="form-group">
<label for="path" class="col-sm-2 control-label">程序路径</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="path" placeholder="程序路径" value="mshta vbscript:clipboarddata.setdata(&#34;text&#34;,&#34;%1&#34;)(close)">
<!-- <input type="file" id="path" placeholder="程序路径"> -->
</div>
</div>
<div class="form-group">
<label for="icon" class="col-sm-2 control-label">图标</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="icon" placeholder="显示的图标,留空表示使用程序默认的图标" value="%SYSTEMROOT%\explorer.exe">
<!-- <input type="file" id="icon" placeholder="显示的图标"> -->
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">右键菜单</label>
<div class="col-sm-10">
<label class="checkbox-inline">
<input type="checkbox" name="option" id="inlineCheckbox1" value="1"> 目录背景
</label>
<label class="checkbox-inline">
<input type="checkbox" name="option" id="inlineCheckbox2" value="2" checked> 选中文件夹
</label>
<label class="checkbox-inline">
<input type="checkbox" name="option" id="inlineCheckbox3" value="3" checked> 所有选中文件
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><b>目录背景</b> <br><code>shift</code>键出现</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="backgroundExtended" value="">
</label>
<label class="radio-inline">
<input type="radio" name="backgroundExtended" value="no" checked>
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><b>选中文件夹</b> <br><code>shift</code>键出现</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="selectedDirectory" value="">
</label>
<label class="radio-inline">
<input type="radio" name="selectedDirectory" value="no" checked>
</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"><b>所有选中文件</b> <br><code>shift</code>键出现</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" name="selectedAll" value="">
</label>
<label class="radio-inline">
<input type="radio" name="selectedAll" value="no" checked>
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" id="generateBtn" class="btn btn-primary col-xs-4">生成</button>
</div>
</div>
</form>
<div class="col-sm-12" id="downloadWrap" style="display: none;">
<div>
<a href="register_table_file.zip" download=""><button class="btn btn-success">下载文件</button></a>
</div>
<div class="col-sm-6">
<h5>创建注册表</h5>
<pre id="createRegText"></pre>
</div>
<div class="col-sm-6">
<h5>删除注册表</h5>
<pre id="removeRegText"></pre>
</div>
</div>
</main>

<footer class="footer mb-4">
<div class="container clearfix">
<span class="text-muted align-middle pull-right">author by <a href="https://github.com/GHBJayce" target="_blank">GHBJayce</a>.</span>
</div>
</footer>
</div>

<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/j-weapons/dist/j-weapons.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.6.8/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-vue@2.0.0-rc.14/dist/bootstrap-vue.common.min.js"></script>
<script src="https://cdn.bootcss.com/element-ui/2.6.1/index.js"></script>
<!--<script src="https://unpkg.com/ant-design-vue@1.3.5/dist/antd.js"></script>-->
<script>
$(function () {
var app = new Vue({
el: '#app',
data: {
collapsed: false,
},
created: function () {

},
methods: {

},
});
});
$('#generateBtn').on('click', function (){
var options = [];
var extended = {
1: $('[name="backgroundExtended"]:checked').val(),
2: $('[name="selectedDirectory"]:checked').val(),
3: $('[name="selectedAll"]:checked').val()
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>right-click-menu-front</title><link rel=stylesheet href=https://cdn.bootcss.com/font-awesome/5.8.1/css/all.min.css integrity=sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf crossorigin=anonymous><link rel=stylesheet href=https://cdn.bootcss.com/element-ui/2.6.1/theme-chalk/index.css><link rel=stylesheet href=https://cdn.bootcss.com/twitter-bootstrap/4.3.1/css/bootstrap.min.css><link rel=stylesheet href=https://unpkg.com/bootstrap-vue@2.0.0-rc.19/dist/bootstrap-vue.min.css><link rel=stylesheet href=https://unpkg.com/ant-design-vue@1.3.8/dist/antd.min.css><style>label {
margin-bottom: initial
}

$("input[name='option']:checked").each(function(i) {
options[i] = $(this).val();
});

$.ajax({
url: './php/index.php',
type: 'post',
data: {
item_name: $('#itemName').val(),
show_name: $('#showName').val(),
path: $('#path').val(),
icon: $('#icon').val(),
extended: JSON.stringify(extended),
options: JSON.stringify(options)
},
success: function (res){
$('#downloadWrap').show();
res = JSON.parse(res);
$('#createRegText').text(res.create_reg_text);
$('#removeRegText').text(res.remove_reg_text);
}
});
return false;
});
</script>
</body>
</html>
.anticon svg {
vertical-align: initial
}</style><link href=./static/css/app.css rel=stylesheet></head><body class=bg-light><div id=app></div><script src=https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js></script><script src=https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js></script><script src=https://unpkg.com/j-weapons/dist/j-weapons.min.js></script><script src=https://cdn.bootcss.com/vue/2.6.8/vue.min.js></script><script src=https://cdn.bootcss.com/vue-router/3.0.2/vue-router.min.js></script><script src=https://cdn.bootcss.com/element-ui/2.6.1/index.js></script><script src=https://unpkg.com/bootstrap-vue@2.0.0-rc.19/dist/bootstrap-vue.min.js></script><script src=https://unpkg.com/ant-design-vue@1.3.8/dist/antd.min.js></script><script src=https://cdn.bootcss.com/clipboard.js/2.0.4/clipboard.min.js></script><script type=text/javascript src=./static/js/manifest.js></script><script type=text/javascript src=./static/js/vendor.js></script><script type=text/javascript src=./static/js/app.js></script></body></html>
18 changes: 11 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# 生成Windows右键菜单的注册文件

一个小工具,可以将windows程序设置在鼠标的右键菜单上。
右键菜单生成器v2.0!可以将windows程序设置在鼠标的右键菜单上,支持层级菜单

这个工具能够生成右键菜单的注册表文件(含`创建``移除`两个文件)。
主要生成右键菜单的注册表文件(含`创建``移除`两个文件)。

> 工具更好的实现方式应该是直接和windows / apple等进行交互,减少用户的操作
> 这个应用是拿来练习PHP设计模式的实例,为了更好地理解设计模式。
> 这个小工具是拿来练习PHP设计模式的实例,为了更好地理解设计模式。
> 用到的设计模式:依赖注入 + 组合模式 + 桥梁模式 + 门面模式 + 原型模式
> 更好的实现方式应该是直接与操作系统进行交互,减少用户的麻烦,更直接的操作右键菜单。
## 运行环境

PHP >= 5.4
PHP >= 5.4 需要本地搭建环境

另外的运行方式 [集成PHP环境的浏览器](https://github.com/cztomczak/phpdesktop/releases/tag/chrome-v57.0-rc)

## 使用
## 演示

![如何选择](https://raw.githubusercontent.com/GHBJayce/RightClickMenu/master/use_demo.gif)
![应用使用演示](https://raw.githubusercontent.com/GHBJayce/Assets/master/RightClickMenu/demo_v2.0.0.gif)

## 线上界面

Expand Down
42 changes: 40 additions & 2 deletions service/common/funs.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function dump()
}


function repairZero($number)
function repair_zero($number)
{
return $number > 10 ? $number : '0'.$number;
}
Expand All @@ -42,11 +42,49 @@ function repairZero($number)
* @param string $children_key
* @return array
*/
function toTree(array $arr, $res = [], $pid_key = 'pid', $children_key = 'children')
function to_tree(array $arr, $res = [], $pid_key = 'pid', $children_key = 'children')
{
foreach ($arr as $k => $v) {
isset($arr[$v[$pid_key]]) ? $arr[$v[$pid_key]][$children_key][] = &$arr[$k] : $res[] = &$arr[$k];
}

return $res;
}

/**
* 异步请求响应
*
* @param string $status
* @param array $data
* @param string $msg
* @return string
*/
function response($status, $data = [], $msg = '')
{
echo json_encode([
'status' => $status,
'data' => $data,
'message' => $msg,
], 256);die;
}

/**
* 提示错误的响应
*
* @param string $msg
*/
function response_error($msg)
{
response('error', [], $msg);
}

/**
* 提示成功的响应
*
* @param array $data
* @param string $msg
*/
function response_success(array $data = [], $msg = '')
{
response('success', $data, $msg);
}
Loading

0 comments on commit ca79320

Please sign in to comment.