mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-24 18:40:03 +08:00
52 lines
994 B
TypeScript
52 lines
994 B
TypeScript
export const useLogStore = defineStore('log', () => {
|
|
const log = ref('');
|
|
const { auth } = useAuth();
|
|
const message = useMessage();
|
|
|
|
function get() {
|
|
const { execute, onResult } = useApi(apiLog.getLog);
|
|
|
|
onResult((value) => {
|
|
log.value = value;
|
|
});
|
|
|
|
if (auth.value !== '') {
|
|
execute();
|
|
}
|
|
}
|
|
|
|
const { execute: reset, onResult: onClearLogResult } = useApi(
|
|
apiLog.clearLog
|
|
);
|
|
|
|
onClearLogResult((res) => {
|
|
if (res) {
|
|
log.value = '';
|
|
}
|
|
});
|
|
|
|
const { pause: offUpdate, resume: onUpdate } = useIntervalFn(get, 3000, {
|
|
immediate: false,
|
|
immediateCallback: true,
|
|
});
|
|
|
|
function copy() {
|
|
const { copy: copyLog, isSupported } = useClipboard({ source: log });
|
|
if (isSupported) {
|
|
copyLog();
|
|
message.success('Copy Success!');
|
|
} else {
|
|
message.error('Your browser does not support Clipboard API!');
|
|
}
|
|
}
|
|
|
|
return {
|
|
log,
|
|
get,
|
|
reset,
|
|
onUpdate,
|
|
offUpdate,
|
|
copy,
|
|
};
|
|
});
|