+
diff --git a/src/components/popup/message.vue b/src/components/popup/message.vue
index aede182..f3047b9 100644
--- a/src/components/popup/message.vue
+++ b/src/components/popup/message.vue
@@ -1,5 +1,9 @@
- message
+
diff --git a/src/edge/auto-imports.d.ts b/src/edge/auto-imports.d.ts
index a7768ef..5e073f1 100644
--- a/src/edge/auto-imports.d.ts
+++ b/src/edge/auto-imports.d.ts
@@ -1,10 +1,6 @@
// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
declare global {
- const ElButton: typeof import('element-plus/es')['ElButton']
- const ElForm: typeof import('element-plus/es')['ElForm']
- const ElFormItem: typeof import('element-plus/es')['ElFormItem']
- const ElInput: typeof import('element-plus/es')['ElInput']
- const ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
+
}
export {}
diff --git a/src/edge/components.d.ts b/src/edge/components.d.ts
index d64885b..7276085 100644
--- a/src/edge/components.d.ts
+++ b/src/edge/components.d.ts
@@ -5,10 +5,23 @@
declare module 'vue' {
export interface GlobalComponents {
ElButton: typeof import('element-plus/es')['ElButton']
+ ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
+ ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
+ ElCol: typeof import('element-plus/es')['ElCol']
+ ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
+ ElDivider: typeof import('element-plus/es')['ElDivider']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElInput: typeof import('element-plus/es')['ElInput']
+ ElOption: typeof import('element-plus/es')['ElOption']
ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
+ ElRadio: typeof import('element-plus/es')['ElRadio']
+ ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
+ ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
+ ElSelect: typeof import('element-plus/es')['ElSelect']
+ ElSwitch: typeof import('element-plus/es')['ElSwitch']
+ ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
+ Loading: typeof import('element-plus/es')['ElLoadingDirective']
}
}
diff --git a/src/edge/popup/popup.html b/src/edge/popup/popup.html
index 9519959..8f339aa 100644
--- a/src/edge/popup/popup.html
+++ b/src/edge/popup/popup.html
@@ -3,7 +3,7 @@
-
+
diff --git a/src/edge/popup/router.ts b/src/edge/popup/router.ts
index 9d96719..7b62a4d 100644
--- a/src/edge/popup/router.ts
+++ b/src/edge/popup/router.ts
@@ -6,6 +6,7 @@ import Setting from "@/components/popup/setting.vue"
import Device from "@/components/popup/device.vue"
import Message from "@/components/popup/message.vue"
import Key from "@/components/popup/key.vue"
+import Push from "@/components/popup/push.vue"
import BlankLayout from "@/components/layout/blank-layout.vue";
import UserLayout from "@/components/layout/user-layout.vue";
import {useGlobalStore} from "@/edge/popup/useGlobal";
@@ -57,6 +58,11 @@ export const router = createRouter({
name: "Key",
component: Key
},
+ {
+ path: "push",
+ name: "Push",
+ component: Push
+ },
{
path: "setting",
name: "Setting",
diff --git a/src/edge/popup/useGlobal.ts b/src/edge/popup/useGlobal.ts
index 9bcca9e..7af0d59 100644
--- a/src/edge/popup/useGlobal.ts
+++ b/src/edge/popup/useGlobal.ts
@@ -24,7 +24,8 @@ export const useGlobalStore = defineStore<'global', {
userInfo?: IUser,
mounted: boolean,
device_id: string,
- devices: any[]
+ devices: any[],
+ pushkeys: string[]
}, any, any>("global", {
state() {
return {
@@ -34,7 +35,8 @@ export const useGlobalStore = defineStore<'global', {
userInfo: undefined,
mounted: false,
device_id: "",
- devices: []
+ devices: [],
+ pushkeys: []
}
},
actions: {
diff --git a/src/helpers/adapter.ts b/src/helpers/adapter.ts
index 5df45a5..ecf0f10 100644
--- a/src/helpers/adapter.ts
+++ b/src/helpers/adapter.ts
@@ -1,7 +1,4 @@
-import {ENDPOINT, GITHUB, TOKEN} from "@/helpers/constants";
-import mitt from 'mitt'
-
-const emitter = mitt()
+import {ENDPOINT, GITHUB} from "@/helpers/constants";
class Adapter {
@@ -44,15 +41,6 @@ class Adapter {
})
}
- on(event: string, callback: (...args: any[]) => void) {
- emitter.on(event, callback)
- }
-
- emit(event: string, ...args: any[]) {
- // @ts-ignore
- emitter.emit(event, ...args)
- }
-
async loginGithub() {
const data = await this.getStorage([ENDPOINT, GITHUB])
await chrome.tabs.create({url: `https://github.com/login/oauth/authorize?client_id=${data[GITHUB]}&redirect_uri=${data[ENDPOINT]}/login/github`})
diff --git a/src/helpers/utils.ts b/src/helpers/utils.ts
new file mode 100644
index 0000000..6eacc9e
--- /dev/null
+++ b/src/helpers/utils.ts
@@ -0,0 +1,8 @@
+import dayjs from "dayjs";
+import {ElMessage} from "element-plus";
+
+export const Utils = {
+ format(date?: string | number | Date | dayjs.Dayjs | null | undefined) {
+ return dayjs(date).format("YYYY/MM/DD");
+ }
+}
diff --git a/src/hooks/useCreateDevice.ts b/src/hooks/device/useCreateDevice.ts
similarity index 87%
rename from src/hooks/useCreateDevice.ts
rename to src/hooks/device/useCreateDevice.ts
index ab589f6..7bbf90d 100644
--- a/src/hooks/useCreateDevice.ts
+++ b/src/hooks/device/useCreateDevice.ts
@@ -4,11 +4,10 @@ import {storeToRefs} from "pinia";
export function useCreateDevice() {
const store = useGlobalStore()
- const {token, device_id} = storeToRefs(store)
+ const {device_id} = storeToRefs(store)
const {run} = useRequest("/device/reg", () => ({
method: "POST",
data: {
- token: token.value,
name: "Browser",
device_id: device_id.value,
is_clip: 0,
diff --git a/src/hooks/useGetDeviceList.ts b/src/hooks/device/useGetDeviceList.ts
similarity index 82%
rename from src/hooks/useGetDeviceList.ts
rename to src/hooks/device/useGetDeviceList.ts
index 5a60c17..abadfb3 100644
--- a/src/hooks/useGetDeviceList.ts
+++ b/src/hooks/device/useGetDeviceList.ts
@@ -5,10 +5,7 @@ import {onMounted} from "vue";
export function useGetDeviceList() {
const store = useGlobalStore();
const listDevice = useRequest('/device/list', {
- method: "POST",
- data: {
- token: store.token,
- }
+ method: "POST"
});
const list = () => {
listDevice.run().then(res => {
@@ -23,6 +20,7 @@ export function useGetDeviceList() {
});
return {
- listDevice: list
+ listDevice: list,
+ listLoading: listDevice.loading
}
}
diff --git a/src/hooks/useGetFingerprint.ts b/src/hooks/device/useGetFingerprint.ts
similarity index 100%
rename from src/hooks/useGetFingerprint.ts
rename to src/hooks/device/useGetFingerprint.ts
diff --git a/src/hooks/useRemoveDevice.ts b/src/hooks/device/useRemoveDevice.ts
similarity index 83%
rename from src/hooks/useRemoveDevice.ts
rename to src/hooks/device/useRemoveDevice.ts
index ca6946d..895d901 100644
--- a/src/hooks/useRemoveDevice.ts
+++ b/src/hooks/device/useRemoveDevice.ts
@@ -5,10 +5,7 @@ export function useRemoveDevice() {
const store = useGlobalStore();
const {run} = useRequest("/device/remove", {
- method: "POST",
- data: {
- token: store.token,
- }
+ method: "POST"
})
return {
diff --git a/src/hooks/useRenameDevice.ts b/src/hooks/device/useRenameDevice.ts
similarity index 94%
rename from src/hooks/useRenameDevice.ts
rename to src/hooks/device/useRenameDevice.ts
index 3f8994d..eb0a9df 100644
--- a/src/hooks/useRenameDevice.ts
+++ b/src/hooks/device/useRenameDevice.ts
@@ -5,10 +5,7 @@ import {useGlobalStore} from "@/edge/popup/useGlobal";
export function useRenameDevice() {
const store = useGlobalStore();
const {run} = useRequest("/device/rename", {
- method: "post",
- data: {
- token: store.token,
- }
+ method: "post"
});
diff --git a/src/hooks/key/useCreateKey.ts b/src/hooks/key/useCreateKey.ts
new file mode 100644
index 0000000..7854bf4
--- /dev/null
+++ b/src/hooks/key/useCreateKey.ts
@@ -0,0 +1,18 @@
+import {useRequest} from "@/hooks/useRequest";
+import {ElMessage} from "element-plus/es";
+
+export function useCreateKey() {
+ const {run, loading} = useRequest("/key/gen", {
+ method: "POST"
+ })
+
+ return {
+ createKey: async () => {
+ const data = await run()
+ if (data.code === 0) {
+ ElMessage.success('新增Key成功')
+ }
+ },
+ createLoading: loading
+ }
+}
diff --git a/src/hooks/key/useGetKeyList.ts b/src/hooks/key/useGetKeyList.ts
new file mode 100644
index 0000000..599dac0
--- /dev/null
+++ b/src/hooks/key/useGetKeyList.ts
@@ -0,0 +1,43 @@
+import {useGlobalStore} from "@/edge/popup/useGlobal";
+import {useRequest} from "@/hooks/useRequest";
+import {computed, onMounted} from "vue";
+import {Utils} from "@/helpers/utils";
+
+export function useGetKeyList() {
+ const store = useGlobalStore()
+ const {run, data, loading} = useRequest("/key/list", {
+ method: "POST"
+ })
+
+ const getKeyList = async () => {
+ const res = await run()
+ if (res.code === 0) {
+ const keys = res?.content?.keys ?? []
+ let pushkeys = keys.map((item: any) => item.key)
+ store.$patch({
+ pushkeys
+ })
+ }
+ }
+
+ onMounted(async () => {
+ await getKeyList()
+ })
+
+ const keyList = computed(() => {
+ return (data.value?.content?.keys ?? []).map((key: any) => {
+ const {created_at} = key
+ return {
+ ...key,
+ created_at: Utils.format(created_at)
+ }
+ })
+ })
+
+
+ return {
+ keyList,
+ getKeyList,
+ listLoading: loading
+ }
+}
diff --git a/src/hooks/key/useRegen.ts b/src/hooks/key/useRegen.ts
new file mode 100644
index 0000000..216f64b
--- /dev/null
+++ b/src/hooks/key/useRegen.ts
@@ -0,0 +1,22 @@
+import {useRequest} from "@/hooks/useRequest";
+import {ElMessage} from "element-plus/es";
+
+export function useRegen() {
+ const {run, loading} = useRequest("/key/regen", {
+ method: "POST",
+ })
+
+ return {
+ regenKey: async (id: number) => {
+ const data = await run({
+ data: {
+ id
+ }
+ })
+ if (data.code === 0) {
+ ElMessage.success('重置Key成功')
+ }
+ },
+ regenLoading: loading
+ }
+}
diff --git a/src/hooks/key/useRemoveKey.ts b/src/hooks/key/useRemoveKey.ts
new file mode 100644
index 0000000..36892ed
--- /dev/null
+++ b/src/hooks/key/useRemoveKey.ts
@@ -0,0 +1,21 @@
+import {useRequest} from "@/hooks/useRequest";
+import {ElMessage} from "element-plus";
+
+export function useRemoveKey() {
+ const {run} = useRequest("/key/remove", {
+ method: "POST",
+ })
+
+ return {
+ removeKey: async (id: number) => {
+ const data = await run({
+ data: {
+ id
+ }
+ })
+ if (data.code === 0) {
+ ElMessage.success('删除Key成功')
+ }
+ }
+ }
+}
diff --git a/src/hooks/message/usePushMessage.ts b/src/hooks/message/usePushMessage.ts
new file mode 100644
index 0000000..f94f499
--- /dev/null
+++ b/src/hooks/message/usePushMessage.ts
@@ -0,0 +1,47 @@
+import {reactive, ref} from "vue";
+import {useRequest} from "@/hooks/useRequest";
+import {ElMessage} from "element-plus";
+
+export function usePushMessage() {
+ const Form = ref()
+ const rules = {
+ pushkey: [
+ {required: true, message: '请选择key', trigger: 'change'},
+ ],
+ text: [
+ {required: true, message: '请输入消息标题', trigger: 'change'},
+ ],
+ }
+ const form = reactive({
+ type: 'markdown',
+ text: '',
+ pushkey: '',
+ desp: '',
+ })
+
+ const {run} = useRequest("/message/push", {
+ method: "POST"
+ })
+ const onPush = () => {
+ Form.value?.validate(async (valid: boolean) => {
+ if (valid) {
+ const data = await run({
+ data: {
+ ...form,
+ token: undefined
+ }
+ })
+
+ if (data.code === 0) {
+ ElMessage.success("发送成功")
+ }
+ }
+ })
+ }
+ return {
+ Form,
+ form,
+ rules,
+ onPush
+ }
+}
diff --git a/src/hooks/useCopy.ts b/src/hooks/useCopy.ts
new file mode 100644
index 0000000..616b08a
--- /dev/null
+++ b/src/hooks/useCopy.ts
@@ -0,0 +1,19 @@
+import {ElMessage} from "element-plus";
+
+export function useCopy() {
+ const copy = (value: string) => {
+ let transfer = document.createElement('input');
+ document.body.appendChild(transfer);
+ transfer.value = value
+ transfer.focus()
+ transfer.select()
+ if (document.execCommand('copy')) {
+ transfer.blur()
+ ElMessage.success("复制成功")
+ }
+ document.body.removeChild(transfer)
+ }
+ return {
+ copy
+ }
+}
diff --git a/src/hooks/useRequest.ts b/src/hooks/useRequest.ts
index e134569..92594d9 100644
--- a/src/hooks/useRequest.ts
+++ b/src/hooks/useRequest.ts
@@ -18,7 +18,9 @@ export const useRequest = (path: string, config?: IConfig | IConfigFunc) => {
const {data = {}, params = {}} = conf ?? {}
const res = await request(`${store.endpoint}${path}`, {
...conf,
- data: Object.assign({}, data, body?.data ?? {}),
+ data: Object.assign({
+ token: store.token
+ }, data, body?.data ?? {}),
params: Object.assign({}, params, body?.params ?? {}),
})
result.value = res
diff --git a/src/styles/popup.less b/src/styles/popup.less
index 4aa38cd..340b632 100644
--- a/src/styles/popup.less
+++ b/src/styles/popup.less
@@ -2,7 +2,7 @@
.box {
display: flex;
- height: 48px;
+ min-height: 48px;
justify-content: space-between;
align-items: center;
margin: 0 24px 24px;
@@ -12,11 +12,16 @@
box-shadow: 1px 1px 10px rgba(49, 61, 125, 0.5);
}
-.el-button--primary {
- background-color: #313d7d!important;
- border-color: #313d7d!important;
+@primary-color: #313d7d;
+
+
+.el-input__inner:focus {
+ box-shadow: 0 0 0 1px @primary-color inset !important;
}
-.el-button--text{
- color: #313d7d!important;
+:root {
+ --el-color-primary: @primary-color !important;
+ --el-color-primary-dark-2: @primary-color !important;
+ --el-color-primary-light-3: @primary-color !important;
}
+
diff --git a/vite.config.ts b/vite.config.ts
index 48a6041..537882d 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -23,12 +23,15 @@ export default defineConfig({
plugins: [
vue(),
Components({
- resolvers: [
- ElementPlusResolver(),
- ]
+ resolvers: [ElementPlusResolver({importStyle: 'css'})],
+ dts: 'components.d.ts'
}),
AutoImport({
- resolvers: [ElementPlusResolver()],
+ resolvers: [ElementPlusResolver({
+ importStyle: 'css',
+ exclude: new RegExp(/^(?!.*loading-directive).*$/)
+ })],
+ dts: 'auto-imports.d.ts'
})],
resolve: {
alias: {
diff --git a/yarn.lock b/yarn.lock
index 1613a68..6c58a0a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -143,11 +143,6 @@
resolved "http://npm.ztosys.com/@types%2ffilewriter/-/filewriter-0.0.29.tgz#a48795ecadf957f6c0d10e0c34af86c098fa5bee"
integrity sha1-pIeV7K35V/bA0Q4MNK+GwJj6W+4=
-"@types/fingerprintjs2@^2.0.0":
- version "2.0.0"
- resolved "https://registry.npmmirror.com/@types/fingerprintjs2/-/fingerprintjs2-2.0.0.tgz#3af76e165416fa75261bbce4393f5445fca4cadd"
- integrity sha512-isSTwNnW5I6zGZnpkinmVcV9pJqr7cLELns+tXDYzskIOAb2J+iCQ0mQJ9bRjHJhZfdlTFXZoCYK9ZgT3oMWXQ==
-
"@types/fs-extra@^8.0.1":
version "8.1.2"
resolved "https://registry.npmmirror.com/@types/fs-extra/-/fs-extra-8.1.2.tgz#7125cc2e4bdd9bd2fc83005ffdb1d0ba00cca61f"
@@ -952,11 +947,6 @@ fill-range@^7.0.1:
dependencies:
to-regex-range "^5.0.1"
-fingerprintjs2@^2.1.4:
- version "2.1.4"
- resolved "http://npm.ztosys.com/fingerprintjs2/-/fingerprintjs2-2.1.4.tgz#a39deb947aa187c098306a0b5dd41ceaa2e15fc5"
- integrity sha1-o53rlHqhh8CYMGoLXdQc6qLhX8U=
-
follow-redirects@^1.14.8:
version "1.14.9"
resolved "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"