Skip to content

Commit

Permalink
feat: uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
DG-Wangtao committed Jan 26, 2020
1 parent ca52188 commit e2677b4
Show file tree
Hide file tree
Showing 8 changed files with 223 additions and 136 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules
out
build
.DS_Store
.idea
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Convert Timestamp
# Quick Tools

**tools convert to locale datetime string**
**tools for developers**
![screenshots](./assets/imgs/screenshots.jpg)

## Features

* auto convert timestamp to date string
* call out with keyboard shortcut: `OptionOrAlt+space`, like `spotlight` in macOs
* [x] auto convert timestamp to date string
* [x] convert date string to timestamp
* [ ] generate uuid
* [x] call out with keyboard shortcut: `Shift+Command+Space`, like `spotlight` in macOs

## TODO

* [x] automatic starting
* [ ] support ubuntu auto build
* [ ] sign code officially
* [x] auto convert date string to timestamp
* [ ] custom keyboard shortcut
* [ ] more custom actions, like [alfred](https://www.alfredapp.com/)? maybe or not

Expand All @@ -23,7 +23,27 @@
* [electron](https://electronjs.org)
* [electron-builder](https://www.electron.build/)
* [electron-builder-action](https://github.com/marketplace/actions/electron-builder-action)
* [uuid](https://github.com/uuidjs/uuid)

## Resources

* icon downloaded from https://icon-icons.com/


# Quick Tools

**方便开发者的小工具**

## 功能

* [x] 时间戳转为时间字符串
* [x] 时间字符串转为时间戳
* [ ] 生成uuid
* [ ] 快捷键`Shift+Command+Space`呼出

## TODO

* [ ] 目前配置的github CI action没有编译ubuntu版本
* [ ] 做代码签名
* [ ] 自定义快捷键
* [ ] 可能实现类似于一个简单的[alfred](https://www.alfredapp.com/)
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "timestamp-convert",
"version": "1.0.4",
"version": "1.0.5",
"description": "A Electron application convert timestamp to datetime loacle string",
"repository": "github:WaylandWong/timestamp-convert",
"main": "./src/main.js",
Expand All @@ -12,8 +12,8 @@
"distm": "electron-builder -m"
},
"build": {
"productName": "timestamp convert",
"appId": "timestamp-convert",
"productName": "quick tools",
"appId": "quick-tools",
"asar": false,
"directories": {
"output": "build"
Expand Down Expand Up @@ -56,6 +56,7 @@
"homepage": "https://github.com/WaylandWong/timestamp-convert",
"dependencies": {
"auto-launch": "^5.0.5",
"update-electron-app": "^1.5.0"
"update-electron-app": "^1.5.0",
"uuid": "^3.3.3"
}
}
10 changes: 9 additions & 1 deletion src/css/component.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ body {
float: left;
z-index: 10;
width: 5%;
}
}

.input__field__input{
width: 35%;
}

.input__field__output{
width: 55%;
}
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<span class='input'>
<img src='../assets/timestamp.png' class="img input--kaede"/>
<input class='input input__field input__field__input' tabindex="0" type='text' id='input' autofocus='true'
placeholder='timestamp'/>
<input class='input input__field' type='text' id='output'
placeholder='quick action'/>
<input class='input input__field input__field__output' type='text' id='output'
value=''/>
</span>
<script type='text/javascript' src='./script/index.js'></script>
Expand Down
148 changes: 81 additions & 67 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Modules to control application life and create native browser window
const {app, BrowserWindow, globalShortcut, ipcMain} = require('electron');
const path = require('path');
const uuidv1 = require('uuid/v1');
const uuidv4 = require('uuid/v4');

var AutoLaunch = require('auto-launch');
var autoLaunch = new AutoLaunch({
Expand All @@ -16,88 +18,100 @@ let mainWindow;
*
*/
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 60,
webPreferences: {
preload: path.join(__dirname, '/script/preload.js'),
},
frame: false,
darkTheme: true,
transparent: false,
center: true,
resizable: false,
alwaysOnTop: true,
skipTaskbar: false,
icon: path.join(__dirname, '../assets/timestamp.ico'),
});

if (process.platform === 'darwin') {
app.dock.setIcon(path.join(__dirname, '../assets/timestamp.png'));
}

// and load the index.html of the app.
mainWindow.loadFile('./src/index.html');

// Open the DevTools.
// mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});

mainWindow.on('blur', ()=>{
if (mainWindow.isVisible()) {
mainWindow.hide();
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 60,
webPreferences: {
preload: path.join(__dirname, '/script/preload.js'),
},
frame: false,
darkTheme: true,
transparent: false,
center: true,
resizable: false,
alwaysOnTop: true,
skipTaskbar: false,
icon: path.join(__dirname, '../assets/timestamp.ico'),
});

if (process.platform === 'darwin') {
app.dock.setIcon(path.join(__dirname, '../assets/timestamp.png'));
}
});

mainWindow.on('show', ()=>{
mainWindow.webContents.send('show');
});

ipcMain.on('esc', (event, message)=>{
if (mainWindow.isVisible()) {
mainWindow.hide();
}
});
// and load the index.html of the app.
mainWindow.loadFile('./src/index.html');

// Open the DevTools.
// mainWindow.webContents.openDevTools()

// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});

mainWindow.on('blur', () => {
if (mainWindow.isVisible()) {
mainWindow.hide();
}
});

mainWindow.on('show', () => {
mainWindow.webContents.send('show');
});

ipcMain.on('esc', (event, message) => {
if (mainWindow.isVisible()) {
mainWindow.hide();
}
});

ipcMain.on('uuid', (event, message) => {
let value = "";
switch (message) {
case 'v1':
value = uuidv1();
case 'v4':
default:
value = uuidv4();
}
mainWindow.webContents.send('uuid', value);
});
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', () => {
// Menu.setApplicationMenu(null)
// Menu.setApplicationMenu(null)

createWindow();
createWindow();

// gloabl shortcut
globalShortcut.register('Shift+Command+Space', () => {
if (!mainWindow.isVisible()) {
mainWindow.show();
}
});
// gloabl shortcut
globalShortcut.register('Shift+Command+Space', () => {
if (!mainWindow.isVisible()) {
mainWindow.show();
}
});

app.dock.hide();
mainWindow.show();
app.dock.hide();
mainWindow.show();
});

// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit();
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit();
});

app.on('activate', function() {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) createWindow();
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
Expand Down Expand Up @@ -129,6 +143,6 @@ app.on('activate', function() {

// info
app.setAboutPanelOptions({
'website': 'https://github.com/WaylandWong/timestamp-convert',
'website': 'https://github.com/WaylandWong/timestamp-convert',
})
;
Loading

0 comments on commit e2677b4

Please sign in to comment.