-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
220 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,74 @@ | ||
{ | ||
"name": "timer", | ||
"version": "2.1.1", | ||
"description": "Web timer", | ||
"homepage": "https://github.com/sheepzh/timer", | ||
"scripts": { | ||
"dev": "webpack --config=webpack/webpack.dev.ts --watch", | ||
"dev:safari": "webpack --config=webpack/webpack.dev.safari.ts --watch", | ||
"build": "webpack --config=webpack/webpack.prod.ts", | ||
"build:safari": "webpack --config=webpack/webpack.prod.safari.ts", | ||
"analyze": "webpack --config=webpack/webpack.analyze.ts", | ||
"test": "jest --env=jsdom", | ||
"test-c": "jest --coverage --env=jsdom" | ||
}, | ||
"author": { | ||
"name": "zhy", | ||
"email": "[email protected]", | ||
"url": "https://www.github.com/sheepzh" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@crowdin/crowdin-api-client": "^1.28.2", | ||
"@types/chrome": "0.0.254", | ||
"@types/copy-webpack-plugin": "^8.0.1", | ||
"@types/echarts": "^4.9.22", | ||
"@types/generate-json-webpack-plugin": "^0.3.7", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "^20.10.5", | ||
"@types/psl": "^1.1.3", | ||
"@types/webpack": "^5.28.5", | ||
"@types/webpack-bundle-analyzer": "^4.6.3", | ||
"babel-loader": "^9.1.3", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"css-loader": "^6.8.1", | ||
"eslint": "^8.56.0", | ||
"filemanager-webpack-plugin": "^8.0.0", | ||
"generate-json-webpack-plugin": "^2.0.0", | ||
"html-webpack-plugin": "^5.5.4", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"mini-css-extract-plugin": "^2.7.6", | ||
"node-sass": "^9.0.0", | ||
"sass-loader": "^13.3.2", | ||
"style-loader": "^3.3.3", | ||
"ts-jest": "^29.1.1", | ||
"ts-loader": "^9.5.1", | ||
"ts-node": "^10.9.2", | ||
"tsconfig-paths": "^4.2.0", | ||
"tslib": "^2.6.2", | ||
"typescript": "5.3.3", | ||
"url-loader": "^4.1.1", | ||
"webpack": "^5.89.0", | ||
"webpack-bundle-analyzer": "^4.10.1", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"dependencies": { | ||
"@element-plus/icons-vue": "^2.3.1", | ||
"axios": "^1.6.2", | ||
"clipboardy": "^4.0.0", | ||
"countup.js": "^2.8.0", | ||
"echarts": "^5.4.3", | ||
"element-plus": "2.4.4", | ||
"psl": "^1.9.0", | ||
"stream-browserify": "^3.0.0", | ||
"vue": "^3.3.12", | ||
"vue-router": "^4.2.5" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} | ||
"name": "timer", | ||
"version": "2.1.1", | ||
"description": "Web timer", | ||
"homepage": "https://github.com/sheepzh/timer", | ||
"scripts": { | ||
"dev": "webpack --config=webpack/webpack.dev.ts --watch", | ||
"dev:safari": "webpack --config=webpack/webpack.dev.safari.ts --watch", | ||
"build": "webpack --config=webpack/webpack.prod.ts", | ||
"build:safari": "webpack --config=webpack/webpack.prod.safari.ts", | ||
"analyze": "webpack --config=webpack/webpack.analyze.ts", | ||
"test": "jest --env=jsdom", | ||
"test-c": "jest --coverage --env=jsdom" | ||
}, | ||
"author": { | ||
"name": "zhy", | ||
"email": "[email protected]", | ||
"url": "https://www.github.com/sheepzh" | ||
}, | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@babel/plugin-transform-modules-commonjs": "^7.23.3", | ||
"@babel/preset-env": "^7.23.8", | ||
"@crowdin/crowdin-api-client": "^1.29.5", | ||
"@types/chrome": "0.0.256", | ||
"@types/copy-webpack-plugin": "^8.0.1", | ||
"@types/echarts": "^4.9.22", | ||
"@types/generate-json-webpack-plugin": "^0.3.7", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "^20.11.3", | ||
"@types/psl": "^1.1.3", | ||
"@types/webpack": "^5.28.5", | ||
"@types/webpack-bundle-analyzer": "^4.6.3", | ||
"@vue/babel-plugin-jsx": "^1.1.6", | ||
"babel-loader": "^9.1.3", | ||
"copy-webpack-plugin": "^12.0.1", | ||
"css-loader": "^6.9.0", | ||
"eslint": "^8.56.0", | ||
"filemanager-webpack-plugin": "^8.0.0", | ||
"generate-json-webpack-plugin": "^2.0.0", | ||
"html-webpack-plugin": "^5.6.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"mini-css-extract-plugin": "^2.7.7", | ||
"node-sass": "^9.0.0", | ||
"sass-loader": "^14.0.0", | ||
"style-loader": "^3.3.4", | ||
"ts-jest": "^29.1.1", | ||
"ts-loader": "^9.5.1", | ||
"ts-node": "^10.9.2", | ||
"tsconfig-paths": "^4.2.0", | ||
"tslib": "^2.6.2", | ||
"typescript": "5.3.3", | ||
"url-loader": "^4.1.1", | ||
"webpack": "^5.89.0", | ||
"webpack-bundle-analyzer": "^4.10.1", | ||
"webpack-cli": "^5.1.4" | ||
}, | ||
"dependencies": { | ||
"@element-plus/icons-vue": "^2.3.1", | ||
"axios": "^1.6.5", | ||
"clipboardy": "^4.0.0", | ||
"countup.js": "^2.8.0", | ||
"echarts": "^5.4.3", | ||
"element-plus": "2.4.4", | ||
"psl": "^1.9.0", | ||
"stream-browserify": "^3.0.0", | ||
"vue": "^3.4.14", | ||
"vue-router": "^4.2.5" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* Copyright (c) 2021 Hengyang Zhang | ||
* | ||
* This software is released under the MIT License. | ||
* https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
import { Delete, Edit } from "@element-plus/icons-vue" | ||
import { ElButton, ElMessageBox, ElTableColumn } from "element-plus" | ||
import { defineComponent } from "vue" | ||
import { t } from "@app/locale" | ||
import optionService from "@service/option-service" | ||
import { judgeVerificationRequired, processVerification } from "./common" | ||
import { locale } from "@i18n" | ||
import { ElTableRowScope } from "@src/element-ui/table" | ||
|
||
const label = t((msg) => msg.limit.item.operation) | ||
const deleteButtonText = t((msg) => msg.button.delete) | ||
const modifyButtonText = t((msg) => msg.button.modify) | ||
|
||
async function handleDelete(row: timer.limit.Item, callback: () => void) { | ||
let promise = undefined | ||
if (await judgeVerificationRequired(row)) { | ||
const option = | ||
(await optionService.getAllOption()) as timer.option.DailyLimitOption | ||
promise = processVerification(option) | ||
} | ||
if (!promise) { | ||
const message = t((msg) => msg.limit.message.deleteConfirm, { | ||
cond: row.cond, | ||
}) | ||
promise = ElMessageBox.confirm(message, { type: "warning" }) | ||
} | ||
promise.then(callback).catch(() => { | ||
/** Do nothing */ | ||
}) | ||
} | ||
|
||
async function handleModify(row: timer.limit.Item, callback: () => void) { | ||
let promise: Promise<void> = undefined | ||
if (await judgeVerificationRequired(row)) { | ||
const option = | ||
(await optionService.getAllOption()) as timer.option.DailyLimitOption | ||
promise = processVerification(option) | ||
promise ? promise.then(callback).catch(() => { }) : callback() | ||
} else { | ||
callback() | ||
} | ||
} | ||
|
||
const LOCALE_WIDTH: { [locale in timer.Locale]: number } = { | ||
en: 220, | ||
zh_CN: 200, | ||
ja: 200, | ||
zh_TW: 200, | ||
pt_PT: 250, | ||
uk: 260, | ||
} | ||
|
||
const _default = defineComponent({ | ||
emits: { | ||
rowDelete: (_row: timer.limit.Item, _cond: string) => true, | ||
rowModify: (_row: timer.limit.Item) => true, | ||
}, | ||
setup(_props, ctx) { | ||
return () => <ElTableColumn | ||
prop="operations" | ||
label={label} | ||
width={LOCALE_WIDTH[locale]} | ||
align="center" | ||
v-slots={({ row }: ElTableRowScope<timer.limit.Item>) => <> | ||
<ElButton | ||
type="danger" | ||
size="small" | ||
icon={<Delete />} | ||
onClick={() => handleDelete(row, () => ctx.emit("rowDelete", row, row.cond))} | ||
> | ||
{deleteButtonText} | ||
</ElButton> | ||
<ElButton | ||
type="primary" | ||
size="small" | ||
icon={<Edit />} | ||
onClick={() => handleModify(row, () => ctx.emit("rowModify", row))} | ||
> | ||
{modifyButtonText} | ||
</ElButton> | ||
</> | ||
} | ||
/> | ||
}, | ||
}) | ||
|
||
export default _default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.